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
Missing call to `__init__` during object initialization
cloudera/ibis/ibis/expr/types.py
[ { "content": " def __init__(self, arg):\n # TODO: all inputs must inherit from a common table API\n self._arg = arg", "metadata": "root.Expr.__init__", "header": "['class', 'Expr', '(', 'object', ')', ':', '___EOS___']", "index": 42 }, { "content": " def __init__(self, args):\n self.args = args", "metadata": "root.Node.__init__", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 197 }, { "content": " def __init__(self, *args):\n args = self._validate_args(args)\n Node.__init__(self, args)", "metadata": "root.ValueNode.__init__", "header": "['class', 'ValueNode', '(', 'Node', ')', ':', '___EOS___']", "index": 295 }, { "content": "class Literal(ValueNode):\n\n\n\n\n\n", "metadata": "root.Literal", "header": "['module', '___EOS___']", "index": 390 }, { "content": " def __init__(self, value):\n self.value = value", "metadata": "root.Literal.__init__", "header": "['class', 'Literal', '(', 'ValueNode', ')', ':', '___EOS___']", "index": 392 }, { "content": " def __init__(self, arg, name=None):\n Expr.__init__(self, arg)\n self._name = name", "metadata": "root.ValueExpr.__init__", "header": "['class', 'ValueExpr', '(', 'Expr', ')', ':', '___EOS___']", "index": 450 }, { "content": "class DecimalValue(NumericValue):\n\n _typename = 'decimal'\n _implicit_casts = set(['float', 'double'])\n\n\n\n", "metadata": "root.DecimalValue", "header": "['module', '___EOS___']", "index": 786 }, { "content": " def __init__(self, meta):\n self.meta = meta\n self._precision = meta.precision\n self._scale = meta.scale", "metadata": "root.DecimalValue.__init__", "header": "['class', 'DecimalValue', '(', 'NumericValue', ')', ':', '___EOS___']", "index": 791 }, { "content": "class CategoryValue(AnyValue):\n\n \"\"\"\n Represents some ordered data categorization; tracked as an int32 value\n until explicitly\n \"\"\"\n\n _typename = 'category'\n _implicit_casts = Int16Value._implicit_casts\n\n\n\n", "metadata": "root.CategoryValue", "header": "['module', '___EOS___']", "index": 943 }, { "content": " def __init__(self, meta):\n self.meta = meta", "metadata": "root.CategoryValue.__init__", "header": "['class', 'CategoryValue', '(', 'AnyValue', ')', ':', '___EOS___']", "index": 953 }, { "content": "class NullLiteral(ValueNode):\n\n \"\"\"\n Typeless NULL literal\n \"\"\"\n\n\n\n\n", "metadata": "root.NullLiteral", "header": "['module', '___EOS___']", "index": 1060 }, { "content": " def __init__(self):\n pass", "metadata": "root.NullLiteral.__init__", "header": "['class', 'NullLiteral', '(', 'ValueNode', ')', ':', '___EOS___']", "index": 1066 } ]
[ { "span": "class Literal(ValueNode):", "start_line": 390, "start_column": 0, "end_line": 390, "end_column": 25 }, { "span": "class DecimalValue(NumericValue):", "start_line": 786, "start_column": 0, "end_line": 786, "end_column": 33 }, { "span": "class CategoryValue(AnyValue):", "start_line": 943, "start_column": 0, "end_line": 943, "end_column": 30 }, { "span": "class NullLiteral(ValueNode):", "start_line": 1060, "start_column": 0, "end_line": 1060, "end_column": 29 } ]
[ { "span": "def __init__(self, arg):", "start_line": 42, "start_column": 4, "end_line": 42, "end_column": 28 }, { "span": "def __init__(self, args):", "start_line": 197, "start_column": 4, "end_line": 197, "end_column": 29 }, { "span": "def __init__(self, *args):", "start_line": 295, "start_column": 4, "end_line": 295, "end_column": 30 }, { "span": "def __init__(self, value):", "start_line": 392, "start_column": 4, "end_line": 392, "end_column": 30 }, { "span": "def __init__(self, arg, name=None):", "start_line": 450, "start_column": 4, "end_line": 450, "end_column": 39 }, { "span": "def __init__(self, meta):", "start_line": 791, "start_column": 4, "end_line": 791, "end_column": 29 }, { "span": "def __init__(self, meta):", "start_line": 953, "start_column": 4, "end_line": 953, "end_column": 29 }, { "span": "def __init__(self):", "start_line": 1066, "start_column": 4, "end_line": 1066, "end_column": 23 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Expr_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "arg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "all", " ", "inputs", " ", "must", " ", "inherit", " ", "from", " ", "a", " ", "common", " ", "table", " ", "API_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "arg_", "=_", "arg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "args_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Value", "Node_", "(_", "Node_", ")_", ":_", "\\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_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "self_", "._", "\\u", "validat", "e\\u", "args_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Node_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", "\\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_", "Literal_", "(_", "Value", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Literal_", "(_", "Value", "Node_", ")_", ":_", "\\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_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "value_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Value", "Expr_", "(_", "Expr_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "arg_", ",_", "name_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Expr_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "arg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Deci", "mal", "Value_", "(_", "Numer", "ic", "Value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "typename_", "=_", "'", "decima", "l", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "implicit", "\\u", "cast", "s_", "=_", "set_", "(_", "[_", "'", "float", "'_", ",_", "'", "double", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Deci", "mal", "Value_", "(_", "Numer", "ic", "Value_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "meta_", "=_", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "precision_", "=_", "meta_", "._", "precision_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "scale_", "=_", "meta_", "._", "scale_", "\\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_", "Cate", "gory", "Value_", "(_", "Any", "Value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Represent", "s", " ", "some", " ", "order", "ed", " ", "data", " ", "categoriz", "ation", ";", " ", "tracked", " ", "as", " ", "an", " ", "int", "32", " ", "value", "\\", "10", ";", " ", " ", " ", " ", "unti", "l", " ", "explicit", "ly", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "typename_", "=_", "'", "category", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "implicit", "\\u", "cast", "s_", "=_", "Int", "16", "Value_", "._", "\\u", "implicit", "\\u", "cast", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Cate", "gory", "Value_", "(_", "Any", "Value_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "meta_", "=_", "meta_", "\\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_", "Null", "Literal_", "(_", "Value", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Type", "less", " ", "NULL", " ", "literal", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Null", "Literal_", "(_", "Value", "Node_", ")_", ":_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 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, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 ]
First parameter of a method is not named 'self'
OneDrive/onedrive-sdk-python/src/onedrivesdk/session_base.py
[ { "content": " @abc.abstractmethod\n def load_session(**load_session_kwargs):\n pass", "metadata": "root.SessionBase.load_session", "header": "['class', 'SessionBase', '(', 'object', ')', ':', '___EOS___']", "index": 53 } ]
[ { "span": "def load_session(**load_session_kwargs):", "start_line": 54, "start_column": 4, "end_line": 54, "end_column": 44 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Sess", "ion", "Base_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "abc_", "._", "abstractmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "load", "\\u", "session_", "(_", "**_", "load", "\\u", "session", "\\u", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_" ]
[ 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2 ]
Unused import
memex-explorer/memex-explorer/source/base/tests/test_rest_project.py
[ { "content": "from __future__ import unicode_literals\n\nimport os\nimport pytest\nimport requests\nimport json\n\nfrom django.conf import settings\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase\nfrom django.db import IntegrityError\n\nfrom rest_framework.test import APITestCase\nfrom rest_framework import status\n\nfrom base.models import Project\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestProjectREST(APITestCase):\n \"\"\"\n Testing for adding Projects through the REST framework.\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TestProjectREST", "header": "['module', '___EOS___']", "index": 18 }, { "content": " @classmethod\n def setUpClass(cls):\n cls.test_project = Project(\n name = \"RestTest\",\n description = \"Testing Rest API\"\n )\n cls.test_project.save()\n cls.url = \"/api/projects/\"", "metadata": "root.TestProjectREST.setUpClass", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 22 }, { "content": " def parse_response(self, response):\n return json.loads(response.content)[0]", "metadata": "root.TestProjectREST.parse_response", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 31 }, { "content": " def test_add_project(self):\n response = self.client.post(self.url, {\"name\":\"Postresttest\"}, format=\"json\")\n assert json.loads(response.content)[\"slug\"] == \"postresttest\"\n assert json.loads(response.content)[\"name\"] == \"Postresttest\"", "metadata": "root.TestProjectREST.test_add_project", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 34 }, { "content": " def test_add_project_no_name(self):\n response = self.client.post(self.url, {}, format=\"json\")\n assert json.loads(response.content)[\"name\"][0] == \"This field is required.\"", "metadata": "root.TestProjectREST.test_add_project_no_name", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 39 }, { "content": " def test_add_project_no_name(self):\n response = self.client.post(self.url, {\"name\":\"postrest!\"}, format=\"json\")\n assert json.loads(response.content)[\"name\"][0] == \"Only numbers, letters, underscores, dashes and spaces are allowed.\"", "metadata": "root.TestProjectREST.test_add_project_no_name", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 43 }, { "content": " def test_get_all_projects(self):\n response = self.client.get(self.url)\n assert self.parse_response(response)", "metadata": "root.TestProjectREST.test_get_all_projects", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 47 }, { "content": " def test_get_project_by_id(self):\n response = self.client.get(self.url + \"?id=%s\" % self.test_project.id)\n assert self.parse_response(response)[\"id\"] == self.test_project.id", "metadata": "root.TestProjectREST.test_get_project_by_id", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 51 }, { "content": " def test_get_project_by_name(self):\n response = self.client.get(self.url + \"?name=%s\" % self.test_project.name)\n assert self.parse_response(response)[\"name\"] == self.test_project.name", "metadata": "root.TestProjectREST.test_get_project_by_name", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 55 }, { "content": " def test_get_project_by_slug(self):\n response = self.client.get(self.url + \"?slug=%s\" % self.test_project.slug)\n assert self.parse_response(response)[\"slug\"] == self.test_project.slug", "metadata": "root.TestProjectREST.test_get_project_by_slug", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 59 }, { "content": " def test_no_project_exists(self):\n response = self.client.get(self.url + \"?id=115\")\n assert not response.data", "metadata": "root.TestProjectREST.test_no_project_exists", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 63 }, { "content": " def test_change_name(self):\n response = self.client.patch(self.url + \"%d/\" % self.test_project.id,\n {'name':'newname'}, format=\"json\")\n assert json.loads(response.content)[\"name\"] == \"newname\"", "metadata": "root.TestProjectREST.test_change_name", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": " def test_change_description(self):\n response = self.client.patch(self.url + \"%d/\" % self.test_project.id,\n {'description':'New Description'}, format=\"json\")\n assert json.loads(response.content)[\"description\"] == \"New Description\"", "metadata": "root.TestProjectREST.test_change_description", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 72 }, { "content": " def test_change_slug_fails(self):\n \"\"\"\n Slug is read-only and cannot be changed. Assert the slug is unchanged.\n \"\"\"\n response = self.client.patch(self.url + \"%d/\" % self.test_project.id,\n {'slug':'Bad Slug'}, format=\"json\")\n assert json.loads(response.content)[\"slug\"] == \"resttest\"", "metadata": "root.TestProjectREST.test_change_slug_fails", "header": "['class', 'TestProjectREST', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 77 } ]
[ { "span": "import os", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 9 }, { "span": "import pytest", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 13 }, { "span": "import requests", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 15 }, { "span": "from django.conf import settings", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 32 }, { "span": "from django.core.urlresolvers import reverse", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 44 }, { "span": "from django.test import TestCase", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 32 }, { "span": "from django.db import IntegrityError", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 36 }, { "span": "from rest_framework import status", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 33 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pytest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "test_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "Int", "egr", "it", "y", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "rest", "\\u", "framework_", "._", "test_", "import_", "API", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "rest", "\\u", "framework_", "import_", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "base_", "._", "models_", "import_", "Project_", "\\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", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "ing", " ", "for", " ", "addin", "g", " ", "Project", "s", " ", "through", " ", "the", " ", "REST", " ", "frame", "work", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "set", "Up", "Class_", "(_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cls_", "._", "test\\u", "project_", "=_", "Project_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "\"", "Rest", "Test", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "\"", "Test", "ing", " ", "Rest", " ", "API", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "test\\u", "project_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "url_", "=_", "\"/", "api", "/", "project", "s", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "\\u", "response_", "(_", "self_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "project_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "self_", "._", "url_", ",_", "{_", "\"", "name", "\"_", ":_", "\"", "Post", "rest", "test", "\"_", "}_", ",_", "format_", "=_", "\"", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "slug", "\"_", "]_", "==_", "\"", "post", "rest", "test", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "name", "\"_", "]_", "==_", "\"", "Post", "rest", "test", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "project", "\\u", "no", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "self_", "._", "url_", ",_", "{_", "}_", ",_", "format_", "=_", "\"", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "name", "\"_", "]_", "[_", "0_", "]_", "==_", "\"", "Thi", "s", " ", "field", " ", "is", " ", "require", "d", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "project", "\\u", "no", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "self_", "._", "url_", ",_", "{_", "\"", "name", "\"_", ":_", "\"", "post", "rest", "!\"_", "}_", ",_", "format_", "=_", "\"", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "name", "\"_", "]_", "[_", "0_", "]_", "==_", "\"", "On", "ly", " ", "numbers", ",", " ", "letter", "s", ",", " ", "underscore", "s", ",", " ", "dashes", " ", "and", " ", "space", "s", " ", "are", " ", "allow", "ed", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "projects_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "self_", "._", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "parse", "\\u", "response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "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", "project", "\\u", "by", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "self_", "._", "url_", "+_", "\"?", "id", "=", "%", "s", "\"_", "%_", "self_", "._", "test\\u", "project_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "parse", "\\u", "response_", "(_", "response_", ")_", "[_", "\"", "id", "\"_", "]_", "==_", "self_", "._", "test\\u", "project_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "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", "project", "\\u", "by", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "self_", "._", "url_", "+_", "\"?", "name", "=", "%", "s", "\"_", "%_", "self_", "._", "test\\u", "project_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "parse", "\\u", "response_", "(_", "response_", ")_", "[_", "\"", "name", "\"_", "]_", "==_", "self_", "._", "test\\u", "project_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "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", "project", "\\u", "by", "\\u", "slug_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "self_", "._", "url_", "+_", "\"?", "slug", "=", "%", "s", "\"_", "%_", "self_", "._", "test\\u", "project_", "._", "slug_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "parse", "\\u", "response_", "(_", "response_", ")_", "[_", "\"", "slug", "\"_", "]_", "==_", "self_", "._", "test\\u", "project_", "._", "slug_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "no", "\\u", "project", "\\u", "exists_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "self_", "._", "url_", "+_", "\"?", "id", "=", "115", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "response_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "change", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "patch_", "(_", "self_", "._", "url_", "+_", "\"%", "d", "/\"_", "%_", "self_", "._", "test\\u", "project_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "name", "'_", ":_", "'", "newn", "ame", "'_", "}_", ",_", "format_", "=_", "\"", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "name", "\"_", "]_", "==_", "\"", "newn", "ame", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "change", "\\u", "description_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "patch_", "(_", "self_", "._", "url_", "+_", "\"%", "d", "/\"_", "%_", "self_", "._", "test\\u", "project_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "description", "'_", ":_", "'", "New", " ", "Descripti", "on", "'_", "}_", ",_", "format_", "=_", "\"", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "description", "\"_", "]_", "==_", "\"", "New", " ", "Descripti", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Project", "REST", "_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "change", "\\u", "slug", "\\u", "fails_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Sl", "ug", " ", "is", " ", "read", "-", "only", " ", "and", " ", "cann", "ot", " ", "be", " ", "change", "d", ".", " ", "Assert", " ", "the", " ", "slug", " ", "is", " ", "unchanged", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "patch_", "(_", "self_", "._", "url_", "+_", "\"%", "d", "/\"_", "%_", "self_", "._", "test\\u", "project_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "slug", "'_", ":_", "'", "Ba", "d", " ", "Sl", "ug", "'_", "}_", ",_", "format_", "=_", "\"", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "\"", "slug", "\"_", "]_", "==_", "\"", "rest", "test", "\"_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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,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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 ]
Unnecessary 'else' clause in loop
mcedit/pymclevel/run_regression_test.py
[ { "content": "def sha1_file(name, checksum=None):\n CHUNKSIZE = 1024\n if checksum is None:\n checksum = hashlib.sha1()\n if fnmatch.fnmatch(name, \"*.dat\"):\n opener = gzip.open\n else:\n opener = open\n\n with contextlib.closing(opener(name, 'rb')) as data:\n chunk = data.read(CHUNKSIZE)\n while len(chunk) == CHUNKSIZE:\n checksum.update(chunk)\n chunk = data.read(CHUNKSIZE)\n else:\n checksum.update(chunk)\n return checksum", "metadata": "root.sha1_file", "header": "['module', '___EOS___']", "index": 21 } ]
[ { "span": "while len(chunk) == CHUNKSIZE:", "start_line": 32, "start_column": 8, "end_line": 32, "end_column": 38 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "'", "else", "'_", "clause_", "in_", "loop_", "[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_", "sha1", "\\u", "file_", "(_", "name_", ",_", "checksum_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "CHUNK", "SIZE_", "=_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "checksum_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checksum_", "=_", "hashlib_", "._", "sha1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fnmatch_", "._", "fnmatch_", "(_", "name_", ",_", "\"*", ".", "dat", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opener_", "=_", "gzip_", "._", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opener_", "=_", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "contextlib_", "._", "closing_", "(_", "opener_", "(_", "name_", ",_", "'", "rb", "'_", ")_", ")_", "as_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chunk_", "=_", "data_", "._", "read_", "(_", "CHUNK", "SIZE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "len_", "(_", "chunk_", ")_", "==_", "CHUNK", "SIZE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checksum_", "._", "update_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chunk_", "=_", "data_", "._", "read_", "(_", "CHUNK", "SIZE_", ")_", "\\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 ", " _", "checksum_", "._", "update_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "checksum_", "\\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, 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 ]
Variable defined multiple times
zrong/wpcmd/wpcmd/update.py
[ { "content": " def _update_a_draft(self):\n postid = self.get_postid()\n if not postid:\n slog.warning('Please provide a post id!')\n return\n afile, aname = self.conf.get_draft(postid)\n\n # If output is provided, write the html to a file and abort.\n if self.args.output:\n self._write_html_file(afile)\n return\n\n html, meta, txt, medias = self._get_and_update_article_content(afile)\n if not html:\n return\n if meta.poststatus == 'draft':\n slog.warning( 'The post status of draft \"%s\" is \"draft\", '\n 'please modify it to \"publish\".'%postid)\n return\n\n # Update all taxonomy before create a new article.\n self.get_terms_from_wp(['category'])\n self.get_terms_from_wp(['post_tag'])\n\n if meta.posttype == 'page':\n post = WordPressPage()\n else:\n post = WordPressPost()\n post.terms = self.cache.get_terms_from_meta(meta.category, meta.tags)\n if not post.terms:\n slog.warning('Please provide some terms.')\n return\n\n post.content= html\n post.title = meta.title\n post.slug = meta.nicename\n post.date = meta.date\n post.user = meta.author\n post.date_modified = meta.modified\n post.post_status = meta.poststatus\n post.comment_status = \"open\"\n post.ping_status = \"open\"\n postid = self.wpcall(NewPost(post))\n\n if postid:\n write_by_templ(afile, afile, {'POSTID':postid, 'SLUG':postid}, True)\n else:\n return\n\n newfile, newname = None, None\n if meta.posttype == 'page':\n newfile, newname = self.conf.get_article(meta.nicename, meta.posttype)\n else:\n newfile, newname = self.conf.get_article(postid, meta.posttype)\n\n slog.info('Move \"%s\" to \"%s\".'%(afile, newfile))\n shutil.move(afile, newfile)", "metadata": "root.UpdateAction._update_a_draft", "header": "['class', 'UpdateAction', '(', 'Action', ')', ':', '___EOS___']", "index": 159 } ]
[ { "span": "newfile,", "start_line": 208, "start_column": 8, "end_line": 208, "end_column": 15 }, { "span": "newname ", "start_line": 208, "start_column": 17, "end_line": 208, "end_column": 24 } ]
[ { "span": "newfile,", "start_line": 210, "start_column": 12, "end_line": 210, "end_column": 19 }, { "span": "newname ", "start_line": 210, "start_column": 21, "end_line": 210, "end_column": 28 }, { "span": "newfile,", "start_line": 212, "start_column": 12, "end_line": 212, "end_column": 19 }, { "span": "newname ", "start_line": 212, "start_column": 21, "end_line": 212, "end_column": 28 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Update", "Action_", "(_", "Action_", ")_", ":_", "\\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", "update", "\\u", "a", "\\u", "draft_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "posti", "d_", "=_", "self_", "._", "get", "\\u", "posti", "d_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "posti", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slo", "g_", "._", "warning_", "(_", "'", "Ple", "ase", " ", "provide", " ", "a", " ", "post", " ", "id", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "afile", "_", ",_", "aname_", "=_", "self_", "._", "conf_", "._", "get", "\\u", "draft_", "(_", "posti", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "output", " ", "is", " ", "provided", ",", " ", "write", " ", "the", " ", "html", " ", "to", " ", "a", " ", "file", " ", "and", " ", "abort", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "args_", "._", "output_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "write", "\\u", "html", "\\u", "file_", "(_", "afile", "_", ")_", "\\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_", "html_", ",_", "meta_", ",_", "txt_", ",_", "medias", "_", "=_", "self_", "._", "\\u", "get", "\\u", "and", "\\u", "update", "\\u", "article", "\\u", "content_", "(_", "afile", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "html_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "meta_", "._", "posts", "tatus_", "==_", "'", "draft", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slo", "g_", "._", "warning_", "(_", "'", "The", " ", "post", " ", "status", " ", "of", " ", "draft", " ", "\"%", "s", "\"", " ", "is", " ", "\"", "draft", "\",", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "plea", "se", " ", "modif", "y", " ", "it", " ", "to", " ", "\"", "publi", "sh", "\".'_", "%_", "posti", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "all", " ", "taxonom", "y", " ", "bef", "ore", " ", "create", " ", "a", " ", "new", " ", "article", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "get", "\\u", "term", "s", "\\u", "from", "\\u", "wp_", "(_", "[_", "'", "category", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "term", "s", "\\u", "from", "\\u", "wp_", "(_", "[_", "'", "post", "\\u", "tag", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "meta_", "._", "post", "type_", "==_", "'", "page", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "post_", "=_", "Word", "Press", "Page_", "(_", ")_", "\\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 ", " _", "post_", "=_", "Word", "Press", "Post_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "terms_", "=_", "self_", "._", "cache_", "._", "get", "\\u", "term", "s", "\\u", "from", "\\u", "meta_", "(_", "meta_", "._", "category_", ",_", "meta_", "._", "tags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "post_", "._", "terms_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slo", "g_", "._", "warning_", "(_", "'", "Ple", "ase", " ", "provide", " ", "some", " ", "term", "s", ".'_", ")_", "\\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_", "post_", "._", "content_", "=_", "html_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "title_", "=_", "meta_", "._", "title_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "slug_", "=_", "meta_", "._", "nice", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "date_", "=_", "meta_", "._", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "user_", "=_", "meta_", "._", "author_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "date", "\\u", "modified_", "=_", "meta_", "._", "modified_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "post", "\\u", "status_", "=_", "meta_", "._", "posts", "tatus_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "comment", "\\u", "status_", "=_", "\"", "open", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "._", "ping", "\\u", "status_", "=_", "\"", "open", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "posti", "d_", "=_", "self_", "._", "wp", "call_", "(_", "New", "Post_", "(_", "post_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "posti", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "write", "\\u", "by", "\\u", "templ", "_", "(_", "afile", "_", ",_", "afile", "_", ",_", "{_", "'", "POST", "ID", "'_", ":_", "posti", "d_", ",_", "'", "SLU", "G", "'_", ":_", "posti", "d_", "}_", ",_", "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_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "newfile", "_", ",_", "newname_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "meta_", "._", "post", "type_", "==_", "'", "page", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "newfile", "_", ",_", "newname_", "=_", "self_", "._", "conf_", "._", "get", "\\u", "article_", "(_", "meta_", "._", "nice", "name_", ",_", "meta_", "._", "post", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "newfile", "_", ",_", "newname_", "=_", "self_", "._", "conf_", "._", "get", "\\u", "article_", "(_", "posti", "d_", ",_", "meta_", "._", "post", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "slo", "g_", "._", "info_", "(_", "'", "Move", " ", "\"%", "s", "\"", " ", "to", " ", "\"%", "s", "\".'_", "%_", "(_", "afile", "_", ",_", "newfile", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shutil_", "._", "move_", "(_", "afile", "_", ",_", "newfile", "_", ")_", "\\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, 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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, 0, 1, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
divio/django-cms/cms/test_utils/testcases.py
[ { "content": " def failUnlessWarns(self, category, message, f, *args, **kwargs):\n warningsShown = []\n result = _collectWarnings(warningsShown.append, f, *args, **kwargs)\n\n if not warningsShown:\n self.fail(\"No warnings emitted\")\n first = warningsShown[0]\n for other in warningsShown[1:]:\n if ((other.message, other.category)\n != (first.message, first.category)):\n self.fail(\"Can't handle different warnings\")\n self.assertEqual(first.message, message)\n self.assertTrue(first.category is category)\n\n return result", "metadata": "root.BaseCMSTestCase.failUnlessWarns", "header": "['class', 'BaseCMSTestCase', '(', 'object', ')', ':', '___EOS___']", "index": 379 } ]
[ { "span": "self.assertTrue(first.category is category)", "start_line": 391, "start_column": 8, "end_line": 391, "end_column": 51 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Base", "CMS", "Test", "Case_", "(_", "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_", "fail", "Un", "less", "Warn", "s_", "(_", "self_", ",_", "category_", ",_", "message_", ",_", "f_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warn", "ings", "Show", "n_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "\\u", "collect", "Warnings", "_", "(_", "warn", "ings", "Show", "n_", "._", "append_", ",_", "f_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "warn", "ings", "Show", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "No", " ", "warn", "ings", " ", "emitte", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "first_", "=_", "warn", "ings", "Show", "n_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "other_", "in_", "warn", "ings", "Show", "n_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "(_", "other_", "._", "message_", ",_", "other_", "._", "category_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "!=_", "(_", "first_", "._", "message_", ",_", "first_", "._", "category_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Can", "'", "t", " ", "handle", " ", "different", " ", "warn", "ings", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "first_", "._", "message_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "first_", "._", "category_", "is_", "category_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Except block handles 'BaseException'
bugsnag/bugsnag-python/bugsnag/__init__.py
[ { "content": "def __bugsnag_excepthook(exctype, exception, traceback):\n try:\n auto_notify(exception, traceback=traceback)\n except:\n print((\"[BUGSNAG] Error in excepthook, probably shutting down.\"))\n pass\n\n _old_excepthook(exctype, exception, traceback)", "metadata": "root.__bugsnag_excepthook", "header": "['module', '___EOS___']", "index": 103 } ]
[ { "span": "except:", "start_line": 106, "start_column": 4, "end_line": 106, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "bug", "sna", "g", "\\u", "except", "hook_", "(_", "exc", "type_", ",_", "exception_", ",_", "traceback_", ")_", ":_", "\\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 ", " _", "auto", "\\u", "notify_", "(_", "exception_", ",_", "traceback_", "=_", "traceback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "(_", "\"[", "BUG", "SNA", "G", "]", " ", "Error", " ", "in", " ", "except", "hook", ",", " ", "probab", "ly", " ", "shutt", "ing", " ", "down", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "old", "\\u", "except", "hook_", "(_", "exc", "type_", ",_", "exception_", ",_", "traceback_", ")_", "\\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, 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 ]
Unused import
baudren/montepython_public/montepython/importance_sampling.py
[ { "content": "\"\"\"\n.. module:: importance_sampling\n :synopsis: Perform an Importance Sampling from an existing folder\n\n.. moduleauthor:: Benjamin Audren <[email protected]>\n\"\"\"\ntry:\n from collections import OrderedDict as od\nexcept ImportError:\n from ordereddict import OrderedDict as od\nfrom copy import copy\nfrom multiprocessing import Pool\nimport os\nimport warnings\nimport math\n\nimport io_mp\nimport sampler\nfrom data import Data\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def run(cosmo, data, command_line):\n \"\"\"\n Performing the Importance Sampling\n\n The idea is to start from an existing run, constraining a certain model I,\n given a set of experiments. The new run will constrain the same model I,\n but adding one or several new experiments. In the case where it is expected\n that the final posterior distribution should not differ too greatly between\n the two parameter extractions, then using Importance Sampling can speed up\n significantly the second one.\n\n Instead of properly sampling randomly the parameter space, it instead reads\n the chains from the previous run, recompute the cosmology at this point,\n then adds the log-likelihood contributed by the new experiments to the\n previous ones. As an input of the method, with the flag\n `--IS-starting-folder`, you can thus specify either a folder containing a\n Monte Python run, or a set of chains that you want to be converted.\n\n The code will automatically compute the minimum amount of things. For\n instance, if the first run had all the Planck likelihoods, and the second,\n all the Planck likelihoods plus a prior on :math:`H_0`, it would be absurd\n to recompute also the cosmological perturbations: the only needed quantity\n is a background quantity.\n\n The new chains will hence store the same points in parameter space, but\n with a different value of the likelihood, and also of the multiplicity -\n that will become non-integer. Indeed, the multiplicity is also a probe of\n the posterior, and this new, higher likelihood should have had a higher\n multiplicity.\n \"\"\"\n # Check that the command_line \"--IS-starting-folder\" points to an existing\n # Monte Python folder run, or a subset of files, and store in any case all\n # the chains to analyze in the chains.\n starting_folder = command_line.IS_starting_folder\n if not starting_folder:\n raise io_mp.ConfigurationError(\n \"When running importance sampling, you should specify a folder or\"\n \" a set of chains with the option '--IS-starting-folder'\")\n chains = []\n # If starting_folder is of length 1, it means it is either a whole folder,\n # or just one chain. If it is a folder, we recover all chains within.\n if len(starting_folder) == 1:\n starting_folder = starting_folder[0]\n if os.path.isdir(starting_folder):\n for elem in os.listdir(starting_folder):\n if elem.find(\"__\") != -1:\n chains.append(elem)\n # Else, it is a list of chains, of which we recover folder name, and store\n # all of them in chains.\n else:\n chains = starting_folder\n starting_folder = os.path.sep.join(chains[0].split(os.path.sep)[:-1])\n chains = [elem.split(os.path.sep)[-1] for elem in chains]\n\n # Recovering only the extra likelihoods\n new_experiments = recover_new_experiments(\n data, command_line, starting_folder)\n if not new_experiments:\n raise io_mp.ConfigurationError(\n \"You are using Importance Sampling without adding a new \"\n \"experiment. This is not what this method is coded for.\")\n\n # resetting the needed cosmo arguments, and deleting the dictionary of\n # likelihoods, only if new_experiments is smaller than the old ones.\n ignore_likelihood = False\n\n # Wipe out the problematic information from previous likelihoods,\n # namely their desired output\n data.cosmo_arguments['output'] = ''\n\n try:\n del data.cosmo_arguments['l_max_scalars']\n del data.cosmo_arguments['lensing']\n except KeyError:\n pass\n\n # Initialise the requirements of the new likelihood\n data.initialise_likelihoods(new_experiments)\n\n # Multiprocessing part, to analyze all the chains in parallel. When not\n # specifying any 'processes' keyword argument to the Pool call, the system\n # uses as many as possible.\n pool = Pool()\n args = [(data, cosmo, command_line, starting_folder,\n elem, ignore_likelihood) for elem in chains]\n # Note the use of translate_chain_star, and not translate_chain, because of\n # the limitations of the `map` function (it only takes one argument). The\n # `_star` function simply unwraps the argument.\n print '\\nStart extracting the chains:\\n'\n pool.map(translate_chain_star, args)\n # Close the pool, and join everything (the join might not be needed)\n pool.close()\n pool.join()", "metadata": "root.run", "header": "['module', '___EOS___']", "index": 21 }, { "content": "def recover_new_experiments(data, command_line, starting_folder):\n \"\"\"\n Given the input, extract the additional likelihoods\n\n \"\"\"\n # Initialize the companion data structure, on a modified command line\n modified_command_line = copy(command_line)\n modified_command_line.folder = starting_folder\n modified_command_line.param = os.path.join(starting_folder, 'log.param')\n\n # Go through the file, and stop when you find the good line. The previous\n # way of doing, to simply initialise another data instance fails when using\n # Planck. Indeed, clik likelihoods can not be initialised twice.\n print 'Reading the starting folder'\n print '---------------------------'\n with open(modified_command_line.param, 'r') as init:\n for line in init:\n if line.find('data.experiments') != -1:\n _, experiments = line.split('=')\n experiments = experiments.strip()\n print 'The likelihood will be computed only for:'\n new_experiments = [\n elem for elem in data.experiments if elem not in experiments]\n print ' ->',\n print ', '.join(new_experiments)\n\n return new_experiments", "metadata": "root.recover_new_experiments", "header": "['module', '___EOS___']", "index": 116 }, { "content": "def translate_chain(data, cosmo, command_line,\n starting_folder, chain_name, ignore_likelihood=False):\n \"\"\"Translate the input to the output\n\n .. note::\n\n If the keyword argument `ignore_likelihood` is set to true, the\n previous value of the likelihood is discarded.\n\n \"\"\"\n\n input_path = os.path.join(starting_folder, chain_name)\n output_path = os.path.join(command_line.folder, chain_name)\n print ' -> reading ', input_path\n parameter_names = data.get_mcmc_parameters(['varying'])\n with open(input_path, 'r') as input_chain:\n with open(output_path, 'w') as output_chain:\n for line in input_chain:\n params = line.split()\n # recover the likelihood of this point\n if not ignore_likelihood:\n loglike = -float(params[1])\n else:\n loglike = 0\n N = float(params[0])\n # Assign all the recovered values to the data structure\n for index, param in enumerate(parameter_names):\n data.mcmc_parameters[param]['current'] = \\\n float(params[2+index])\n data.update_cosmo_arguments()\n\n newloglike = sampler.compute_lkl(cosmo, data)\n\n weight = math.exp(newloglike)\n newloglike += loglike\n # Accept the point\n sampler.accept_step(data)\n io_mp.print_vector([output_chain], N*weight, newloglike, data)\n print output_path, 'written'", "metadata": "root.translate_chain", "header": "['module', '___EOS___']", "index": 145 }, { "content": "def translate_chain_star(args):\n \"\"\"Trick function for multiprocessing\"\"\"\n return translate_chain(*args)", "metadata": "root.translate_chain_star", "header": "['module', '___EOS___']", "index": 186 } ]
[ { "span": "from collections import OrderedDict as od", "start_line": 7, "start_column": 4, "end_line": 7, "end_column": 45 }, { "span": "from ordereddict import OrderedDict as od", "start_line": 9, "start_column": 4, "end_line": 9, "end_column": 45 }, { "span": "import warnings", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 15 }, { "span": "from data import Data", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 21 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "..", " ", "module", "::", " ", "importance", "\\u", "samp", "ling", "\\", "10", ";", " ", " ", " ", " ", ":", "synopsis", ":", " ", "Perform", " ", "an", " ", "Importa", "nce", " ", "Sampl", "ing", " ", "from", " ", "an", " ", "exist", "ing", " ", "folder", "\\", "10", ";", "\\", "10", ";", "..", " ", "module", "author", "::", " ", "Ben", "jam", "in", " ", "Au", "dre", "n", " ", "<", "ben", "jam", "in", ".", "aud", "ren", "@", "ep", "fl", ".", "ch", ">", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "collections_", "import_", "Order", "ed", "Dict_", "as_", "od_", "\\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 ", " _", "from_", "order", "eddi", "ct_", "import_", "Order", "ed", "Dict_", "as_", "od_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "copy_", "import_", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "multiprocessing_", "import_", "Pool_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "io", "\\u", "mp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sampler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "data_", "import_", "Data_", "\\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_", "run_", "(_", "cosmo", "_", ",_", "data_", ",_", "command", "\\u", "line_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Perform", "ing", " ", "the", " ", "Importa", "nce", " ", "Sampl", "ing", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "idea", " ", "is", " ", "to", " ", "start", " ", "from", " ", "an", " ", "exist", "ing", " ", "run", ",", " ", "constrain", "ing", " ", "a", " ", "cert", "ain", " ", "model", " ", "I", ",", "\\", "10", ";", " ", " ", " ", " ", "give", "n", " ", "a", " ", "set", " ", "of", " ", "experiment", "s", ".", " ", "The", " ", "new", " ", "run", " ", "will", " ", "constrain", " ", "the", " ", "same", " ", "model", " ", "I", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "addin", "g", " ", "one", " ", "or", " ", "sever", "al", " ", "new", " ", "experiment", "s", ".", " ", "In", " ", "the", " ", "case", " ", "where", " ", "it", " ", "is", " ", "expected", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "the", " ", "final", " ", "posterior", " ", "distribu", "tion", " ", "shou", "ld", " ", "not", " ", "differ", " ", "too", " ", "great", "ly", " ", "bet", "ween", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "two", " ", "parameter", " ", "extracti", "ons", ",", " ", "then", " ", "usi", "ng", " ", "Importa", "nce", " ", "Sampl", "ing", " ", "can", " ", "speed", " ", "up", "\\", "10", ";", " ", " ", " ", " ", "significant", "ly", " ", "the", " ", "second", " ", "one", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ins", "tea", "d", " ", "of", " ", "proper", "ly", " ", "samp", "ling", " ", "random", "ly", " ", "the", " ", "parameter", " ", "space", ",", " ", "it", " ", "inst", "ead", " ", "reads", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "chain", "s", " ", "from", " ", "the", " ", "previ", "ous", " ", "run", ",", " ", "recompute", " ", "the", " ", "cosmo", "log", "y", " ", "at", " ", "this", " ", "point", ",", "\\", "10", ";", " ", " ", " ", " ", "then", " ", "adds", " ", "the", " ", "log", "-", "likelihood", " ", "contribute", "d", " ", "by", " ", "the", " ", "new", " ", "experiment", "s", " ", "to", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "previ", "ous", " ", "ones", ".", " ", "As", " ", "an", " ", "input", " ", "of", " ", "the", " ", "method", ",", " ", "with", " ", "the", " ", "flag", "\\", "10", ";", " ", " ", " ", " ", "`-", "-", "IS", "-", "startin", "g", "-", "folder", "`", ",", " ", "you", " ", "can", " ", "thu", "s", " ", "speci", "fy", " ", "eit", "her", " ", "a", " ", "folder", " ", "contain", "ing", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "Monte", " ", "Pyth", "on", " ", "run", ",", " ", "or", " ", "a", " ", "set", " ", "of", " ", "chain", "s", " ", "tha", "t", " ", "you", " ", "want", " ", "to", " ", "be", " ", "convert", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "code", " ", "will", " ", "automati", "call", "y", " ", "compute", " ", "the", " ", "minim", "um", " ", "amo", "unt", " ", "of", " ", "thing", "s", ".", " ", "For", "\\", "10", ";", " ", " ", " ", " ", "instance", ",", " ", "if", " ", "the", " ", "first", " ", "run", " ", "had", " ", "all", " ", "the", " ", "Plan", "ck", " ", "likelihood", "s", ",", " ", "and", " ", "the", " ", "second", ",", "\\", "10", ";", " ", " ", " ", " ", "all", " ", "the", " ", "Plan", "ck", " ", "likelihood", "s", " ", "plus", " ", "a", " ", "prior", " ", "on", " ", ":", "math", ":`", "H", "\\u", "0", "`", ",", " ", "it", " ", "wou", "ld", " ", "be", " ", "abs", "ur", "d", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "recompute", " ", "als", "o", " ", "the", " ", "cosmo", "logical", " ", "perturbation", "s", ":", " ", "the", " ", "only", " ", "need", "ed", " ", "quanti", "ty", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "a", " ", "background", " ", "quanti", "ty", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "new", " ", "chain", "s", " ", "will", " ", "hen", "ce", " ", "store", " ", "the", " ", "same", " ", "points", " ", "in", " ", "parameter", " ", "space", ",", " ", "but", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "a", " ", "different", " ", "value", " ", "of", " ", "the", " ", "likelihood", ",", " ", "and", " ", "als", "o", " ", "of", " ", "the", " ", "multiplicit", "y", " ", "-", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "will", " ", "bec", "ome", " ", "non", "-", "integ", "er", ".", " ", "Inde", "ed", ",", " ", "the", " ", "multiplicit", "y", " ", "is", " ", "als", "o", " ", "a", " ", "prob", "e", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "posterior", ",", " ", "and", " ", "this", " ", "new", ",", " ", "higher", " ", "likelihood", " ", "shou", "ld", " ", "have", " ", "had", " ", "a", " ", "higher", "\\", "10", ";", " ", " ", " ", " ", "multiplicit", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "the", " ", "command", "\\u", "line", " ", "\"--", "IS", "-", "startin", "g", "-", "folder", "\"", " ", "points", " ", "to", " ", "an", " ", "existing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Monte", " ", "Pyth", "on", " ", "folder", " ", "run", ",", " ", "or", " ", "a", " ", "subse", "t", " ", "of", " ", "files", ",", " ", "and", " ", "store", " ", "in", " ", "any", " ", "case", " ", "all_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "chain", "s", " ", "to", " ", "analyze", " ", "in", " ", "the", " ", "chain", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "startin", "g", "\\u", "folder_", "=_", "command", "\\u", "line_", "._", "IS", "\\u", "startin", "g", "\\u", "folder_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "startin", "g", "\\u", "folder_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "io", "\\u", "mp_", "._", "Configura", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Whe", "n", " ", "runn", "ing", " ", "importance", " ", "samp", "ling", ",", " ", "you", " ", "shou", "ld", " ", "speci", "fy", " ", "a", " ", "folder", " ", "or", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", " ", "a", " ", "set", " ", "of", " ", "chain", "s", " ", "with", " ", "the", " ", "option", " ", "'--", "IS", "-", "startin", "g", "-", "folder", "'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "chains_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "startin", "g", "\\u", "folder", " ", "is", " ", "of", " ", "length", " ", "1", ",", " ", "it", " ", "means", " ", "it", " ", "is", " ", "eit", "her", " ", "a", " ", "whole", " ", "folder", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "just", " ", "one", " ", "chain", ".", " ", "If", " ", "it", " ", "is", " ", "a", " ", "folder", ",", " ", "we", " ", "recover", " ", "all", " ", "chain", "s", " ", "within", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "startin", "g", "\\u", "folder_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "startin", "g", "\\u", "folder_", "=_", "startin", "g", "\\u", "folder_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "isdir_", "(_", "startin", "g", "\\u", "folder_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "elem_", "in_", "os_", "._", "listdir_", "(_", "startin", "g", "\\u", "folder_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "elem_", "._", "find_", "(_", "\"\\u\\u", "\"_", ")_", "!=_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "chains_", "._", "append_", "(_", "elem_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Else", ",", " ", "it", " ", "is", " ", "a", " ", "list", " ", "of", " ", "chain", "s", ",", " ", "of", " ", "whi", "ch", " ", "we", " ", "recover", " ", "folder", " ", "name", ",", " ", "and", " ", "store_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "of", " ", "them", " ", "in", " ", "chain", "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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chains_", "=_", "startin", "g", "\\u", "folder_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "startin", "g", "\\u", "folder_", "=_", "os_", "._", "path_", "._", "sep_", "._", "join_", "(_", "chains_", "[_", "0_", "]_", "._", "split_", "(_", "os_", "._", "path_", "._", "sep_", ")_", "[_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chains_", "=_", "[_", "elem_", "._", "split_", "(_", "os_", "._", "path_", "._", "sep_", ")_", "[_", "-_", "1_", "]_", "for_", "elem_", "in_", "chains_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Recover", "ing", " ", "only", " ", "the", " ", "extra", " ", "likelihood", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "experiments_", "=_", "recover", "\\u", "new", "\\u", "experiments_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "data_", ",_", "command", "\\u", "line_", ",_", "startin", "g", "\\u", "folder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "new", "\\u", "experiments_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "io", "\\u", "mp_", "._", "Configura", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "You", " ", "are", " ", "usi", "ng", " ", "Importa", "nce", " ", "Sampl", "ing", " ", "with", "out", " ", "addin", "g", " ", "a", " ", "new", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "experiment", ".", " ", "Thi", "s", " ", "is", " ", "not", " ", "what", " ", "this", " ", "method", " ", "is", " ", "code", "d", " ", "for", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "reset", "ting", " ", "the", " ", "need", "ed", " ", "cosmo", " ", "argu", "ment", "s", ",", " ", "and", " ", "delet", "ing", " ", "the", " ", "dictionar", "y", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "likelihood", "s", ",", " ", "only", " ", "if", " ", "new", "\\u", "experiment", "s", " ", "is", " ", "small", "er", " ", "than", " ", "the", " ", "old", " ", "ones", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ignore", "\\u", "likelihood_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wi", "pe", " ", "out", " ", "the", " ", "problem", "atic", " ", "informati", "on", " ", "from", " ", "previ", "ous", " ", "likelihood", "s", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "namel", "y", " ", "thei", "r", " ", "desi", "red", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "._", "cosmo", "\\u", "arguments_", "[_", "'", "output", "'_", "]_", "=_", "''_", "\\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 ", " _", "del_", "data_", "._", "cosmo", "\\u", "arguments_", "[_", "'", "l\\u", "max", "\\u", "scalars", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "data_", "._", "cosmo", "\\u", "arguments_", "[_", "'", "lens", "ing", "'_", "]_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initialise", " ", "the", " ", "require", "ment", "s", " ", "of", " ", "the", " ", "new", " ", "likelihood_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "._", "initialise", "\\u", "likelihood", "s_", "(_", "new", "\\u", "experiments_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Multi", "process", "ing", " ", "part", ",", " ", "to", " ", "analyze", " ", "all", " ", "the", " ", "chain", "s", " ", "in", " ", "parall", "el", ".", " ", "Whe", "n", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "speci", "fy", "ing", " ", "any", " ", "'", "process", "es", "'", " ", "keyw", "ord", " ", "argu", "ment", " ", "to", " ", "the", " ", "Poo", "l", " ", "call", ",", " ", "the", " ", "system_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "use", "s", " ", "as", " ", "many", " ", "as", " ", "possib", "le", "._", "\\u\\u\\uNL\\u\\u\\u_", "pool_", "=_", "Pool_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "[_", "(_", "data_", ",_", "cosmo", "_", ",_", "command", "\\u", "line_", ",_", "startin", "g", "\\u", "folder_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "elem_", ",_", "ignore", "\\u", "likelihood_", ")_", "for_", "elem_", "in_", "chains_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", "e", " ", "the", " ", "use", " ", "of", " ", "translat", "e\\u", "chain", "\\u", "star", ",", " ", "and", " ", "not", " ", "translat", "e\\u", "chain", ",", " ", "bec", "aus", "e", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "limit", "ation", "s", " ", "of", " ", "the", " ", "`", "map", "`", " ", "function", " ", "(", "it", " ", "only", " ", "take", "s", " ", "one", " ", "argu", "ment", ").", " ", "The", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "`\\u", "star", "`", " ", "function", " ", "simp", "ly", " ", "unwrap", "s", " ", "the", " ", "argu", "ment", "._", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Start", " ", "extracti", "ng", " ", "the", " ", "chain", "s", ":\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool_", "._", "map_", "(_", "translat", "e\\u", "chain", "\\u", "star_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Clos", "e", " ", "the", " ", "pool", ",", " ", "and", " ", "join", " ", "every", "thing", " ", "(", "the", " ", "join", " ", "mig", "ht", " ", "not", " ", "be", " ", "need", "ed", ")_", "\\u\\u\\uNL\\u\\u\\u_", "pool_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool_", "._", "join_", "(_", ")_", "\\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_", "recover", "\\u", "new", "\\u", "experiments_", "(_", "data_", ",_", "command", "\\u", "line_", ",_", "startin", "g", "\\u", "folder_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Give", "n", " ", "the", " ", "input", ",", " ", "extract", " ", "the", " ", "addition", "al", " ", "likelihood", "s", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Initializ", "e", " ", "the", " ", "compan", "ion", " ", "data", " ", "structure", ",", " ", "on", " ", "a", " ", "modifi", "ed", " ", "command", " ", "line_", "\\u\\u\\uNL\\u\\u\\u_", "modifi", "ed", "\\u", "command", "\\u", "line_", "=_", "copy_", "(_", "command", "\\u", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modifi", "ed", "\\u", "command", "\\u", "line_", "._", "folder_", "=_", "startin", "g", "\\u", "folder_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modifi", "ed", "\\u", "command", "\\u", "line_", "._", "param_", "=_", "os_", "._", "path_", "._", "join_", "(_", "startin", "g", "\\u", "folder_", ",_", "'", "log", ".", "param", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Go", " ", "through", " ", "the", " ", "file", ",", " ", "and", " ", "stop", " ", "whe", "n", " ", "you", " ", "find", " ", "the", " ", "good", " ", "line", ".", " ", "The", " ", "previous_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "way", " ", "of", " ", "doi", "ng", ",", " ", "to", " ", "simp", "ly", " ", "initialise", " ", "anot", "her", " ", "data", " ", "instance", " ", "fail", "s", " ", "whe", "n", " ", "using_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plan", "ck", ".", " ", "Inde", "ed", ",", " ", "cli", "k", " ", "likelihood", "s", " ", "can", " ", "not", " ", "be", " ", "initialise", "d", " ", "twi", "ce", "._", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "Reading", " ", "the", " ", "startin", "g", " ", "folder", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'-------", "--------------", "------", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "modifi", "ed", "\\u", "command", "\\u", "line_", "._", "param_", ",_", "'", "r", "'_", ")_", "as_", "init_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "init_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "line_", "._", "find_", "(_", "'", "data", ".", "experiment", "s", "'_", ")_", "!=_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u_", ",_", "experiments_", "=_", "line_", "._", "split_", "(_", "'='_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "experiments_", "=_", "experiments_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'", "The", " ", "likelihood", " ", "will", " ", "be", " ", "compute", "d", " ", "only", " ", "for", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "experiments_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "elem_", "for_", "elem_", "in_", "data_", "._", "experiments_", "if_", "elem_", "not_", "in_", "experiments_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", " ", "->", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "',", " ", "'_", "._", "join_", "(_", "new", "\\u", "experiments_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "new", "\\u", "experiments_", "\\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_", "translat", "e\\u", "chain_", "(_", "data_", ",_", "cosmo", "_", ",_", "command", "\\u", "line_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "startin", "g", "\\u", "folder_", ",_", "chain", "\\u", "name_", ",_", "ignore", "\\u", "likelihood_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Translate", " ", "the", " ", "input", " ", "to", " ", "the", " ", "output", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "note", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "keyw", "ord", " ", "argu", "ment", " ", "`", "ignore", "\\u", "likelihood", "`", " ", "is", " ", "set", " ", "to", " ", "true", ",", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "previ", "ous", " ", "value", " ", "of", " ", "the", " ", "likelihood", " ", "is", " ", "discard", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "startin", "g", "\\u", "folder_", ",_", "chain", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output", "\\u", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "command", "\\u", "line_", "._", "folder_", ",_", "chain", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", " ", "->", " ", "readi", "ng", " ", "'_", ",_", "input", "\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "\\u", "names_", "=_", "data_", "._", "get", "\\u", "mcmc", "\\u", "parameters_", "(_", "[_", "'", "varying", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "input", "\\u", "path_", ",_", "'", "r", "'_", ")_", "as_", "input", "\\u", "chain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "output", "\\u", "path_", ",_", "'", "w", "'_", ")_", "as_", "output", "\\u", "chain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "input", "\\u", "chain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "line_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "recover", " ", "the", " ", "likelihood", " ", "of", " ", "this", " ", "point_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "ignore", "\\u", "likelihood_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "loglik", "e_", "=_", "-_", "float_", "(_", "params_", "[_", "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 ", " ", "_", "loglik", "e_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "N_", "=_", "float_", "(_", "params_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Assign", " ", "all", " ", "the", " ", "recovered", " ", "values", " ", "to", " ", "the", " ", "data", " ", "structure_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "index_", ",_", "param_", "in_", "enumerate_", "(_", "parameter", "\\u", "names_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "data_", "._", "mcmc", "\\u", "parameters_", "[_", "param_", "]_", "[_", "'", "current", "'_", "]_", "=_", "float_", "(_", "params_", "[_", "2_", "+_", "index_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "._", "update", "\\u", "cosmo", "\\u", "arguments_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "newl", "og", "like_", "=_", "sampler_", "._", "compute", "\\u", "lk", "l_", "(_", "cosmo", "_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "weight_", "=_", "math_", "._", "exp_", "(_", "newl", "og", "like_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newl", "og", "like_", "+=_", "loglik", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Accept", " ", "the", " ", "point_", "\\u\\u\\uNL\\u\\u\\u_", "sampler_", "._", "accept", "\\u", "step_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "io", "\\u", "mp_", "._", "print", "\\u", "vector_", "(_", "[_", "output", "\\u", "chain_", "]_", ",_", "N_", "*_", "weight_", ",_", "newl", "og", "like_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "output", "\\u", "path_", ",_", "'", "writt", "en", "'_", "\\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_", "translat", "e\\u", "chain", "\\u", "star_", "(_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Tri", "ck", " ", "function", " ", "for", " ", "multipro", "cess", "ing", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "translat", "e\\u", "chain_", "(_", "*_", "args_", ")_" ]
[ 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, 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, 0, 1, 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, 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, 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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, 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 ]
Unused import
googlei18n/nototools/nototools/grab_download.py
[ { "content": "#!/usr/bin/python\n#\n# Copyright 2014 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\"\"\"Base code for copying and unpacking font drops from vendors.\n\nSee grab_mt_download.py and grab_adobe_download.py\"\"\"\n\n__author__ = \"[email protected] (Doug Felt)\"\n\nimport argparse\nimport os\nimport os.path\nimport re\nimport shutil\nimport zipfile\n\nfrom fontTools import ttLib\n\nimport notoconfig\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def grab_files(dst, files, src_vendor, name_date_re, extract_fn):\n \"\"\"Get date from each filename in files, create a folder for it, under\n dst/drops, then extract the files to it.\"\"\"\n\n # The zip indicates that the corresponding drop is good and built from it. But\n # we might have messed up along the way, so:\n # - if we have a drop and a zip, assume it's already handled\n # - if we have a drop but no zip, assume the drop needs to be rebuilt from the zip\n # - if we have a zip and no drop\n # - if we have new zip, complain\n # - else rebuild the drop from the old zip\n # - else build the drop, and if successful, save the zip\n\n for f in files:\n if not os.path.exists(f):\n print 'file \\'%s\\' does not exist, skipping' % f\n continue\n\n filename = os.path.basename(f)\n result = name_date_re.match(filename)\n if not result:\n print 'could not parse %s, skipping' % f\n continue\n\n name = result.group(1)\n date = '_'.join([d for d in result.group(2,3,4)])\n drop_dir = os.path.join(dst, 'drops', name + '_' + date)\n\n zip_dir = os.path.join(dst, 'zips')\n zip_filename = os.path.join(zip_dir, filename)\n if os.path.exists(drop_dir):\n if os.path.exists(zip_filename):\n print 'already have a %s drop and zip for %s' % (src_vendor, filename)\n continue\n else:\n # clean up, assume needs rebuild\n shutil.rmtree(drop_dir)\n else:\n if os.path.exists(zip_filename):\n if os.path.realpath(f) != os.path.realpath(zip_filename):\n print 'already have a zip file named %s for %s' % (zip_filename, f)\n continue\n\n os.mkdir(drop_dir)\n extract_fn(drop_dir, f)\n\n if not os.path.exists(zip_filename):\n print 'writing %s to %s' % (f, zip_filename)\n shutil.copy2(f, zip_filename)", "metadata": "root.grab_files", "header": "['module', '___EOS___']", "index": 34 }, { "content": "def matching_files_in_dir(src, namere):\n \"\"\"Iterate over files in src with names matching namere, returning the list.\"\"\"\n filelist = []\n for f in os.listdir(src):\n path = os.path.join(src, f)\n if not os.path.isfile(path):\n continue\n if not re.search(namere, f):\n continue\n filelist.append(path)\n if not filelist:\n print \"no files in %s matched '%s'\" % (src, namere)\n return filelist", "metadata": "root.matching_files_in_dir", "header": "['module', '___EOS___']", "index": 85 }, { "content": "def invoke_main(src_vendor, name_date_re, extract_fn, default_params = {}):\n \"\"\"Grab the files.\n\n src_vendor is a string, currently either Adobe or Monotype.\n name_date_re is a regex, it should extract name, year, month, and day fields from the filename\n extract_fn is a fn to to extract a file, it takes two args, a dest dir and the zip file name.\n\n default_params are default values for argparse. They can be:\n - default_srcdir\n - default_dstdir\n - default_regex\n\n The default regex and the name_date_re are superficially similar, but different in\n purpose. The default_regex is used to select files under the src directory. The\n name_date_re is used to extract the date from the file name. Both apply to the\n file name, but the default_regex can be anything, while name_date_re needs to select\n four groups, where the 2nd, 3rd, and 4th are the year, month, and day (yes this is\n brittle, but all of this is).\n\n The dest directory must exist and should have 'zips' and 'drops' subdirs.\"\"\"\n\n if not src_vendor:\n print 'must define src_vendor'\n return\n if not name_date_re:\n print 'must define name_date_re'\n return\n if not extract_fn:\n print 'must define extract_fn'\n return\n\n default_srcdir = default_params.get('default_srcdir')\n default_dstdir = default_params.get('default_dstdir')\n default_regex = default_params.get('default_regex')\n\n parser = argparse.ArgumentParser(description='Copy and extract drop from %s.' %\n src_vendor)\n parser.add_argument('-dd', '--dstdir', help='destination directory (default %s)' %\n default_dstdir, default=default_dstdir, metavar='dst')\n parser.add_argument('-sd', '--srcdir', help='source directory (default %s)' %\n default_srcdir, default=default_srcdir, metavar='src')\n parser.add_argument('--name', help='file name regex to match (default \\'%s\\')' %\n default_regex, default=default_regex, metavar='re')\n parser.add_argument('--srcs', help='source files (if defined, use instead of srcdir+name)',\n nargs=\"*\", metavar='zip')\n args = parser.parse_args()\n\n if not os.path.exists(args.dstdir):\n print '%s does not exists or is not a directory' % args.dstdir\n return\n\n if not args.srcs:\n if not os.path.isdir(args.srcdir):\n print '%s does not exist or is not a directory' % args.srcdir\n return\n filelist = matching_files_in_dir(args.srcdir, args.name)\n else:\n filelist = args.srcs\n\n grab_files(args.dstdir, filelist, src_vendor, name_date_re, extract_fn)", "metadata": "root.invoke_main", "header": "['module', '___EOS___']", "index": 100 } ]
[ { "span": "import zipfile", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 14 }, { "span": "from fontTools import ttLib", "start_line": 29, "start_column": 0, "end_line": 29, "end_column": 27 }, { "span": "import notoconfig", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2014", " ", "Goo", "gle", " ", "Inc", ".", " ", "All", " ", "rights", " ", "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_", "\"\"\"", "Base", " ", "code", " ", "for", " ", "copy", "ing", " ", "and", " ", "unpack", "ing", " ", "font", " ", "drops", " ", "from", " ", "vendor", "s", ".", "\\", "10", ";", "\\", "10", ";", "See", " ", "gra", "b", "\\u", "mt", "\\u", "download", ".", "py", " ", "and", " ", "gra", "b", "\\u", "ado", "be", "\\u", "download", ".", "py", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "\"", "dou", "gf", "elt", "@", "google", ".", "com", " ", "(", "Dou", "g", " ", "Fel", "t", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "argparse_", "\\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_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "zipfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "font", "Tools_", "import_", "tt", "Lib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "not", "oco", "nfig_", "\\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_", "gra", "b", "\\u", "files_", "(_", "dst_", ",_", "files_", ",_", "src", "\\u", "vendor_", ",_", "name", "\\u", "date", "\\u", "re_", ",_", "extract", "\\u", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "date", " ", "from", " ", "each", " ", "filename", " ", "in", " ", "files", ",", " ", "create", " ", "a", " ", "folder", " ", "for", " ", "it", ",", " ", "under", "\\", "10", ";", " ", " ", "dst", "/", "drops", ",", " ", "then", " ", "extract", " ", "the", " ", "files", " ", "to", " ", "it", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "zip", " ", "indicat", "es", " ", "tha", "t", " ", "the", " ", "correspond", "ing", " ", "drop", " ", "is", " ", "good", " ", "and", " ", "bui", "lt", " ", "from", " ", "it", ".", " ", "Bu", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "mig", "ht", " ", "have", " ", "mess", "ed", " ", "up", " ", "along", " ", "the", " ", "way", ",", " ", "so", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "if", " ", "we", " ", "have", " ", "a", " ", "drop", " ", "and", " ", "a", " ", "zip", ",", " ", "assume", " ", "it", "'", "s", " ", "alr", "ead", "y", " ", "handled_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "if", " ", "we", " ", "have", " ", "a", " ", "drop", " ", "but", " ", "no", " ", "zip", ",", " ", "assume", " ", "the", " ", "drop", " ", "need", "s", " ", "to", " ", "be", " ", "rebu", "ilt", " ", "from", " ", "the", " ", "zip_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "if", " ", "we", " ", "have", " ", "a", " ", "zip", " ", "and", " ", "no", " ", "drop_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "-", " ", "if", " ", "we", " ", "have", " ", "new", " ", "zip", ",", " ", "compl", "ain_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "-", " ", "else", " ", "rebu", "ild", " ", "the", " ", "drop", " ", "from", " ", "the", " ", "old", " ", "zip_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "else", " ", "build", " ", "the", " ", "drop", ",", " ", "and", " ", "if", " ", "success", "ful", ",", " ", "save", " ", "the", " ", "zip_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "f_", "in_", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "file", " ", "\\\\'", "%", "s", "\\\\'", " ", "doe", "s", " ", "not", " ", "exist", ",", " ", "skip", "ping", "'_", "%_", "f_", "\\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_", "filename_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "name", "\\u", "date", "\\u", "re_", "._", "match_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "coul", "d", " ", "not", " ", "parse", " ", "%", "s", ",", " ", "skip", "ping", "'_", "%_", "f_", "\\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_", "name_", "=_", "result_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "'\\u'_", "._", "join_", "(_", "[_", "d_", "for_", "d_", "in_", "result_", "._", "group_", "(_", "2_", ",_", "3_", ",_", "4_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drop", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dst_", ",_", "'", "drops", "'_", ",_", "name_", "+_", "'\\u'_", "+_", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "zip", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dst_", ",_", "'", "zip", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zip", "\\u", "filename_", "=_", "os_", "._", "path_", "._", "join_", "(_", "zip", "\\u", "dir_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "drop", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "path_", "._", "exists_", "(_", "zip", "\\u", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "alr", "ead", "y", " ", "have", " ", "a", " ", "%", "s", " ", "drop", " ", "and", " ", "zip", " ", "for", " ", "%", "s", "'_", "%_", "(_", "src", "\\u", "vendor_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "clean", " ", "up", ",", " ", "assume", " ", "need", "s", " ", "rebuild_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "shutil_", "._", "rmtree_", "(_", "drop", "\\u", "dir_", ")_", "\\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_", "os_", "._", "path_", "._", "exists_", "(_", "zip", "\\u", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "path_", "._", "realpath_", "(_", "f_", ")_", "!=_", "os_", "._", "path_", "._", "realpath_", "(_", "zip", "\\u", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "alr", "ead", "y", " ", "have", " ", "a", " ", "zip", " ", "file", " ", "named", " ", "%", "s", " ", "for", " ", "%", "s", "'_", "%_", "(_", "zip", "\\u", "filename_", ",_", "f_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "mkdir_", "(_", "drop", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extract", "\\u", "fn_", "(_", "drop", "\\u", "dir_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "zip", "\\u", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "writ", "ing", " ", "%", "s", " ", "to", " ", "%", "s", "'_", "%_", "(_", "f_", ",_", "zip", "\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shutil_", "._", "copy2_", "(_", "f_", ",_", "zip", "\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "matchi", "ng", "\\u", "files", "\\u", "in", "\\u", "dir_", "(_", "src_", ",_", "name", "re_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Iterat", "e", " ", "over", " ", "files", " ", "in", " ", "src", " ", "with", " ", "names", " ", "matchi", "ng", " ", "name", "re", ",", " ", "return", "ing", " ", "the", " ", "list", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filelist_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "src_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "src_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "isfile_", "(_", "path_", ")_", ":_", "\\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_", "not_", "re_", "._", "search_", "(_", "name", "re_", ",_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "filelist_", "._", "append_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "filelist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "no", " ", "files", " ", "in", " ", "%", "s", " ", "matche", "d", " ", "'%", "s", "'\"_", "%_", "(_", "src_", ",_", "name", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "filelist_", "\\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_", "invoke", "\\u", "main_", "(_", "src", "\\u", "vendor_", ",_", "name", "\\u", "date", "\\u", "re_", ",_", "extract", "\\u", "fn_", ",_", "default", "\\u", "params_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Grab", " ", "the", " ", "files", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "src", "\\u", "vendor", " ", "is", " ", "a", " ", "string", ",", " ", "currentl", "y", " ", "eit", "her", " ", "Ado", "be", " ", "or", " ", "Mono", "type", ".", "\\", "10", ";", " ", " ", "name", "\\u", "date", "\\u", "re", " ", "is", " ", "a", " ", "regex", ",", " ", "it", " ", "shou", "ld", " ", "extract", " ", "name", ",", " ", "year", ",", " ", "month", ",", " ", "and", " ", "day", " ", "fields", " ", "from", " ", "the", " ", "filename", "\\", "10", ";", " ", " ", "extract", "\\u", "fn", " ", "is", " ", "a", " ", "fn", " ", "to", " ", "to", " ", "extract", " ", "a", " ", "file", ",", " ", "it", " ", "take", "s", " ", "two", " ", "args", ",", " ", "a", " ", "dest", " ", "dir", " ", "and", " ", "the", " ", "zip", " ", "file", " ", "name", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "default", "\\u", "params", " ", "are", " ", "default", " ", "values", " ", "for", " ", "argp", "arse", ".", " ", " ", "The", "y", " ", "can", " ", "be", ":", "\\", "10", ";", " ", " ", "-", " ", "default", "\\u", "src", "dir", "\\", "10", ";", " ", " ", "-", " ", "default", "\\u", "dst", "dir", "\\", "10", ";", " ", " ", "-", " ", "default", "\\u", "regex", "\\", "10", ";", "\\", "10", ";", " ", " ", "The", " ", "default", " ", "regex", " ", "and", " ", "the", " ", "name", "\\u", "date", "\\u", "re", " ", "are", " ", "super", "ficia", "ll", "y", " ", "similar", ",", " ", "but", " ", "different", " ", "in", "\\", "10", ";", " ", " ", "purpose", ".", " ", " ", "The", " ", "default", "\\u", "regex", " ", "is", " ", "used", " ", "to", " ", "select", " ", "files", " ", "under", " ", "the", " ", "src", " ", "director", "y", ".", " ", "The", "\\", "10", ";", " ", " ", "name", "\\u", "date", "\\u", "re", " ", "is", " ", "used", " ", "to", " ", "extract", " ", "the", " ", "date", " ", "from", " ", "the", " ", "file", " ", "name", ".", " ", " ", "Bot", "h", " ", "appl", "y", " ", "to", " ", "the", "\\", "10", ";", " ", " ", "file", " ", "name", ",", " ", "but", " ", "the", " ", "default", "\\u", "regex", " ", "can", " ", "be", " ", "anyt", "hing", ",", " ", "whi", "le", " ", "name", "\\u", "date", "\\u", "re", " ", "need", "s", " ", "to", " ", "select", "\\", "10", ";", " ", " ", "four", " ", "group", "s", ",", " ", "where", " ", "the", " ", "2n", "d", ",", " ", "3", "rd", ",", " ", "and", " ", "4", "th", " ", "are", " ", "the", " ", "year", ",", " ", "month", ",", " ", "and", " ", "day", " ", "(", "ye", "s", " ", "this", " ", "is", "\\", "10", ";", " ", " ", "bri", "ttl", "e", ",", " ", "but", " ", "all", " ", "of", " ", "this", " ", "is", ").", "\\", "10", ";", "\\", "10", ";", " ", " ", "The", " ", "dest", " ", "director", "y", " ", "must", " ", "exist", " ", "and", " ", "shou", "ld", " ", "have", " ", "'", "zip", "s", "'", " ", "and", " ", "'", "drops", "'", " ", "subdir", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "src", "\\u", "vendor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "must", " ", "defin", "e", " ", "src", "\\u", "vendor", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "name", "\\u", "date", "\\u", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "must", " ", "defin", "e", " ", "name", "\\u", "date", "\\u", "re", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "extract", "\\u", "fn_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "must", " ", "defin", "e", " ", "extract", "\\u", "fn", "'_", "\\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_", "default", "\\u", "srcdir_", "=_", "default", "\\u", "params_", "._", "get_", "(_", "'", "default", "\\u", "src", "dir", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "dst", "dir_", "=_", "default", "\\u", "params_", "._", "get_", "(_", "'", "default", "\\u", "dst", "dir", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "regex_", "=_", "default", "\\u", "params_", "._", "get_", "(_", "'", "default", "\\u", "regex", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "description_", "=_", "'", "Copy", " ", "and", " ", "extract", " ", "drop", " ", "from", " ", "%", "s", ".'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "src", "\\u", "vendor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'-", "dd", "'_", ",_", "'--", "dst", "dir", "'_", ",_", "help_", "=_", "'", "destinat", "ion", " ", "director", "y", " ", "(", "default", " ", "%", "s", ")'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "dst", "dir_", ",_", "default_", "=_", "default", "\\u", "dst", "dir_", ",_", "metavar_", "=_", "'", "dst", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'-", "sd", "'_", ",_", "'--", "src", "dir", "'_", ",_", "help_", "=_", "'", "source", " ", "director", "y", " ", "(", "default", " ", "%", "s", ")'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "srcdir_", ",_", "default_", "=_", "default", "\\u", "srcdir_", ",_", "metavar_", "=_", "'", "src", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "name", "'_", ",_", "help_", "=_", "'", "file", " ", "name", " ", "regex", " ", "to", " ", "match", " ", "(", "default", " ", "\\\\'", "%", "s", "\\\\')", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "regex_", ",_", "default_", "=_", "default", "\\u", "regex_", ",_", "metavar_", "=_", "'", "re", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "srcs", "'_", ",_", "help_", "=_", "'", "source", " ", "files", " ", "(", "if", " ", "defin", "ed", ",", " ", "use", " ", "inst", "ead", " ", "of", " ", "src", "dir", "+", "name", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nargs_", "=_", "\"*\"_", ",_", "metavar_", "=_", "'", "zip", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "args_", "._", "dst", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'%", "s", " ", "doe", "s", " ", "not", " ", "exist", "s", " ", "or", " ", "is", " ", "not", " ", "a", " ", "director", "y", "'_", "%_", "args_", "._", "dst", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "args_", "._", "srcs", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "isdir_", "(_", "args_", "._", "srcdir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'%", "s", " ", "doe", "s", " ", "not", " ", "exist", " ", "or", " ", "is", " ", "not", " ", "a", " ", "director", "y", "'_", "%_", "args_", "._", "srcdir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "filelist_", "=_", "matchi", "ng", "\\u", "files", "\\u", "in", "\\u", "dir_", "(_", "args_", "._", "srcdir_", ",_", "args_", "._", "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 ", " _", "filelist_", "=_", "args_", "._", "srcs", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gra", "b", "\\u", "files_", "(_", "args_", "._", "dst", "dir_", ",_", "filelist_", ",_", "src", "\\u", "vendor_", ",_", "name", "\\u", "date", "\\u", "re_", ",_", "extract", "\\u", "fn_", ")_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
cloudera/hue/desktop/core/ext-py/Django-1.6.10/tests/utils_tests/test_simplelazyobject.py
[ { "content": " def test_repr(self):\n # First, for an unevaluated SimpleLazyObject\n x = SimpleLazyObject(complex_object)\n # __repr__ contains __repr__ of setup function and does not evaluate\n # the SimpleLazyObject\n self.assertEqual(\"<SimpleLazyObject: %r>\" % complex_object, repr(x))\n self.assertEqual(empty, x._wrapped)\n\n # Second, for an evaluated SimpleLazyObject\n name = x.name # evaluate\n self.assertIsInstance(x._wrapped, _ComplexObject)\n # __repr__ contains __repr__ of wrapped object\n self.assertEqual(\"<SimpleLazyObject: %r>\" % x._wrapped, repr(x))", "metadata": "root.TestUtilsSimpleLazyObject.test_repr", "header": "['class', 'TestUtilsSimpleLazyObject', '(', 'TestCase', ')', ':', '___EOS___']", "index": 62 }, { "content": " def test_deepcopy(self):\n # Check that we *can* do deep copy, and that it returns the right\n # objects.\n\n # First, for an unevaluated SimpleLazyObject\n s = SimpleLazyObject(complex_object)\n self.assertIs(s._wrapped, empty)\n s2 = copy.deepcopy(s)\n # something has gone wrong is s is evaluated\n self.assertIs(s._wrapped, empty)\n self.assertEqual(s2, complex_object())\n\n # Second, for an evaluated SimpleLazyObject\n name = s.name # evaluate\n self.assertIsNot(s._wrapped, empty)\n s3 = copy.deepcopy(s)\n self.assertEqual(s3, complex_object())", "metadata": "root.TestUtilsSimpleLazyObject.test_deepcopy", "header": "['class', 'TestUtilsSimpleLazyObject', '(', 'TestCase', ')', ':', '___EOS___']", "index": 88 }, { "content": " def test_pickle_py2_regression(self):\n # See ticket #20212\n user = User.objects.create_user('johndoe', '[email protected]', 'pass')\n x = SimpleLazyObject(lambda: user)\n\n # This would fail with \"TypeError: can't pickle instancemethod objects\",\n # only on Python 2.X.\n pickled = pickle.dumps(x)\n\n # Try the variant protocol levels.\n pickled = pickle.dumps(x, 0)\n pickled = pickle.dumps(x, 1)\n pickled = pickle.dumps(x, 2)\n\n if six.PY2:\n import cPickle\n\n # This would fail with \"TypeError: expected string or Unicode object, NoneType found\".\n pickled = cPickle.dumps(x)", "metadata": "root.TestUtilsSimpleLazyObjectDjangoTestCase.test_pickle_py2_regression", "header": "['class', 'TestUtilsSimpleLazyObjectDjangoTestCase', '(', 'DjangoTestCase', ')', ':', '___EOS___']", "index": 169 } ]
[ { "span": "name ", "start_line": 71, "start_column": 8, "end_line": 71, "end_column": 12 }, { "span": "name ", "start_line": 101, "start_column": 8, "end_line": 101, "end_column": 12 }, { "span": "pickled ", "start_line": 187, "start_column": 12, "end_line": 187, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Ut", "il", "s", "Simple", "La", "zy", "Object_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "repr_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fi", "rst", ",", " ", "for", " ", "an", " ", "une", "valu", "ated", " ", "Simple", "La", "zy", "Object_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "Simple", "La", "zy", "Object_", "(_", "complex", "\\u", "object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "\\u\\u", "repr", "\\u\\u", " ", "contain", "s", " ", "\\u\\u", "repr", "\\u\\u", " ", "of", " ", "setup", " ", "function", " ", "and", " ", "doe", "s", " ", "not", " ", "evaluate_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "Simple", "La", "zy", "Object_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"<", "Simple", "La", "zy", "Object", ":", " ", "%", "r", ">\"_", "%_", "complex", "\\u", "object_", ",_", "repr_", "(_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "empty_", ",_", "x_", "._", "\\u", "wrapped_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Second", ",", " ", "for", " ", "an", " ", "evaluate", "d", " ", "Simple", "La", "zy", "Object_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "x_", "._", "name_", "#", " ", "evaluate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "Instance_", "(_", "x_", "._", "\\u", "wrapped_", ",_", "\\u", "Comple", "x", "Object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "\\u\\u", "repr", "\\u\\u", " ", "contain", "s", " ", "\\u\\u", "repr", "\\u\\u", " ", "of", " ", "wrapp", "ed", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"<", "Simple", "La", "zy", "Object", ":", " ", "%", "r", ">\"_", "%_", "x_", "._", "\\u", "wrapped_", ",_", "repr_", "(_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ut", "il", "s", "Simple", "La", "zy", "Object_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "deepcopy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "we", " ", "*", "can", "*", " ", "do", " ", "deep", " ", "copy", ",", " ", "and", " ", "tha", "t", " ", "it", " ", "return", "s", " ", "the", " ", "right_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "object", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", ",", " ", "for", " ", "an", " ", "une", "valu", "ated", " ", "Simple", "La", "zy", "Object_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Simple", "La", "zy", "Object_", "(_", "complex", "\\u", "object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is_", "(_", "s_", "._", "\\u", "wrapped_", ",_", "empty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s2_", "=_", "copy_", "._", "deepcopy_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "somet", "hing", " ", "has", " ", "gone", " ", "wrong", " ", "is", " ", "s", " ", "is", " ", "evaluate", "d_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Is_", "(_", "s_", "._", "\\u", "wrapped_", ",_", "empty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s2_", ",_", "complex", "\\u", "object_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Second", ",", " ", "for", " ", "an", " ", "evaluate", "d", " ", "Simple", "La", "zy", "Object_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "s_", "._", "name_", "#", " ", "evaluate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "Not_", "(_", "s_", "._", "\\u", "wrapped_", ",_", "empty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s3_", "=_", "copy_", "._", "deepcopy_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s3_", ",_", "complex", "\\u", "object_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ut", "il", "s", "Simple", "La", "zy", "Object", "Dj", "ang", "o", "Test", "Case_", "(_", "Dj", "ang", "o", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "pickle", "\\u", "py2", "\\u", "regression_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "See", " ", "tick", "et", " ", "#", "202", "12_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "objects_", "._", "create", "\\u", "user_", "(_", "'", "john", "doe", "'_", ",_", "'", "john", "@", "example", ".", "com", "'_", ",_", "'", "pass", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "Simple", "La", "zy", "Object_", "(_", "lambda_", ":_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "wou", "ld", " ", "fail", " ", "with", " ", "\"", "Type", "Error", ":", " ", "can", "'", "t", " ", "pickle", " ", "instance", "method", " ", "object", "s", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "only", " ", "on", " ", "Pyth", "on", " ", "2", ".", "X", "._", "\\u\\u\\uNL\\u\\u\\u_", "pickled", "_", "=_", "pickle_", "._", "dumps_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tr", "y", " ", "the", " ", "variant", " ", "protoc", "ol", " ", "level", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "pickled", "_", "=_", "pickle_", "._", "dumps_", "(_", "x_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pickled", "_", "=_", "pickle_", "._", "dumps_", "(_", "x_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pickled", "_", "=_", "pickle_", "._", "dumps_", "(_", "x_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "six_", "._", "PY", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "c", "Pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "wou", "ld", " ", "fail", " ", "with", " ", "\"", "Type", "Error", ":", " ", "expected", " ", "string", " ", "or", " ", "Unic", "ode", " ", "object", ",", " ", "Non", "e",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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, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
ufora/ufora/ufora/BackendGateway/SubscribableWebObjects/MessageProcessor.py
[ { "content": " def handleReadMessage(self, jsonMessage, objectToRead):\n fieldFun = self.getFieldExtractorForReadMessage(jsonMessage, objectToRead)\n try:\n return [{\n \"messageId\": jsonMessage[\"messageId\"],\n \"responseType\": \"ReadResponse\",\n \"value\": self.outgoingObjectCache.convertResponseToJson(fieldFun(objectToRead))\n }]\n\n except Exception as e:\n try:\n objectType = objectToRead.__location_class__ if ComputedGraph.isLocation(objectToRead) else str(objectToRead)\n logging.info(\"converting %s of type %s\", fieldFun(objectToRead), objectType)\n except:\n pass\n return [unexpectedExceptionJson(jsonMessage, Exceptions.wrapException(e).message)]", "metadata": "root.MessageProcessor.handleReadMessage", "header": "['class', 'MessageProcessor', '(', 'object', ')', ':', '___EOS___']", "index": 531 }, { "content": " def encodeSubscriptionChangesAsJsonAndDrop(self, changedSubscriptionIds):\n result = []\n\n for messageId in changedSubscriptionIds:\n value = self.subscriptions.getValueAndDropSubscription(messageId)\n\n try:\n if isinstance(value, Exceptions.SubscribableWebObjectsException):\n valueResponseJson = {\n \"messageId\": messageId,\n \"responseType\": \"Exception\",\n \"message\": value.message\n }\n else:\n valueResponseJson = {\n \"messageId\": messageId,\n \"responseType\": \"ValueChanged\",\n \"value\": self.outgoingObjectCache.convertResponseToJson(value)\n }\n except:\n guid = uuid.uuid4()\n logging.error(\n \"Exception occurred converting subscription value to json. guid = %s. tb =\\n%s\",\n guid,\n traceback.format_exc()\n )\n\n valueResponseJson = {\n \"messageId\": messageId,\n \"responseType\": \"Exception\",\n \"message\": \"Error converting result to json. guid = %s\" % guid\n }\n\n result.append(valueResponseJson)\n\n return result", "metadata": "root.MessageProcessor.encodeSubscriptionChangesAsJsonAndDrop", "header": "['class', 'MessageProcessor', '(', 'object', ')', ':', '___EOS___']", "index": 571 } ]
[ { "span": "except:", "start_line": 544, "start_column": 12, "end_line": 544, "end_column": 19 }, { "span": "except:", "start_line": 590, "start_column": 12, "end_line": 590, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Messag", "e", "Processor_", "(_", "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_", "handle", "Read", "Message_", "(_", "self_", ",_", "json", "Message_", ",_", "object", "To", "Read_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "Fun", "_", "=_", "self_", "._", "get", "Field", "Extract", "or", "For", "Read", "Message_", "(_", "json", "Message_", ",_", "object", "To", "Read_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "Id", "\"_", ":_", "json", "Message_", "[_", "\"", "message", "Id", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "response", "Type", "\"_", ":_", "\"", "Read", "Respons", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "value", "\"_", ":_", "self_", "._", "outgoing", "Object", "Cache_", "._", "convert", "Respons", "e", "To", "Json_", "(_", "field", "Fun", "_", "(_", "object", "To", "Read_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "object", "Type_", "=_", "object", "To", "Read_", "._", "\\u\\u", "location", "\\u", "class\\u\\u_", "if_", "Computed", "Graph_", "._", "is", "Location_", "(_", "object", "To", "Read_", ")_", "else_", "str_", "(_", "object", "To", "Read_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "convert", "ing", " ", "%", "s", " ", "of", " ", "type", " ", "%", "s", "\"_", ",_", "field", "Fun", "_", "(_", "object", "To", "Read_", ")_", ",_", "object", "Type_", ")_", "\\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_", "return_", "[_", "unexpected", "Except", "ion", "Json_", "(_", "json", "Message_", ",_", "Exceptions_", "._", "wrap", "Exception_", "(_", "e_", ")_", "._", "message_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Messag", "e", "Processor_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "encode", "Subscription", "Change", "s", "As", "Js", "on", "And", "Drop", "_", "(_", "self_", ",_", "change", "d", "Subscription", "Ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "message", "Id_", "in_", "change", "d", "Subscription", "Ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "self_", "._", "subscriptions_", "._", "get", "Value", "And", "Drop", "Subscription_", "(_", "message", "Id_", ")_", "\\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_", "isinstance_", "(_", "value_", ",_", "Exceptions_", "._", "Subscrib", "able", "Web", "Object", "s", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value", "Respons", "e", "Json_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "Id", "\"_", ":_", "message", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "response", "Type", "\"_", ":_", "\"", "Except", "ion", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "\"_", ":_", "value_", "._", "message_", "\\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 ", " ", "_", "value", "Respons", "e", "Json_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "Id", "\"_", ":_", "message", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "response", "Type", "\"_", ":_", "\"", "Value", "Change", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "value", "\"_", ":_", "self_", "._", "outgoing", "Object", "Cache_", "._", "convert", "Respons", "e", "To", "Json_", "(_", "value_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\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 ", " _", "guid_", "=_", "uuid_", "._", "uuid4_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Except", "ion", " ", "occur", "red", " ", "convert", "ing", " ", "subscript", "ion", " ", "value", " ", "to", " ", "json", ".", " ", "guid", " ", "=", " ", "%", "s", ".", " ", "tb", " ", "=\\\\", "n", "%", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "guid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "value", "Respons", "e", "Json_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "Id", "\"_", ":_", "message", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "response", "Type", "\"_", ":_", "\"", "Except", "ion", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "\"_", ":_", "\"", "Error", " ", "convert", "ing", " ", "result", " ", "to", " ", "json", ".", " ", "guid", " ", "=", " ", "%", "s", "\"_", "%_", "guid_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "._", "append_", "(_", "value", "Respons", "e", "Json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\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, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
lsbardel/python-stdnet/tests/all/utils/zset.py
[ { "content": " def test_update(self):\n string = test.populate('string', size=100)\n values = test.populate('float', size=100)\n s = zset()\n s.update(zip(values,string))\n self.assertTrue(s)\n prev = None\n for score, _ in s.items():\n if prev is not None:\n self.assertTrue(score>=prev)\n prev = score\n return s", "metadata": "root.TestPythonZset.test_update", "header": "['class', 'TestPythonZset', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 30 }, { "content": " def test_remove(self):\n s = self.test_update()\n values = list(s)\n while values:\n index = randint(0, len(values)-1)\n val = values.pop(index)\n self.assertTrue(val in s)\n self.assertNotEqual(s.remove(val), None)\n self.assertFalse(val in s)\n self.assertFalse(s)", "metadata": "root.TestPythonZset.test_remove", "header": "['class', 'TestPythonZset', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 43 } ]
[ { "span": "self.assertTrue(score>=prev)", "start_line": 39, "start_column": 16, "end_line": 39, "end_column": 44 }, { "span": "self.assertTrue(val in s)", "start_line": 49, "start_column": 12, "end_line": 49, "end_column": 37 }, { "span": "self.assertFalse(val in s)", "start_line": 51, "start_column": 12, "end_line": 51, "end_column": 38 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Pyth", "on", "Zs", "et_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "update_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "string_", "=_", "test_", "._", "populate_", "(_", "'", "string", "'_", ",_", "size_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "=_", "test_", "._", "populate_", "(_", "'", "float", "'_", ",_", "size_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "zs", "et_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "update_", "(_", "zip_", "(_", "values_", ",_", "string_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "score_", ",_", "\\u_", "in_", "s_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "prev_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "score_", ">=_", "prev_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prev_", "=_", "score_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Pyth", "on", "Zs", "et_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "remove_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "self_", "._", "test\\u", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "=_", "list_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index_", "=_", "randint_", "(_", "0_", ",_", "len_", "(_", "values_", ")_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "val_", "=_", "values_", "._", "pop_", "(_", "index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "val_", "in_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Not", "Equal_", "(_", "s_", "._", "remove_", "(_", "val_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "val_", "in_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "s_", ")_" ]
[ 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, 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, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Duplicate key in dict literal
GraylinKim/sc2reader/sc2reader/utils.py
[ { "content": "def toDict(replay):\n # Build observers into dictionary\n observers = list()\n for observer in replay.observers:\n messages = list()\n for message in getattr(observer, 'messages', list()):\n messages.append({\n 'time': message.time.seconds,\n 'text': message.text,\n 'is_public': message.to_all\n })\n observers.append({\n 'name': getattr(observer, 'name', None),\n 'pid': getattr(observer, 'pid', None),\n 'messages': messages,\n })\n\n # Build players into dictionary\n players = list()\n for player in replay.players:\n messages = list()\n for message in player.messages:\n messages.append({\n 'time': message.time.seconds,\n 'text': message.text,\n 'is_public': message.to_all\n })\n players.append({\n 'avg_apm': getattr(player, 'avg_apm', None),\n 'color': player.color.__dict__ if hasattr(player, 'color') else None,\n 'handicap': getattr(player, 'handicap', None),\n 'name': getattr(player, 'name', None),\n 'pick_race': getattr(player, 'pick_race', None),\n 'pid': getattr(player, 'pid', None),\n 'play_race': getattr(player, 'play_race', None),\n 'result': getattr(player, 'result', None),\n 'type': getattr(player, 'type', None),\n 'uid': getattr(player, 'uid', None),\n 'url': getattr(player, 'url', None),\n 'messages': messages,\n })\n\n # Consolidate replay metadata into dictionary\n return {\n 'region': getattr(replay, 'region', None),\n 'map_name': getattr(replay, 'map_name', None),\n 'file_time': getattr(replay, 'file_time', None),\n 'filehash': getattr(replay, 'filehash', None),\n 'unix_timestamp': getattr(replay, 'unix_timestamp', None),\n 'date': getattr(replay, 'date', None),\n 'utc_date': getattr(replay, 'utc_date', None),\n 'speed': getattr(replay, 'speed', None),\n 'category': getattr(replay, 'category', None),\n 'type': getattr(replay, 'type', None),\n 'is_ladder': getattr(replay, 'is_ladder', False),\n 'is_private': getattr(replay, 'is_private', False),\n 'filename': getattr(replay, 'filename', None),\n 'file_time': getattr(replay, 'file_time', None),\n 'frames': getattr(replay, 'frames', None),\n 'build': getattr(replay, 'build', None),\n 'release': getattr(replay, 'release_string', None),\n 'game_fps': getattr(replay, 'game_fps', None),\n 'game_length': getattr(getattr(replay, 'game_length', None), 'seconds', None),\n 'players': players,\n 'observers': observers,\n 'real_length': getattr(getattr(replay, 'real_length', None), 'seconds', None),\n 'real_type': getattr(replay, 'real_type', None),\n 'time_zone': getattr(replay, 'time_zone', None),\n 'versions': getattr(replay, 'versions', None)\n }", "metadata": "root.toDict", "header": "['module', '___EOS___']", "index": 234 } ]
[ { "span": "'file_time':", "start_line": 280, "start_column": 8, "end_line": 280, "end_column": 19 } ]
[ { "span": "'file_time':", "start_line": 291, "start_column": 8, "end_line": 291, "end_column": 19 } ]
1
true
[ "[CLS]_", "Duplicate", "_", "key_", "in_", "dict_", "literal_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "to", "Dict_", "(_", "replay_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Build", " ", "observer", "s", " ", "int", "o", " ", "dictionary_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "observers_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "observer_", "in_", "replay_", "._", "observers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "message_", "in_", "getattr_", "(_", "observer_", ",_", "'", "message", "s", "'_", ",_", "list_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "time", "'_", ":_", "message_", "._", "time_", "._", "seconds_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "message_", "._", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "public", "'_", ":_", "message_", "._", "to", "\\u", "all_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "observers_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "getattr_", "(_", "observer_", ",_", "'", "name", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pid", "'_", ":_", "getattr_", "(_", "observer_", ",_", "'", "pid", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "s", "'_", ":_", "messages_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Build", " ", "player", "s", " ", "int", "o", " ", "dictionary_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "players_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "player_", "in_", "replay_", "._", "players_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "message_", "in_", "player_", "._", "messages_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "time", "'_", ":_", "message_", "._", "time_", "._", "seconds_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "message_", "._", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "public", "'_", ":_", "message_", "._", "to", "\\u", "all_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "players_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "avg", "\\u", "ap", "m", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "avg", "\\u", "ap", "m", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "color", "'_", ":_", "player_", "._", "color_", "._", "\\u\\u", "dict\\u\\u_", "if_", "hasattr_", "(_", "player_", ",_", "'", "color", "'_", ")_", "else_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hand", "ica", "p", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "hand", "ica", "p", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "name", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pick", "\\u", "race", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "pick", "\\u", "race", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pid", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "pid", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "play", "\\u", "race", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "play", "\\u", "race", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "result", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "result", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "type", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "uid", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "uid", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "getattr_", "(_", "player_", ",_", "'", "url", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "s", "'_", ":_", "messages_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Cons", "oli", "date", " ", "repla", "y", " ", "metadata", " ", "int", "o", " ", "dictionary_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "region", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "region", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "map", "\\u", "name", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "map", "\\u", "name", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "file", "\\u", "time", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "file", "\\u", "time", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fileh", "ash", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "fileh", "ash", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "unix", "\\u", "timestamp", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "unix", "\\u", "timestamp", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "date", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "utc", "\\u", "date", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "utc", "\\u", "date", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "speed", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "speed", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "category", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "category", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "type", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "ladder", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "is", "\\u", "ladder", "'_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "private", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "is", "\\u", "private", "'_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filename", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "filename", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "file", "\\u", "time", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "file", "\\u", "time", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "frames", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "frames", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "build", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "build", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "release", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "release", "\\u", "string", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "game", "\\u", "fp", "s", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "game", "\\u", "fp", "s", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "game", "\\u", "length", "'_", ":_", "getattr_", "(_", "getattr_", "(_", "replay_", ",_", "'", "game", "\\u", "length", "'_", ",_", "None_", ")_", ",_", "'", "second", "s", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "player", "s", "'_", ":_", "players_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "observer", "s", "'_", ":_", "observers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "real", "\\u", "length", "'_", ":_", "getattr_", "(_", "getattr_", "(_", "replay_", ",_", "'", "real", "\\u", "length", "'_", ",_", "None_", ")_", ",_", "'", "second", "s", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "real", "\\u", "type", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "real", "\\u", "type", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "time", "\\u", "zone", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "time", "\\u", "zone", "'_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "version", "s", "'_", ":_", "getattr_", "(_", "replay_", ",_", "'", "version", "s", "'_", ",_", "None_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Imprecise assert
azer/jsbuild/test/lib/dependency.py
[ { "content": " def testRead(self):\n self.dp.src = 'dependency.py'\n self.assertTrue(self.dp.read().find(\"self.assertTrue\")>-1)", "metadata": "root.TestDependency.testRead", "header": "['class', 'TestDependency', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 25 } ]
[ { "span": "self.assertTrue(self.dp.read().find(\"self.assertTrue\")>-1)", "start_line": 27, "start_column": 4, "end_line": 27, "end_column": 62 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Dependency_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Read_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "dp_", "._", "src_", "=_", "'", "dependen", "cy", ".", "py", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "dp_", "._", "read_", "(_", ")_", "._", "find_", "(_", "\"", "self", ".", "assert", "Tru", "e", "\"_", ")_", ">_", "-_", "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, 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 ]
Comparison using is when operands support `__eq__`
facebook/augmented-traffic-control/atc/atc_thrift/atc_thrift/ttypes.py
[ { "content": "class Delay(object):\n \"\"\"\n Attributes:\n - delay\n - jitter\n - correlation\n \"\"\"\n\n thrift_spec = (\n None, # 0\n (1, TType.I32, 'delay', None, None, ), # 1\n (2, TType.I32, 'jitter', None, 0, ), # 2\n (3, TType.DOUBLE, 'correlation', None, 0, ), # 3\n )\n\n\n\n\n\n\n\n", "metadata": "root.Delay", "header": "['module', '___EOS___']", "index": 72 }, { "content": " def __init__(self, delay=None, jitter=thrift_spec[2][4], correlation=thrift_spec[3][4],):\n self.delay = delay\n self.jitter = jitter\n self.correlation = correlation", "metadata": "root.Delay.__init__", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 87 }, { "content": " def read(self, iprot):\n if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:\n fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))\n return\n iprot.readStructBegin()\n while True:\n (fname, ftype, fid) = iprot.readFieldBegin()\n if ftype == TType.STOP:\n break\n if fid == 1:\n if ftype == TType.I32:\n self.delay = iprot.readI32();\n else:\n iprot.skip(ftype)\n elif fid == 2:\n if ftype == TType.I32:\n self.jitter = iprot.readI32();\n else:\n iprot.skip(ftype)\n elif fid == 3:\n if ftype == TType.DOUBLE:\n self.correlation = iprot.readDouble();\n else:\n iprot.skip(ftype)\n else:\n iprot.skip(ftype)\n iprot.readFieldEnd()\n iprot.readStructEnd()", "metadata": "root.Delay.read", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 92 }, { "content": " def write(self, oprot):\n if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:\n oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))\n return\n oprot.writeStructBegin('Delay')\n if self.delay is not None:\n oprot.writeFieldBegin('delay', TType.I32, 1)\n oprot.writeI32(self.delay)\n oprot.writeFieldEnd()\n if self.jitter is not None:\n oprot.writeFieldBegin('jitter', TType.I32, 2)\n oprot.writeI32(self.jitter)\n oprot.writeFieldEnd()\n if self.correlation is not None:\n oprot.writeFieldBegin('correlation', TType.DOUBLE, 3)\n oprot.writeDouble(self.correlation)\n oprot.writeFieldEnd()\n oprot.writeFieldStop()\n oprot.writeStructEnd()", "metadata": "root.Delay.write", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 121 }, { "content": " def validate(self):\n return", "metadata": "root.Delay.validate", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 141 }, { "content": " def __repr__(self):\n L = ['%s=%r' % (key, value)\n for key, value in self.__dict__.iteritems()]\n return '%s(%s)' % (self.__class__.__name__, ', '.join(L))", "metadata": "root.Delay.__repr__", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 145 }, { "content": " def __eq__(self, other):\n return isinstance(other, self.__class__) and self.__dict__ == other.__dict__", "metadata": "root.Delay.__eq__", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 150 }, { "content": " def __ne__(self, other):\n return not (self == other)", "metadata": "root.Delay.__ne__", "header": "['class', 'Delay', '(', 'object', ')', ':', '___EOS___']", "index": 153 }, { "content": "class Loss(object):\n \"\"\"\n Attributes:\n - percentage\n - correlation\n \"\"\"\n\n thrift_spec = (\n None, # 0\n (1, TType.DOUBLE, 'percentage', None, None, ), # 1\n (2, TType.DOUBLE, 'correlation', None, 0, ), # 2\n )\n\n\n\n\n\n\n\n", "metadata": "root.Loss", "header": "['module', '___EOS___']", "index": 156 }, { "content": " def __init__(self, percentage=None, correlation=thrift_spec[2][4],):\n self.percentage = percentage\n self.correlation = correlation", "metadata": "root.Loss.__init__", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 169 }, { "content": " def read(self, iprot):\n if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:\n fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))\n return\n iprot.readStructBegin()\n while True:\n (fname, ftype, fid) = iprot.readFieldBegin()\n if ftype == TType.STOP:\n break\n if fid == 1:\n if ftype == TType.DOUBLE:\n self.percentage = iprot.readDouble();\n else:\n iprot.skip(ftype)\n elif fid == 2:\n if ftype == TType.DOUBLE:\n self.correlation = iprot.readDouble();\n else:\n iprot.skip(ftype)\n else:\n iprot.skip(ftype)\n iprot.readFieldEnd()\n iprot.readStructEnd()", "metadata": "root.Loss.read", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 173 }, { "content": " def write(self, oprot):\n if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:\n oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))\n return\n oprot.writeStructBegin('Loss')\n if self.percentage is not None:\n oprot.writeFieldBegin('percentage', TType.DOUBLE, 1)\n oprot.writeDouble(self.percentage)\n oprot.writeFieldEnd()\n if self.correlation is not None:\n oprot.writeFieldBegin('correlation', TType.DOUBLE, 2)\n oprot.writeDouble(self.correlation)\n oprot.writeFieldEnd()\n oprot.writeFieldStop()\n oprot.writeStructEnd()", "metadata": "root.Loss.write", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 197 }, { "content": " def validate(self):\n return", "metadata": "root.Loss.validate", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 213 }, { "content": " def __repr__(self):\n L = ['%s=%r' % (key, value)\n for key, value in self.__dict__.iteritems()]\n return '%s(%s)' % (self.__class__.__name__, ', '.join(L))", "metadata": "root.Loss.__repr__", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 217 }, { "content": " def __eq__(self, other):\n return isinstance(other, self.__class__) and self.__dict__ == other.__dict__", "metadata": "root.Loss.__eq__", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 222 }, { "content": " def __ne__(self, other):\n return not (self == other)", "metadata": "root.Loss.__ne__", "header": "['class', 'Loss', '(', 'object', ')', ':', '___EOS___']", "index": 225 }, { "content": "class Reorder(object):\n \"\"\"\n Attributes:\n - percentage\n - gap\n - correlation\n \"\"\"\n\n thrift_spec = (\n None, # 0\n (1, TType.DOUBLE, 'percentage', None, None, ), # 1\n (2, TType.I32, 'gap', None, 0, ), # 2\n (3, TType.DOUBLE, 'correlation', None, 0, ), # 3\n )\n\n\n\n\n\n\n\n", "metadata": "root.Reorder", "header": "['module', '___EOS___']", "index": 228 }, { "content": " def __init__(self, percentage=None, gap=thrift_spec[2][4], correlation=thrift_spec[3][4],):\n self.percentage = percentage\n self.gap = gap\n self.correlation = correlation", "metadata": "root.Reorder.__init__", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 243 }, { "content": " def read(self, iprot):\n if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:\n fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))\n return\n iprot.readStructBegin()\n while True:\n (fname, ftype, fid) = iprot.readFieldBegin()\n if ftype == TType.STOP:\n break\n if fid == 1:\n if ftype == TType.DOUBLE:\n self.percentage = iprot.readDouble();\n else:\n iprot.skip(ftype)\n elif fid == 2:\n if ftype == TType.I32:\n self.gap = iprot.readI32();\n else:\n iprot.skip(ftype)\n elif fid == 3:\n if ftype == TType.DOUBLE:\n self.correlation = iprot.readDouble();\n else:\n iprot.skip(ftype)\n else:\n iprot.skip(ftype)\n iprot.readFieldEnd()\n iprot.readStructEnd()", "metadata": "root.Reorder.read", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 248 }, { "content": " def write(self, oprot):\n if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:\n oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))\n return\n oprot.writeStructBegin('Reorder')\n if self.percentage is not None:\n oprot.writeFieldBegin('percentage', TType.DOUBLE, 1)\n oprot.writeDouble(self.percentage)\n oprot.writeFieldEnd()\n if self.gap is not None:\n oprot.writeFieldBegin('gap', TType.I32, 2)\n oprot.writeI32(self.gap)\n oprot.writeFieldEnd()\n if self.correlation is not None:\n oprot.writeFieldBegin('correlation', TType.DOUBLE, 3)\n oprot.writeDouble(self.correlation)\n oprot.writeFieldEnd()\n oprot.writeFieldStop()\n oprot.writeStructEnd()", "metadata": "root.Reorder.write", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 277 }, { "content": " def validate(self):\n return", "metadata": "root.Reorder.validate", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 297 }, { "content": " def __repr__(self):\n L = ['%s=%r' % (key, value)\n for key, value in self.__dict__.iteritems()]\n return '%s(%s)' % (self.__class__.__name__, ', '.join(L))", "metadata": "root.Reorder.__repr__", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 301 }, { "content": " def __eq__(self, other):\n return isinstance(other, self.__class__) and self.__dict__ == other.__dict__", "metadata": "root.Reorder.__eq__", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 306 }, { "content": " def __ne__(self, other):\n return not (self == other)", "metadata": "root.Reorder.__ne__", "header": "['class', 'Reorder', '(', 'object', ')', ':', '___EOS___']", "index": 309 }, { "content": "class Corruption(object):\n \"\"\"\n Attributes:\n - percentage\n - correlation\n \"\"\"\n\n thrift_spec = (\n None, # 0\n (1, TType.DOUBLE, 'percentage', None, 0, ), # 1\n (2, TType.DOUBLE, 'correlation', None, 0, ), # 2\n )\n\n\n\n\n\n\n\n", "metadata": "root.Corruption", "header": "['module', '___EOS___']", "index": 312 }, { "content": " def __init__(self, percentage=thrift_spec[1][4], correlation=thrift_spec[2][4],):\n self.percentage = percentage\n self.correlation = correlation", "metadata": "root.Corruption.__init__", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 325 }, { "content": " def read(self, iprot):\n if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:\n fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))\n return\n iprot.readStructBegin()\n while True:\n (fname, ftype, fid) = iprot.readFieldBegin()\n if ftype == TType.STOP:\n break\n if fid == 1:\n if ftype == TType.DOUBLE:\n self.percentage = iprot.readDouble();\n else:\n iprot.skip(ftype)\n elif fid == 2:\n if ftype == TType.DOUBLE:\n self.correlation = iprot.readDouble();\n else:\n iprot.skip(ftype)\n else:\n iprot.skip(ftype)\n iprot.readFieldEnd()\n iprot.readStructEnd()", "metadata": "root.Corruption.read", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 329 }, { "content": " def write(self, oprot):\n if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:\n oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))\n return\n oprot.writeStructBegin('Corruption')\n if self.percentage is not None:\n oprot.writeFieldBegin('percentage', TType.DOUBLE, 1)\n oprot.writeDouble(self.percentage)\n oprot.writeFieldEnd()\n if self.correlation is not None:\n oprot.writeFieldBegin('correlation', TType.DOUBLE, 2)\n oprot.writeDouble(self.correlation)\n oprot.writeFieldEnd()\n oprot.writeFieldStop()\n oprot.writeStructEnd()", "metadata": "root.Corruption.write", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 353 }, { "content": " def validate(self):\n return", "metadata": "root.Corruption.validate", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 369 }, { "content": " def __repr__(self):\n L = ['%s=%r' % (key, value)\n for key, value in self.__dict__.iteritems()]\n return '%s(%s)' % (self.__class__.__name__, ', '.join(L))", "metadata": "root.Corruption.__repr__", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 373 }, { "content": " def __eq__(self, other):\n return isinstance(other, self.__class__) and self.__dict__ == other.__dict__", "metadata": "root.Corruption.__eq__", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 378 }, { "content": " def __ne__(self, other):\n return not (self == other)", "metadata": "root.Corruption.__ne__", "header": "['class', 'Corruption', '(', 'object', ')', ':', '___EOS___']", "index": 381 }, { "content": " def __init__(self, rate=None, delay=thrift_spec[2][4], loss=thrift_spec[3][4], reorder=thrift_spec[4][4], corruption=thrift_spec[5][4], iptables_options=None,):\n self.rate = rate\n if delay is self.thrift_spec[2][4]:\n delay = Delay(**{\n \"delay\" : 0,\n })\n self.delay = delay\n if loss is self.thrift_spec[3][4]:\n loss = Loss(**{\n \"percentage\" : 0,\n })\n self.loss = loss\n if reorder is self.thrift_spec[4][4]:\n reorder = Reorder(**{\n \"percentage\" : 0,\n })\n self.reorder = reorder\n if corruption is self.thrift_spec[5][4]:\n corruption = Corruption(**{\n \"percentage\" : 0,\n })\n self.corruption = corruption\n self.iptables_options = iptables_options", "metadata": "root.Shaping.__init__", "header": "['class', 'Shaping', '(', 'object', ')', ':', '___EOS___']", "index": 413 } ]
[ { "span": "delay is self.thrift_spec[2][4]:", "start_line": 415, "start_column": 7, "end_line": 415, "end_column": 38 }, { "span": "loss is self.thrift_spec[3][4]:", "start_line": 420, "start_column": 7, "end_line": 420, "end_column": 37 }, { "span": "reorder is self.thrift_spec[4][4]:", "start_line": 425, "start_column": 7, "end_line": 425, "end_column": 40 }, { "span": "corruption is self.thrift_spec[5][4]:", "start_line": 430, "start_column": 7, "end_line": 430, "end_column": 43 } ]
[]
1
false
[ "[CLS]_", "Compari", "son_", "using_", "is_", "when_", "operands_", "support_", " _", "`_", "\\u\\u", "eq\\u\\u_", "`_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Delay_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Attribute", "s", ":", "\\", "10", ";", " ", " ", " ", "-", " ", "dela", "y", "\\", "10", ";", " ", " ", " ", "-", " ", "jitter", "\\", "10", ";", " ", " ", " ", "-", " ", "correlation", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "thrift", "\\u", "spec_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "#", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "1_", ",_", "TT", "ype_", "._", "I32_", ",_", "'", "dela", "y", "'_", ",_", "None_", ",_", "None_", ",_", ")_", ",_", "#", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "2_", ",_", "TT", "ype_", "._", "I32_", ",_", "'", "jitter", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "3_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "correlation", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "[SEP]_", "class_", "Delay_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "delay_", "=_", "None_", ",_", "jitter_", "=_", "thrift", "\\u", "spec_", "[_", "2_", "]_", "[_", "4_", "]_", ",_", "correlation_", "=_", "thrift", "\\u", "spec_", "[_", "3_", "]_", "[_", "4_", "]_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "delay_", "=_", "delay_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "jitter_", "=_", "jitter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "correlation_", "=_", "correlation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delay_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ",_", "iprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "iprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "isinstance_", "(_", "iprot_", "._", "trans_", ",_", "TT", "rans", "port_", "._", "CR", "ead", "able", "Transport_", ")_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fastbinary_", "._", "decode", "\\u", "binary_", "(_", "self_", ",_", "iprot_", "._", "trans_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "fname_", ",_", "ftype_", ",_", "fid_", ")_", "=_", "iprot_", "._", "read", "Field", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ftype_", "==_", "TT", "ype_", "._", "STOP_", ":_", "\\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_", "if_", "fid_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "I32_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "delay_", "=_", "iprot_", "._", "read", "I32_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "fid_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "I32_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "jitter_", "=_", "iprot_", "._", "read", "I32_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "fid_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "correlation_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delay_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write_", "(_", "self_", ",_", "oprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "oprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "trans_", "._", "write_", "(_", "fastbinary_", "._", "encode", "\\u", "binary_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "Begin_", "(_", "'", "Delay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "delay_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "dela", "y", "'_", ",_", "TT", "ype_", "._", "I32_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "I32_", "(_", "self_", "._", "delay_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "jitter_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "jitter", "'_", ",_", "TT", "ype_", "._", "I32_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "I32_", "(_", "self_", "._", "jitter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "correlation_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "correlation", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "correlation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Field", "Stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delay_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delay_", "(_", "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 ", " _", "L_", "=_", "[_", "'%", "s", "=", "%", "r", "'_", "%_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "iteritems_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'%", "s", "(%", "s", ")'_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "',", " ", "'_", "._", "join_", "(_", "L_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delay_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "isinstance_", "(_", "other_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "and_", "self_", "._", "\\u\\u", "dict\\u\\u_", "==_", "other_", "._", "\\u\\u", "dict\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delay_", "(_", "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 ", " _", "return_", "not_", "(_", "self_", "==_", "other_", ")_", "\\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_", "Loss_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Attribute", "s", ":", "\\", "10", ";", " ", " ", " ", "-", " ", "percentage", "\\", "10", ";", " ", " ", " ", "-", " ", "correlation", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "thrift", "\\u", "spec_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "#", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "1_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "percentage", "'_", ",_", "None_", ",_", "None_", ",_", ")_", ",_", "#", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "2_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "correlation", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "[SEP]_", "class_", "Loss_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "percentage_", "=_", "None_", ",_", "correlation_", "=_", "thrift", "\\u", "spec_", "[_", "2_", "]_", "[_", "4_", "]_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "percentage_", "=_", "percentage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "correlation_", "=_", "correlation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Loss_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ",_", "iprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "iprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "isinstance_", "(_", "iprot_", "._", "trans_", ",_", "TT", "rans", "port_", "._", "CR", "ead", "able", "Transport_", ")_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fastbinary_", "._", "decode", "\\u", "binary_", "(_", "self_", ",_", "iprot_", "._", "trans_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "fname_", ",_", "ftype_", ",_", "fid_", ")_", "=_", "iprot_", "._", "read", "Field", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ftype_", "==_", "TT", "ype_", "._", "STOP_", ":_", "\\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_", "if_", "fid_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "percentage_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "fid_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "correlation_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Loss_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write_", "(_", "self_", ",_", "oprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "oprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "trans_", "._", "write_", "(_", "fastbinary_", "._", "encode", "\\u", "binary_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "Begin_", "(_", "'", "Lo", "ss", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "percentage_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "percentage", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "percentage_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "correlation_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "correlation", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "correlation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Field", "Stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Loss_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Loss_", "(_", "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 ", " _", "L_", "=_", "[_", "'%", "s", "=", "%", "r", "'_", "%_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "iteritems_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'%", "s", "(%", "s", ")'_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "',", " ", "'_", "._", "join_", "(_", "L_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Loss_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "isinstance_", "(_", "other_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "and_", "self_", "._", "\\u\\u", "dict\\u\\u_", "==_", "other_", "._", "\\u\\u", "dict\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Loss_", "(_", "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 ", " _", "return_", "not_", "(_", "self_", "==_", "other_", ")_", "\\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_", "Re", "order_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Attribute", "s", ":", "\\", "10", ";", " ", " ", " ", "-", " ", "percentage", "\\", "10", ";", " ", " ", " ", "-", " ", "gap", "\\", "10", ";", " ", " ", " ", "-", " ", "correlation", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "thrift", "\\u", "spec_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "#", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "1_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "percentage", "'_", ",_", "None_", ",_", "None_", ",_", ")_", ",_", "#", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "2_", ",_", "TT", "ype_", "._", "I32_", ",_", "'", "gap", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "3_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "correlation", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "[SEP]_", "class_", "Re", "order_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "percentage_", "=_", "None_", ",_", "gap_", "=_", "thrift", "\\u", "spec_", "[_", "2_", "]_", "[_", "4_", "]_", ",_", "correlation_", "=_", "thrift", "\\u", "spec_", "[_", "3_", "]_", "[_", "4_", "]_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "percentage_", "=_", "percentage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gap_", "=_", "gap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "correlation_", "=_", "correlation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Re", "order_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ",_", "iprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "iprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "isinstance_", "(_", "iprot_", "._", "trans_", ",_", "TT", "rans", "port_", "._", "CR", "ead", "able", "Transport_", ")_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fastbinary_", "._", "decode", "\\u", "binary_", "(_", "self_", ",_", "iprot_", "._", "trans_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "fname_", ",_", "ftype_", ",_", "fid_", ")_", "=_", "iprot_", "._", "read", "Field", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ftype_", "==_", "TT", "ype_", "._", "STOP_", ":_", "\\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_", "if_", "fid_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "percentage_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "fid_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "I32_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "gap_", "=_", "iprot_", "._", "read", "I32_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "fid_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "correlation_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Re", "order_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write_", "(_", "self_", ",_", "oprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "oprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "trans_", "._", "write_", "(_", "fastbinary_", "._", "encode", "\\u", "binary_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "Begin_", "(_", "'", "Re", "order", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "percentage_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "percentage", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "percentage_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "gap_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "gap", "'_", ",_", "TT", "ype_", "._", "I32_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "I32_", "(_", "self_", "._", "gap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "correlation_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "correlation", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "correlation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Field", "Stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Re", "order_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Re", "order_", "(_", "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 ", " _", "L_", "=_", "[_", "'%", "s", "=", "%", "r", "'_", "%_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "iteritems_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'%", "s", "(%", "s", ")'_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "',", " ", "'_", "._", "join_", "(_", "L_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Re", "order_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "isinstance_", "(_", "other_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "and_", "self_", "._", "\\u\\u", "dict\\u\\u_", "==_", "other_", "._", "\\u\\u", "dict\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Re", "order_", "(_", "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 ", " _", "return_", "not_", "(_", "self_", "==_", "other_", ")_", "\\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_", "Corr", "upti", "on_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Attribute", "s", ":", "\\", "10", ";", " ", " ", " ", "-", " ", "percentage", "\\", "10", ";", " ", " ", " ", "-", " ", "correlation", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "thrift", "\\u", "spec_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "#", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "1_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "percentage", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "2_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "'", "correlation", "'_", ",_", "None_", ",_", "0_", ",_", ")_", ",_", "#", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "percentage_", "=_", "thrift", "\\u", "spec_", "[_", "1_", "]_", "[_", "4_", "]_", ",_", "correlation_", "=_", "thrift", "\\u", "spec_", "[_", "2_", "]_", "[_", "4_", "]_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "percentage_", "=_", "percentage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "correlation_", "=_", "correlation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ",_", "iprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "iprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "isinstance_", "(_", "iprot_", "._", "trans_", ",_", "TT", "rans", "port_", "._", "CR", "ead", "able", "Transport_", ")_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fastbinary_", "._", "decode", "\\u", "binary_", "(_", "self_", ",_", "iprot_", "._", "trans_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "fname_", ",_", "ftype_", ",_", "fid_", ")_", "=_", "iprot_", "._", "read", "Field", "Begin_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ftype_", "==_", "TT", "ype_", "._", "STOP_", ":_", "\\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_", "if_", "fid_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "percentage_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "fid_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ftype_", "==_", "TT", "ype_", "._", "DOUBLE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "correlation_", "=_", "iprot_", "._", "read", "Double_", "(_", ")_", ";_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\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 ", " _", "iprot_", "._", "skip_", "(_", "ftype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "iprot_", "._", "read", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write_", "(_", "self_", ",_", "oprot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "oprot_", "._", "\\u\\u", "class\\u\\u_", "==_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Proto", "col", "Accelerated_", "and_", "self_", "._", "thrift", "\\u", "spec_", "is_", "not_", "None_", "and_", "fastbinary_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "trans_", "._", "write_", "(_", "fastbinary_", "._", "encode", "\\u", "binary_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "self_", "._", "thrift", "\\u", "spec_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "Begin_", "(_", "'", "Corr", "upti", "on", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "percentage_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "percentage", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "percentage_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "correlation_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oprot_", "._", "write", "Field", "Begin_", "(_", "'", "correlation", "'_", ",_", "TT", "ype_", "._", "DOUBLE_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Double_", "(_", "self_", "._", "correlation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Field", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "oprot_", "._", "write", "Field", "Stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oprot_", "._", "write", "Stru", "ct", "End_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "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 ", " _", "L_", "=_", "[_", "'%", "s", "=", "%", "r", "'_", "%_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "iteritems_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'%", "s", "(%", "s", ")'_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "',", " ", "'_", "._", "join_", "(_", "L_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "isinstance_", "(_", "other_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "and_", "self_", "._", "\\u\\u", "dict\\u\\u_", "==_", "other_", "._", "\\u\\u", "dict\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Corr", "upti", "on_", "(_", "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 ", " _", "return_", "not_", "(_", "self_", "==_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sha", "ping_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "rate_", "=_", "None_", ",_", "delay_", "=_", "thrift", "\\u", "spec_", "[_", "2_", "]_", "[_", "4_", "]_", ",_", "loss_", "=_", "thrift", "\\u", "spec_", "[_", "3_", "]_", "[_", "4_", "]_", ",_", "reorder", "_", "=_", "thrift", "\\u", "spec_", "[_", "4_", "]_", "[_", "4_", "]_", ",_", "corrupt", "ion_", "=_", "thrift", "\\u", "spec_", "[_", "5_", "]_", "[_", "4_", "]_", ",_", "iptables", "\\u", "options_", "=_", "None_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "rate_", "=_", "rate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "delay_", "is_", "self_", "._", "thrift", "\\u", "spec_", "[_", "2_", "]_", "[_", "4_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "delay_", "=_", "Delay_", "(_", "**_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "delay_", "=_", "delay_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "loss_", "is_", "self_", "._", "thrift", "\\u", "spec_", "[_", "3_", "]_", "[_", "4_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "loss_", "=_", "Loss_", "(_", "**_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "percentage", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "loss_", "=_", "loss_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "reorder", "_", "is_", "self_", "._", "thrift", "\\u", "spec_", "[_", "4_", "]_", "[_", "4_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reorder", "_", "=_", "Re", "order_", "(_", "**_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "percentage", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "reorder", "_", "=_", "reorder", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "corrupt", "ion_", "is_", "self_", "._", "thrift", "\\u", "spec_", "[_", "5_", "]_", "[_", "4_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "corrupt", "ion_", "=_", "Corr", "upti", "on_", "(_", "**_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "percentage", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "corrupt", "ion_", "=_", "corrupt", "ion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "iptables", "\\u", "options_", "=_", "iptables", "\\u", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 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, 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, 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 ]
Except block handles 'BaseException'
boakley/robotframework-workbench/rwb/widgets/dte.py
[ { "content": " def __del__(self):\n try:\n self._tk.globalunsetvar(self._name)\n except:\n print \"D'oh!\"\n pass", "metadata": "root.QuietIntVar.__del__", "header": "['class', 'QuietIntVar', '(', 'tk', '.', 'IntVar', ')', ':', '___EOS___']", "index": 32 }, { "content": " def get_autocomplete_string(self):\n try:\n return self.get(\"current_cell.first\", \"current_cell.last\")\n except:\n return \"WTF?\"", "metadata": "root.DynamicTableEditor.get_autocomplete_string", "header": "['class', 'DynamicTableEditor', '(', 'tk', '.', 'Text', ',', 'HighlightMixin', ')', ':', '___EOS___']", "index": 143 }, { "content": " def _on_paste(self, event):\n '''I was having problems on my mac where the clipboard had \n strings terminated by \\r. This converts those to newlines\n before doing the paste\n '''\n data = self.clipboard_get().replace(\"\\r\\n\", \"\\n\").replace(\"\\r\", \"\\n\")\n self.edit_separator()\n try:\n self.delete(\"sel.first\", \"sel.last\")\n except:\n pass\n self.insert(\"insert\", data)\n self.edit_separator()\n return \"break\"", "metadata": "root.DynamicTableEditor._on_paste", "header": "['class', 'DynamicTableEditor', '(', 'tk', '.', 'Text', ',', 'HighlightMixin', ')', ':', '___EOS___']", "index": 337 }, { "content": " def _on_click(self, event):\n try:\n if self.complete_frame.winfo_viewable():\n self.complete_frame.place_forget()\n except:\n pass", "metadata": "root.DynamicTableEditor._on_click", "header": "['class', 'DynamicTableEditor', '(', 'tk', '.', 'Text', ',', 'HighlightMixin', ')', ':', '___EOS___']", "index": 489 }, { "content": " def _on_return(self, event):\n try:\n if self.complete_frame.winfo_viewable():\n selection = self.list.curselection()\n if selection is not None and len(selection) > 0:\n i = selection[0]\n text = self.list.get(i)\n self.replace(\"current_cell.first\", \"current_cell.last\", text)\n self.complete_frame.place_forget()\n return \"break\"\n except:\n pass", "metadata": "root.DynamicTableEditor._on_return", "header": "['class', 'DynamicTableEditor', '(', 'tk', '.', 'Text', ',', 'HighlightMixin', ')', ':', '___EOS___']", "index": 529 } ]
[ { "span": "except:", "start_line": 35, "start_column": 8, "end_line": 35, "end_column": 15 }, { "span": "except:", "start_line": 146, "start_column": 8, "end_line": 146, "end_column": 15 }, { "span": "except:", "start_line": 346, "start_column": 8, "end_line": 346, "end_column": 15 }, { "span": "except:", "start_line": 493, "start_column": 8, "end_line": 493, "end_column": 15 }, { "span": "except:", "start_line": 539, "start_column": 8, "end_line": 539, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Qui", "et", "Int", "Var_", "(_", "tk_", "._", "Int", "Var_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\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 ", " _", "self_", "._", "\\u", "tk_", "._", "global", "unse", "tva", "r_", "(_", "self_", "._", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "D", "'", "oh", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dynamic", "Table", "Editor_", "(_", "tk_", "._", "Text_", ",_", "Highlight", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "autocomplete", "\\u", "string_", "(_", "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_", "._", "get_", "(_", "\"", "current", "\\u", "cell", ".", "first", "\"_", ",_", "\"", "current", "\\u", "cell", ".", "last", "\"_", ")_", "\\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_", "\"", "WT", "F", "?\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dynamic", "Table", "Editor_", "(_", "tk_", "._", "Text_", ",_", "Highlight", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "on", "\\u", "paste_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "I", " ", "was", " ", "hav", "ing", " ", "problem", "s", " ", "on", " ", "my", " ", "mac", " ", "where", " ", "the", " ", "clip", "board", " ", "had", " ", "\\", "10", ";", " ", " ", " ", " ", "string", "s", " ", "terminate", "d", " ", "by", " ", "\\\\", "r", ".", " ", "Thi", "s", " ", "convert", "s", " ", "tho", "se", " ", "to", " ", "newline", "s", "\\", "10", ";", " ", " ", " ", " ", "bef", "ore", " ", "doi", "ng", " ", "the", " ", "paste", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "self_", "._", "clip", "board", "\\u", "get_", "(_", ")_", "._", "replace_", "(_", "\"\\\\", "r", "\\\\", "n", "\"_", ",_", "\"\\\\", "n", "\"_", ")_", "._", "replace_", "(_", "\"\\\\", "r", "\"_", ",_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edit", "\\u", "separator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "delete_", "(_", "\"", "sel", ".", "first", "\"_", ",_", "\"", "sel", ".", "last", "\"_", ")_", "\\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_", "._", "insert_", "(_", "\"", "insert", "\"_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edit", "\\u", "separator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"", "break", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dynamic", "Table", "Editor_", "(_", "tk_", "._", "Text_", ",_", "Highlight", "Mixin_", ")_", ":_", "\\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", "on", "\\u", "click_", "(_", "self_", ",_", "event_", ")_", ":_", "\\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_", "self_", "._", "complete", "\\u", "frame_", "._", "win", "fo", "\\u", "view", "able_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "complete", "\\u", "frame_", "._", "place", "\\u", "forget", "_", "(_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dynamic", "Table", "Editor_", "(_", "tk_", "._", "Text_", ",_", "Highlight", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "on", "\\u", "return_", "(_", "self_", ",_", "event_", ")_", ":_", "\\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_", "self_", "._", "complete", "\\u", "frame_", "._", "win", "fo", "\\u", "view", "able_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "selection_", "=_", "self_", "._", "list_", "._", "curse", "lection", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "selection_", "is_", "not_", "None_", "and_", "len_", "(_", "selection_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "i_", "=_", "selection_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "self_", "._", "list_", "._", "get_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "replace_", "(_", "\"", "current", "\\u", "cell", ".", "first", "\"_", ",_", "\"", "current", "\\u", "cell", ".", "last", "\"_", ",_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "complete", "\\u", "frame_", "._", "place", "\\u", "forget", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"", "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 ", " _", "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, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 ]
Unused import
toumorokoshi/sprinter/sprinter/formula/tests/test_command.py
[ { "content": "from __future__ import unicode_literals\nfrom mock import patch, Mock\nfrom nose.tools import raises, ok_\nfrom sprinter.exceptions import SprinterException\nfrom sprinter.testtools import FormulaTest\nimport subprocess\nimport sprinter.lib as lib\n\nsource_config = \"\"\"\n[update]\nformula = sprinter.formula.command\nupdate = echo 'this is old...'\n\n[remove]\nformula = sprinter.formula.command\nremove = echo 'destroy up...'\n\n[deactivate]\nformula = sprinter.formula.command\ndeactivate = echo 'deactivating...'\n\n[activate]\nformula = sprinter.formula.command\nactivate = echo 'activating...'\n\"\"\"\n\ntarget_config = \"\"\"\n[install]\nformula = sprinter.formula.command\ninstall = echo 'setting up...'\nupdate = echo 'updating...'\n\n[update]\nformula = sprinter.formula.command\nupdate = echo 'update up...'\n\n[with-shell]\nformula = sprinter.formula.command\ninstall = echo 'installing...'\nshell = True\n\n[failure]\nformula = sprinter.formula.command\ninstall = exit 1\nfail_on_error = true\n\n[failure_no_error]\nformula = sprinter.formula.command\ninstall = exit 1\nfail_on_error = false\n\n[dont-log]\nformula = sprinter.formula.command\ninstall = ls\nredirect_stdout_to_log = false\n\"\"\"\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def create_mock_call():\n m = Mock()\n m.return_value = (0, \"\")\n return m", "metadata": "root.create_mock_call", "header": "['module', '___EOS___']", "index": 58 }, { "content": "class TestCommandFormula(FormulaTest):\n \"\"\"\n Tests for the command formula.\n \"\"\"\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TestCommandFormula", "header": "['module', '___EOS___']", "index": 64 }, { "content": " def setup(self):\n super(TestCommandFormula, self).setup(source_config=source_config,\n target_config=target_config)", "metadata": "root.TestCommandFormula.setup", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 68 }, { "content": " def teardown(self):\n del(self.environment)", "metadata": "root.TestCommandFormula.teardown", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 72 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_install(self, call):\n self.environment.run_feature(\"install\", 'sync')\n call.assert_called_once_with(\"echo 'setting up...'\", shell=False, stdout=subprocess.PIPE)", "metadata": "root.TestCommandFormula.test_install", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 75 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_update(self, call):\n self.environment.run_feature(\"update\", 'sync')\n call.assert_called_once_with(\"echo 'update up...'\", shell=False, stdout=subprocess.PIPE)", "metadata": "root.TestCommandFormula.test_update", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 80 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_remove(self, call):\n self.environment.run_feature(\"remove\", 'sync')\n call.assert_called_once_with(\"echo 'destroy up...'\", shell=False, stdout=subprocess.PIPE)", "metadata": "root.TestCommandFormula.test_remove", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 85 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_deactivate(self, call):\n self.environment.run_feature(\"deactivate\", 'deactivate')\n call.assert_called_once_with(\"echo 'deactivating...'\", shell=False, stdout=subprocess.PIPE)", "metadata": "root.TestCommandFormula.test_deactivate", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 90 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_activate(self, call):\n self.environment.run_feature(\"activate\", 'activate')\n call.assert_called_once_with(\"echo 'activating...'\", shell=False, stdout=subprocess.PIPE)", "metadata": "root.TestCommandFormula.test_activate", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 95 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n @raises(SprinterException)\n def test_failure(self, call):\n \"\"\" If a failure occurs and fail_on_error is true, raise an error \"\"\"\n call.return_value = (1, \"dummy\")\n self.environment.run_feature('failure', 'sync')", "metadata": "root.TestCommandFormula.test_failure", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 100 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_failure_no_fail_on_error(self, call):\n \"\"\" If a failure occurs and fail_on_error is false, don't raise an error \"\"\"\n call.return_value = (1, \"dummy\")\n self.environment.run_feature('failure_no_error', 'sync')\n assert not self.environment.error_occured", "metadata": "root.TestCommandFormula.test_failure_no_fail_on_error", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 107 }, { "content": " @patch.object(lib, 'is_affirmative')\n @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_shell(self, call, is_affirmative):\n \"\"\"The shell clause should make the command run with shell \"\"\"\n is_affirmative.return_value = True\n self.environment.run_feature(\"with-shell\", 'sync')\n call.assert_called_once_with(\"echo 'installing...'\", shell=True, stdout=subprocess.PIPE)", "metadata": "root.TestCommandFormula.test_shell", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 114 }, { "content": " @patch.object(lib, 'call', new_callable=create_mock_call)\n def test_shell_redirect_to_stdout(self, call):\n \"\"\" Shell with redirect_stdout_to_log as False should print to stdout \"\"\"\n self.environment.run_feature('dont-log', 'sync')\n call.assert_called_once_with(\"ls\", shell=False, stdout=None)", "metadata": "root.TestCommandFormula.test_shell_redirect_to_stdout", "header": "['class', 'TestCommandFormula', '(', 'FormulaTest', ')', ':', '___EOS___']", "index": 122 } ]
[ { "span": "from nose.tools import raises, ok_", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 34 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mock_", "import_", "patch_", ",_", "Mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nose_", "._", "tools_", "import_", "raises_", ",_", "ok\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sprint", "er_", "._", "exceptions_", "import_", "Sprin", "ter", "Exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sprint", "er_", "._", "testtools_", "import_", "Form", "ula", "Test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sprint", "er_", "._", "lib_", "as_", "lib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "config_", "=_", "\"\"\"", "\\", "10", ";", "[", "update", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "update", " ", "=", " ", "echo", " ", "'", "this", " ", "is", " ", "old", "...", "'", "\\", "10", ";", "\\", "10", ";", "[", "remove", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "remove", " ", "=", " ", "echo", " ", "'", "destroy", " ", "up", "...", "'", "\\", "10", ";", "\\", "10", ";", "[", "deactivate", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "deactivate", " ", "=", " ", "echo", " ", "'", "dea", "ctivat", "ing", "...", "'", "\\", "10", ";", "\\", "10", ";", "[", "activat", "e", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "activat", "e", " ", "=", " ", "echo", " ", "'", "activat", "ing", "...", "'", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "config_", "=_", "\"\"\"", "\\", "10", ";", "[", "install", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "install", " ", "=", " ", "echo", " ", "'", "setti", "ng", " ", "up", "...", "'", "\\", "10", ";", "update", " ", "=", " ", "echo", " ", "'", "updat", "ing", "...", "'", "\\", "10", ";", "\\", "10", ";", "[", "update", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "update", " ", "=", " ", "echo", " ", "'", "update", " ", "up", "...", "'", "\\", "10", ";", "\\", "10", ";", "[", "with", "-", "shell", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "install", " ", "=", " ", "echo", " ", "'", "install", "ing", "...", "'", "\\", "10", ";", "shell", " ", "=", " ", "Tru", "e", "\\", "10", ";", "\\", "10", ";", "[", "fail", "ure", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "install", " ", "=", " ", "exit", " ", "1", "\\", "10", ";", "fail", "\\u", "on", "\\u", "error", " ", "=", " ", "true", "\\", "10", ";", "\\", "10", ";", "[", "fail", "ure", "\\u", "no", "\\u", "error", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "install", " ", "=", " ", "exit", " ", "1", "\\", "10", ";", "fail", "\\u", "on", "\\u", "error", " ", "=", " ", "fal", "se", "\\", "10", ";", "\\", "10", ";", "[", "don", "t", "-", "log", "]", "\\", "10", ";", "formula", " ", "=", " ", "sprint", "er", ".", "formula", ".", "command", "\\", "10", ";", "install", " ", "=", " ", "ls", "\\", "10", ";", "redirec", "t", "\\u", "stdout", "\\u", "to", "\\u", "log", " ", "=", " ", "fal", "se", "\\", "10", ";\"\"\"_", "\\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_", "def_", "create", "\\u", "mock", "\\u", "call_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "return", "\\u", "value_", "=_", "(_", "0_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "m_", "\\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", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "for", " ", "the", " ", "command", " ", "formula", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "setup_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Test", "Command", "Formula_", ",_", "self_", ")_", "._", "setup_", "(_", "source", "\\u", "config_", "=_", "source", "\\u", "config_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "config_", "=_", "target", "\\u", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "teardown_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "(_", "self_", "._", "environment_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "install_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "\"", "install", "\"_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "echo", " ", "'", "setti", "ng", " ", "up", "...", "'\"_", ",_", "shell_", "=_", "False_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "update_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "\"", "update", "\"_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "echo", " ", "'", "update", " ", "up", "...", "'\"_", ",_", "shell_", "=_", "False_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "remove_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "\"", "remove", "\"_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "echo", " ", "'", "destroy", " ", "up", "...", "'\"_", ",_", "shell_", "=_", "False_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "deactivate_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "\"", "deactivate", "\"_", ",_", "'", "deactivate", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "echo", " ", "'", "dea", "ctivat", "ing", "...", "'\"_", ",_", "shell_", "=_", "False_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "activate_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "\"", "activat", "e", "\"_", ",_", "'", "activat", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "echo", " ", "'", "activat", "ing", "...", "'\"_", ",_", "shell_", "=_", "False_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "raises_", "(_", "Sprin", "ter", "Exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "failure_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "If", " ", "a", " ", "fail", "ure", " ", "occur", "s", " ", "and", " ", "fail", "\\u", "on", "\\u", "error", " ", "is", " ", "true", ",", " ", "raise", " ", "an", " ", "error", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "return", "\\u", "value_", "=_", "(_", "1_", ",_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "'", "fail", "ure", "'_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "fail", "ure", "\\u", "no", "\\u", "fail", "\\u", "on", "\\u", "error_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "If", " ", "a", " ", "fail", "ure", " ", "occur", "s", " ", "and", " ", "fail", "\\u", "on", "\\u", "error", " ", "is", " ", "fal", "se", ",", " ", "don", "'", "t", " ", "raise", " ", "an", " ", "error", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "return", "\\u", "value_", "=_", "(_", "1_", ",_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "'", "fail", "ure", "\\u", "no", "\\u", "error", "'_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "self_", "._", "environment_", "._", "error", "\\u", "occure", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "is", "\\u", "affi", "rmat", "ive", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "shell_", "(_", "self_", ",_", "call_", ",_", "is", "\\u", "affi", "rmat", "ive_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "The", " ", "shell", " ", "clause", " ", "shou", "ld", " ", "make", " ", "the", " ", "command", " ", "run", " ", "with", " ", "shell", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "affi", "rmat", "ive_", "._", "return", "\\u", "value_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "\"", "with", "-", "shell", "\"_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "echo", " ", "'", "install", "ing", "...", "'\"_", ",_", "shell_", "=_", "True_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Formula_", "(_", "Form", "ula", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "patch_", "._", "object_", "(_", "lib_", ",_", "'", "call", "'_", ",_", "new", "\\u", "callable_", "=_", "create", "\\u", "mock", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "shell", "\\u", "redirec", "t", "\\u", "to", "\\u", "stdout_", "(_", "self_", ",_", "call_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Shel", "l", " ", "with", " ", "redirec", "t", "\\u", "stdout", "\\u", "to", "\\u", "log", " ", "as", " ", "Fal", "se", " ", "shou", "ld", " ", "print", " ", "to", " ", "stdout", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "environment_", "._", "run", "\\u", "feature_", "(_", "'", "don", "t", "-", "log", "'_", ",_", "'", "sync", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "._", "assert", "\\u", "call", "ed", "\\u", "onc", "e\\u", "with_", "(_", "\"", "ls", "\"_", ",_", "shell_", "=_", "False_", ",_", "stdout_", "=_", "None_", ")_" ]
[ 4, 4, 4, 4, 4, 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 ]
Unused local variable
timonwong/OmniMarkupPreviewer/OmniMarkupLib/Common.py
[ { "content": " def exec_(_code_, _globs_=None, _locs_=None):\n \"\"\"Execute code in a namespace.\"\"\"\n if _globs_ is None:\n frame = sys._getframe(1)\n _globs_ = frame.f_globals\n if _locs_ is None:\n _locs_ = frame.f_locals\n del frame\n elif _locs_ is None:\n _locs_ = _globs_\n exec(\"\"\"exec _code_ in _globs_, _locs_\"\"\")", "metadata": "root.exec_", "header": "['module', '___EOS___']", "index": 50 } ]
[ { "span": "_globs_ ", "start_line": 54, "start_column": 12, "end_line": 54, "end_column": 19 }, { "span": "_locs_ ", "start_line": 56, "start_column": 16, "end_line": 56, "end_column": 22 }, { "span": "_locs_ ", "start_line": 59, "start_column": 12, "end_line": 59, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "exec\\u_", "(_", "\\u", "code", "\\u_", ",_", "\\u", "glob", "s\\u_", "=_", "None_", ",_", "\\u", "locs", "\\u_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Execut", "e", " ", "code", " ", "in", " ", "a", " ", "namespace", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "glob", "s\\u_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "frame_", "=_", "sys_", "._", "\\u", "getframe_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "glob", "s\\u_", "=_", "frame_", "._", "f", "\\u", "globals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "locs", "\\u_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "locs", "\\u_", "=_", "frame_", "._", "f", "\\u", "locals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "frame_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "\\u", "locs", "\\u_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "locs", "\\u_", "=_", "\\u", "glob", "s\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "exec_", "(_", "\"\"\"", "exec", " ", "\\u", "code", "\\u", " ", "in", " ", "\\u", "glob", "s", "\\u", ",", " ", "\\u", "locs", "\\u\"", "\"\"_", ")_", "\\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, 0, 1, 1, 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, 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 ]
Unreachable code
ngsutils/ngsutils/ngsutils/fastq/barcode_split.py
[ { "content": "def _tag_aln_check(aln, seqlen, barcodelen, orientation, edit=0, pos=0):\n r_len = aln.r_end - aln.r_pos\n mismatches = barcodelen - r_len + aln.mismatches\n\n if mismatches <= edit:\n if orientation == '5' and aln.q_pos <= pos: # allow at most {pos} extra bases at start\n return True, ''\n elif orientation == '3' and aln.q_end >= seqlen - pos: # allow at most {pos} extra bases at end\n return True, ''\n else:\n return False, 'Not at right location'\n else:\n return False, 'too many mismatches'\n\n return False, '?'", "metadata": "root._tag_aln_check", "header": "['module', '___EOS___']", "index": 122 } ]
[ { "span": "return False, '?'", "start_line": 136, "start_column": 4, "end_line": 136, "end_column": 21 } ]
[]
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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "tag", "\\u", "aln", "\\u", "check_", "(_", "aln_", ",_", "seq", "len_", ",_", "barcode", "len_", ",_", "orientation_", ",_", "edit_", "=_", "0_", ",_", "pos_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r", "\\u", "len_", "=_", "aln_", "._", "r", "\\u", "end_", "-_", "aln_", "._", "r", "\\u", "pos_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mismatche", "s_", "=_", "barcode", "len_", "-_", "r", "\\u", "len_", "+_", "aln_", "._", "mismatche", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "mismatche", "s_", "<=_", "edit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "orientation_", "==_", "'", "5", "'_", "and_", "aln_", "._", "q", "\\u", "pos_", "<=_", "pos_", ":_", "#", " ", "allow", " ", "at", " ", "most", " ", "{", "pos", "}", " ", "extra", " ", "base", "s", " ", "at", " ", "start_", "\\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_", "elif_", "orientation_", "==_", "'", "3", "'_", "and_", "aln_", "._", "q", "\\u", "end_", ">=_", "seq", "len_", "-_", "pos_", ":_", "#", " ", "allow", " ", "at", " ", "most", " ", "{", "pos", "}", " ", "extra", " ", "base", "s", " ", "at", " ", "end_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", ",_", "'", "Not", " ", "at", " ", "right", " ", "location", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", ",_", "'", "too", " ", "many", " ", "mismatche", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", ",_", "'?'_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 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, 0, 1, 1, 1, 1, 2 ]
Except block handles 'BaseException'
compbrain/dexcom_reader/ez_setup.py
[ { "content": "def has_powershell():\n if platform.system() != 'Windows':\n return False\n cmd = ['powershell', '-Command', 'echo test']\n devnull = open(os.path.devnull, 'wb')\n try:\n subprocess.check_call(cmd, stdout=devnull, stderr=devnull)\n except:\n return False\n finally:\n devnull.close()\n return True", "metadata": "root.has_powershell", "header": "['module', '___EOS___']", "index": 166 }, { "content": "def has_curl():\n cmd = ['curl', '--version']\n devnull = open(os.path.devnull, 'wb')\n try:\n subprocess.check_call(cmd, stdout=devnull, stderr=devnull)\n except:\n return False\n finally:\n devnull.close()\n return True", "metadata": "root.has_curl", "header": "['module', '___EOS___']", "index": 185 }, { "content": "def has_wget():\n cmd = ['wget', '--version']\n devnull = open(os.path.devnull, 'wb')\n try:\n subprocess.check_call(cmd, stdout=devnull, stderr=devnull)\n except:\n return False\n finally:\n devnull.close()\n return True", "metadata": "root.has_wget", "header": "['module', '___EOS___']", "index": 202 } ]
[ { "span": "except:", "start_line": 173, "start_column": 4, "end_line": 173, "end_column": 11 }, { "span": "except:", "start_line": 190, "start_column": 4, "end_line": 190, "end_column": 11 }, { "span": "except:", "start_line": 207, "start_column": 4, "end_line": 207, "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_", "has", "\\u", "powers", "hell", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "platform_", "._", "system_", "(_", ")_", "!=_", "'", "Window", "s", "'_", ":_", "\\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_", "cmd_", "=_", "[_", "'", "powers", "hell", "'_", ",_", "'-", "Command", "'_", ",_", "'", "echo", " ", "test", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "devnull_", "=_", "open_", "(_", "os_", "._", "path_", "._", "devnull_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subprocess_", "._", "check", "\\u", "call_", "(_", "cmd_", ",_", "stdout_", "=_", "devnull_", ",_", "stderr_", "=_", "devnull_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "devnull_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "has", "\\u", "curl_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "[_", "'", "curl", "'_", ",_", "'--", "version", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "devnull_", "=_", "open_", "(_", "os_", "._", "path_", "._", "devnull_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subprocess_", "._", "check", "\\u", "call_", "(_", "cmd_", ",_", "stdout_", "=_", "devnull_", ",_", "stderr_", "=_", "devnull_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "devnull_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "has", "\\u", "wg", "et_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "[_", "'", "wg", "et", "'_", ",_", "'--", "version", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "devnull_", "=_", "open_", "(_", "os_", "._", "path_", "._", "devnull_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subprocess_", "._", "check", "\\u", "call_", "(_", "cmd_", ",_", "stdout_", "=_", "devnull_", ",_", "stderr_", "=_", "devnull_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "devnull_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "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, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 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, 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 ]
Unused import
rcbops/glance-buildpackage/glance/tests/unit/test_s3_store.py
[ { "content": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\n# Copyright 2011 OpenStack, LLC\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this s3 except in compliance with the License. You may obtain\n# 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, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\n\"\"\"Tests the S3 backend store\"\"\"\n\nimport StringIO\nimport hashlib\nimport httplib\nimport sys\nimport unittest\nimport urlparse\n\nimport stubout\nimport boto.s3.connection\n\nfrom glance.common import exception\nfrom glance.common import utils\nfrom glance.store import BackendException, UnsupportedBackend\nfrom glance.store.location import get_location_from_uri\nfrom glance.store.s3 import Store\nfrom glance.tests import utils as test_utils\n\n\nFAKE_UUID = utils.generate_uuid()\n\nFIVE_KB = (5 * 1024)\nS3_CONF = {'verbose': True,\n 'debug': True,\n 's3_store_access_key': 'user',\n 's3_store_secret_key': 'key',\n 's3_store_host': 'localhost:8080',\n 's3_store_bucket': 'glance'}\n\n\n# We stub out as little as possible to ensure that the code paths\n# between glance.store.s3 and boto.s3.connection are tested\n# thoroughly\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def stub_out_s3(stubs):\n\n class FakeKey:\n \"\"\"\n Acts like a ``boto.s3.key.Key``\n \"\"\"\n def __init__(self, bucket, name):\n self.bucket = bucket\n self.name = name\n self.data = None\n self.size = 0\n self.BufferSize = 1024\n\n def close(self):\n pass\n\n def exists(self):\n return self.bucket.exists(self.name)\n\n def delete(self):\n self.bucket.delete(self.name)\n\n def compute_md5(self, data):\n chunk = data.read(self.BufferSize)\n checksum = hashlib.md5()\n while chunk:\n checksum.update(chunk)\n chunk = data.read(self.BufferSize)\n checksum_hex = checksum.hexdigest()\n return checksum_hex, None\n\n def set_contents_from_file(self, fp, replace=False, **kwargs):\n self.data = StringIO.StringIO()\n for bytes in fp:\n self.data.write(bytes)\n self.size = self.data.len\n # Reset the buffer to start\n self.data.seek(0)\n self.read = self.data.read\n\n def get_file(self):\n return self.data\n\n class FakeBucket:\n \"\"\"\n Acts like a ``boto.s3.bucket.Bucket``\n \"\"\"\n def __init__(self, name, keys=None):\n self.name = name\n self.keys = keys or {}\n\n def __str__(self):\n return self.name\n\n def exists(self, key):\n return key in self.keys\n\n def delete(self, key):\n del self.keys[key]\n\n def get_key(self, key_name, **kwargs):\n key = self.keys.get(key_name)\n if not key:\n return FakeKey(self, key_name)\n return key\n\n def new_key(self, key_name):\n new_key = FakeKey(self, key_name)\n self.keys[key_name] = new_key\n return new_key\n\n fixture_buckets = {'glance': FakeBucket('glance')}\n b = fixture_buckets['glance']\n k = b.new_key(FAKE_UUID)\n k.set_contents_from_file(StringIO.StringIO(\"*\" * FIVE_KB))\n\n def fake_connection_constructor(self, *args, **kwargs):\n host = kwargs.get('host')\n if host.startswith('http://') or host.startswith('https://'):\n raise UnsupportedBackend(host)\n\n def fake_get_bucket(conn, bucket_id):\n bucket = fixture_buckets.get(bucket_id)\n if not bucket:\n bucket = FakeBucket(bucket_id)\n return bucket\n\n stubs.Set(boto.s3.connection.S3Connection,\n '__init__', fake_connection_constructor)\n stubs.Set(boto.s3.connection.S3Connection,\n 'get_bucket', fake_get_bucket)", "metadata": "root.stub_out_s3", "header": "['module', '___EOS___']", "index": 51 }, { "content": "def format_s3_location(user, key, authurl, bucket, obj):\n \"\"\"\n Helper method that returns a S3 store URI given\n the component pieces.\n \"\"\"\n scheme = 's3'\n if authurl.startswith('https://'):\n scheme = 's3+https'\n authurl = authurl[8:]\n elif authurl.startswith('http://'):\n authurl = authurl[7:]\n authurl = authurl.strip('/')\n return \"%s://%s:%s@%s/%s/%s\" % (scheme, user, key, authurl,\n bucket, obj)", "metadata": "root.format_s3_location", "header": "['module', '___EOS___']", "index": 144 }, { "content": "class TestStore(unittest.TestCase):\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TestStore", "header": "['module', '___EOS___']", "index": 160 }, { "content": " def setUp(self):\n \"\"\"Establish a clean test environment\"\"\"\n self.stubs = stubout.StubOutForTesting()\n stub_out_s3(self.stubs)\n self.store = Store(test_utils.TestConfigOpts(S3_CONF))", "metadata": "root.TestStore.setUp", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 162 }, { "content": " def tearDown(self):\n \"\"\"Clear the test environment\"\"\"\n self.stubs.UnsetAll()", "metadata": "root.TestStore.tearDown", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 168 }, { "content": " def test_get(self):\n \"\"\"Test a \"normal\" retrieval of an image in chunks\"\"\"\n loc = get_location_from_uri(\n \"s3://user:key@auth_address/glance/%s\" % FAKE_UUID)\n (image_s3, image_size) = self.store.get(loc)\n\n self.assertEqual(image_size, FIVE_KB)\n\n expected_data = \"*\" * FIVE_KB\n data = \"\"\n\n for chunk in image_s3:\n data += chunk\n self.assertEqual(expected_data, data)", "metadata": "root.TestStore.test_get", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 172 }, { "content": " def test_get_non_existing(self):\n \"\"\"\n Test that trying to retrieve a s3 that doesn't exist\n raises an error\n \"\"\"\n uri = \"s3://user:key@auth_address/badbucket/%s\" % FAKE_UUID\n loc = get_location_from_uri(uri)\n self.assertRaises(exception.NotFound, self.store.get, loc)\n\n uri = \"s3://user:key@auth_address/glance/noexist\"\n loc = get_location_from_uri(uri)\n self.assertRaises(exception.NotFound, self.store.get, loc)", "metadata": "root.TestStore.test_get_non_existing", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 187 }, { "content": " def test_add(self):\n \"\"\"Test that we can add an image via the s3 backend\"\"\"\n expected_image_id = utils.generate_uuid()\n expected_s3_size = FIVE_KB\n expected_s3_contents = \"*\" * expected_s3_size\n expected_checksum = hashlib.md5(expected_s3_contents).hexdigest()\n expected_location = format_s3_location(\n S3_CONF['s3_store_access_key'],\n S3_CONF['s3_store_secret_key'],\n S3_CONF['s3_store_host'],\n S3_CONF['s3_store_bucket'],\n expected_image_id)\n image_s3 = StringIO.StringIO(expected_s3_contents)\n\n location, size, checksum = self.store.add(expected_image_id,\n image_s3,\n expected_s3_size)\n\n self.assertEquals(expected_location, location)\n self.assertEquals(expected_s3_size, size)\n self.assertEquals(expected_checksum, checksum)\n\n loc = get_location_from_uri(expected_location)\n (new_image_s3, new_image_size) = self.store.get(loc)\n new_image_contents = StringIO.StringIO()\n for chunk in new_image_s3:\n new_image_contents.write(chunk)\n new_image_s3_size = new_image_contents.len\n\n self.assertEquals(expected_s3_contents, new_image_contents.getvalue())\n self.assertEquals(expected_s3_size, new_image_s3_size)", "metadata": "root.TestStore.test_add", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 200 }, { "content": " def test_add_host_variations(self):\n \"\"\"\n Test that having http(s):// in the s3serviceurl in config\n options works as expected.\n \"\"\"\n variations = ['http://localhost:80',\n 'http://localhost',\n 'http://localhost/v1',\n 'http://localhost/v1/',\n 'https://localhost',\n 'https://localhost:8080',\n 'https://localhost/v1',\n 'https://localhost/v1/',\n 'localhost',\n 'localhost:8080/v1']\n for variation in variations:\n expected_image_id = utils.generate_uuid()\n expected_s3_size = FIVE_KB\n expected_s3_contents = \"*\" * expected_s3_size\n expected_checksum = \\\n hashlib.md5(expected_s3_contents).hexdigest()\n new_conf = S3_CONF.copy()\n new_conf['s3_store_host'] = variation\n expected_location = format_s3_location(\n new_conf['s3_store_access_key'],\n new_conf['s3_store_secret_key'],\n new_conf['s3_store_host'],\n new_conf['s3_store_bucket'],\n expected_image_id)\n image_s3 = StringIO.StringIO(expected_s3_contents)\n\n self.store = Store(test_utils.TestConfigOpts(new_conf))\n location, size, checksum = self.store.add(expected_image_id,\n image_s3,\n expected_s3_size)\n\n self.assertEquals(expected_location, location)\n self.assertEquals(expected_s3_size, size)\n self.assertEquals(expected_checksum, checksum)\n\n loc = get_location_from_uri(expected_location)\n (new_image_s3, new_image_size) = self.store.get(loc)\n new_image_contents = new_image_s3.getvalue()\n new_image_s3_size = new_image_s3.len\n\n self.assertEquals(expected_s3_contents, new_image_contents)\n self.assertEquals(expected_s3_size, new_image_s3_size)", "metadata": "root.TestStore.test_add_host_variations", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 232 }, { "content": " def test_add_already_existing(self):\n \"\"\"\n Tests that adding an image with an existing identifier\n raises an appropriate exception\n \"\"\"\n image_s3 = StringIO.StringIO(\"nevergonnamakeit\")\n self.assertRaises(exception.Duplicate,\n self.store.add,\n FAKE_UUID, image_s3, 0)", "metadata": "root.TestStore.test_add_already_existing", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 280 }, { "content": " def _option_required(self, key):\n conf = S3_CONF.copy()\n del conf[key]\n\n try:\n self.store = Store(test_utils.TestConfigOpts(conf))\n return self.store.add == self.store.add_disabled\n except:\n return False\n return False", "metadata": "root.TestStore._option_required", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 290 }, { "content": " def test_no_access_key(self):\n \"\"\"\n Tests that options without access key disables the add method\n \"\"\"\n self.assertTrue(self._option_required('s3_store_access_key'))", "metadata": "root.TestStore.test_no_access_key", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 301 }, { "content": " def test_no_secret_key(self):\n \"\"\"\n Tests that options without secret key disables the add method\n \"\"\"\n self.assertTrue(self._option_required('s3_store_secret_key'))", "metadata": "root.TestStore.test_no_secret_key", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 307 }, { "content": " def test_no_host(self):\n \"\"\"\n Tests that options without host disables the add method\n \"\"\"\n self.assertTrue(self._option_required('s3_store_host'))", "metadata": "root.TestStore.test_no_host", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 313 }, { "content": " def test_delete(self):\n \"\"\"\n Test we can delete an existing image in the s3 store\n \"\"\"\n uri = \"s3://user:key@auth_address/glance/%s\" % FAKE_UUID\n loc = get_location_from_uri(uri)\n self.store.delete(loc)\n\n self.assertRaises(exception.NotFound, self.store.get, loc)", "metadata": "root.TestStore.test_delete", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 319 }, { "content": " def test_delete_non_existing(self):\n \"\"\"\n Test that trying to delete a s3 that doesn't exist\n raises an error\n \"\"\"\n uri = \"s3://user:key@auth_address/glance/noexist\"\n loc = get_location_from_uri(uri)\n self.assertRaises(exception.NotFound, self.store.delete, loc)", "metadata": "root.TestStore.test_delete_non_existing", "header": "['class', 'TestStore', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 329 } ]
[ { "span": "import httplib", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 14 }, { "span": "import sys", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 10 }, { "span": "import urlparse", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 15 }, { "span": "from glance.store import BackendException, UnsupportedBackend", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 61 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "vim", ":", " ", "tabs", "top", "=", "4", " ", "shift", "widt", "h", "=", "4", " ", "soft", "tabs", "top", "=", "4_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2011", " ", "Open", "Stack", ",", " ", "LLC", "_", "\\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", "\");", " ", "you", " ", "may", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "not", " ", "use", " ", "this", " ", "s3", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", ".", " ", "You", " ", "may", " ", "obtain", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "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", ",", " ", "WITH", "OUT_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", " ", "See", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", " ", "limit", "ations_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "under", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Test", "s", " ", "the", " ", "S", "3", " ", "back", "end", " ", "store", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "httplib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "stub", "out_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "boto_", "._", "s3_", "._", "connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "glance_", "._", "common_", "import_", "exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "glance_", "._", "common_", "import_", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "glance_", "._", "store_", "import_", "Back", "end", "Exception_", ",_", "Unsu", "ppo", "rted", "Backend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "glance_", "._", "store_", "._", "location_", "import_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "glance_", "._", "store_", "._", "s3_", "import_", "Store_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "glance_", "._", "tests_", "import_", "utils_", "as_", "test\\u", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "FAKE", "\\u", "UUID_", "=_", "utils_", "._", "generat", "e\\u", "uuid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "FI", "VE", "\\u", "KB", "_", "=_", "(_", "5_", "*_", "1024_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "S", "3", "\\u", "CONF_", "=_", "{_", "'", "verbo", "se", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "debug", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "s3", "\\u", "store", "\\u", "access", "\\u", "key", "'_", ":_", "'", "user", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "s3", "\\u", "store", "\\u", "secret", "\\u", "key", "'_", ":_", "'", "key", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "s3", "\\u", "store", "\\u", "host", "'_", ":_", "'", "local", "host", ":", "808", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "s3", "\\u", "store", "\\u", "bucket", "'_", ":_", "'", "gla", "nce", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "stub", " ", "out", " ", "as", " ", "litt", "le", " ", "as", " ", "possib", "le", " ", "to", " ", "ensure", " ", "tha", "t", " ", "the", " ", "code", " ", "paths_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bet", "ween", " ", "gla", "nce", ".", "store", ".", "s3", " ", "and", " ", "boto", ".", "s3", ".", "connecti", "on", " ", "are", " ", "tested", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "thor", "ou", "gh", "ly_", "\\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\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "stub", "\\u", "out", "\\u", "s3_", "(_", "stubs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Fake", "Key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Act", "s", " ", "like", " ", "a", " ", "``", "boto", ".", "s3", ".", "key", ".", "Key", "``", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "bucket_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bucket_", "=_", "bucket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "size_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Buffer", "Size_", "=_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "close_", "(_", "self_", ")_", ":_", "\\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_", "def_", "exists_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "bucket_", "._", "exists_", "(_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bucket_", "._", "delete_", "(_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "compute", "\\u", "md5_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chunk_", "=_", "data_", "._", "read_", "(_", "self_", "._", "Buffer", "Size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checksum_", "=_", "hashlib_", "._", "md5_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "chunk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checksum_", "._", "update_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chunk_", "=_", "data_", "._", "read_", "(_", "self_", "._", "Buffer", "Size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "checks", "um", "\\u", "hex_", "=_", "checksum_", "._", "hexdigest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "checks", "um", "\\u", "hex_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "content", "s", "\\u", "from", "\\u", "file_", "(_", "self_", ",_", "fp_", ",_", "replace_", "=_", "False_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "data_", "=_", "String", "IO_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "bytes_", "in_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "data_", "._", "write_", "(_", "bytes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "size_", "=_", "self_", "._", "data_", "._", "len_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Reset", " ", "the", " ", "buffer", " ", "to", " ", "start_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "data_", "._", "seek_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "read_", "=_", "self_", "._", "data_", "._", "read_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "file_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "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_", "Fake", "Bucket_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Act", "s", " ", "like", " ", "a", " ", "``", "boto", ".", "s3", ".", "bucket", ".", "Buck", "et", "``", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "keys_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "keys_", "=_", "keys_", "or_", "{_", "}_", "\\u\\u\\uNEWLINE\\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_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "exists_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "key_", "in_", "self_", "._", "keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "keys_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "key_", "(_", "self_", ",_", "key", "\\u", "name_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key_", "=_", "self_", "._", "keys_", "._", "get_", "(_", "key", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Fake", "Key_", "(_", "self_", ",_", "key", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "new", "\\u", "key_", "(_", "self_", ",_", "key", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "key_", "=_", "Fake", "Key_", "(_", "self_", ",_", "key", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "keys_", "[_", "key", "\\u", "name_", "]_", "=_", "new", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "new", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fixture", "\\u", "buckets_", "=_", "{_", "'", "gla", "nce", "'_", ":_", "Fake", "Bucket_", "(_", "'", "gla", "nce", "'_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "fixture", "\\u", "buckets_", "[_", "'", "gla", "nce", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "b_", "._", "new", "\\u", "key_", "(_", "FAKE", "\\u", "UUID_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "set\\u", "content", "s", "\\u", "from", "\\u", "file_", "(_", "String", "IO_", "._", "String", "IO_", "(_", "\"*\"_", "*_", "FI", "VE", "\\u", "KB", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "fake", "\\u", "connecti", "on", "\\u", "constructor_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "host_", "=_", "kwargs_", "._", "get_", "(_", "'", "host", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "host_", "._", "startswith_", "(_", "'", "http", "://'_", ")_", "or_", "host_", "._", "startswith_", "(_", "'", "https", "://'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Unsu", "ppo", "rted", "Backend_", "(_", "host_", ")_", "\\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_", "fake", "\\u", "get", "\\u", "bucket_", "(_", "conn_", ",_", "bucket", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bucket_", "=_", "fixture", "\\u", "buckets_", "._", "get_", "(_", "bucket", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "bucket_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bucket_", "=_", "Fake", "Bucket_", "(_", "bucket", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "bucket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stubs_", "._", "Set_", "(_", "boto_", "._", "s3_", "._", "connection_", "._", "S", "3", "Connection_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'\\u", "\\u", "init", "\\u\\u'_", ",_", "fake", "\\u", "connecti", "on", "\\u", "constructor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stubs_", "._", "Set_", "(_", "boto_", "._", "s3_", "._", "connection_", "._", "S", "3", "Connection_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "get", "\\u", "bucket", "'_", ",_", "fake", "\\u", "get", "\\u", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "format\\u", "s3", "\\u", "location_", "(_", "user_", ",_", "key_", ",_", "auth", "url_", ",_", "bucket_", ",_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Help", "er", " ", "method", " ", "tha", "t", " ", "return", "s", " ", "a", " ", "S", "3", " ", "store", " ", "URI", " ", "give", "n", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "component", " ", "piece", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scheme_", "=_", "'", "s3", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "auth", "url_", "._", "startswith_", "(_", "'", "https", "://'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "scheme_", "=_", "'", "s3", "+", "https", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auth", "url_", "=_", "auth", "url_", "[_", "8_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "auth", "url_", "._", "startswith_", "(_", "'", "http", "://'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "auth", "url_", "=_", "auth", "url_", "[_", "7_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "auth", "url_", "=_", "auth", "url_", "._", "strip_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"%", "s", "://", "%", "s", ":", "%", "s", "@", "%", "s", "/", "%", "s", "/", "%", "s", "\"_", "%_", "(_", "scheme_", ",_", "user_", ",_", "key_", ",_", "auth", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "bucket_", ",_", "obj_", ")_", "\\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", "Store_", "(_", "unittest_", "._", "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_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Store_", "(_", "unittest_", "._", "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 ", " _", "\"\"\"", "Esta", "blis", "h", " ", "a", " ", "clean", " ", "test", " ", "environ", "ment", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stubs_", "=_", "stub", "out_", "._", "Stu", "b", "Out", "For", "Test", "ing_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stub", "\\u", "out", "\\u", "s3_", "(_", "self_", "._", "stubs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "store_", "=_", "Store_", "(_", "test\\u", "utils_", "._", "Test", "Config", "Opts_", "(_", "S", "3", "\\u", "CONF_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tear", "Down_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Clear", " ", "the", " ", "test", " ", "environ", "ment", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stubs_", "._", "Unse", "t", "All_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "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_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "a", " ", "\"", "normal", "\"", " ", "retrie", "val", " ", "of", " ", "an", " ", "image", " ", "in", " ", "chunks", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "s3", "://", "user", ":", "key", "@", "auth", "\\u", "address", "/", "gla", "nce", "/", "%", "s", "\"_", "%_", "FAKE", "\\u", "UUID_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "image", "\\u", "s3_", ",_", "image", "\\u", "size_", ")_", "=_", "self_", "._", "store_", "._", "get_", "(_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "image", "\\u", "size_", ",_", "FI", "VE", "\\u", "KB", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "data_", "=_", "\"*\"_", "*_", "FI", "VE", "\\u", "KB", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "chunk_", "in_", "image", "\\u", "s3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "+=_", "chunk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "expected", "\\u", "data_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "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", "non", "\\u", "existing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "tha", "t", " ", "try", "ing", " ", "to", " ", "retrieve", " ", "a", " ", "s3", " ", "tha", "t", " ", "doe", "sn", "'", "t", " ", "exist", "\\", "10", ";", " ", " ", " ", " ", "raise", "s", " ", "an", " ", "error", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "\"", "s3", "://", "user", ":", "key", "@", "auth", "\\u", "address", "/", "bad", "bucket", "/", "%", "s", "\"_", "%_", "FAKE", "\\u", "UUID_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "exception_", "._", "Not", "Found_", ",_", "self_", "._", "store_", "._", "get_", ",_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "uri_", "=_", "\"", "s3", "://", "user", ":", "key", "@", "auth", "\\u", "address", "/", "gla", "nce", "/", "noe", "xist", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "exception_", "._", "Not", "Found_", ",_", "self_", "._", "store_", "._", "get_", ",_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "tha", "t", " ", "we", " ", "can", " ", "add", " ", "an", " ", "image", " ", "via", " ", "the", " ", "s3", " ", "back", "end", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "image", "\\u", "id_", "=_", "utils_", "._", "generat", "e\\u", "uuid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "s3", "\\u", "size_", "=_", "FI", "VE", "\\u", "KB", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "s3", "\\u", "contents_", "=_", "\"*\"_", "*_", "expected", "\\u", "s3", "\\u", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "checksum_", "=_", "hashlib_", "._", "md5_", "(_", "expected", "\\u", "s3", "\\u", "contents_", ")_", "._", "hexdigest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "location_", "=_", "format\\u", "s3", "\\u", "location_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "S", "3", "\\u", "CONF_", "[_", "'", "s3", "\\u", "store", "\\u", "access", "\\u", "key", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "S", "3", "\\u", "CONF_", "[_", "'", "s3", "\\u", "store", "\\u", "secret", "\\u", "key", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "S", "3", "\\u", "CONF_", "[_", "'", "s3", "\\u", "store", "\\u", "host", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "S", "3", "\\u", "CONF_", "[_", "'", "s3", "\\u", "store", "\\u", "bucket", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "s3_", "=_", "String", "IO_", "._", "String", "IO_", "(_", "expected", "\\u", "s3", "\\u", "contents_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "location_", ",_", "size_", ",_", "checksum_", "=_", "self_", "._", "store_", "._", "add_", "(_", "expected", "\\u", "image", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "s3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "s3", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "location_", ",_", "location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "s3", "\\u", "size_", ",_", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "checksum_", ",_", "checksum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "expected", "\\u", "location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "new", "\\u", "image", "\\u", "s3_", ",_", "new", "\\u", "image", "\\u", "size_", ")_", "=_", "self_", "._", "store_", "._", "get_", "(_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "image", "\\u", "contents_", "=_", "String", "IO_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "chunk_", "in_", "new", "\\u", "image", "\\u", "s3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image", "\\u", "contents_", "._", "write_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "image", "\\u", "s3", "\\u", "size_", "=_", "new", "\\u", "image", "\\u", "contents_", "._", "len_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "s3", "\\u", "contents_", ",_", "new", "\\u", "image", "\\u", "contents_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "s3", "\\u", "size_", ",_", "new", "\\u", "image", "\\u", "s3", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "host", "\\u", "variations", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "tha", "t", " ", "hav", "ing", " ", "http", "(", "s", "):", "//", " ", "in", " ", "the", " ", "s3", "service", "url", " ", "in", " ", "config", "\\", "10", ";", " ", " ", " ", " ", "options", " ", "works", " ", "as", " ", "expected", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "variations", "_", "=_", "[_", "'", "http", "://", "local", "host", ":", "80", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "://", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "://", "local", "host", "/", "v1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "://", "local", "host", "/", "v1", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "https", "://", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "https", "://", "local", "host", ":", "808", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "https", "://", "local", "host", "/", "v1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "https", "://", "local", "host", "/", "v1", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "local", "host", ":", "808", "0", "/", "v1", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "variation_", "in_", "variations", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expected", "\\u", "image", "\\u", "id_", "=_", "utils_", "._", "generat", "e\\u", "uuid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "s3", "\\u", "size_", "=_", "FI", "VE", "\\u", "KB", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "s3", "\\u", "contents_", "=_", "\"*\"_", "*_", "expected", "\\u", "s3", "\\u", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "checksum_", "=_", "hashlib_", "._", "md5_", "(_", "expected", "\\u", "s3", "\\u", "contents_", ")_", "._", "hexdigest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "conf_", "=_", "S", "3", "\\u", "CONF_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "conf_", "[_", "'", "s3", "\\u", "store", "\\u", "host", "'_", "]_", "=_", "variation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "location_", "=_", "format\\u", "s3", "\\u", "location_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "conf_", "[_", "'", "s3", "\\u", "store", "\\u", "access", "\\u", "key", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "conf_", "[_", "'", "s3", "\\u", "store", "\\u", "secret", "\\u", "key", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "conf_", "[_", "'", "s3", "\\u", "store", "\\u", "host", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "conf_", "[_", "'", "s3", "\\u", "store", "\\u", "bucket", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "s3_", "=_", "String", "IO_", "._", "String", "IO_", "(_", "expected", "\\u", "s3", "\\u", "contents_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "store_", "=_", "Store_", "(_", "test\\u", "utils_", "._", "Test", "Config", "Opts_", "(_", "new", "\\u", "conf_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "location_", ",_", "size_", ",_", "checksum_", "=_", "self_", "._", "store_", "._", "add_", "(_", "expected", "\\u", "image", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "s3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "s3", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "location_", ",_", "location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "s3", "\\u", "size_", ",_", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "checksum_", ",_", "checksum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "expected", "\\u", "location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "new", "\\u", "image", "\\u", "s3_", ",_", "new", "\\u", "image", "\\u", "size_", ")_", "=_", "self_", "._", "store_", "._", "get_", "(_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "image", "\\u", "contents_", "=_", "new", "\\u", "image", "\\u", "s3_", "._", "getvalue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "image", "\\u", "s3", "\\u", "size_", "=_", "new", "\\u", "image", "\\u", "s3_", "._", "len_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "s3", "\\u", "contents_", ",_", "new", "\\u", "image", "\\u", "contents_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "expected", "\\u", "s3", "\\u", "size_", ",_", "new", "\\u", "image", "\\u", "s3", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "alr", "ead", "y", "\\u", "existing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "addin", "g", " ", "an", " ", "image", " ", "with", " ", "an", " ", "exist", "ing", " ", "identifi", "er", "\\", "10", ";", " ", " ", " ", " ", "raise", "s", " ", "an", " ", "appropr", "iate", " ", "exception", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "s3_", "=_", "String", "IO_", "._", "String", "IO_", "(_", "\"", "neve", "rg", "onn", "ama", "kei", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "exception_", "._", "Duplicate", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "store_", "._", "add_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FAKE", "\\u", "UUID_", ",_", "image", "\\u", "s3_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "option", "\\u", "required_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conf_", "=_", "S", "3", "\\u", "CONF_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "conf_", "[_", "key_", "]_", "\\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 ", " _", "self_", "._", "store_", "=_", "Store_", "(_", "test\\u", "utils_", "._", "Test", "Config", "Opts_", "(_", "conf_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "store_", "._", "add_", "==_", "self_", "._", "store_", "._", "add", "\\u", "disabled_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "no", "\\u", "access", "\\u", "key_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "options", " ", "with", "out", " ", "access", " ", "key", " ", "disable", "s", " ", "the", " ", "add", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "\\u", "option", "\\u", "required_", "(_", "'", "s3", "\\u", "store", "\\u", "access", "\\u", "key", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "no", "\\u", "secret", "\\u", "key_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "options", " ", "with", "out", " ", "secret", " ", "key", " ", "disable", "s", " ", "the", " ", "add", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "\\u", "option", "\\u", "required_", "(_", "'", "s3", "\\u", "store", "\\u", "secret", "\\u", "key", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "no", "\\u", "host_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "options", " ", "with", "out", " ", "host", " ", "disable", "s", " ", "the", " ", "add", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "\\u", "option", "\\u", "required_", "(_", "'", "s3", "\\u", "store", "\\u", "host", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "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_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "we", " ", "can", " ", "delete", " ", "an", " ", "exist", "ing", " ", "image", " ", "in", " ", "the", " ", "s3", " ", "store", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "\"", "s3", "://", "user", ":", "key", "@", "auth", "\\u", "address", "/", "gla", "nce", "/", "%", "s", "\"_", "%_", "FAKE", "\\u", "UUID_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "store_", "._", "delete_", "(_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "exception_", "._", "Not", "Found_", ",_", "self_", "._", "store_", "._", "get_", ",_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Store_", "(_", "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", "non", "\\u", "existing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "tha", "t", " ", "try", "ing", " ", "to", " ", "delete", " ", "a", " ", "s3", " ", "tha", "t", " ", "doe", "sn", "'", "t", " ", "exist", "\\", "10", ";", " ", " ", " ", " ", "raise", "s", " ", "an", " ", "error", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "\"", "s3", "://", "user", ":", "key", "@", "auth", "\\u", "address", "/", "gla", "nce", "/", "noe", "xist", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loc_", "=_", "get", "\\u", "location", "\\u", "from", "\\u", "uri_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "exception_", "._", "Not", "Found_", ",_", "self_", "._", "store_", "._", "delete_", ",_", "loc_", ")_" ]
[ 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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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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 more than once
chaosmail/python-fs/fs/fs.py
[ { "content": "\nimport os\n\n\"\"\"Constants\"\"\"\n\nOPEN_FUNC = open\nsep = os.sep\ntry:\n import types\n LIST_TYPE = types.ListType\nexcept Exception:\n LIST_TYPE = list\n\n\n\"\"\"Helper Functions\"\"\"\n\n\n\n\n\"\"\"Filesystem Methods\"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\"\"\" Aliases \"\"\"\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def rename(oldPath, newPath, **kwargs):\n \"\"\"rename the file oldPath to newPath\"\"\"\n import os\n return os.rename(oldPath, newPath, **kwargs)", "metadata": "root.rename", "header": "['module', '___EOS___']", "index": 37 }, { "content": "def chdir(path, **kwargs):\n \"\"\"change current working directory\"\"\"\n import os\n return os.chdir(path, **kwargs)", "metadata": "root.chdir", "header": "['module', '___EOS___']", "index": 53 }, { "content": "def chown(path, user=None, group=None):\n \"\"\"change ownership of path\"\"\"\n import os\n import pwd\n import grp\n uid = pwd.getpwnam(user).pw_uid if user else -1\n gid = grp.getgrnam(group).gr_gid if group else -1\n return os.chown(path, uid, gid)", "metadata": "root.chown", "header": "['module', '___EOS___']", "index": 58 }, { "content": "def chmod(path, mode):\n \"\"\"change pernmissions of path\"\"\"\n import os, stat\n st = os.stat(path)\n return os.chmod(path, mode)", "metadata": "root.chmod", "header": "['module', '___EOS___']", "index": 67 }, { "content": "def link(srcPath, destPath):\n \"\"\"create a hard link from srcPath to destPath\"\"\"\n import os\n return os.link(srcPath, destPath)", "metadata": "root.link", "header": "['module', '___EOS___']", "index": 73 }, { "content": "def symlink(srcPath, destPath):\n \"\"\"create a symbolic link from srcPath to destPath\"\"\"\n import os\n return os.symlink(srcPath, destPath)", "metadata": "root.symlink", "header": "['module', '___EOS___']", "index": 78 }, { "content": "def stat(path):\n \"\"\"Return file stats\"\"\"\n import os\n return os.stat(path)", "metadata": "root.stat", "header": "['module', '___EOS___']", "index": 83 }, { "content": "def rm(path, **kwargs):\n \"\"\"Remove the file *path*\"\"\"\n import os\n return os.unlink(path, **kwargs)", "metadata": "root.rm", "header": "['module', '___EOS___']", "index": 114 }, { "content": "def rmdir(path, recursive=True, **kwargs):\n \"\"\"Remove the directory *path*\"\"\"\n if recursive:\n import shutil\n return shutil.rmtree(path, **kwargs)\n else:\n import os\n return os.remdir(path, **kwargs)", "metadata": "root.rmdir", "header": "['module', '___EOS___']", "index": 123 }, { "content": "def mkdir(path, recursive=True, **kwargs):\n \"\"\"Unix equivalent *mkdir*\"\"\"\n import os\n if recursive:\n os.makedirs(path, **kwargs)\n else:\n os.mkdir(path, **kwargs)", "metadata": "root.mkdir", "header": "['module', '___EOS___']", "index": 142 }, { "content": "def touch(path):\n \"\"\"Unix equivalent *touch*\n @src: http://stackoverflow.com/a/1158096\"\"\"\n import os\n try:\n OPEN_FUNC(path, 'a+').close()\n except IOError:\n os.utime(path, None)", "metadata": "root.touch", "header": "['module', '___EOS___']", "index": 150 }, { "content": "def list(path='.'):\n \"\"\"generator that returns all files of *path*\"\"\"\n import os\n for f in os.listdir(path):\n if isfile(join(path, f)):\n yield join(path, f) if path != '.' else f", "metadata": "root.list", "header": "['module', '___EOS___']", "index": 167 }, { "content": "def listdirs(path='.'):\n \"\"\"generator that returns all directories of *path*\"\"\"\n import os\n for f in os.listdir(path):\n if isdir(join(path, f)):\n yield join(path, f) if path != '.' else f", "metadata": "root.listdirs", "header": "['module', '___EOS___']", "index": 174 }, { "content": "def find(pattern, path='.', exclude=None, recursive=True):\n \"\"\"Find files that match *pattern* in *path*\"\"\"\n import fnmatch\n import os\n\n if recursive:\n for root, dirnames, filenames in os.walk(path):\n for pat in _to_list(pattern):\n for filename in fnmatch.filter(filenames, pat):\n filepath = join(abspath(root), filename)\n for excl in _to_list(exclude):\n if excl and fnmatch.fnmatch(filepath, excl):\n break\n else:\n yield filepath\n else:\n for pat in _to_list(pattern):\n for filename in fnmatch.filter(list(path), pat):\n filepath = join(abspath(path), filename)\n for excl in _to_list(exclude):\n if excl and fnmatch.fnmatch(filepath, excl):\n break\n else:\n yield filepath", "metadata": "root.find", "header": "['module', '___EOS___']", "index": 181 }, { "content": "def finddirs(pattern, path='.', exclude=None, recursive=True):\n \"\"\"Find directories that match *pattern* in *path*\"\"\"\n import fnmatch\n import os\n if recursive:\n for root, dirnames, filenames in os.walk(path):\n for pat in _to_list(pattern):\n for dirname in fnmatch.filter(dirnames, pat):\n dirpath = join(abspath(root), dirname)\n for excl in _to_list(exclude):\n if excl and fnmatch.fnmatch(dirpath, excl):\n break\n else:\n yield dirpath\n else:\n for pat in _to_list(pattern):\n for dirname in fnmatch.filter(listdirs(path), pat):\n dirpath = join(abspath(path), dirname)\n for excl in _to_list(exclude):\n if excl and fnmatch.fnmatch(dirpath, excl):\n break\n else:\n yield dirpath", "metadata": "root.finddirs", "header": "['module', '___EOS___']", "index": 206 }, { "content": "def cwd():\n \"\"\"Get the current working directory\"\"\"\n import os\n return os.getcwd()", "metadata": "root.cwd", "header": "['module', '___EOS___']", "index": 277 } ]
[ { "span": "import os", "start_line": 39, "start_column": 4, "end_line": 39, "end_column": 13 }, { "span": "import os", "start_line": 55, "start_column": 4, "end_line": 55, "end_column": 13 }, { "span": "import os", "start_line": 60, "start_column": 4, "end_line": 60, "end_column": 13 }, { "span": "import os, stat", "start_line": 69, "start_column": 4, "end_line": 69, "end_column": 19 }, { "span": "import os", "start_line": 75, "start_column": 4, "end_line": 75, "end_column": 13 }, { "span": "import os", "start_line": 80, "start_column": 4, "end_line": 80, "end_column": 13 }, { "span": "import os", "start_line": 85, "start_column": 4, "end_line": 85, "end_column": 13 }, { "span": "import os", "start_line": 116, "start_column": 4, "end_line": 116, "end_column": 13 }, { "span": "import os", "start_line": 129, "start_column": 8, "end_line": 129, "end_column": 17 }, { "span": "import os", "start_line": 144, "start_column": 4, "end_line": 144, "end_column": 13 }, { "span": "import os", "start_line": 153, "start_column": 4, "end_line": 153, "end_column": 13 }, { "span": "import os", "start_line": 169, "start_column": 4, "end_line": 169, "end_column": 13 }, { "span": "import os", "start_line": 176, "start_column": 4, "end_line": 176, "end_column": 13 }, { "span": "import os", "start_line": 184, "start_column": 4, "end_line": 184, "end_column": 13 }, { "span": "import os", "start_line": 209, "start_column": 4, "end_line": 209, "end_column": 13 }, { "span": "import os", "start_line": 279, "start_column": 4, "end_line": 279, "end_column": 13 } ]
[ { "span": "import os", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 9 } ]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "more_", "than_", "once_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Const", "ant", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "OPEN", "\\u", "FUNC", "_", "=_", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sep_", "=_", "os_", "._", "sep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LIST", "\\u", "TYPE_", "=_", "types_", "._", "List", "Type_", "\\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 ", " _", "LIST", "\\u", "TYPE_", "=_", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "Help", "er", " ", "Function", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "Files", "yste", "m", " ", "Meth", "ods", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_",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\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "\"\"\"", " ", "Aliase", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rename_", "(_", "old", "Path_", ",_", "new", "Path_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "rename", " ", "the", " ", "file", " ", "old", "Path", " ", "to", " ", "new", "Path", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "rename_", "(_", "old", "Path_", ",_", "new", "Path_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "chdir_", "(_", "path_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "change", " ", "current", " ", "working", " ", "director", "y", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "chdir_", "(_", "path_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "chown", "_", "(_", "path_", ",_", "user_", "=_", "None_", ",_", "group_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "change", " ", "owner", "ship", " ", "of", " ", "path", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pwd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "grp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uid_", "=_", "pwd_", "._", "getpw", "nam_", "(_", "user_", ")_", "._", "pw", "\\u", "uid_", "if_", "user_", "else_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gid_", "=_", "grp_", "._", "getg", "rnam", "_", "(_", "group_", ")_", "._", "gr", "\\u", "gid_", "if_", "group_", "else_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "chown", "_", "(_", "path_", ",_", "uid_", ",_", "gid_", ")_", "\\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_", "chmod_", "(_", "path_", ",_", "mode_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "change", " ", "per", "nmi", "ssion", "s", " ", "of", " ", "path", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "stat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "st_", "=_", "os_", "._", "stat_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "chmod_", "(_", "path_", ",_", "mode_", ")_", "\\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_", "link_", "(_", "src", "Path_", ",_", "dest", "Path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "create", " ", "a", " ", "hard", " ", "link", " ", "from", " ", "src", "Path", " ", "to", " ", "dest", "Path", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "link_", "(_", "src", "Path_", ",_", "dest", "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_", "symlink_", "(_", "src", "Path_", ",_", "dest", "Path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "create", " ", "a", " ", "symbolic", " ", "link", " ", "from", " ", "src", "Path", " ", "to", " ", "dest", "Path", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "symlink_", "(_", "src", "Path_", ",_", "dest", "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_", "stat_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "file", " ", "stats", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "stat_", "(_", "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_", "(_", "path_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Remove", " ", "the", " ", "file", " ", "*", "path", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "unlink_", "(_", "path_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rmdir_", "(_", "path_", ",_", "recursive_", "=_", "True_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Remove", " ", "the", " ", "director", "y", " ", "*", "path", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "recursive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "shutil_", "._", "rmtree_", "(_", "path_", ",_", "**_", "kwargs_", ")_", "\\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 ", " _", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "rem", "dir_", "(_", "path_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mkdir_", "(_", "path_", ",_", "recursive_", "=_", "True_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Uni", "x", " ", "equivalent", " ", "*", "mkd", "ir", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "recursive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "path_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "mkdir_", "(_", "path_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "touch_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Uni", "x", " ", "equivalent", " ", "*", "touch", "*", "\\", "10", ";", " ", " ", " ", " ", "@", "src", ":", " ", "http", "://", "stack", "overflow", ".", "com", "/", "a", "/", "115", "809", "6", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "OPEN", "\\u", "FUNC", "_", "(_", "path_", ",_", "'", "a", "+'_", ")_", "._", "close_", "(_", ")_", "\\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 ", " _", "os_", "._", "utime", "_", "(_", "path_", ",_", "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_", "list_", "(_", "path_", "=_", "'.'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "generat", "or", " ", "tha", "t", " ", "return", "s", " ", "all", " ", "files", " ", "of", " ", "*", "path", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isfile_", "(_", "join_", "(_", "path_", ",_", "f_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "join_", "(_", "path_", ",_", "f_", ")_", "if_", "path_", "!=_", "'.'_", "else_", "f_", "\\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_", "listd", "irs_", "(_", "path_", "=_", "'.'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "generat", "or", " ", "tha", "t", " ", "return", "s", " ", "all", " ", "director", "ies", " ", "of", " ", "*", "path", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isdir_", "(_", "join_", "(_", "path_", ",_", "f_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "join_", "(_", "path_", ",_", "f_", ")_", "if_", "path_", "!=_", "'.'_", "else_", "f_", "\\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_", "find_", "(_", "pattern_", ",_", "path_", "=_", "'.'_", ",_", "exclude_", "=_", "None_", ",_", "recursive_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Fin", "d", " ", "files", " ", "tha", "t", " ", "match", " ", "*", "pattern", "*", " ", "in", " ", "*", "path", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "fnmatch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "recursive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "root_", ",_", "dirnames_", ",_", "filenames_", "in_", "os_", "._", "walk_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "pat_", "in_", "\\u", "to", "\\u", "list_", "(_", "pattern_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "filename_", "in_", "fnmatch_", "._", "filter_", "(_", "filenames_", ",_", "pat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "filepath_", "=_", "join_", "(_", "abspath_", "(_", "root_", ")_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "excl", "_", "in_", "\\u", "to", "\\u", "list_", "(_", "exclude_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "excl", "_", "and_", "fnmatch_", "._", "fnmatch_", "(_", "filepath_", ",_", "excl", "_", ")_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "yield_", "filepath_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "pat_", "in_", "\\u", "to", "\\u", "list_", "(_", "pattern_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "filename_", "in_", "fnmatch_", "._", "filter_", "(_", "list_", "(_", "path_", ")_", ",_", "pat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filepath_", "=_", "join_", "(_", "abspath_", "(_", "path_", ")_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "excl", "_", "in_", "\\u", "to", "\\u", "list_", "(_", "exclude_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "excl", "_", "and_", "fnmatch_", "._", "fnmatch_", "(_", "filepath_", ",_", "excl", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "yield_", "filepath_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "find", "dirs_", "(_", "pattern_", ",_", "path_", "=_", "'.'_", ",_", "exclude_", "=_", "None_", ",_", "recursive_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Fin", "d", " ", "director", "ies", " ", "tha", "t", " ", "match", " ", "*", "pattern", "*", " ", "in", " ", "*", "path", "*\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "fnmatch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "recursive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "root_", ",_", "dirnames_", ",_", "filenames_", "in_", "os_", "._", "walk_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "pat_", "in_", "\\u", "to", "\\u", "list_", "(_", "pattern_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "dirname_", "in_", "fnmatch_", "._", "filter_", "(_", "dirnames_", ",_", "pat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "dirpath_", "=_", "join_", "(_", "abspath_", "(_", "root_", ")_", ",_", "dirname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "excl", "_", "in_", "\\u", "to", "\\u", "list_", "(_", "exclude_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "excl", "_", "and_", "fnmatch_", "._", "fnmatch_", "(_", "dirpath_", ",_", "excl", "_", ")_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "yield_", "dirpath_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "pat_", "in_", "\\u", "to", "\\u", "list_", "(_", "pattern_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "dirname_", "in_", "fnmatch_", "._", "filter_", "(_", "listd", "irs_", "(_", "path_", ")_", ",_", "pat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dirpath_", "=_", "join_", "(_", "abspath_", "(_", "path_", ")_", ",_", "dirname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "excl", "_", "in_", "\\u", "to", "\\u", "list_", "(_", "exclude_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "excl", "_", "and_", "fnmatch_", "._", "fnmatch_", "(_", "dirpath_", ",_", "excl", "_", ")_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "yield_", "dirpath_", "\\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_", "cwd_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "the", " ", "current", " ", "working", " ", "director", "y", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 2, 2,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2, 2 ]
Unused import
pcapriotti/pledger/tests/test-directive.py
[ { "content": "# Copyright (C) 2011 by Paolo Capriotti <[email protected]>\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n# THE SOFTWARE.\n\nimport unittest\nfrom pledger.parser import Parser\nfrom pledger.directive import *\nfrom pledger.ledger_processor import LedgerProcessor\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ProcessorStub(object):\n\n\n", "metadata": "root.ProcessorStub", "header": "['module', '___EOS___']", "index": 26 }, { "content": " def __init__(self, root):\n self.account = root\n self.included = []", "metadata": "root.ProcessorStub.__init__", "header": "['class', 'ProcessorStub', '(', 'object', ')', ':', '___EOS___']", "index": 27 }, { "content": " def add_account_prefix(self, prefix):\n self.account = self.account[prefix]", "metadata": "root.ProcessorStub.add_account_prefix", "header": "['class', 'ProcessorStub', '(', 'object', ')', ':', '___EOS___']", "index": 31 }, { "content": " def remove_account_prefix(self):\n self.account = self.account.parent", "metadata": "root.ProcessorStub.remove_account_prefix", "header": "['class', 'ProcessorStub', '(', 'object', ')', ':', '___EOS___']", "index": 34 }, { "content": " def include(self, filename):\n self.included.append(filename)", "metadata": "root.ProcessorStub.include", "header": "['class', 'ProcessorStub', '(', 'object', ')', ':', '___EOS___']", "index": 37 }, { "content": "class DirectiveTest(unittest.TestCase):\n\n\n\n\n\n", "metadata": "root.DirectiveTest", "header": "['module', '___EOS___']", "index": 41 }, { "content": " def setUp(self):\n self.parser = Parser()\n self.processor = ProcessorStub(self.parser.accounts)", "metadata": "root.DirectiveTest.setUp", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 42 }, { "content": " def testDirectiveRegistry(self):\n self.assertEqual(AccountDirective, Directive.directives['account'])\n self.assertIsNone(Directive.directives.get('non-existing-directive'))", "metadata": "root.DirectiveTest.testDirectiveRegistry", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 46 }, { "content": " def testUnsupportedDirective(self):\n with self.assertRaises(UnsupportedDirective) as cm:\n self.parser.parse_directive(\"!nonexisting\")\n\n self.assertRegexpMatches(str(cm.exception), \"nonexisting\")", "metadata": "root.DirectiveTest.testUnsupportedDirective", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 50 }, { "content": " def testAccountDirective(self):\n directive = AccountDirective(\"Assets\")\n self.assertIsNone(self.processor.account.name)\n directive.execute(self.processor)\n self.assertEqual(\"Assets\", self.processor.account.name)", "metadata": "root.DirectiveTest.testAccountDirective", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 56 }, { "content": " def testEndAccountDirective(self):\n directive = EndAccountDirective()\n self.processor.add_account_prefix(\"Assets\")\n directive.execute(self.processor)\n self.assertIsNone(self.processor.account.name)", "metadata": "root.DirectiveTest.testEndAccountDirective", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 62 }, { "content": " def testIncludeDirective(self):\n directive = IncludeDirective(\"test.dat\")\n self.assertEqual([], self.processor.included)\n directive.execute(self.processor)\n self.assertEqual([\"test.dat\"], self.processor.included)", "metadata": "root.DirectiveTest.testIncludeDirective", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 68 }, { "content": " def testDirectiveParsing(self):\n directive = self.parser.parse_directive(\"!include test.dat\")\n self.assertEqual(\"test.dat\", directive.filename)", "metadata": "root.DirectiveTest.testDirectiveParsing", "header": "['class', 'DirectiveTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 74 } ]
[ { "span": "from pledger.ledger_processor import LedgerProcessor", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 52 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "C", ")", " ", "2011", " ", "by", " ", "Pa", "olo", " ", "Cap", "rio", "tti", " ", "<", "p", ".", "cap", "rio", "tti", "@", "gma", "il", ".", "com", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Permi", "ssion", " ", "is", " ", "here", "by", " ", "grant", "ed", ",", " ", "free", " ", "of", " ", "charge", ",", " ", "to", " ", "any", " ", "person", " ", "obtain", "ing", " ", "a", " ", "copy_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "this", " ", "software", " ", "and", " ", "associate", "d", " ", "documentation", " ", "files", " ", "(", "the", " ", "\"", "Sof", "twa", "re", "\")", ",", " ", "to", " ", "deal", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "the", " ", "Sof", "twa", "re", " ", "with", "out", " ", "restriction", ",", " ", "inclu", "ding", " ", "with", "out", " ", "limit", "ation", " ", "the", " ", "rights_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "use", ",", " ", "copy", ",", " ", "modif", "y", ",", " ", "merge", ",", " ", "publi", "sh", ",", " ", "distribute", ",", " ", "subli", "cens", "e", ",", " ", "and", "/", "or", " ", "sell", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "copie", "s", " ", "of", " ", "the", " ", "Sof", "twa", "re", ",", " ", "and", " ", "to", " ", "permit", " ", "person", "s", " ", "to", " ", "who", "m", " ", "the", " ", "Sof", "twa", "re", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fur", "nish", "ed", " ", "to", " ", "do", " ", "so", ",", " ", "subject", " ", "to", " ", "the", " ", "follow", "ing", " ", "condition", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "above", " ", "copyr", "ight", " ", "notice", " ", "and", " ", "this", " ", "permissi", "on", " ", "notice", " ", "sha", "ll", " ", "be", " ", "include", "d", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "copie", "s", " ", "or", " ", "substa", "nti", "al", " ", "porti", "ons", " ", "of", " ", "the", " ", "Sof", "twa", "re", "._", "\\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", ",", " ", "EXPR", "ESS", " ", "OR_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IMPL", "IED", ",", " ", "INC", "LU", "DING", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", " ", "THE", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", " ", "AND", " ", "NON", "INF", "RING", "EME", "NT", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "AUTHOR", "S", " ", "OR", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "CLA", "IM", ",", " ", "DA", "MAGE", "S", " ", "OR", " ", "OTHER", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "LI", "ABI", "LIT", "Y", ",", " ", "WHE", "THER", " ", "IN", " ", "AN", " ", "ACTI", "ON", " ", "OF", " ", "CONTR", "ACT", ",", " ", "TOR", "T", " ", "OR", " ", "OTHER", "WI", "SE", ",", " ", "ARI", "SIN", "G", " ", "FROM", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OUT", " ", "OF", " ", "OR", " ", "IN", " ", "CONNECTION", " ", "WITH", " ", "THE", " ", "SOFT", "WARE", " ", "OR", " ", "THE", " ", "USE", " ", "OR", " ", "OTHER", " ", "DEA", "LING", "S", " ", "IN_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "SOFT", "WARE", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ple", "dge", "r_", "._", "parser_", "import_", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ple", "dge", "r_", "._", "directive_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ple", "dge", "r_", "._", "ledger", "\\u", "processor_", "import_", "Led", "ger", "Processor_", "\\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_", "Process", "or", "Stub_", "(_", "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_", "[SEP]_", "class_", "Process", "or", "Stub_", "(_", "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_", ",_", "root_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "account_", "=_", "root_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "included_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Process", "or", "Stub_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "account", "\\u", "prefix_", "(_", "self_", ",_", "prefix_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "account_", "=_", "self_", "._", "account_", "[_", "prefix_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Process", "or", "Stub_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "account", "\\u", "prefix_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "account_", "=_", "self_", "._", "account_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Process", "or", "Stub_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "include_", "(_", "self_", ",_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "included_", "._", "append_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "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_", "Directive", "Test_", "(_", "unittest_", "._", "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_", "._", "parser_", "=_", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "processor_", "=_", "Process", "or", "Stub_", "(_", "self_", "._", "parser_", "._", "accounts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Directive", "Registry_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "Account", "Directive", "_", ",_", "Directive", "_", "._", "directives_", "[_", "'", "account", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "None_", "(_", "Directive", "_", "._", "directives_", "._", "get_", "(_", "'", "non", "-", "exist", "ing", "-", "directive", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Unsu", "ppo", "rted", "Directive", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "self_", "._", "assert", "Raises_", "(_", "Unsu", "ppo", "rted", "Directive", "_", ")_", "as_", "cm_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parser_", "._", "parse", "\\u", "directive_", "(_", "\"!", "nonexist", "ing", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Rege", "xp", "Matches_", "(_", "str_", "(_", "cm_", "._", "exception_", ")_", ",_", "\"", "nonexist", "ing", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Account", "Directive", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "directive_", "=_", "Account", "Directive", "_", "(_", "\"", "Asset", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "None_", "(_", "self_", "._", "processor_", "._", "account_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "directive_", "._", "execute_", "(_", "self_", "._", "processor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "Asset", "s", "\"_", ",_", "self_", "._", "processor_", "._", "account_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "End", "Account", "Directive", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "directive_", "=_", "End", "Account", "Directive", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "processor_", "._", "add", "\\u", "account", "\\u", "prefix_", "(_", "\"", "Asset", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "directive_", "._", "execute_", "(_", "self_", "._", "processor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "None_", "(_", "self_", "._", "processor_", "._", "account_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Include", "Directive", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "directive_", "=_", "Include", "Directive", "_", "(_", "\"", "test", ".", "dat", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "]_", ",_", "self_", "._", "processor_", "._", "included_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "directive_", "._", "execute_", "(_", "self_", "._", "processor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "\"", "test", ".", "dat", "\"_", "]_", ",_", "self_", "._", "processor_", "._", "included_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Directive", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Directive", "Pars", "ing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "directive_", "=_", "self_", "._", "parser_", "._", "parse", "\\u", "directive_", "(_", "\"!", "include", " ", "test", ".", "dat", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "test", ".", "dat", "\"_", ",_", "directive_", "._", "filename_", ")_" ]
[ 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, 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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, 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, 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, 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 ]
Imprecise assert
ImageEngine/gaffer/python/GafferImageTest/FormatPlugTest.py
[ { "content": "\tdef testDefaultFormatFromScript( self ) :\n\n\t\ts = Gaffer.ScriptNode()\n\t\tself.assertFalse( \"defaultFormat\" in s )\n\n\t\ts[\"c\"] = GafferImage.Constant()\n\t\tself.assertTrue( \"defaultFormat\" in s )\n\n\t\tdefaultFormatPlug = GafferImage.FormatPlug.acquireDefaultFormatPlug( s )\n\t\tself.assertTrue( defaultFormatPlug.isSame( s[\"defaultFormat\"] ) )\n\n\t\twith s.context() :\n\n\t\t\tself.assertFalse(\n\t\t\t\tGafferImage.empty(\n\t\t\t\t\ts[\"c\"][\"out\"][\"format\"].getValue().getDisplayWindow()\n\t\t\t\t)\n\t\t\t)\n\n\t\t\tf = GafferImage.Format( 100, 200, 2 )\n\t\t\tdefaultFormatPlug.setValue( f )\n\t\t\tself.assertEqual( s[\"c\"][\"out\"][\"format\"].getValue(), f )\n\n\t\t\tf = GafferImage.Format( 200, 400, 1 )\n\t\t\tdefaultFormatPlug.setValue( f )\n\t\t\tself.assertEqual( s[\"c\"][\"out\"][\"format\"].getValue(), f )", "metadata": "root.FormatPlugTest.testDefaultFormatFromScript", "header": "['class', 'FormatPlugTest', '(', 'GafferImageTest', '.', 'ImageTestCase', ')', ':', '___EOS___']", "index": 127 }, { "content": "\tdef testDefaultFormatFromScriptWithBox( self ) :\n\n\t\ts = Gaffer.ScriptNode()\n\t\tself.assertFalse( \"defaultFormat\" in s )\n\n\t\ts[\"b\"] = Gaffer.Box()\n\t\ts[\"b\"][\"c\"] = GafferImage.Constant()\n\t\tself.assertTrue( \"defaultFormat\" in s )", "metadata": "root.FormatPlugTest.testDefaultFormatFromScriptWithBox", "header": "['class', 'FormatPlugTest', '(', 'GafferImageTest', '.', 'ImageTestCase', ')', ':', '___EOS___']", "index": 169 } ]
[ { "span": "self.assertFalse( \"defaultFormat\" in s )", "start_line": 130, "start_column": 2, "end_line": 130, "end_column": 42 }, { "span": "self.assertTrue( \"defaultFormat\" in s )", "start_line": 133, "start_column": 2, "end_line": 133, "end_column": 41 }, { "span": "self.assertFalse( \"defaultFormat\" in s )", "start_line": 172, "start_column": 2, "end_line": 172, "end_column": 42 }, { "span": "self.assertTrue( \"defaultFormat\" in s )", "start_line": 176, "start_column": 2, "end_line": 176, "end_column": 41 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Format", "Plug", "Test_", "(_", "Ga", "ffer", "Image", "Test_", "._", "Image", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Default", "Format", "Fro", "m", "Script_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "\"", "default", "Format", "\"_", "in_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "=_", "Ga", "ffer", "Image_", "._", "Constant_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "default", "Format", "\"_", "in_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "default", "Format", "Plug", "_", "=_", "Ga", "ffer", "Image_", "._", "Format", "Plug", "_", "._", "acquir", "e", "Default", "Format", "Plug", "_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "default", "Format", "Plug", "_", "._", "is", "Sam", "e_", "(_", "s_", "[_", "\"", "default", "Format", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "s_", "._", "context_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "self_", "._", "assert", "False_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Ga", "ffer", "Image_", "._", "empty_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", "[_", "\"", "format", "\"_", "]_", "._", "get", "Value_", "(_", ")_", "._", "get", "Display", "Window_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "Ga", "ffer", "Image_", "._", "Format_", "(_", "100_", ",_", "200_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "Format", "Plug", "_", "._", "set", "Value_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", "[_", "\"", "format", "\"_", "]_", "._", "get", "Value_", "(_", ")_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "Ga", "ffer", "Image_", "._", "Format_", "(_", "200_", ",_", "400_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "Format", "Plug", "_", "._", "set", "Value_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", "[_", "\"", "format", "\"_", "]_", "._", "get", "Value_", "(_", ")_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Format", "Plug", "Test_", "(_", "Ga", "ffer", "Image", "Test_", "._", "Image", "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", "Default", "Format", "Fro", "m", "Script", "With", "Box_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "\"", "default", "Format", "\"_", "in_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "b", "\"_", "]_", "=_", "Ga", "ffer", "_", "._", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "b", "\"_", "]_", "[_", "\"", "c", "\"_", "]_", "=_", "Ga", "ffer", "Image_", "._", "Constant_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "default", "Format", "\"_", "in_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
erkyrath/tworld/lib/twest/test_funcs.py
[ { "content": "\"\"\"\nTo run: python3 -m tornado.testing twest.test_funcs\n(The twest, two, twcommon modules must be in your PYTHON_PATH.)\n\"\"\"\n\nimport datetime\nimport logging\nimport unittest\nimport ast\n\nfrom bson.objectid import ObjectId\nimport tornado.testing\n\nimport motor\n\nimport twcommon.misc\nimport two.execute\nimport two.symbols\nimport two.task\nfrom two.execute import EvalPropContext\nfrom twcommon.excepts import SymbolError\n\nimport twest.mock\nfrom twest.mock import NotFound\n\n\n \nfrom two.evalctx import LEVEL_EXECUTE, LEVEL_DISPSPECIAL, LEVEL_DISPLAY, LEVEL_MESSAGE, LEVEL_FLAT, LEVEL_RAW\nfrom two.evalctx import EVALTYPE_SYMBOL, EVALTYPE_RAW, EVALTYPE_CODE, EVALTYPE_TEXT\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestEvalAsync(twest.mock.MockAppTestCase):\n mockappargs = { 'propcache':True, 'globals':True }\n \n \n\n\n \n \n\n ", "metadata": "root.TestEvalAsync", "header": "['module', '___EOS___']", "index": 25 }, { "content": " @tornado.gen.coroutine\n def resetTables(self):\n # Invent some arbitrary objids for the world and instance.\n self.exuid = ObjectId()\n self.exwid = ObjectId()\n self.exiid = ObjectId()\n self.exlocid = ObjectId()\n self.exscid = ObjectId()\n self.loctx = two.task.LocContext(\n uid=self.exuid, wid=self.exwid, scid=self.exscid,\n iid=self.exiid, locid=self.exlocid)\n \n yield motor.Op(self.app.mongodb.worldprop.remove,\n {})\n yield motor.Op(self.app.mongodb.worldprop.insert,\n {'wid':self.exwid, 'locid':self.exlocid,\n 'key':'x', 'val':0})\n yield motor.Op(self.app.mongodb.worldprop.insert,\n {'wid':self.exwid, 'locid':self.exlocid,\n 'key':'w', 'val':'world'})\n yield motor.Op(self.app.mongodb.worldprop.insert,\n {'wid':self.exwid, 'locid':None,\n 'key':'r', 'val':11})\n yield motor.Op(self.app.mongodb.worldprop.insert,\n {'wid':self.exwid, 'locid':self.exlocid,\n 'key':'r', 'val':12})\n \n yield motor.Op(self.app.mongodb.instanceprop.remove,\n {})\n yield motor.Op(self.app.mongodb.instanceprop.insert,\n {'iid':self.exiid, 'locid':self.exlocid,\n 'key':'x', 'val':1})\n yield motor.Op(self.app.mongodb.instanceprop.insert,\n {'iid':self.exiid, 'locid':self.exlocid,\n 'key':'y', 'val':2})\n yield motor.Op(self.app.mongodb.instanceprop.insert,\n {'iid':self.exiid, 'locid':self.exlocid,\n 'key':'ls', 'val':[1,2,3]})\n yield motor.Op(self.app.mongodb.instanceprop.insert,\n {'iid':self.exiid, 'locid':self.exlocid,\n 'key':'map', 'val':{'one':1, 'two':2, 'three':3}})\n yield motor.Op(self.app.mongodb.instanceprop.insert,\n {'iid':self.exiid, 'locid':None,\n 'key':'r', 'val':13})\n yield motor.Op(self.app.mongodb.instanceprop.insert,\n {'iid':self.exiid, 'locid':self.exlocid,\n 'key':'r', 'val':14})", "metadata": "root.TestEvalAsync.resetTables", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 28 }, { "content": " @tornado.testing.gen_test\n def test_global_funcs(self):\n yield self.resetTables()\n \n task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())\n ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)\n\n res = yield ctx.eval('len(\"xyzzy\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 5)\n res = yield ctx.eval('len(ls)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 3)\n res = yield ctx.eval('min(5,3,4)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 3)\n res = yield ctx.eval('min([5,3,4])', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 3)\n res = yield ctx.eval('max(5,3,4)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 5)\n \n res = yield ctx.eval('int(6.5)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 6)\n res = yield ctx.eval('int(\"17\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 17)\n res = yield ctx.eval('str(6)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, '6')\n res = yield ctx.eval('bool(6)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('list((6,7))', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [6,7])\n res = yield ctx.eval('set((7,6))', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {6,7})\n res = yield ctx.eval('dict([(6,7)])', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {6:7})\n \n res = yield ctx.eval('[text(\"x\")]', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [{'type': 'text', 'text': 'x'}])\n res = yield ctx.eval('[code(\"x\")]', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [{'type': 'code', 'text': 'x'}])\n res = yield ctx.eval('[gentext.gentext(\"x\")]', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [{'type': 'gentext', 'text': 'x'}])\n res = yield ctx.eval('ObjectId(\"5245c6b26b3d30521a6996ec\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ObjectId(\"5245c6b26b3d30521a6996ec\"))\n\n res = yield ctx.eval('isinstance(True, bool)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance(True, int)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res) # a Python quirk\n res = yield ctx.eval('isinstance(5, (str, int))', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance([], (str, int))', evaltype=EVALTYPE_CODE)\n self.assertFalse(res)\n res = yield ctx.eval('isinstance(32, int)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance(\"X\", str)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance(ObjectId(\"5245c6b26b3d30521a6996ec\"), ObjectId)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance({}, dict)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance({1}, set)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance([1], list)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance({\"type\":\"text\", \"text\":\"x\"}, text)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance({\"type\":\"code\", \"text\":\"x\"}, code)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance({\"type\":\"gentext\", \"text\":\"x\"}, gentext.gentext)', evaltype=EVALTYPE_CODE)\n self.assertTrue(res)\n res = yield ctx.eval('isinstance({\"type\":\"foo\", \"text\":\"x\"}, text)', evaltype=EVALTYPE_CODE)\n self.assertFalse(res)\n res = yield ctx.eval('isinstance({\"type\":\"foo\", \"text\":\"x\"}, code)', evaltype=EVALTYPE_CODE)\n self.assertFalse(res)\n res = yield ctx.eval('isinstance({\"type\":\"foo\", \"text\":\"x\"}, gentext.gentext)', evaltype=EVALTYPE_CODE)\n self.assertFalse(res)\n \n res = yield ctx.eval('realm', evaltype=EVALTYPE_CODE)\n self.assertTrue(isinstance(res, two.execute.RealmProxy))\n res = yield ctx.eval('locations', evaltype=EVALTYPE_CODE)\n self.assertTrue(isinstance(res, two.execute.WorldLocationsProxy))\n res = yield ctx.eval('player', evaltype=EVALTYPE_CODE)\n self.assertTrue(isinstance(res, two.execute.PlayerProxy))\n self.assertEqual(res, self.exuid)\n\n res = yield ctx.eval('random.choice([\"X\",\"Y\",\"Z\"])', evaltype=EVALTYPE_CODE)\n self.assertIn(res, [\"X\",\"Y\",\"Z\"])\n res = yield ctx.eval('random.randint(4, 6)', evaltype=EVALTYPE_CODE)\n self.assertIn(res, [4,5,6])\n res = yield ctx.eval('random.randrange(3)', evaltype=EVALTYPE_CODE)\n self.assertIn(res, [0,1,2])\n res = yield ctx.eval('random.randrange(4, 6)', evaltype=EVALTYPE_CODE)\n self.assertIn(res, [4,5])", "metadata": "root.TestEvalAsync.test_global_funcs", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 77 }, { "content": " @tornado.testing.gen_test\n def test_type_methods_list(self):\n yield self.resetTables()\n \n task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())\n ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)\n\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls.append(4);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2,3,4])\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls.clear();_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [])\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls2=_ls.copy();_ls[0]=0;_ls2', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2,3])\n res = yield ctx.eval('[1,2,3,2].count(2)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 2)\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls.extend([4,5]);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2,3,4,5])\n res = yield ctx.eval('[5,4,3].index(4)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 1)\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls.insert(0,4);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [4,1,2,3])\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls.pop();_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2])\n res = yield ctx.eval('_ls=[1,2,3]\\n_ls.remove(2);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,3])\n res = yield ctx.eval('_ls=[3,2,1]\\n_ls.reverse();_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2,3])\n \n task.resetticks()\n\n res = yield ctx.eval('_ls=[3,1,2]\\n_ls.sort();_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2,3])\n res = yield ctx.eval('_ls=[3,1,2]\\nlist.sort(_ls);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1,2,3])\n res = yield ctx.eval('_ls=[3,1,2]\\n_ls.sort(reverse=True);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [3,2,1])\n res = yield ctx.eval('_ls=[3,1,2]\\nlist.sort(_ls,reverse=True);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [3,2,1])\n res = yield ctx.eval('_ls=[-1,2,-3,4]\\n_ls.sort(key=str);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [-1,-3,2,4])\n res = yield ctx.eval('_ls=[-1,2,-3,4]\\nlist.sort(_ls,key=str);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [-1,-3,2,4])\n res = yield ctx.eval('_ls=[-1,2,-3,4]\\n_ls.sort(key=str,reverse=True);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [4,2,-3,-1])\n res = yield ctx.eval('_ls=[-1,2,-3,4]\\nlist.sort(_ls,key=str,reverse=True);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [4,2,-3,-1])\n res = yield ctx.eval('_ls=[-1,-3,2,4]\\n_func=code(\"x*x\",args=\"x\")\\n_ls.sort(key=_func);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [-1,2,-3,4])\n res = yield ctx.eval('_ls=[-1,-3,2,4]\\n_func=code(\"x*x\",args=\"x\")\\nlist.sort(_ls,key=_func);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [-1,2,-3,4])\n res = yield ctx.eval('_ls=[-1,-3,2,4]\\n_func=code(\"x*x\",args=\"x\")\\n_ls.sort(key=_func,reverse=True);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [4,-3,2,-1])\n res = yield ctx.eval('_ls=[-1,-3,2,4]\\n_func=code(\"x*x\",args=\"x\")\\nlist.sort(_ls,key=_func,reverse=True);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [4,-3,2,-1])\n \n res = yield ctx.eval('_ls=[\"d\",\"C\",\"b\",\"A\"]\\n_ls.sort(key=str.upper);_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ['A','b','C','d'])\n res = yield ctx.eval('_ls=[\"d\",\"p\",\"q\",\"x\",\"y\"]\\n_ls.sort(key=functools.partial(str.index,\"xyzpdq\"));_ls', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ['x','y','p','d','q'])\n \n with self.assertRaises(TypeError):\n res = yield ctx.eval('_ls=[1]\\n_ls.sort(key=foo);_ls', locals={'foo':open}, evaltype=EVALTYPE_CODE)\n with self.assertRaises(TypeError):\n res = yield ctx.eval('_ls=[1]\\n_ls.sort(key=foo);_ls', locals={'foo':123}, evaltype=EVALTYPE_CODE)", "metadata": "root.TestEvalAsync.test_type_methods_list", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 169 }, { "content": " @tornado.testing.gen_test\n def test_type_methods_dict(self):\n yield self.resetTables()\n \n task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())\n ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)\n\n res = yield ctx.eval('_map={1:11,2:22}\\n_map.clear();_map', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {})\n res = yield ctx.eval('_map={1:11,2:22}\\n_map2=_map.copy();_map[3]=0;_map2', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {1:11,2:22})\n res = yield ctx.eval('dict.fromkeys([1,2,3],4)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {1:4,2:4,3:4})\n res = yield ctx.eval('{1:11,2:22,3:33}.get(2)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 22)\n res = yield ctx.eval('list({1:11}.items())', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [(1, 11)])\n res = yield ctx.eval('list({1:11}.keys())', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [1])\n res = yield ctx.eval('{1:11,2:22,3:33}.pop(2)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 22)\n res = yield ctx.eval('_map={1:11,2:22,3:33};_map.pop(2);_map', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {1:11,3:33})\n res = yield ctx.eval('{1:11}.popitem()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, (1,11))\n res = yield ctx.eval('_map={1:11,2:22};_map.setdefault(3,33)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 33)\n res = yield ctx.eval('_map={1:11,2:22};_map.update({3:33});_map', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, {1:11,2:22,3:33})\n res = yield ctx.eval('list({1:11}.values())', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, [11])", "metadata": "root.TestEvalAsync.test_type_methods_dict", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 234 }, { "content": " @tornado.testing.gen_test\n def test_type_methods_string(self):\n yield self.resetTables()\n \n task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())\n ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)\n \n res = yield ctx.eval('\"foo bar\".capitalize()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'Foo bar')\n res = yield ctx.eval('\"Foo BAR\".casefold()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'foo bar')\n res = yield ctx.eval('\"foo bar\".center(9)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ' foo bar ')\n res = yield ctx.eval('\"foo bar\".count(\"o\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 2)\n res = yield ctx.eval('\"foo bar\".endswith(\"ar\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"foo bar\".find(\"a\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 5)\n res = yield ctx.eval('\"foo bar\".index(\"a\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 5)\n res = yield ctx.eval('\"foo bar\".isalnum()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, False)\n res = yield ctx.eval('\"foobar\".isalpha()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"1235\".isdecimal()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"1235x\".isdigit()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, False)\n res = yield ctx.eval('\"Foo_bar\".isidentifier()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"foo bar\".islower()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"1235\".isnumeric()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"foo bar\".isprintable()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"foo bar\".isspace()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, False)\n res = yield ctx.eval('\"Foo Bar\".istitle()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\"Foo Bar\".isupper()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, False)\n res = yield ctx.eval('\",\".join([\"x\",\"y\",\"zz\"])', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'x,y,zz')\n res = yield ctx.eval('\"foo bar\".ljust(9)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'foo bar ')\n res = yield ctx.eval('\"Foo BAR\".lower()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'foo bar')\n res = yield ctx.eval('\" foo \".lstrip()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'foo ')\n res = yield ctx.eval('\"x,y,z\".partition(\",\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ('x', ',', 'y,z') )\n res = yield ctx.eval('\"foo bar\".replace(\"o\",\"z\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'fzz bar')\n res = yield ctx.eval('\"foo bar\".rfind(\"o\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 2)\n res = yield ctx.eval('\"foo bar\".rindex(\"o\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 2)\n res = yield ctx.eval('\"foo bar\".rjust(9)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ' foo bar')\n res = yield ctx.eval('\"x,y,z\".rpartition(\",\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ('x,y', ',', 'z') )\n res = yield ctx.eval('\"x,y,z\".rsplit(\",\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ['x', 'y', 'z'] )\n res = yield ctx.eval('\" foo \".rstrip()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ' foo')\n res = yield ctx.eval('\"x,y,z\".split(\",\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ['x', 'y', 'z'] )\n res = yield ctx.eval('\"x\\\\ny\\\\nz\".splitlines()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ['x', 'y', 'z'] )\n res = yield ctx.eval('\"foo bar\".startswith(\"fo\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, True)\n res = yield ctx.eval('\" foo \".strip()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'foo')\n res = yield ctx.eval('\"Foo BAR\".swapcase()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'fOO bar')\n res = yield ctx.eval('\"foo bar\".title()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'Foo Bar')\n res = yield ctx.eval('\"foo bar\".upper()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'FOO BAR')\n res = yield ctx.eval('\"foo bar\".zfill(9)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, '00foo bar')\n\n # Miscellaneous cases\n res = yield ctx.eval('str.upper(\"foo bar\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 'FOO BAR')\n \n with self.assertRaises(twcommon.excepts.ExecSandboxException):\n res = yield ctx.eval('\"x\".__class__', evaltype=EVALTYPE_CODE)\n with self.assertRaises(twcommon.excepts.ExecSandboxException):\n res = yield ctx.eval('str.__class__', evaltype=EVALTYPE_CODE)\n with self.assertRaises(twcommon.excepts.ExecSandboxException):\n res = yield ctx.eval('\"x\".nosuchattr', evaltype=EVALTYPE_CODE)\n with self.assertRaises(twcommon.excepts.ExecSandboxException):\n res = yield ctx.eval('str.nosuchattr', evaltype=EVALTYPE_CODE)\n with self.assertRaises(twcommon.excepts.ExecSandboxException):\n res = yield ctx.eval('\"x\".format', evaltype=EVALTYPE_CODE)\n with self.assertRaises(twcommon.excepts.ExecSandboxException):\n res = yield ctx.eval('str.format', evaltype=EVALTYPE_CODE)", "metadata": "root.TestEvalAsync.test_type_methods_string", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 266 }, { "content": " @tornado.testing.gen_test\n def test_datetime(self):\n yield self.resetTables()\n \n task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())\n ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)\n\n res = yield ctx.eval('datetime.now', evaltype=EVALTYPE_CODE)\n self.assertTrue(res is task.starttime)\n res = yield ctx.eval('datetime.datetime(2013,5,1)', evaltype=EVALTYPE_CODE)\n self.assertTrue(isinstance(res, datetime.datetime))\n self.assertEqual(res, datetime.datetime(year=2013, month=5, day=1, tzinfo=datetime.timezone.utc))\n res = yield ctx.eval('datetime.datetime(year=2013, month=5, day=2, hour=3, minute=4, second=5, microsecond=500000)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, datetime.datetime(year=2013, month=5, day=2, hour=3, minute=4, second=5, microsecond=500000, tzinfo=datetime.timezone.utc))\n \n res = yield ctx.eval('datetime.now.year', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.year)\n res = yield ctx.eval('datetime.now.month', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.month)\n res = yield ctx.eval('datetime.now.day', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.day)\n res = yield ctx.eval('datetime.now.hour', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.hour)\n res = yield ctx.eval('datetime.now.minute', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.minute)\n res = yield ctx.eval('datetime.now.second', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.second)\n res = yield ctx.eval('datetime.now.microsecond', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.microsecond)\n res = yield ctx.eval('datetime.now.min', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.min)\n res = yield ctx.eval('datetime.now.max', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.max)\n res = yield ctx.eval('datetime.now.resolution', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, task.starttime.resolution)\n\n res = yield ctx.eval('datetime.timedelta()', evaltype=EVALTYPE_CODE)\n self.assertTrue(isinstance(res, datetime.timedelta))\n self.assertEqual(res, datetime.timedelta())\n res = yield ctx.eval('datetime.timedelta(days=1, seconds=2, milliseconds=3)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, datetime.timedelta(days=1, seconds=2, milliseconds=3))\n res = yield ctx.eval('datetime.timedelta(hours=1, minutes=2, weeks=3)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, datetime.timedelta(hours=1, minutes=2, weeks=3))\n res = yield ctx.eval('datetime.timedelta(hours=1, minutes=2, weeks=3).total_seconds()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 1818120)\n res = yield ctx.eval('datetime.timedelta().min', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, datetime.timedelta().min)\n res = yield ctx.eval('datetime.timedelta().max', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, datetime.timedelta().max)\n res = yield ctx.eval('datetime.timedelta().resolution', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, datetime.timedelta().resolution)", "metadata": "root.TestEvalAsync.test_datetime", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 367 }, { "content": " @tornado.testing.gen_test\n def test_partial(self):\n yield self.resetTables()\n \n task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())\n task.set_writable()\n ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)\n\n res = yield ctx.eval('functools.partial(int)()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 0)\n res = yield ctx.eval('functools.partial(int, \"10\")()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 10)\n res = yield ctx.eval('functools.partial(int)(\"11\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 11)\n res = yield ctx.eval('functools.partial(int, \"10\", 4)()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 4)\n res = yield ctx.eval('functools.partial(int)(\"11\", 4)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 5)\n res = yield ctx.eval('functools.partial(int, \"12\")(4)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 6)\n res = yield ctx.eval('functools.partial(int, \"10\", base=5)()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 5)\n res = yield ctx.eval('functools.partial(int)(\"11\", base=5)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 6)\n res = yield ctx.eval('functools.partial(int, \"12\")(base=5)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 7)\n \n res = yield ctx.eval('propint = code(\"int(x, base=base)\", args=\"x, base=None\")', evaltype=EVALTYPE_CODE)\n res = yield ctx.eval('functools.partial(propint, \"10\", base=6)()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 6)\n res = yield ctx.eval('functools.partial(propint)(\"11\", base=6)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 7)\n res = yield ctx.eval('functools.partial(propint, \"12\")(base=6)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, 8)\n\n res = yield ctx.eval('functools.partial(ObjectId, \"528d3862689e9d17a7a96473\")()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ObjectId('528d3862689e9d17a7a96473'))\n res = yield ctx.eval('functools.partial(ObjectId)(\"528d3862689e9d17a7a96474\")', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, ObjectId('528d3862689e9d17a7a96474'))\n \n res = yield ctx.eval('functools.partial(location)()', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, self.exlocid)\n res = yield ctx.eval('functools.partial(location)(None)', evaltype=EVALTYPE_CODE)\n self.assertEqual(res, self.exlocid)\n\n with self.assertRaises(TypeError):\n res = yield ctx.eval('functools.partial(foo)()', locals={'foo':open}, evaltype=EVALTYPE_CODE)", "metadata": "root.TestEvalAsync.test_partial", "header": "['class', 'TestEvalAsync', '(', 'twest', '.', 'mock', '.', 'MockAppTestCase', ')', ':', '___EOS___']", "index": 419 } ]
[ { "span": "import logging", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 14 }, { "span": "import unittest", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 15 }, { "span": "import ast", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 10 }, { "span": "from twcommon.excepts import SymbolError", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 40 }, { "span": "from twest.mock import NotFound", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 31 }, { "span": "from two.evalctx import LEVEL_EXECUTE, LEVEL_DISPSPECIAL, LEVEL_DISPLAY, LEVEL_MESSAGE, LEVEL_FLAT, LEVEL_RAW", "start_line": 468, "start_column": 0, "end_line": 468, "end_column": 109 }, { "span": "from two.evalctx import EVALTYPE_SYMBOL, EVALTYPE_RAW, EVALTYPE_CODE, EVALTYPE_TEXT", "start_line": 469, "start_column": 0, "end_line": 469, "end_column": 83 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "To", " ", "run", ":", " ", " ", " ", "python", "3", " ", "-", "m", " ", "torn", "ado", ".", "testi", "ng", " ", "twe", "st", ".", "test\\u", "funcs", "\\", "10", ";", "(", "The", " ", "twe", "st", ",", " ", "two", ",", " ", "tw", "common", " ", "module", "s", " ", "must", " ", "be", " ", "in", " ", "your", " ", "PYTHON", "\\u", "PATH", ".)", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "ast_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "bson_", "._", "objectid", "_", "import_", "Object", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tornado_", "._", "testing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "motor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "tw", "common_", "._", "misc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "two_", "._", "execute_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "two_", "._", "symbols_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "two_", "._", "task_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "two_", "._", "execute_", "import_", "Eval", "Prop", "Context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tw", "common_", "._", "except", "s_", "import_", "Sym", "bol", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "twe", "st_", "._", "mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "twe", "st_", "._", "mock_", "import_", "Not", "Found_", "\\u\\u\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "two_", "._", "eval", "ctx_", "import_", "LE", "VEL", "\\u", "EXECUTE", "_", ",_", "LE", "VEL", "\\u", "DISP", "SPECIAL", "_", ",_", "LE", "VEL", "\\u", "DISPLAY", "_", ",_", "LE", "VEL", "\\u", "MESSAGE_", ",_", "LE", "VEL", "\\u", "FLAT", "_", ",_", "LE", "VEL", "\\u", "RAW_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "two_", "._", "eval", "ctx_", "import_", "EVAL", "TYPE", "\\u", "SYMBOL_", ",_", "EVAL", "TYPE", "\\u", "RAW_", ",_", "EVAL", "TYPE", "\\u", "CODE_", ",_", "EVAL", "TYPE", "\\u", "TEXT_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "appa", "rgs_", "=_", "{_", "'", "prop", "cache", "'_", ":_", "True_", ",_", "'", "globals", "'_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "tornado_", "._", "gen_", "._", "coroutine_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "reset", "Tables_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Inven", "t", " ", "some", " ", "arbitra", "ry", " ", "obji", "ds", " ", "for", " ", "the", " ", "world", " ", "and", " ", "instance", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ex", "uid_", "=_", "Object", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ex", "wid_", "=_", "Object", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "exi", "id_", "=_", "Object", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ex", "loci", "d_", "=_", "Object", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ex", "sci", "d_", "=_", "Object", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "loc", "tx_", "=_", "two_", "._", "task_", "._", "Loc", "Context_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "uid_", "=_", "self_", "._", "ex", "uid_", ",_", "wid_", "=_", "self_", "._", "ex", "wid_", ",_", "sci", "d_", "=_", "self_", "._", "ex", "sci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "iid_", "=_", "self_", "._", "exi", "id_", ",_", "loci", "d_", "=_", "self_", "._", "ex", "loci", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "world", "prop_", "._", "remove_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "world", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "wid", "'_", ":_", "self_", "._", "ex", "wid_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "x", "'_", ",_", "'", "val", "'_", ":_", "0_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "world", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "wid", "'_", ":_", "self_", "._", "ex", "wid_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "w", "'_", ",_", "'", "val", "'_", ":_", "'", "world", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "world", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "wid", "'_", ":_", "self_", "._", "ex", "wid_", ",_", "'", "loci", "d", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "r", "'_", ",_", "'", "val", "'_", ":_", "11_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "world", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "wid", "'_", ":_", "self_", "._", "ex", "wid_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "r", "'_", ",_", "'", "val", "'_", ":_", "12_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "remove_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "iid", "'_", ":_", "self_", "._", "exi", "id_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "x", "'_", ",_", "'", "val", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "iid", "'_", ":_", "self_", "._", "exi", "id_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "y", "'_", ",_", "'", "val", "'_", ":_", "2_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "iid", "'_", ":_", "self_", "._", "exi", "id_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "ls", "'_", ",_", "'", "val", "'_", ":_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "iid", "'_", ":_", "self_", "._", "exi", "id_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "map", "'_", ",_", "'", "val", "'_", ":_", "{_", "'", "one", "'_", ":_", "1_", ",_", "'", "two", "'_", ":_", "2_", ",_", "'", "three", "'_", ":_", "3_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "iid", "'_", ":_", "self_", "._", "exi", "id_", ",_", "'", "loci", "d", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "r", "'_", ",_", "'", "val", "'_", ":_", "13_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "motor_", "._", "Op_", "(_", "self_", "._", "app_", "._", "mongodb", "_", "._", "instance", "prop_", "._", "insert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "iid", "'_", ":_", "self_", "._", "exi", "id_", ",_", "'", "loci", "d", "'_", ":_", "self_", "._", "ex", "loci", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "r", "'_", ",_", "'", "val", "'_", ":_", "14_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "tornado_", "._", "testing_", "._", "gen", "\\u", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "global", "\\u", "funcs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "._", "reset", "Tables_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "=_", "two_", "._", "task_", "._", "Task_", "(_", "self_", "._", "app_", ",_", "None_", ",_", "1_", ",_", "2_", ",_", "tw", "common_", "._", "misc_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "Eval", "Prop", "Context_", "(_", "task_", ",_", "loc", "tx_", "=_", "self_", "._", "loc", "tx_", ",_", "level_", "=_", "LE", "VEL", "\\u", "EXECUTE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "len", "(\"", "xyz", "zy", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "len", "(", "ls", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "min", "(", "5", ",", "3", ",", "4", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "min", "([", "5", ",", "3", ",", "4", "])'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "max", "(", "5", ",", "3", ",", "4", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "int", "(", "6.5", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "int", "(\"", "1", "7", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "17_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "str", "(", "6", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "6", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "bool", "(", "6", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "list", "((", "6", ",", "7", "))'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "6_", ",_", "7_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "set", "((", "7", ",", "6", "))'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "6_", ",_", "7_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "dict", "([(", "6", ",", "7", ")])", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "6_", ":_", "7_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'[", "text", "(\"", "x", "\")]", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "{_", "'", "type", "'_", ":_", "'", "text", "'_", ",_", "'", "text", "'_", ":_", "'", "x", "'_", "}_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'[", "code", "(\"", "x", "\")]", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "{_", "'", "type", "'_", ":_", "'", "code", "'_", ",_", "'", "text", "'_", ":_", "'", "x", "'_", "}_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'[", "gent", "ext", ".", "gent", "ext", "(\"", "x", "\")]", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "{_", "'", "type", "'_", ":_", "'", "gent", "ext", "'_", ",_", "'", "text", "'_", ":_", "'", "x", "'_", "}_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "Object", "Id", "(\"", "524", "5c", "6b", "2", "6b", "3d", "305", "21", "a6", "996", "ec", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "Object", "Id_", "(_", "\"", "524", "5c", "6b", "2", "6b", "3d", "305", "21", "a6", "996", "ec", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "(", "Tru", "e", ",", " ", "bool", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "(", "Tru", "e", ",", " ", "int", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "#", " ", "a", " ", "Pyth", "on", " ", "quir", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "(", "5", ",", " ", "(", "str", ",", " ", "int", "))'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "([", "],", " ", "(", "str", ",", " ", "int", "))'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "(", "32", ",", " ", "int", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "(\"", "X", "\",", " ", "str", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "(", "Object", "Id", "(\"", "524", "5c", "6b", "2", "6b", "3d", "305", "21", "a6", "996", "ec", "\")", ",", " ", "Object", "Id", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({},", " ", "dict", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "1", "},", " ", "set", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "([", "1", "],", " ", "list", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "\"", "type", "\":\"", "text", "\",", " ", "\"", "text", "\":\"", "x", "\"},", " ", "text", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "\"", "type", "\":\"", "code", "\",", " ", "\"", "text", "\":\"", "x", "\"},", " ", "code", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "\"", "type", "\":\"", "gent", "ext", "\",", " ", "\"", "text", "\":\"", "x", "\"},", " ", "gent", "ext", ".", "gent", "ext", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "\"", "type", "\":\"", "foo", "\",", " ", "\"", "text", "\":\"", "x", "\"},", " ", "text", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "\"", "type", "\":\"", "foo", "\",", " ", "\"", "text", "\":\"", "x", "\"},", " ", "code", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "isin", "stance", "({", "\"", "type", "\":\"", "foo", "\",", " ", "\"", "text", "\":\"", "x", "\"},", " ", "gent", "ext", ".", "gent", "ext", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "real", "m", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "res_", ",_", "two_", "._", "execute_", "._", "Realm", "Proxy_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "location", "s", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "res_", ",_", "two_", "._", "execute_", "._", "Wor", "ld", "Locat", "ion", "s", "Proxy_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "player", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "res_", ",_", "two_", "._", "execute_", "._", "Player", "Proxy_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "self_", "._", "ex", "uid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "random", ".", "choice", "([", "\"", "X", "\",\"", "Y", "\",\"", "Z", "\"]", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "res_", ",_", "[_", "\"", "X", "\"_", ",_", "\"", "Y", "\"_", ",_", "\"", "Z", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "random", ".", "rand", "int", "(", "4", ",", " ", "6", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "res_", ",_", "[_", "4_", ",_", "5_", ",_", "6_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "random", ".", "rand", "range", "(", "3", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "res_", ",_", "[_", "0_", ",_", "1_", ",_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "random", ".", "rand", "range", "(", "4", ",", " ", "6", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "res_", ",_", "[_", "4_", ",_", "5_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "tornado_", "._", "testing_", "._", "gen", "\\u", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "type", "\\u", "method", "s", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "._", "reset", "Tables_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "=_", "two_", "._", "task_", "._", "Task_", "(_", "self_", "._", "app_", ",_", "None_", ",_", "1_", ",_", "2_", ",_", "tw", "common_", "._", "misc_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "Eval", "Prop", "Context_", "(_", "task_", ",_", "loc", "tx_", "=_", "self_", "._", "loc", "tx_", ",_", "level_", "=_", "LE", "VEL", "\\u", "EXECUTE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", ".", "append", "(", "4", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", ",_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", ".", "clear", "();", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", "2", "=", "\\u", "ls", ".", "copy", "();", "\\u", "ls", "[", "0", "]=", "0", ";", "\\u", "ls", "2", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'[", "1", ",", "2", ",", "3", ",", "2", "].", "count", "(", "2", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", ".", "extend", "([", "4", ",", "5", "])", ";", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", ",_", "4_", ",_", "5_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'[", "5", ",", "4", ",", "3", "].", "index", "(", "4", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", ".", "insert", "(", "0", ",", "4", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "4_", ",_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", ".", "pop", "();", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", ",", "2", ",", "3", "]\\\\", "n", "\\u", "ls", ".", "remove", "(", "2", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "3", ",", "2", ",", "1", "]\\\\", "n", "\\u", "ls", ".", "reverse", "();", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "._", "reset", "ticks_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "3", ",", "1", ",", "2", "]\\\\", "n", "\\u", "ls", ".", "sort", "();", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "3", ",", "1", ",", "2", "]\\\\", "nli", "st", ".", "sort", "(\\u", "ls", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "3", ",", "1", ",", "2", "]\\\\", "n", "\\u", "ls", ".", "sort", "(", "reverse", "=", "Tru", "e", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "3_", ",_", "2_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "3", ",", "1", ",", "2", "]\\\\", "nli", "st", ".", "sort", "(\\u", "ls", ",", "reverse", "=", "Tru", "e", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "3_", ",_", "2_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",", "2", ",-", "3", ",", "4", "]\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "str", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "-_", "1_", ",_", "-_", "3_", ",_", "2_", ",_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",", "2", ",-", "3", ",", "4", "]\\\\", "nli", "st", ".", "sort", "(\\u", "ls", ",", "key", "=", "str", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "-_", "1_", ",_", "-_", "3_", ",_", "2_", ",_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",", "2", ",-", "3", ",", "4", "]\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "str", ",", "reverse", "=", "Tru", "e", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "4_", ",_", "2_", ",_", "-_", "3_", ",_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",", "2", ",-", "3", ",", "4", "]\\\\", "nli", "st", ".", "sort", "(\\u", "ls", ",", "key", "=", "str", ",", "reverse", "=", "Tru", "e", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "4_", ",_", "2_", ",_", "-_", "3_", ",_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",-", "3", ",", "2", ",", "4", "]\\\\", "n", "\\u", "func", "=", "code", "(\"", "x", "*", "x", "\",", "args", "=\"", "x", "\")\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "\\u", "func", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "-_", "1_", ",_", "2_", ",_", "-_", "3_", ",_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",-", "3", ",", "2", ",", "4", "]\\\\", "n", "\\u", "func", "=", "code", "(\"", "x", "*", "x", "\",", "args", "=\"", "x", "\")\\\\", "nli", "st", ".", "sort", "(\\u", "ls", ",", "key", "=", "\\u", "func", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "-_", "1_", ",_", "2_", ",_", "-_", "3_", ",_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",-", "3", ",", "2", ",", "4", "]\\\\", "n", "\\u", "func", "=", "code", "(\"", "x", "*", "x", "\",", "args", "=\"", "x", "\")\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "\\u", "func", ",", "reverse", "=", "Tru", "e", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "4_", ",_", "-_", "3_", ",_", "2_", ",_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "-1", ",-", "3", ",", "2", ",", "4", "]\\\\", "n", "\\u", "func", "=", "code", "(\"", "x", "*", "x", "\",", "args", "=\"", "x", "\")\\\\", "nli", "st", ".", "sort", "(\\u", "ls", ",", "key", "=", "\\u", "func", ",", "reverse", "=", "Tru", "e", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "4_", ",_", "-_", "3_", ",_", "2_", ",_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[\"", "d", "\",\"", "C", "\",\"", "b", "\",\"", "A", "\"]", "\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "str", ".", "upper", ");", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "'", "A", "'_", ",_", "'", "b", "'_", ",_", "'", "C", "'_", ",_", "'", "d", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[\"", "d", "\",\"", "p", "\",\"", "q", "\",\"", "x", "\",\"", "y", "\"]", "\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "functo", "ols", ".", "partial", "(", "str", ".", "index", ",\"", "xyz", "pd", "q", "\"))", ";", "\\u", "ls", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "'", "x", "'_", ",_", "'", "y", "'_", ",_", "'", "p", "'_", ",_", "'", "d", "'_", ",_", "'", "q", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Type", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", "]\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "foo", ");", "\\u", "ls", "'_", ",_", "locals_", "=_", "{_", "'", "foo", "'_", ":_", "open_", "}_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Type", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "ls", "=[", "1", "]\\\\", "n", "\\u", "ls", ".", "sort", "(", "key", "=", "foo", ");", "\\u", "ls", "'_", ",_", "locals_", "=_", "{_", "'", "foo", "'_", ":_", "123_", "}_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "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_", "@_", "tornado_", "._", "testing_", "._", "gen", "\\u", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "type", "\\u", "method", "s", "\\u", "dict_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "._", "reset", "Tables_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "=_", "two_", "._", "task_", "._", "Task_", "(_", "self_", "._", "app_", ",_", "None_", ",_", "1_", ",_", "2_", ",_", "tw", "common_", "._", "misc_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "Eval", "Prop", "Context_", "(_", "task_", ",_", "loc", "tx_", "=_", "self_", "._", "loc", "tx_", ",_", "level_", "=_", "LE", "VEL", "\\u", "EXECUTE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "map", "={", "1", ":", "11", ",", "2", ":", "2", "2", "}\\\\", "n", "\\u", "map", ".", "clear", "();", "\\u", "map", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "map", "={", "1", ":", "11", ",", "2", ":", "2", "2", "}\\\\", "n", "\\u", "map", "2", "=", "\\u", "map", ".", "copy", "();", "\\u", "map", "[", "3", "]=", "0", ";", "\\u", "map", "2", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "1_", ":_", "11_", ",_", "2_", ":_", "22_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "dict", ".", "from", "keys", "([", "1", ",", "2", ",", "3", "],", "4", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "1_", ":_", "4_", ",_", "2_", ":_", "4_", ",_", "3_", ":_", "4_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'{", "1", ":", "11", ",", "2", ":", "2", "2", ",", "3", ":", "3", "3", "}.", "get", "(", "2", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "22_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "list", "({", "1", ":", "11", "}.", "items", "())", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "(_", "1_", ",_", "11_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "list", "({", "1", ":", "11", "}.", "keys", "())", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'{", "1", ":", "11", ",", "2", ":", "2", "2", ",", "3", ":", "3", "3", "}.", "pop", "(", "2", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "22_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "map", "={", "1", ":", "11", ",", "2", ":", "2", "2", ",", "3", ":", "3", "3", "};", "\\u", "map", ".", "pop", "(", "2", ");", "\\u", "map", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "1_", ":_", "11_", ",_", "3_", ":_", "33_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'{", "1", ":", "11", "}.", "popi", "tem", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "(_", "1_", ",_", "11_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "map", "={", "1", ":", "11", ",", "2", ":", "2", "2", "};", "\\u", "map", ".", "setdefault", "(", "3", ",", "3", "3", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "33_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\\u", "map", "={", "1", ":", "11", ",", "2", ":", "2", "2", "};", "\\u", "map", ".", "update", "({", "3", ":", "3", "3", "})", ";", "\\u", "map", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "{_", "1_", ":_", "11_", ",_", "2_", ":_", "22_", ",_", "3_", ":_", "33_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "list", "({", "1", ":", "11", "}.", "values", "())", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "11_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "tornado_", "._", "testing_", "._", "gen", "\\u", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "type", "\\u", "method", "s", "\\u", "string_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "._", "reset", "Tables_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "=_", "two_", "._", "task_", "._", "Task_", "(_", "self_", "._", "app_", ",_", "None_", ",_", "1_", ",_", "2_", ",_", "tw", "common_", "._", "misc_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "Eval", "Prop", "Context_", "(_", "task_", ",_", "loc", "tx_", "=_", "self_", "._", "loc", "tx_", ",_", "level_", "=_", "LE", "VEL", "\\u", "EXECUTE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "capitaliz", "e", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "Foo", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "Foo", " ", "BAR", "\".", "case", "fold", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "foo", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "center", "(", "9", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", " ", "foo", " ", "bar", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "count", "(\"", "o", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "ends", "with", "(\"", "ar", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "find", "(\"", "a", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "index", "(\"", "a", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "isal", "num", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "fooba", "r", "\".", "isal", "pha", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "123", "5", "\".", "isd", "eci", "mal", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "123", "5", "x", "\".", "isdi", "git", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "Foo", "\\u", "bar", "\".", "isi", "denti", "fier", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "isl", "ower", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "123", "5", "\".", "isn", "ume", "ric", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "isp", "rint", "able", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "isspace", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "Foo", " ", "Bar", "\".", "isti", "tle", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "Foo", " ", "Bar", "\".", "isupper", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\",", "\".", "join", "([", "\"", "x", "\",\"", "y", "\",\"", "zz", "\"]", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "x", ",", "y", ",", "zz", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "lj", "ust", "(", "9", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "foo", " ", "bar", " ", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "Foo", " ", "BAR", "\".", "lower", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "foo", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", " ", "foo", " ", "\".", "lst", "rip", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "foo", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", ",", "y", ",", "z", "\".", "partit", "ion", "(\"", ",\"", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "(_", "'", "x", "'_", ",_", "','_", ",_", "'", "y", ",", "z", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "replace", "(\"", "o", "\",\"", "z", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "fz", "z", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "rfi", "nd", "(\"", "o", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "rindex", "(\"", "o", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "rj", "ust", "(", "9", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", " ", " ", "foo", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", ",", "y", ",", "z", "\".", "rpa", "rti", "tion", "(\"", ",\"", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "(_", "'", "x", ",", "y", "'_", ",_", "','_", ",_", "'", "z", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", ",", "y", ",", "z", "\".", "rsp", "lit", "(\"", ",\"", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "'", "x", "'_", ",_", "'", "y", "'_", ",_", "'", "z", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", " ", "foo", " ", "\".", "rstr", "ip", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", " ", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", ",", "y", ",", "z", "\".", "split", "(\"", ",\"", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "'", "x", "'_", ",_", "'", "y", "'_", ",_", "'", "z", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", "\\\\\\\\", "ny", "\\\\\\\\", "nz", "\".", "split", "lines", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "[_", "'", "x", "'_", ",_", "'", "y", "'_", ",_", "'", "z", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "startswith", "(\"", "fo", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", " ", "foo", " ", "\".", "strip", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "Foo", " ", "BAR", "\".", "swap", "case", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "f", "OO", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "title", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "Foo", " ", "Bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "upper", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "FOO", " ", "BAR", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "foo", " ", "bar", "\".", "zfil", "l", "(", "9", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "00", "foo", " ", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mis", "cell", "ane", "ous", " ", "cases_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "str", ".", "upper", "(\"", "foo", " ", "bar", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "'", "FOO", " ", "BAR", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "tw", "common_", "._", "except", "s_", "._", "Exe", "c", "Sandbox", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", "\".\\", "u\\u", "class", "\\u\\u'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "tw", "common_", "._", "except", "s_", "._", "Exe", "c", "Sandbox", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "str", ".\\u", "\\u", "class", "\\u\\u'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "tw", "common_", "._", "except", "s_", "._", "Exe", "c", "Sandbox", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", "\".", "nos", "uch", "attr", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "tw", "common_", "._", "except", "s_", "._", "Exe", "c", "Sandbox", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "str", ".", "nos", "uch", "attr", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "tw", "common_", "._", "except", "s_", "._", "Exe", "c", "Sandbox", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'\"", "x", "\".", "format", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "tw", "common_", "._", "except", "s_", "._", "Exe", "c", "Sandbox", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "str", ".", "format", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "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_", "@_", "tornado_", "._", "testing_", "._", "gen", "\\u", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "datetime_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "._", "reset", "Tables_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "=_", "two_", "._", "task_", "._", "Task_", "(_", "self_", "._", "app_", ",_", "None_", ",_", "1_", ",_", "2_", ",_", "tw", "common_", "._", "misc_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "Eval", "Prop", "Context_", "(_", "task_", ",_", "loc", "tx_", "=_", "self_", "._", "loc", "tx_", ",_", "level_", "=_", "LE", "VEL", "\\u", "EXECUTE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", "is_", "task_", "._", "starttime_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "datetime", "(", "2013", ",", "5", ",", "1", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "res_", ",_", "datetime_", "._", "datetime_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "5_", ",_", "day_", "=_", "1_", ",_", "tzinfo_", "=_", "datetime_", "._", "timezone_", "._", "utc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "datetime", "(", "year", "=", "2013", ",", " ", "month", "=", "5", ",", " ", "day", "=", "2", ",", " ", "hour", "=", "3", ",", " ", "minute", "=", "4", ",", " ", "second", "=", "5", ",", " ", "microsecond", "=", "500000", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "5_", ",_", "day_", "=_", "2_", ",_", "hour_", "=_", "3_", ",_", "minute_", "=_", "4_", ",_", "second_", "=_", "5_", ",_", "microsecond_", "=_", "500000", "_", ",_", "tzinfo_", "=_", "datetime_", "._", "timezone_", "._", "utc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "year", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "year_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "month", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "month_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "day", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "hour", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "hour_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "minute", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "minute_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "second", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "second_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "microsecond", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "microsecond_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "min", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "min_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "max", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "max_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "now", ".", "resolu", "tion", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "task_", "._", "starttime_", "._", "resolution_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "(", "day", "s", "=", "1", ",", " ", "second", "s", "=", "2", ",", " ", "milliseconds", "=", "3", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", "(_", "days_", "=_", "1_", ",_", "seconds_", "=_", "2_", ",_", "milliseconds", "_", "=_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "(", "hour", "s", "=", "1", ",", " ", "minute", "s", "=", "2", ",", " ", "week", "s", "=", "3", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", "(_", "hours_", "=_", "1_", ",_", "minutes_", "=_", "2_", ",_", "weeks_", "=_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "(", "hour", "s", "=", "1", ",", " ", "minute", "s", "=", "2", ",", " ", "week", "s", "=", "3", ").", "total", "\\u", "second", "s", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "1818", "120_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "()", ".", "min", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", "(_", ")_", "._", "min_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "()", ".", "max", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", "(_", ")_", "._", "max_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "datetime", ".", "timedelta", "()", ".", "resolu", "tion", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "datetime_", "._", "timedelta_", "(_", ")_", "._", "resolution_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Eval", "Async", "_", "(_", "twe", "st_", "._", "mock_", "._", "Moc", "k", "App", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "tornado_", "._", "testing_", "._", "gen", "\\u", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "partial_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "._", "reset", "Tables_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "task_", "=_", "two_", "._", "task_", "._", "Task_", "(_", "self_", "._", "app_", ",_", "None_", ",_", "1_", ",_", "2_", ",_", "tw", "common_", "._", "misc_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "task_", "._", "set\\u", "writable_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "Eval", "Prop", "Context_", "(_", "task_", ",_", "loc", "tx_", "=_", "self_", "._", "loc", "tx_", ",_", "level_", "=_", "LE", "VEL", "\\u", "EXECUTE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ")()", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ",", " ", "\"", "10", "\")", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ")(", "\"", "11", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "11_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ",", " ", "\"", "10", "\",", " ", "4", ")()", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ")(", "\"", "11", "\",", " ", "4", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ",", " ", "\"", "1", "2", "\")", "(", "4", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ",", " ", "\"", "10", "\",", " ", "base", "=", "5", ")()", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ")(", "\"", "11", "\",", " ", "base", "=", "5", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "int", ",", " ", "\"", "1", "2", "\")", "(", "base", "=", "5", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "prop", "int", " ", "=", " ", "code", "(\"", "int", "(", "x", ",", " ", "base", "=", "base", ")\"", ",", " ", "args", "=\"", "x", ",", " ", "base", "=", "Non", "e", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "prop", "int", ",", " ", "\"", "10", "\",", " ", "base", "=", "6", ")()", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "prop", "int", ")(", "\"", "11", "\",", " ", "base", "=", "6", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "prop", "int", ",", " ", "\"", "1", "2", "\")", "(", "base", "=", "6", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "Object", "Id", ",", " ", "\"", "528", "d3", "862", "689", "e9", "d1", "7a", "7a", "964", "7", "3", "\")", "()'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "Object", "Id_", "(_", "'", "528", "d3", "862", "689", "e9", "d1", "7a", "7a", "964", "7", "3", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "Object", "Id", ")(", "\"", "528", "d3", "862", "689", "e9", "d1", "7a", "7a", "964", "7", "4", "\")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "Object", "Id_", "(_", "'", "528", "d3", "862", "689", "e9", "d1", "7a", "7a", "964", "7", "4", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "location", ")()", "'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "self_", "._", "ex", "loci", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "location", ")(", "Non", "e", ")'_", ",_", "eval", "type_", "=_", "EVAL", "TYPE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "self_", "._", "ex", "loci", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Type", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "yield_", "ctx_", "._", "eval_", "(_", "'", "functo", "ols", ".", "partial", "(", "foo", ")()", "'_", ",_", "locals_", "=_", "{_", "'", "foo", "'_", ":_", "open_", "}_", ",_", "eval", "type_", "=_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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 ]
Unused import
hwaf/hwaf/py-hwaftools/find_cmake.py
[ { "content": "# -*- python -*-\n\n# stdlib imports ---\nimport os\nimport os.path as osp\nimport textwrap\n\n# waf imports ---\nimport waflib.Utils\nimport waflib.Logs as msg\nfrom waflib.Configure import conf\n\n#\n_heptooldir = osp.dirname(osp.abspath(__file__))\n\n\n\n\n## EOF ##\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def options(opt):\n\n opt.load('hwaf-base', tooldir=_heptooldir)\n\n opt.add_option(\n '--with-cmake',\n default=None,\n help=\"Look for CMake at the given path\")\n return", "metadata": "root.options", "header": "['module', '___EOS___']", "index": 15 }, { "content": "def configure(conf):\n conf.load('hwaf-base', tooldir=_heptooldir)\n return", "metadata": "root.configure", "header": "['module', '___EOS___']", "index": 25 }, { "content": "@conf\ndef find_cmake(ctx, **kwargs):\n \n if not ctx.env.HWAF_FOUND_C_COMPILER:\n ctx.fatal('load a C compiler first')\n pass\n\n if not ctx.env.HWAF_FOUND_CXX_COMPILER:\n ctx.fatal('load a C++ compiler first')\n pass\n\n\n path_list = waflib.Utils.to_list(kwargs.get('path_list', []))\n if getattr(ctx.options, 'with_cmake', None):\n topdir = ctx.options.with_cmake\n topdir = ctx.hwaf_subst_vars(topdir)\n path_list.append(osp.join(topdir, \"bin\"))\n pass\n kwargs['path_list'] = path_list\n \n ctx.find_program(\n \"cmake\",\n var=\"CMAKE\",\n **kwargs)\n\n kwargs['mandatory'] = False\n ctx.find_program(\n \"ccmake\",\n var=\"CCMAKE\",\n **kwargs)\n \n ctx.find_program(\n \"cpack\",\n var=\"CPACK\",\n **kwargs)\n \n ctx.find_program(\n \"ctest\",\n var=\"CTEST\",\n **kwargs)\n\n version=\"N/A\"\n cmd = [ctx.env.CMAKE, \"--version\"]\n lines=ctx.cmd_and_log(cmd).splitlines()\n for l in lines:\n l = l.lower()\n if \"version\" in l:\n version=l[l.find(\"version\")+len(\"version\"):].strip()\n break\n pass\n ctx.start_msg(\"CMake version\")\n ctx.end_msg(version)\n\n ctx.hwaf_declare_runtime_env('CMAKE')\n\n ctx.env.CMAKE_HOME = osp.dirname(osp.dirname(ctx.env.CMAKE))\n ctx.env.CMAKE_VERSION = version\n ctx.env.HWAF_FOUND_CMAKE = 1\n return", "metadata": "root.find_cmake", "header": "['module', '___EOS___']", "index": 29 } ]
[ { "span": "import os", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 9 }, { "span": "import textwrap", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 15 }, { "span": "import waflib.Logs as msg", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 25 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "python", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "stdlib", " ", "import", "s", " ", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "as_", "osp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "textwrap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "waf", " ", "import", "s", " ", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "waf", "lib_", "._", "Utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "waf", "lib_", "._", "Logs_", "as_", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "waf", "lib_", "._", "Configure", "_", "import_", "conf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "hep", "tool", "dir_", "=_", "osp_", "._", "dirname_", "(_", "osp_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "EO", "F", " ", "##", "_", "\\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_", "options_", "(_", "opt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opt_", "._", "load_", "(_", "'", "hwa", "f", "-", "base", "'_", ",_", "tool", "dir_", "=_", "\\u", "hep", "tool", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "opt_", "._", "add", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'--", "with", "-", "cma", "ke", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "Look", " ", "for", " ", "CM", "ake", " ", "at", " ", "the", " ", "give", "n", " ", "path", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\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_", "configure_", "(_", "conf_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conf_", "._", "load_", "(_", "'", "hwa", "f", "-", "base", "'_", ",_", "tool", "dir_", "=_", "\\u", "hep", "tool", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\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_", "@_", "conf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "find", "\\u", "cma", "ke_", "(_", "ctx_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "ctx_", "._", "env_", "._", "HW", "AF", "\\u", "FO", "UND", "\\u", "C", "\\u", "COMPILER", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ctx_", "._", "fatal_", "(_", "'", "load", " ", "a", " ", "C", " ", "compiler", " ", "first", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "ctx_", "._", "env_", "._", "HW", "AF", "\\u", "FO", "UND", "\\u", "CXX", "\\u", "COMPILER", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ctx_", "._", "fatal_", "(_", "'", "load", " ", "a", " ", "C", "++", " ", "compiler", " ", "first", "'_", ")_", "\\u\\u\\uNEWLINE\\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_", "path", "\\u", "list_", "=_", "waf", "lib_", "._", "Utils_", "._", "to", "\\u", "list_", "(_", "kwargs_", "._", "get_", "(_", "'", "path", "\\u", "list", "'_", ",_", "[_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "getattr_", "(_", "ctx_", "._", "options_", ",_", "'", "with", "\\u", "cma", "ke", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "topdi", "r_", "=_", "ctx_", "._", "options_", "._", "with", "\\u", "cma", "ke_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "topdi", "r_", "=_", "ctx_", "._", "hwa", "f", "\\u", "subst", "\\u", "vars_", "(_", "topdi", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path", "\\u", "list_", "._", "append_", "(_", "osp_", "._", "join_", "(_", "topdi", "r_", ",_", "\"", "bin", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kwargs_", "[_", "'", "path", "\\u", "list", "'_", "]_", "=_", "path", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "._", "find", "\\u", "program_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "cma", "ke", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "var_", "=_", "\"", "CMA", "KE", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "[_", "'", "mandat", "ory", "'_", "]_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "._", "find", "\\u", "program_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "cc", "make", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "var_", "=_", "\"", "CC", "MAKE", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "._", "find", "\\u", "program_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "cpa", "ck", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "var_", "=_", "\"", "CP", "AC", "K", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "._", "find", "\\u", "program_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "cte", "st", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "var_", "=_", "\"", "CT", "EST", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "\"", "N", "/", "A", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "[_", "ctx_", "._", "env_", "._", "CMA", "KE", "_", ",_", "\"--", "version", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "ctx_", "._", "cmd", "\\u", "and", "\\u", "log_", "(_", "cmd_", ")_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "l_", "in_", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "=_", "l_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\"", "version", "\"_", "in_", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "l_", "[_", "l_", "._", "find_", "(_", "\"", "version", "\"_", ")_", "+_", "len_", "(_", "\"", "version", "\"_", ")_", ":_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ctx_", "._", "start", "\\u", "msg_", "(_", "\"", "CM", "ake", " ", "version", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "._", "end", "\\u", "msg_", "(_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "._", "hwa", "f", "\\u", "declar", "e\\u", "runt", "ime", "\\u", "env_", "(_", "'", "CMA", "KE", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "._", "env_", "._", "CMA", "KE", "\\u", "HOME_", "=_", "osp_", "._", "dirname_", "(_", "osp_", "._", "dirname_", "(_", "ctx_", "._", "env_", "._", "CMA", "KE", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "._", "env_", "._", "CMA", "KE", "\\u", "VERSION_", "=_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "._", "env_", "._", "HW", "AF", "\\u", "FO", "UND", "\\u", "CMA", "KE", "_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 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, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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,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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 ]
Unused local variable
splunk/splunk-webframework/server/splunkdj/views.py
[ { "content": "def get_exception_info(request): \n # We use Django's debug reporter, even though we are doing our own template.\n # This is because it has a great way of collecting all the useful info we \n # need, so no reason not to leverage it \n exc_info = sys.exc_info()\n reporter = ExceptionReporter(request, *exc_info)\n ctx = reporter.get_traceback_data()\n \n # This is a refactor of what the technical_500_template contains, just\n # doing the logic in Python rather than in a template. We collect all this\n # information so that we can log it.\n exception_type = ctx['exception_type'] if 'exception_type' in ctx else \"No exception supplied\"\n exception_value = ctx['exception_value'] if 'exception_value' in ctx else \"No exception supplied\"\n django_version = ctx[\"django_version_info\"]\n python_executable = ctx['sys_executable']\n python_version = ctx['sys_version_info']\n python_path = ctx['sys_path']\n server_time = str(ctx['server_time'])\n unicode_hint = None\n if 'unicode_hint' in ctx:\n unicdoe_hint = ctx['unicode_hint']\n last_frame = None\n if 'lastframe' in ctx:\n frame_info = ctx['lastframe']\n last_frame = \"%s in %s, line %s\" % (frame_info['filename'], frame_info['function'], frame_info['lineno'])\n loaders = []\n if 'template_does_not_exist' in ctx and 'loader_debug_info' in ctx and ctx['loader_debug_info']:\n for loader in ctx['loader_debug_info']:\n loader_info = {\"name\": loader['loader'], \"templates\": []}\n for tmpl in loader['templates']:\n loader_info['templates'].append({\"file\": tmpl['name'], \"exists\": tmpl['exists']})\n loaders.append(loader_info)\n template_errors = None\n if 'template_info' in ctx and ctx['template_info']:\n template_info = ctx['template_info']\n template_errors = {\n \"name\": template_info['name'],\n \"line\": template_info['line'],\n \"message\": template_info['message']\n }\n exception_info = []\n if 'frames' in ctx:\n frames = ctx['frames']\n for frame in frames:\n frame_info = {\n \"filename\": frame['filename'],\n \"function\": frame['function'],\n \"line\": frame['lineno'],\n \"context_line\": frame['context_line'],\n \"vars\": []\n }\n if 'vars' in frame:\n for var in frame['vars']:\n frame_info['vars'].append({\n \"variable\": str(var[0]),\n \"value\": format(var[1])\n })\n exception_info.append(frame_info)\n request_info = {\n \"path_info\": request.path_info,\n \"method\": request.META['REQUEST_METHOD'],\n \"url\": request.build_absolute_uri(),\n \"GET\": {},\n \"POST\": {},\n \"FILES\": {},\n \"COOKIES\": {},\n \"META\": {}\n }\n if hasattr(request, \"GET\"):\n for key, value in request.GET.iteritems():\n request_info['GET'][key] = format(value)\n if \"filtered_POST\" in ctx:\n for key, value in ctx['filtered_POST'].iteritems():\n request_info['POST'][key] = format(value)\n if hasattr(request, \"FILES\"):\n for key, value in request.FILES.iteritems():\n request_info['FILES'][key] = format(value)\n if hasattr(request, \"COOKIES\"):\n for key, value in request.COOKIES.iteritems():\n request_info['COOKIES'][key] = format(value)\n if hasattr(request, \"META\"):\n for key, value in request.META.iteritems():\n request_info['META'][key] = format(value)\n settings_info = {}\n for key, value in ctx['settings'].iteritems():\n settings_info[key] = format(value)\n \n ctx['errorid'] = errorid = uuid.uuid4().hex\n \n full_info = dict(\n __time=datetime.datetime.now().isoformat(),\n __uuid=errorid,\n settings=settings_info,\n request=request_info,\n traceback=exception_info,\n stack=traceback.format_exc(exc_info[2]),\n last_frame=last_frame,\n template_loaders=loaders,\n template_errors=template_errors,\n unicode_hint=unicdoe_hint,\n exception_type=exception_type,\n exception_value=exception_value,\n django_version=django_version,\n python_version=python_version,\n python_executable=python_executable,\n python_path=python_path,\n server_time=server_time\n )\n \n return (errorid, ctx, full_info)", "metadata": "root.get_exception_info", "header": "['module', '___EOS___']", "index": 39 } ]
[ { "span": "unicode_hint ", "start_line": 57, "start_column": 4, "end_line": 57, "end_column": 16 } ]
[]
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_", "get", "\\u", "exception", "\\u", "info_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "use", " ", "Dj", "ang", "o", "'", "s", " ", "debug", " ", "reporter", ",", " ", "even", " ", "tho", "ugh", " ", "we", " ", "are", " ", "doi", "ng", " ", "our", " ", "own", " ", "template", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "a", " ", "great", " ", "way", " ", "of", " ", "collecti", "ng", " ", "all", " ", "the", " ", "usef", "ul", " ", "info", " ", "we", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "need", ",", " ", "so", " ", "no", " ", "reason", " ", "not", " ", "to", " ", "leve", "rage", " ", "it", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc", "\\u", "info_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reporter_", "=_", "Except", "ion", "Reporter_", "(_", "request_", ",_", "*_", "exc", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "reporter_", "._", "get", "\\u", "traceback", "\\u", "data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "refactor", " ", "of", " ", "what", " ", "the", " ", "technical", "\\u", "500", "\\u", "template", " ", "contain", "s", ",", " ", "just", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "doi", "ng", " ", "the", " ", "logic", " ", "in", " ", "Pyth", "on", " ", "rat", "her", " ", "than", " ", "in", " ", "a", " ", "template", ".", " ", "We", " ", "collect", " ", "all", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "informati", "on", " ", "so", " ", "tha", "t", " ", "we", " ", "can", " ", "log", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "exception", "\\u", "type_", "=_", "ctx_", "[_", "'", "exception", "\\u", "type", "'_", "]_", "if_", "'", "exception", "\\u", "type", "'_", "in_", "ctx_", "else_", "\"", "No", " ", "exception", " ", "supplie", "d", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exception", "\\u", "value_", "=_", "ctx_", "[_", "'", "exception", "\\u", "value", "'_", "]_", "if_", "'", "exception", "\\u", "value", "'_", "in_", "ctx_", "else_", "\"", "No", " ", "exception", " ", "supplie", "d", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "django", "\\u", "version_", "=_", "ctx_", "[_", "\"", "django", "\\u", "version", "\\u", "info", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "python", "\\u", "executable_", "=_", "ctx_", "[_", "'", "sys", "\\u", "executable", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "python", "\\u", "version_", "=_", "ctx_", "[_", "'", "sys", "\\u", "version", "\\u", "info", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "python", "\\u", "path_", "=_", "ctx_", "[_", "'", "sys", "\\u", "path", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server", "\\u", "time_", "=_", "str_", "(_", "ctx_", "[_", "'", "server", "\\u", "time", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unicode", "\\u", "hint_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "unicode", "\\u", "hin", "t", "'_", "in_", "ctx_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uni", "cdo", "e\\u", "hint_", "=_", "ctx_", "[_", "'", "unicode", "\\u", "hin", "t", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "last", "\\u", "frame_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "lastf", "rame", "'_", "in_", "ctx_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "frame", "\\u", "info_", "=_", "ctx_", "[_", "'", "lastf", "rame", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "frame_", "=_", "\"%", "s", " ", "in", " ", "%", "s", ",", " ", "line", " ", "%", "s", "\"_", "%_", "(_", "frame", "\\u", "info_", "[_", "'", "filename", "'_", "]_", ",_", "frame", "\\u", "info_", "[_", "'", "function", "'_", "]_", ",_", "frame", "\\u", "info_", "[_", "'", "linen", "o", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "loaders_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "template", "\\u", "doe", "s", "\\u", "not", "\\u", "exist", "'_", "in_", "ctx_", "and_", "'", "load", "er", "\\u", "debug", "\\u", "info", "'_", "in_", "ctx_", "and_", "ctx_", "[_", "'", "load", "er", "\\u", "debug", "\\u", "info", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "loader_", "in_", "ctx_", "[_", "'", "load", "er", "\\u", "debug", "\\u", "info", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "load", "er", "\\u", "info_", "=_", "{_", "\"", "name", "\"_", ":_", "loader_", "[_", "'", "load", "er", "'_", "]_", ",_", "\"", "template", "s", "\"_", ":_", "[_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "tmpl_", "in_", "loader_", "[_", "'", "template", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "load", "er", "\\u", "info_", "[_", "'", "template", "s", "'_", "]_", "._", "append_", "(_", "{_", "\"", "file", "\"_", ":_", "tmpl_", "[_", "'", "name", "'_", "]_", ",_", "\"", "exist", "s", "\"_", ":_", "tmpl_", "[_", "'", "exist", "s", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "loaders_", "._", "append_", "(_", "load", "er", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "template", "\\u", "errors_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "template", "\\u", "info", "'_", "in_", "ctx_", "and_", "ctx_", "[_", "'", "template", "\\u", "info", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "info_", "=_", "ctx_", "[_", "'", "template", "\\u", "info", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "errors_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "template", "\\u", "info_", "[_", "'", "name", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "line", "\"_", ":_", "template", "\\u", "info_", "[_", "'", "line", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "\"_", ":_", "template", "\\u", "info_", "[_", "'", "message", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "exception", "\\u", "info_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "frames", "'_", "in_", "ctx_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "frames_", "=_", "ctx_", "[_", "'", "frames", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "frame_", "in_", "frames_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "frame", "\\u", "info_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "filename", "\"_", ":_", "frame_", "[_", "'", "filename", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "function", "\"_", ":_", "frame_", "[_", "'", "function", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "line", "\"_", ":_", "frame_", "[_", "'", "linen", "o", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "context", "\\u", "line", "\"_", ":_", "frame_", "[_", "'", "context", "\\u", "line", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "vars", "\"_", ":_", "[_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "vars", "'_", "in_", "frame_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "var_", "in_", "frame_", "[_", "'", "vars", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "frame", "\\u", "info_", "[_", "'", "vars", "'_", "]_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "variab", "le", "\"_", ":_", "str_", "(_", "var_", "[_", "0_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "value", "\"_", ":_", "format_", "(_", "var_", "[_", "1_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "exception", "\\u", "info_", "._", "append_", "(_", "frame", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "request", "\\u", "info_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "path", "\\u", "info", "\"_", ":_", "request_", "._", "path", "\\u", "info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ":_", "request_", "._", "META_", "[_", "'", "REQUEST", "\\u", "METH", "OD", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "url", "\"_", ":_", "request_", "._", "build", "\\u", "abs", "olute", "\\u", "uri_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "GET", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "POST", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "FILE", "S", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "COOKIE", "S", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "MET", "A", "\"_", ":_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "request_", ",_", "\"", "GET", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "request_", "._", "GET_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "\\u", "info_", "[_", "'", "GET", "'_", "]_", "[_", "key_", "]_", "=_", "format_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\"", "filter", "ed", "\\u", "POST", "\"_", "in_", "ctx_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "ctx_", "[_", "'", "filter", "ed", "\\u", "POST", "'_", "]_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "\\u", "info_", "[_", "'", "POST", "'_", "]_", "[_", "key_", "]_", "=_", "format_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "request_", ",_", "\"", "FILE", "S", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "request_", "._", "FILES_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "\\u", "info_", "[_", "'", "FILE", "S", "'_", "]_", "[_", "key_", "]_", "=_", "format_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "request_", ",_", "\"", "COOKIE", "S", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "request_", "._", "COOKIE", "S_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "\\u", "info_", "[_", "'", "COOKIE", "S", "'_", "]_", "[_", "key_", "]_", "=_", "format_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "request_", ",_", "\"", "MET", "A", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "request_", "._", "META_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "\\u", "info_", "[_", "'", "MET", "A", "'_", "]_", "[_", "key_", "]_", "=_", "format_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "settings", "\\u", "info_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "ctx_", "[_", "'", "settings", "'_", "]_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "settings", "\\u", "info_", "[_", "key_", "]_", "=_", "format_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ctx_", "[_", "'", "error", "id", "'_", "]_", "=_", "error", "id_", "=_", "uuid_", "._", "uuid4_", "(_", ")_", "._", "hex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "full", "\\u", "info_", "=_", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "time_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "._", "isoformat_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "uuid_", "=_", "error", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "settings_", "=_", "settings", "\\u", "info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "request", "\\u", "info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "traceback_", "=_", "exception", "\\u", "info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "stack_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", "exc", "\\u", "info_", "[_", "2_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "last", "\\u", "frame_", "=_", "last", "\\u", "frame_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "loaders_", "=_", "loaders_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "errors_", "=_", "template", "\\u", "errors_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unicode", "\\u", "hint_", "=_", "uni", "cdo", "e\\u", "hint_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exception", "\\u", "type_", "=_", "exception", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exception", "\\u", "value_", "=_", "exception", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "django", "\\u", "version_", "=_", "django", "\\u", "version_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "python", "\\u", "version_", "=_", "python", "\\u", "version_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "python", "\\u", "executable_", "=_", "python", "\\u", "executable_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "python", "\\u", "path_", "=_", "python", "\\u", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "server", "\\u", "time_", "=_", "server", "\\u", "time_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "error", "id_", ",_", "ctx_", ",_", "full", "\\u", "info_", ")_", "\\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, 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mti.py
[ { "content": "# Copyright 2009-2015 Luc Saffre\n# License: BSD (see file COPYING for details)\n\n\"\"\"\nA collection of tools around :doc:`/topics/mti`.\nSee the source code of :mod:`lino.test_apps.mti`.\nCertainly not perfect, but works for me.\nI wrote it mainly to solve ticket :srcref:`docs/tickets/22`.\n\n\n\n\"\"\"\nfrom builtins import str\nimport logging\nlogger = logging.getLogger(__name__)\n\nfrom django.db import models\nfrom django.db import router\nfrom django.db.models.deletion import Collector, DO_NOTHING\nfrom django.core.exceptions import ValidationError\nfrom django.utils.translation import ugettext_lazy as _\n\n\nfrom lino.core.utils import resolve_model\nfrom lino.core.fields import VirtualField\nfrom lino.core.signals import pre_remove_child, pre_add_child # , on_add_child\nfrom lino import AFTER17\n\n\n\n\n\n\n\n\n\n\n \n\n#~ def insert_child_and_save(obj,child_model,**attrs):\n #~ \"\"\"\n #~ Insert (create) and save a `child_model` instance of existing `obj`.\n #~ \"\"\"\n #~ obj = insert_child(obj,child_model,**attrs)\n #~ obj.save()\n #~ return obj\n\n\n\n\nfrom lino.utils.dpy import create_mti_child as create_child\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ChildCollector(Collector):\n\n \"\"\"\n A Collector that does not delete the MTI parents.\n \"\"\"\n", "metadata": "root.ChildCollector", "header": "['module', '___EOS___']", "index": 29 }, { "content": " def collect(self, objs, source=None, nullable=False, collect_related=True,\n source_attr=None, reverse_dependency=False):\n # modified copy of django.db.models.deletion.Collector.collect()\n # changes:\n # DOES NOT Recursively collect concrete model's parent models.\n # calls get_all_related_objects() with local_only=True\n\n if self.can_fast_delete(objs):\n self.fast_deletes.append(objs)\n return\n new_objs = self.add(objs, source, nullable,\n reverse_dependency=reverse_dependency)\n if not new_objs:\n return\n\n model = new_objs[0].__class__\n\n if collect_related:\n for related in model._meta.get_all_related_objects(\n include_hidden=True, include_proxy_eq=True,\n local_only=True):\n field = related.field\n if field.rel.on_delete == DO_NOTHING:\n continue\n sub_objs = self.related_objects(related, new_objs)\n if self.can_fast_delete(sub_objs, from_field=field):\n self.fast_deletes.append(sub_objs)\n elif sub_objs:\n field.rel.on_delete(self, field, sub_objs, self.using)\n for field in model._meta.virtual_fields:\n if hasattr(field, 'bulk_related_objects'):\n # Its something like generic foreign key.\n sub_objs = field.bulk_related_objects(new_objs, self.using)\n self.collect(sub_objs,\n source=model,\n source_attr=field.rel.related_name,\n nullable=True)", "metadata": "root.ChildCollector.collect", "header": "['class', 'ChildCollector', '(', 'Collector', ')', ':', '___EOS___']", "index": 35 }, { "content": "class OldChildCollector(Collector):\n # version which worked for Django 1.5", "metadata": "root.OldChildCollector", "header": "['module', '___EOS___']", "index": 74 }, { "content": " def collect(self, objs, source=None, nullable=False, collect_related=True,\n source_attr=None, collect_parents=True):\n # modified copy from original Django code\n new_objs = self.add(objs, source, nullable)\n if not new_objs:\n return\n model = new_objs[0].__class__\n\n if collect_related:\n #~ for m,related in model._meta.get_all_related_objects_with_model(include_hidden=True):\n for related in model._meta.get_all_related_objects(include_hidden=True, local_only=True):\n field = related.field\n if related.model._meta.auto_created:\n # Django 1.5.x:\n self.add_batch(related.model, field, new_objs)\n else:\n sub_objs = self.related_objects(related, new_objs)\n #~ print 20130828, related.model._meta.concrete_model\n if not sub_objs:\n continue\n field.rel.on_delete(self, field, sub_objs, self.using)\n\n # TODO This entire block is only needed as a special case\n # to support cascade-deletes for GenericRelation. It\n # should be removed/fixed when the ORM gains a proper\n # abstraction for virtual or composite fields, and GFKs\n # are reworked to fit into that.\n for relation in model._meta.many_to_many:\n if not relation.rel.through:\n sub_objs = relation.bulk_related_objects(\n new_objs, self.using)\n self.collect(sub_objs,\n source=model,\n source_attr=relation.rel.related_name,\n nullable=True)", "metadata": "root.OldChildCollector.collect", "header": "['class', 'OldChildCollector', '(', 'Collector', ')', ':', '___NEWLINE___', '# version which worked for Django 1.5', '___NL___', '___EOS___']", "index": 76 }, { "content": "def get_child(obj, child_model):\n if obj.pk is not None:\n try:\n return child_model.objects.get(pk=obj.pk)\n except child_model.DoesNotExist:\n # logger.warning(\n # \"No mti child %s in %s\",\n # obj.pk, child_model.objects.all().query)\n return None", "metadata": "root.get_child", "header": "['module', '___EOS___']", "index": 113 }, { "content": "def delete_child(obj, child_model, ar=None, using=None):\n \"\"\"\n Delete the `child_model` instance related to `obj` without\n deleting the parent `obj` itself.\n \"\"\"\n # logger.info(u\"delete_child %s from %s\",child_model.__name__,obj)\n using = using or router.db_for_write(obj.__class__, instance=obj)\n child = get_child(obj, child_model)\n if child is None:\n raise Exception(\"%s has no child in %s\" % (obj, child_model.__name__))\n\n # msg = child.disable_delete(ar)\n ignore_models = set()\n # for m in models_by_base(obj.__class__):\n # ignore_models.remove(child_model)\n msg = child._lino_ddh.disable_delete_on_object(\n obj, ignore_models)\n if msg:\n raise ValidationError(msg)\n # logger.debug(u\"Delete child %s from %s\",child_model.__name__,obj)\n if True:\n collector = ChildCollector(using=using)\n collector.collect([child])\n # raise Exception(repr(collector.data))\n # model = obj.__class__\n\n # remove the collected MTI parents so they are not deleted\n # (this idea didnt work: yes the parents were saved, but not\n # their related objects).\n\n # concrete_model = child_model._meta.concrete_model\n # for ptr in six.itervalues(concrete_model._meta.parents):\n # if ptr:\n # # raise Exception(repr(ptr.rel.model))\n # del collector.data[ptr.rel.model]\n\n else:\n collector = ChildCollector(using=using)\n collector.collect([child], source=obj.__class__,\n nullable=True, collect_parents=False)\n collector.delete()\n\n #~ setattr(obj,child_model.__name__.lower(),None)\n #~ delattr(obj,child_model.__name__.lower())\n\n # TODO: unchecking e.g. Company.is_courseprovider deletes the\n # child when saving the form, but the response to the PUT returns\n # still a True value because it works on the same memory instance\n # (`obj`). User sees the effect only after clicking the refresh\n # button. Fortunately there's no problem if the user unchecks the\n # field and saves the form a second time.", "metadata": "root.delete_child", "header": "['module', '___EOS___']", "index": 124 }, { "content": "def insert_child(obj, child_model, full_clean=False, **attrs):\n \"\"\"Create and save an instance of `child_model` from existing `obj`.\n\n If `full_clean` is True, call full_clean on the newly created\n object. Default is `False` because this was the historic\n behaviour.\n\n \"\"\"\n #~ assert child_model != obj.__class__\n #~ if child_model == obj.__class__:\n #~ raise ValidationError(\n #~ \"A %s cannot be parent for itself\" %\n #~ obj.__class__.__name__)\n parent_link_field = child_model._meta.parents.get(obj.__class__, None)\n if parent_link_field is None:\n raise ValidationError(str(\"A %s cannot be parent for a %s\" % (\n obj.__class__.__name__, child_model.__name__)))\n attrs[parent_link_field.name] = obj\n # ~ for pm,pf in child_model._meta.parents.items(): # pm : parent model, pf : parent link field\n #~ attrs[pf.name] = obj\n #~ attrs[\"%s_ptr\" % obj.__class__.__name__.lower()] = obj\n if AFTER17:\n fields_list = obj._meta.concrete_fields\n else:\n fields_list = obj._meta.fields\n for field in fields_list:\n attrs[field.name] = getattr(obj, field.name)\n new_obj = child_model(**attrs)\n #~ logger.info(\"20120830 insert_child %s\",obj2str(new_obj))\n\n new_obj.save()\n # on_add_child.send(sender=obj, child=new_obj)\n if full_clean:\n try:\n new_obj.full_clean()\n new_obj.save()\n except ValidationError as e:\n msg = obj.error2str(e)\n raise ValidationError(\n _(\"Problem while inserting %(child)s \"\n \"child of %(parent)s: %(message)s\") %\n dict(child=child_model.__name__,\n parent=obj.__class__.__name__,\n message=msg))\n return new_obj", "metadata": "root.insert_child", "header": "['module', '___EOS___']", "index": 177 }, { "content": "class EnableChild(VirtualField):\n \"\"\"Rendered as a checkbox that indicates whether an mti child of the\n given model exists.\n\n Deprecated. Use polymorphic.Polymorphic instead.\n\n \"\"\"\n\n editable = True\n #~ default = models.NOT_PROVIDED\n\n\n\n\n", "metadata": "root.EnableChild", "header": "['module', '___EOS___']", "index": 233 }, { "content": " def __init__(self, child_model, **kw):\n raise Exception(\"No longer recommended. \"\n \"Use `lino.mixins.polymorphic` instead.\")\n kw.update(default=False)\n self.child_model = child_model\n VirtualField.__init__(self, models.BooleanField(**kw), self.has_child)", "metadata": "root.EnableChild.__init__", "header": "['class', 'EnableChild', '(', 'VirtualField', ')', ':', '___EOS___']", "index": 244 }, { "content": " def is_enabled(self, lh):\n \"\"\"When a FormLayout is inherited by an MTI child, EnableChild fields\n must be disabled.\n\n \"\"\"\n return lh.layout._datasource.model != self.child_model \\\n and issubclass(self.child_model, lh.layout._datasource.model)", "metadata": "root.EnableChild.is_enabled", "header": "['class', 'EnableChild', '(', 'VirtualField', ')', ':', '___EOS___']", "index": 251 }, { "content": " def attach_to_model(self, model, name):\n self.child_model = resolve_model(\n self.child_model, model._meta.app_label)\n VirtualField.attach_to_model(self, model, name)", "metadata": "root.EnableChild.attach_to_model", "header": "['class', 'EnableChild', '(', 'VirtualField', ')', ':', '___EOS___']", "index": 259 }, { "content": " def has_child(self, obj, request=None):\n \"\"\"Returns True if `obj` has an MTI child in `self.child_model`. The\n optional 2nd argument `request` (passed from\n `VirtualField.value_from_object`) is ignored.\n\n \"\"\"\n try:\n getattr(obj, self.child_model.__name__.lower())\n #~ child = getattr(obj,self.child_model.__name__.lower())\n #~ if child is None: return False\n #~ print 20120531, repr(child)\n #~ self.child_model.objects.get(pk=obj.pk)\n except self.child_model.DoesNotExist:\n return False\n return True", "metadata": "root.EnableChild.has_child", "header": "['class', 'EnableChild', '(', 'VirtualField', ')', ':', '___EOS___']", "index": 264 }, { "content": " def set_value_in_object(self, ar, obj, v):\n if self.has_child(obj):\n #~ logger.debug('set_value_in_object : %s has child %s',\n #~ obj.__class__.__name__,self.child_model.__name__)\n # child exists, delete it if it may not\n if not v:\n if ar is not None:\n pre_remove_child.send(\n sender=obj, request=ar.request,\n child=self.child_model)\n delete_child(obj, self.child_model, ar)\n else:\n #~ logger.debug('set_value_in_object : %s has no child %s',\n #~ obj.__class__.__name__,self.child_model.__name__)\n if v:\n # child doesn't exist. insert if it should\n if ar is not None:\n pre_add_child.send(\n sender=obj, request=ar.request,\n child=self.child_model)\n insert_child(obj, self.child_model, full_clean=True)", "metadata": "root.EnableChild.set_value_in_object", "header": "['class', 'EnableChild', '(', 'VirtualField', ')', ':', '___EOS___']", "index": 280 } ]
[ { "span": "from lino.utils.dpy import create_mti_child as create_child", "start_line": 303, "start_column": 0, "end_line": 303, "end_column": 59 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "200", "9", "-", "201", "5", " ", "Luc", " ", "Saf", "fre", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ":", " ", "BS", "D", " ", "(", "see", " ", "file", " ", "COPY", "ING", " ", "for", " ", "deta", "il", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "A", " ", "collection", " ", "of", " ", "tool", "s", " ", "aro", "und", " ", ":", "doc", ":`", "/", "topic", "s", "/", "mti", "`.", "\\", "10", ";", "See", " ", "the", " ", "source", " ", "code", " ", "of", " ", ":", "mod", ":`", "lino", ".", "test\\u", "apps", ".", "mti", "`.", "\\", "10", ";", "Cert", "ain", "ly", " ", "not", " ", "perfect", ",", " ", "but", " ", "works", " ", "for", " ", "me", ".", "\\", "10", ";", "I", " ", "wrote", " ", "it", " ", "mainl", "y", " ", "to", " ", "solve", " ", "tick", "et", " ", ":", "src", "ref", ":`", "docs", "/", "tick", "ets", "/", "2", "2", "`.", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "builtins_", "import_", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "router_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "deletion_", "import_", "Collector_", ",_", "DO", "\\u", "NOT", "HING", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Validat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "translation_", "import_", "uge", "ttext", "\\u", "lazy_", "as_", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "lino", "_", "._", "core_", "._", "utils_", "import_", "resolve", "\\u", "model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "core_", "._", "fields_", "import_", "Virt", "ual", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "core_", "._", "signals_", "import_", "pre", "\\u", "remove", "\\u", "child_", ",_", "pre", "\\u", "add", "\\u", "child_", "#", " ", ",", " ", "on", "\\u", "add", "\\u", "child_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "import_", "AFTER", "17_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "def", " ", "insert", "\\u", "child", "\\u", "and", "\\u", "save", "(", "obj", ",", "child", "\\u", "model", ",*", "*", "attr", "s", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "\"\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "Insert", " ", "(", "create", ")", " ", "and", " ", "save", " ", "a", " ", "`", "child", "\\u", "model", "`", " ", "instance", " ", "of", " ", "exist", "ing", " ", "`", "obj", "`.", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "\"\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "obj", " ", "=", " ", "insert", "\\u", "child", "(", "obj", ",", "child", "\\u", "model", ",*", "*", "attr", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "obj", ".", "save", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "return", " ", "obj_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "lino", "_", "._", "utils_", "._", "dp", "y_", "import_", "create", "\\u", "mti", "\\u", "child_", "as_", "create", "\\u", "child_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Chil", "d", "Collector_", "(_", "Collector_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "Collect", "or", " ", "tha", "t", " ", "doe", "s", " ", "not", " ", "delete", " ", "the", " ", "MT", "I", " ", "parents", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Chil", "d", "Collector_", "(_", "Collector_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "collect_", "(_", "self_", ",_", "objs_", ",_", "source_", "=_", "None_", ",_", "nullable_", "=_", "False_", ",_", "collect", "\\u", "related_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "attr_", "=_", "None_", ",_", "reverse", "\\u", "dependency_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "modifi", "ed", " ", "copy", " ", "of", " ", "django", ".", "db", ".", "model", "s", ".", "deletion", ".", "Collect", "or", ".", "collect", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "change", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "DO", "ES", " ", "NOT", " ", "Recursive", "ly", " ", "collect", " ", "concre", "te", " ", "model", "'", "s", " ", "parent", " ", "model", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "calls", " ", "get", "\\u", "all", "\\u", "relate", "d\\u", "object", "s", "()", " ", "with", " ", "local", "\\u", "only", "=", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "can", "\\u", "fast", "\\u", "delete_", "(_", "objs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fast", "\\u", "delete", "s_", "._", "append_", "(_", "objs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "objs_", "=_", "self_", "._", "add_", "(_", "objs_", ",_", "source_", ",_", "nullable_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reverse", "\\u", "dependency_", "=_", "reverse", "\\u", "dependency_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "new", "\\u", "objs_", ":_", "\\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_", "model_", "=_", "new", "\\u", "objs_", "[_", "0_", "]_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "collect", "\\u", "related_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "related_", "in_", "model_", "._", "\\u", "meta_", "._", "get", "\\u", "all", "\\u", "relate", "d\\u", "objects_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "include", "\\u", "hidden_", "=_", "True_", ",_", "include", "\\u", "proxy", "\\u", "eq_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "local", "\\u", "only_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field_", "=_", "related_", "._", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "field_", "._", "rel_", "._", "on", "\\u", "delete_", "==_", "DO", "\\u", "NOT", "HING", "_", ":_", "\\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_", "sub\\u", "objs_", "=_", "self_", "._", "relate", "d\\u", "objects_", "(_", "related_", ",_", "new", "\\u", "objs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "can", "\\u", "fast", "\\u", "delete_", "(_", "sub\\u", "objs_", ",_", "from", "\\u", "field_", "=_", "field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "fast", "\\u", "delete", "s_", "._", "append_", "(_", "sub\\u", "objs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "sub\\u", "objs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "field_", "._", "rel_", "._", "on", "\\u", "delete_", "(_", "self_", ",_", "field_", ",_", "sub\\u", "objs_", ",_", "self_", "._", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "field_", "in_", "model_", "._", "\\u", "meta_", "._", "virtual", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "field_", ",_", "'", "bul", "k", "\\u", "relate", "d\\u", "object", "s", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "It", "s", " ", "somet", "hing", " ", "like", " ", "gener", "ic", " ", "foreign", " ", "key", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sub\\u", "objs_", "=_", "field_", "._", "bul", "k", "\\u", "relate", "d\\u", "objects_", "(_", "new", "\\u", "objs_", ",_", "self_", "._", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "collect_", "(_", "sub\\u", "objs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source_", "=_", "model_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "attr_", "=_", "field_", "._", "rel_", "._", "relate", "d\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nullable_", "=_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Old", "Chil", "d", "Collector_", "(_", "Collector_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "version", " ", "whi", "ch", " ", "worked", " ", "for", " ", "Dj", "ang", "o", " ", "1.5_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Old", "Chil", "d", "Collector_", "(_", "Collector_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "version", " ", "whi", "ch", " ", "worked", " ", "for", " ", "Dj", "ang", "o", " ", "1.5_", "\\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_", "collect_", "(_", "self_", ",_", "objs_", ",_", "source_", "=_", "None_", ",_", "nullable_", "=_", "False_", ",_", "collect", "\\u", "related_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "attr_", "=_", "None_", ",_", "collect", "\\u", "parents_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "modifi", "ed", " ", "copy", " ", "from", " ", "original", " ", "Dj", "ang", "o", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "objs_", "=_", "self_", "._", "add_", "(_", "objs_", ",_", "source_", ",_", "nullable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "new", "\\u", "objs_", ":_", "\\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_", "model_", "=_", "new", "\\u", "objs_", "[_", "0_", "]_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "collect", "\\u", "related_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "for", " ", "m", ",", "relate", "d", " ", "in", " ", "model", ".\\u", "meta", ".", "get", "\\u", "all", "\\u", "relate", "d\\u", "object", "s", "\\u", "with", "\\u", "model", "(", "include", "\\u", "hidden", "=", "Tru", "e", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "related_", "in_", "model_", "._", "\\u", "meta_", "._", "get", "\\u", "all", "\\u", "relate", "d\\u", "objects_", "(_", "include", "\\u", "hidden_", "=_", "True_", ",_", "local", "\\u", "only_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field_", "=_", "related_", "._", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "related_", "._", "model_", "._", "\\u", "meta_", "._", "auto", "\\u", "created_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Dj", "ang", "o", " ", "1.5", ".", "x", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "add", "\\u", "batch_", "(_", "related_", "._", "model_", ",_", "field_", ",_", "new", "\\u", "objs_", ")_", "\\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 ", " ", "_", "sub\\u", "objs_", "=_", "self_", "._", "relate", "d\\u", "objects_", "(_", "related_", ",_", "new", "\\u", "objs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "print", " ", "20130", "828", ",", " ", "relate", "d", ".", "model", ".\\u", "meta", ".", "concre", "te", "\\u", "model_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "sub\\u", "objs_", ":_", "\\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_", "field_", "._", "rel_", "._", "on", "\\u", "delete_", "(_", "self_", ",_", "field_", ",_", "sub\\u", "objs_", ",_", "self_", "._", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", " ", "Thi", "s", " ", "entire", " ", "block", " ", "is", " ", "only", " ", "need", "ed", " ", "as", " ", "a", " ", "special", " ", "case_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "support", " ", "cascade", "-", "delete", "s", " ", "for", " ", "Gene", "ric", "Relation", ".", " ", "It_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "shou", "ld", " ", "be", " ", "remove", "d", "/", "fixed", " ", "whe", "n", " ", "the", " ", "ORM", " ", "gains", " ", "a", " ", "proper", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "abstract", "ion", " ", "for", " ", "virtual", " ", "or", " ", "composi", "te", " ", "fields", ",", " ", "and", " ", "GF", "Ks", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "are", " ", "rew", "ork", "ed", " ", "to", " ", "fit", " ", "int", "o", " ", "tha", "t", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "relation_", "in_", "model_", "._", "\\u", "meta_", "._", "many", "\\u", "to", "\\u", "many_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "relation_", "._", "rel_", "._", "through_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sub\\u", "objs_", "=_", "relation_", "._", "bul", "k", "\\u", "relate", "d\\u", "objects_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "objs_", ",_", "self_", "._", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "collect_", "(_", "sub\\u", "objs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source_", "=_", "model_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "attr_", "=_", "relation_", "._", "rel_", "._", "relate", "d\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nullable_", "=_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "child_", "(_", "obj_", ",_", "child", "\\u", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "obj_", "._", "pk_", "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 ", " _", "return_", "child", "\\u", "model_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "obj_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "child", "\\u", "model_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "logg", "er", ".", "warn", "ing", "(_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "No", " ", "mti", " ", "child", " ", "%", "s", " ", "in", " ", "%", "s", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "obj", ".", "pk", ",", " ", "child", "\\u", "model", ".", "object", "s", ".", "all", "()", ".", "query", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "\\u", "child_", "(_", "obj_", ",_", "child", "\\u", "model_", ",_", "ar_", "=_", "None_", ",_", "using_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Delete", " ", "the", " ", "`", "child", "\\u", "model", "`", " ", "instance", " ", "relate", "d", " ", "to", " ", "`", "obj", "`", " ", "with", "out", "\\", "10", ";", " ", " ", " ", " ", "delet", "ing", " ", "the", " ", "parent", " ", "`", "obj", "`", " ", "its", "elf", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "logg", "er", ".", "info", "(", "u", "\"", "delete", "\\u", "child", " ", "%", "s", " ", "from", " ", "%", "s", "\",", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u", ",", "obj", ")_", "\\u\\u\\uNL\\u\\u\\u_", "using_", "=_", "using_", "or_", "router_", "._", "db", "\\u", "for", "\\u", "write_", "(_", "obj_", "._", "\\u\\u", "class\\u\\u_", ",_", "instance_", "=_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child_", "=_", "get", "\\u", "child_", "(_", "obj_", ",_", "child", "\\u", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "child_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"%", "s", " ", "has", " ", "no", " ", "child", " ", "in", " ", "%", "s", "\"_", "%_", "(_", "obj_", ",_", "child", "\\u", "model_", "._", "\\u\\u", "name\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "msg", " ", "=", " ", "child", ".", "disable", "\\u", "delete", "(", "ar", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ignore", "\\u", "models_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "for", " ", "m", " ", "in", " ", "model", "s", "\\u", "by", "\\u", "base", "(", "obj", ".\\u", "\\u", "class", "\\u\\u)", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ignore", "\\u", "model", "s", ".", "remove", "(", "child", "\\u", "model", ")_", "\\u\\u\\uNL\\u\\u\\u_", "msg_", "=_", "child_", "._", "\\u", "lino", "\\u", "dd", "h_", "._", "disable", "\\u", "delete", "\\u", "on", "\\u", "object_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", ",_", "ignore", "\\u", "models_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Validat", "ion", "Error_", "(_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "logg", "er", ".", "debug", "(", "u", "\"", "Delete", " ", "child", " ", "%", "s", " ", "from", " ", "%", "s", "\",", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u", ",", "obj", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "collector_", "=_", "Chil", "d", "Collector_", "(_", "using_", "=_", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "collector_", "._", "collect_", "(_", "[_", "child_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "raise", " ", "Except", "ion", "(", "repr", "(", "collect", "or", ".", "data", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "model", " ", "=", " ", "obj", ".\\u", "\\u", "class\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remove", " ", "the", " ", "collected", " ", "MT", "I", " ", "parents", " ", "so", " ", "the", "y", " ", "are", " ", "not", " ", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "this", " ", "idea", " ", "did", "nt", " ", "work", ":", " ", "ye", "s", " ", "the", " ", "parents", " ", "wer", "e", " ", "saved", ",", " ", "but", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "thei", "r", " ", "relate", "d", " ", "object", "s", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "concre", "te", "\\u", "model", " ", "=", " ", "child", "\\u", "model", ".\\u", "meta", ".", "concre", "te", "\\u", "model_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "ptr", " ", "in", " ", "si", "x", ".", "iter", "values", "(", "concre", "te", "\\u", "model", ".\\u", "meta", ".", "parents", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "ptr", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "#", " ", "raise", " ", "Except", "ion", "(", "repr", "(", "ptr", ".", "rel", ".", "model", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "del", " ", "collect", "or", ".", "data", "[", "ptr", ".", "rel", ".", "model", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "collector_", "=_", "Chil", "d", "Collector_", "(_", "using_", "=_", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "collector_", "._", "collect_", "(_", "[_", "child_", "]_", ",_", "source_", "=_", "obj_", "._", "\\u\\u", "class\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nullable_", "=_", "True_", ",_", "collect", "\\u", "parents_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "collector_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "setattr", "(", "obj", ",", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u", ".", "lower", "()", ",", "Non", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "delattr", "(", "obj", ",", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u", ".", "lower", "())", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "uncheck", "ing", " ", "e", ".", "g", ".", " ", "Compa", "ny", ".", "is", "\\u", "course", "provide", "r", " ", "delete", "s", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "child", " ", "whe", "n", " ", "saving", " ", "the", " ", "form", ",", " ", "but", " ", "the", " ", "response", " ", "to", " ", "the", " ", "PU", "T", " ", "returns_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "still", " ", "a", " ", "Tru", "e", " ", "value", " ", "bec", "aus", "e", " ", "it", " ", "works", " ", "on", " ", "the", " ", "same", " ", "memory", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "`", "obj", "`)", ".", " ", " ", "User", " ", "see", "s", " ", "the", " ", "effect", " ", "only", " ", "after", " ", "click", "ing", " ", "the", " ", "refresh_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "button", ".", " ", " ", "Fort", "unat", "el", "y", " ", "there", "'", "s", " ", "no", " ", "problem", " ", "if", " ", "the", " ", "user", " ", "uncheck", "s", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "field", " ", "and", " ", "save", "s", " ", "the", " ", "form", " ", "a", " ", "second", " ", "time", "._", "\\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_", "insert", "\\u", "child_", "(_", "obj_", ",_", "child", "\\u", "model_", ",_", "full", "\\u", "clean_", "=_", "False_", ",_", "**_", "attrs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "and", " ", "save", " ", "an", " ", "instance", " ", "of", " ", "`", "child", "\\u", "model", "`", " ", "from", " ", "exist", "ing", " ", "`", "obj", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "`", "full", "\\u", "clean", "`", " ", "is", " ", "Tru", "e", ",", " ", "call", " ", "full", "\\u", "clean", " ", "on", " ", "the", " ", "newl", "y", " ", "created", "\\", "10", ";", " ", " ", " ", " ", "object", ".", " ", "Default", " ", "is", " ", "`", "Fal", "se", "`", " ", "bec", "aus", "e", " ", "this", " ", "was", " ", "the", " ", "histori", "c", "\\", "10", ";", " ", " ", " ", " ", "behaviour", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "assert", " ", "child", "\\u", "model", " ", "!=", " ", "obj", ".\\u", "\\u", "class\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "if", " ", "child", "\\u", "model", " ", "==", " ", "obj", ".\\u", "\\u", "class", "\\u\\u:", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "raise", " ", "Validat", "ion", "Error", "(_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "\"", "A", " ", "%", "s", " ", "cann", "ot", " ", "be", " ", "parent", " ", "for", " ", "its", "elf", "\"", " ", "%_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "obj", ".\\u", "\\u", "class", "\\u\\u", ".\\u", "\\u", "name", "\\u\\u)", "_", "\\u\\u\\uNL\\u\\u\\u_", "parent", "\\u", "link", "\\u", "field_", "=_", "child", "\\u", "model_", "._", "\\u", "meta_", "._", "parents_", "._", "get_", "(_", "obj_", "._", "\\u\\u", "class\\u\\u_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "parent", "\\u", "link", "\\u", "field_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Validat", "ion", "Error_", "(_", "str_", "(_", "\"", "A", " ", "%", "s", " ", "cann", "ot", " ", "be", " ", "parent", " ", "for", " ", "a", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "child", "\\u", "model_", "._", "\\u\\u", "name\\u\\u_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "attrs_", "[_", "parent", "\\u", "link", "\\u", "field_", "._", "name_", "]_", "=_", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "~", " ", "for", " ", "pm", ",", "pf", " ", "in", " ", "child", "\\u", "model", ".\\u", "meta", ".", "parents", ".", "items", "():", " ", "#", " ", "pm", " ", ":", " ", "parent", " ", "model", ",", " ", "pf", " ", ":", " ", "parent", " ", "link", " ", "field_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "attr", "s", "[", "pf", ".", "name", "]", " ", "=", " ", "obj_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "attr", "s", "[\"", "%", "s", "\\u", "ptr", "\"", " ", "%", " ", "obj", ".\\u", "\\u", "class", "\\u\\u", ".\\u", "\\u", "name", "\\u\\u", ".", "lower", "()]", " ", "=", " ", "obj_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "AFTER", "17_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fields", "\\u", "list_", "=_", "obj_", "._", "\\u", "meta_", "._", "concre", "te", "\\u", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fields", "\\u", "list_", "=_", "obj_", "._", "\\u", "meta_", "._", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "field_", "in_", "fields", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attrs_", "[_", "field_", "._", "name_", "]_", "=_", "getattr_", "(_", "obj_", ",_", "field_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "obj_", "=_", "child", "\\u", "model_", "(_", "**_", "attrs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "logg", "er", ".", "info", "(\"", "20120", "830", " ", "insert", "\\u", "child", " ", "%", "s", "\",", "obj2", "str", "(", "new", "\\u", "obj", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "obj_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "on", "\\u", "add", "\\u", "child", ".", "send", "(", "sender", "=", "obj", ",", " ", "child", "=", "new", "\\u", "obj", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "full", "\\u", "clean_", ":_", "\\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 ", " _", "new", "\\u", "obj_", "._", "full", "\\u", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "obj_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Validat", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "obj_", "._", "error", "2str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Validat", "ion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Prob", "lem", " ", "whi", "le", " ", "insert", "ing", " ", "%", "(", "child", ")", "s", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "child", " ", "of", " ", "%", "(", "parent", ")", "s", ":", " ", "%", "(", "message", ")", "s", "\"_", ")_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "child_", "=_", "child", "\\u", "model_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "=_", "obj_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "new", "\\u", "obj_", "\\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_", "Enable", "Child_", "(_", "Virt", "ual", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Render", "ed", " ", "as", " ", "a", " ", "checkb", "ox", " ", "tha", "t", " ", "indicat", "es", " ", "whe", "ther", " ", "an", " ", "mti", " ", "child", " ", "of", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "give", "n", " ", "model", " ", "exist", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Dep", "reca", "ted", ".", " ", "Us", "e", " ", "polymorphic", ".", "Poly", "morphi", "c", " ", "inst", "ead", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "editable_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "default", " ", "=", " ", "model", "s", ".", "NOT", "\\u", "PROVI", "DED", "_", "\\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_", "Enable", "Child_", "(_", "Virt", "ual", "Field_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "child", "\\u", "model_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"", "No", " ", "long", "er", " ", "recommende", "d", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Us", "e", " ", "`", "lino", ".", "mix", "ins", ".", "polymorphic", "`", " ", "inst", "ead", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "child", "\\u", "model_", "=_", "child", "\\u", "model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Virt", "ual", "Field_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "models_", "._", "Boo", "lean", "Field_", "(_", "**_", "kw_", ")_", ",_", "self_", "._", "has", "\\u", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Enable", "Child_", "(_", "Virt", "ual", "Field_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "enabled_", "(_", "self_", ",_", "lh", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Whe", "n", " ", "a", " ", "Form", "Lay", "out", " ", "is", " ", "inherited", " ", "by", " ", "an", " ", "MT", "I", " ", "child", ",", " ", "Enable", "Chil", "d", " ", "fields", "\\", "10", ";", " ", " ", " ", " ", "must", " ", "be", " ", "disable", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "lh", "_", "._", "layout_", "._", "\\u", "datasource_", "._", "model_", "!=_", "self_", "._", "child", "\\u", "model_", "and_", "issubclass_", "(_", "self_", "._", "child", "\\u", "model_", ",_", "lh", "_", "._", "layout_", "._", "\\u", "datasource_", "._", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Enable", "Child_", "(_", "Virt", "ual", "Field_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "attach", "\\u", "to", "\\u", "model_", "(_", "self_", ",_", "model_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "child", "\\u", "model_", "=_", "resolve", "\\u", "model_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "child", "\\u", "model_", ",_", "model_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Virt", "ual", "Field_", "._", "attach", "\\u", "to", "\\u", "model_", "(_", "self_", ",_", "model_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Enable", "Child_", "(_", "Virt", "ual", "Field_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "has", "\\u", "child_", "(_", "self_", ",_", "obj_", ",_", "request_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "Tru", "e", " ", "if", " ", "`", "obj", "`", " ", "has", " ", "an", " ", "MT", "I", " ", "child", " ", "in", " ", "`", "self", ".", "child", "\\u", "model", "`.", " ", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "option", "al", " ", "2n", "d", " ", "argu", "ment", " ", "`", "request", "`", " ", "(", "pass", "ed", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "`", "Virt", "ual", "Field", ".", "value", "\\u", "from", "\\u", "object", "`)", " ", "is", " ", "ignore", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "getattr_", "(_", "obj_", ",_", "self_", "._", "child", "\\u", "model_", "._", "\\u\\u", "name\\u\\u_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "child", " ", "=", " ", "getattr", "(", "obj", ",", "self", ".", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u", ".", "lower", "())", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "if", " ", "child", " ", "is", " ", "Non", "e", ":", " ", "return", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "print", " ", "20120", "531", ",", " ", "repr", "(", "child", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "self", ".", "child", "\\u", "model", ".", "object", "s", ".", "get", "(", "pk", "=", "obj", ".", "pk", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "self_", "._", "child", "\\u", "model_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Enable", "Child_", "(_", "Virt", "ual", "Field_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "value", "\\u", "in", "\\u", "object_", "(_", "self_", ",_", "ar_", ",_", "obj_", ",_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "has", "\\u", "child_", "(_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "logg", "er", ".", "debug", "('", "set\\u", "value", "\\u", "in", "\\u", "object", " ", ":", " ", "%", "s", " ", "has", " ", "child", " ", "%", "s", "',", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "obj", ".\\u", "\\u", "class", "\\u\\u", ".\\u", "\\u", "name", "\\u\\u", ",", "self", ".", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u)", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "child", " ", "exist", "s", ",", " ", "delete", " ", "it", " ", "if", " ", "it", " ", "may", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ar_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pre", "\\u", "remove", "\\u", "child_", "._", "send_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sender_", "=_", "obj_", ",_", "request_", "=_", "ar_", "._", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "child_", "=_", "self_", "._", "child", "\\u", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "delete", "\\u", "child_", "(_", "obj_", ",_", "self_", "._", "child", "\\u", "model_", ",_", "ar_", ")_", "\\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_", "#", "~", " ", "logg", "er", ".", "debug", "('", "set\\u", "value", "\\u", "in", "\\u", "object", " ", ":", " ", "%", "s", " ", "has", " ", "no", " ", "child", " ", "%", "s", "',", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "obj", ".\\u", "\\u", "class", "\\u\\u", ".\\u", "\\u", "name", "\\u\\u", ",", "self", ".", "child", "\\u", "model", ".\\u", "\\u", "name", "\\u\\u)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "child", " ", "doe", "sn", "'", "t", " ", "exist", ".", " ", "insert", " ", "if", " ", "it", " ", "should_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ar_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pre", "\\u", "add", "\\u", "child_", "._", "send_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sender_", "=_", "obj_", ",_", "request_", "=_", "ar_", "._", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "child_", "=_", "self_", "._", "child", "\\u", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "insert", "\\u", "child_", "(_", "obj_", ",_", "self_", "._", "child", "\\u", "model_", ",_", "full", "\\u", "clean_", "=_", "True_", ")_", "\\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, 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 ]
Except block handles 'BaseException'
nymanjens/gedit-intelligent-text-completion/gedit3-0--3-7/intelligent_text_completion.py
[ { "content": " def _on_view_key_press_event(self, view, event, window):\n doc = window.get_active_document()\n try:\n return self._handle_event(view, event, window)\n except:\n err = \"Exception\\n\"\n err += traceback.format_exc()\n doc.set_text(err)", "metadata": "root.IntelligentTextCompletionPlugin._on_view_key_press_event", "header": "['class', 'IntelligentTextCompletionPlugin', '(', 'GObject', '.', 'Object', ',', 'Gedit', '.', 'WindowActivatable', ',', 'PeasGtk', '.', 'Configurable', ')', ':', '___EOS___']", "index": 66 } ]
[ { "span": "except:", "start_line": 70, "start_column": 8, "end_line": 70, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Intel", "lig", "ent", "Text", "Completi", "on", "Plugin_", "(_", "GO", "bject_", "._", "Object_", ",_", "Ge", "dit", "_", "._", "Window", "Activat", "able_", ",_", "Pea", "s", "Gtk_", "._", "Configura", "ble_", ")_", ":_", "\\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", "on", "\\u", "view", "\\u", "key", "\\u", "press", "\\u", "event_", "(_", "self_", ",_", "view_", ",_", "event_", ",_", "window_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "doc_", "=_", "window_", "._", "get", "\\u", "active", "\\u", "document_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "handle", "\\u", "event_", "(_", "view_", ",_", "event_", ",_", "window_", ")_", "\\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 ", " _", "err_", "=_", "\"", "Except", "ion", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err_", "+=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doc_", "._", "set\\u", "text_", "(_", "err_", ")_", "\\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, 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 ]
Missing call to `__init__` during object initialization
hycis/Pynet/hps/deprecated/AE.py
[ { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.AE.__init__", "header": "['class', 'AE', ':', '___EOS___']", "index": 28 }, { "content": "class AE_Testing(AE):\n\n\n", "metadata": "root.AE_Testing", "header": "['module', '___EOS___']", "index": 332 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.AE_Testing.__init__", "header": "['class', 'AE_Testing', '(', 'AE', ')', ':', '___EOS___']", "index": 334 }, { "content": "class Laura_Mapping(AE):\n", "metadata": "root.Laura_Mapping", "header": "['module', '___EOS___']", "index": 363 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.Laura_Mapping.__init__", "header": "['class', 'Laura_Mapping', '(', 'AE', ')', ':', '___EOS___']", "index": 364 }, { "content": "class Laura(AE):\n\n\n", "metadata": "root.Laura", "header": "['module', '___EOS___']", "index": 408 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.Laura.__init__", "header": "['class', 'Laura', '(', 'AE', ')', ':', '___EOS___']", "index": 410 }, { "content": "class Laura_Continue(AE):\n\n\n\n", "metadata": "root.Laura_Continue", "header": "['module', '___EOS___']", "index": 452 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.Laura_Continue.__init__", "header": "['class', 'Laura_Continue', '(', 'AE', ')', ':', '___EOS___']", "index": 454 }, { "content": "class Laura_Two_Layers(AE):\n\n\n\n", "metadata": "root.Laura_Two_Layers", "header": "['module', '___EOS___']", "index": 501 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.Laura_Two_Layers.__init__", "header": "['class', 'Laura_Two_Layers', '(', 'AE', ')', ':', '___EOS___']", "index": 503 }, { "content": "class Laura_Three_Layers(AE):\n\n\n", "metadata": "root.Laura_Three_Layers", "header": "['module', '___EOS___']", "index": 555 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.Laura_Three_Layers.__init__", "header": "['class', 'Laura_Three_Layers', '(', 'AE', ')', ':', '___EOS___']", "index": 556 }, { "content": "class Laura_Two_Layers_No_Transpose(AE):\n\n\n", "metadata": "root.Laura_Two_Layers_No_Transpose", "header": "['module', '___EOS___']", "index": 616 }, { "content": " def __init__(self, state):\n self.state = state", "metadata": "root.Laura_Two_Layers_No_Transpose.__init__", "header": "['class', 'Laura_Two_Layers_No_Transpose', '(', 'AE', ')', ':', '___EOS___']", "index": 618 } ]
[ { "span": "class AE_Testing(AE):", "start_line": 332, "start_column": 0, "end_line": 332, "end_column": 21 }, { "span": "class Laura_Mapping(AE):", "start_line": 363, "start_column": 0, "end_line": 363, "end_column": 24 }, { "span": "class Laura(AE):", "start_line": 408, "start_column": 0, "end_line": 408, "end_column": 16 }, { "span": "class Laura_Continue(AE):", "start_line": 452, "start_column": 0, "end_line": 452, "end_column": 25 }, { "span": "class Laura_Two_Layers(AE):", "start_line": 501, "start_column": 0, "end_line": 501, "end_column": 27 }, { "span": "class Laura_Three_Layers(AE):", "start_line": 555, "start_column": 0, "end_line": 555, "end_column": 29 }, { "span": "class Laura_Two_Layers_No_Transpose(AE):", "start_line": 616, "start_column": 0, "end_line": 616, "end_column": 40 } ]
[ { "span": "def __init__(self, state):", "start_line": 28, "start_column": 4, "end_line": 28, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 334, "start_column": 4, "end_line": 334, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 364, "start_column": 4, "end_line": 364, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 410, "start_column": 4, "end_line": 410, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 454, "start_column": 4, "end_line": 454, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 503, "start_column": 4, "end_line": 503, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 556, "start_column": 4, "end_line": 556, "end_column": 30 }, { "span": "def __init__(self, state):", "start_line": 618, "start_column": 4, "end_line": 618, "end_column": 30 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "AE", "_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "AE", "\\u", "Test", "ing_", "(_", "AE", "_", ")_", ":_", "\\u\\u\\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_", "AE", "\\u", "Test", "ing_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "Lau", "ra", "\\u", "Mapping_", "(_", "AE", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Lau", "ra", "\\u", "Mapping_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "Lau", "ra_", "(_", "AE", "_", ")_", ":_", "\\u\\u\\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_", "Lau", "ra_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "Lau", "ra", "\\u", "Continu", "e_", "(_", "AE", "_", ")_", ":_", "\\u\\u\\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_", "Lau", "ra", "\\u", "Continu", "e_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "Lau", "ra", "\\u", "Tw", "o", "\\u", "Layers_", "(_", "AE", "_", ")_", ":_", "\\u\\u\\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_", "Lau", "ra", "\\u", "Tw", "o", "\\u", "Layers_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "Lau", "ra", "\\u", "Thre", "e\\u", "Layers_", "(_", "AE", "_", ")_", ":_", "\\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_", "[SEP]_", "class_", "Lau", "ra", "\\u", "Thre", "e\\u", "Layers_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\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_", "Lau", "ra", "\\u", "Tw", "o", "\\u", "Layer", "s", "\\u", "No", "\\u", "Transpose", "_", "(_", "AE", "_", ")_", ":_", "\\u\\u\\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_", "Lau", "ra", "\\u", "Tw", "o", "\\u", "Layer", "s", "\\u", "No", "\\u", "Transpose", "_", "(_", "AE", "_", ")_", ":_", "\\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_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state_", "=_", "state_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
AppScale/appscale/AppServer/google/appengine/api/images/images_stub.py
[ { "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Google Inc.\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\n\n\n\n\"\"\"Stub version of the images API.\"\"\"\n\n\n\n\n\n\n\nimport datetime\nimport logging\nimport re\nimport time\nimport StringIO\n\ntry:\n import json as simplejson\nexcept ImportError:\n import simplejson\n\ntry:\n import PIL\n from PIL import _imaging\n from PIL import Image\nexcept ImportError:\n import _imaging\n # Try importing the 'Image' module directly. If that fails, try\n # importing it from the 'PIL' package (this is necessary to also\n # cover \"pillow\" package installations).\n try:\n import Image\n except ImportError:\n from PIL import Image\n\nfrom google.appengine.api import apiproxy_stub\nfrom google.appengine.api import apiproxy_stub_map\nfrom google.appengine.api import blobstore\nfrom google.appengine.api import datastore\nfrom google.appengine.api import datastore_errors\nfrom google.appengine.api import datastore_types\nfrom google.appengine.api import images\nfrom google.appengine.api.images import images_blob_stub\nfrom google.appengine.api.images import images_service_pb\nfrom google.appengine.runtime import apiproxy_errors\n\n\n\n\n\nGS_INFO_KIND = \"__GsFileInfo__\"\n\nBLOB_SERVING_URL_KIND = images_blob_stub.BLOB_SERVING_URL_KIND\n\nMAX_REQUEST_SIZE = 32 << 20\n\n\n_EXIF_ORIENTATION_TAG = 274\n\n\n_EXIF_DATETIMEORIGINAL_TAG = 36867\n\n\n_EXIF_TAGS = {\n 256: \"ImageWidth\",\n 257: \"ImageLength\",\n 271: \"Make\",\n 272: \"Model\",\n _EXIF_ORIENTATION_TAG: \"Orientation\",\n 305: \"Software\",\n 306: \"DateTime\",\n 34855: \"ISOSpeedRatings\",\n _EXIF_DATETIMEORIGINAL_TAG: \"DateTimeOriginal\",\n 36868: \"DateTimeDigitized\",\n 37383: \"MeteringMode\",\n 37385: \"Flash\",\n 41987: \"WhiteBallance\"}\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def _ArgbToRgbaTuple(argb):\n \"\"\"Convert from a single ARGB value to a tuple containing RGBA.\n\n Args:\n argb: Signed 32 bit integer containing an ARGB value.\n\n Returns:\n RGBA tuple.\n \"\"\"\n\n unsigned_argb = argb % 0x100000000\n return ((unsigned_argb >> 16) & 0xFF,\n (unsigned_argb >> 8) & 0xFF,\n unsigned_argb & 0xFF,\n (unsigned_argb >> 24) & 0xFF)", "metadata": "root._ArgbToRgbaTuple", "header": "['module', '___EOS___']", "index": 97 }, { "content": "def _BackendPremultiplication(color):\n \"\"\"Apply premultiplication and unpremultiplication to match production.\n\n Args:\n color: color tuple as returned by _ArgbToRgbaTuple.\n\n Returns:\n RGBA tuple.\n \"\"\"\n\n\n\n\n alpha = color[3]\n rgb = color[0:3]\n multiplied = [(x * (alpha + 1)) >> 8 for x in rgb]\n if alpha:\n alpha_inverse = 0xffffff / alpha\n unmultiplied = [(x * alpha_inverse) >> 16 for x in multiplied]\n else:\n unmultiplied = [0] * 3\n\n return tuple(unmultiplied + [alpha])", "metadata": "root._BackendPremultiplication", "header": "['module', '___EOS___']", "index": 114 }, { "content": "class ImagesServiceStub(apiproxy_stub.APIProxyStub):\n \"\"\"Stub version of images API to be used with the dev_appserver.\"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.ImagesServiceStub", "header": "['module', '___EOS___']", "index": 139 }, { "content": " def __init__(self, service_name=\"images\", host_prefix=\"\"):\n \"\"\"Preloads PIL to load all modules in the unhardened environment.\n\n Args:\n service_name: Service name expected for all calls.\n host_prefix: the URL prefix (protocol://host:port) to preprend to\n image urls on a call to GetUrlBase.\n \"\"\"\n super(ImagesServiceStub, self).__init__(service_name,\n max_request_size=MAX_REQUEST_SIZE)\n self._blob_stub = images_blob_stub.ImagesBlobStub(host_prefix)\n Image.init()", "metadata": "root.ImagesServiceStub.__init__", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 142 }, { "content": " def _Dynamic_Composite(self, request, response):\n \"\"\"Implementation of ImagesService::Composite.\n\n Based off documentation of the PIL library at\n http://www.pythonware.com/library/pil/handbook/index.htm\n\n Args:\n request: ImagesCompositeRequest, contains image request info.\n response: ImagesCompositeResponse, contains transformed image.\n \"\"\"\n width = request.canvas().width()\n height = request.canvas().height()\n color = _ArgbToRgbaTuple(request.canvas().color())\n\n\n color = _BackendPremultiplication(color)\n canvas = Image.new(\"RGBA\", (width, height), color)\n sources = []\n if (not request.canvas().width() or request.canvas().width() > 4000 or\n not request.canvas().height() or request.canvas().height() > 4000):\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n if not request.image_size():\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n if not request.options_size():\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n if request.options_size() > images.MAX_COMPOSITES_PER_REQUEST:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n for image in request.image_list():\n sources.append(self._OpenImageData(image))\n\n for options in request.options_list():\n if (options.anchor() < images.TOP_LEFT or\n options.anchor() > images.BOTTOM_RIGHT):\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n if options.source_index() >= len(sources) or options.source_index() < 0:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n if options.opacity() < 0 or options.opacity() > 1:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n source = sources[options.source_index()]\n x_anchor = (options.anchor() % 3) * 0.5\n y_anchor = (options.anchor() / 3) * 0.5\n x_offset = int(options.x_offset() + x_anchor * (width - source.size[0]))\n y_offset = int(options.y_offset() + y_anchor * (height - source.size[1]))\n if source.mode == \"RGBA\":\n canvas.paste(source, (x_offset, y_offset), source)\n else:\n alpha = options.opacity() * 255\n mask = Image.new(\"L\", source.size, alpha)\n canvas.paste(source, (x_offset, y_offset), mask)\n response_value = self._EncodeImage(canvas, request.canvas().output())\n response.mutable_image().set_content(response_value)", "metadata": "root.ImagesServiceStub._Dynamic_Composite", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 155 }, { "content": " def _Dynamic_Histogram(self, request, response):\n \"\"\"Trivial implementation of ImagesService::Histogram.\n\n Based off documentation of the PIL library at\n http://www.pythonware.com/library/pil/handbook/index.htm\n\n Args:\n request: ImagesHistogramRequest, contains the image.\n response: ImagesHistogramResponse, contains histogram of the image.\n \"\"\"\n image = self._OpenImageData(request.image())\n\n img_format = image.format\n if img_format not in (\"BMP\", \"GIF\", \"ICO\", \"JPEG\", \"PNG\", \"TIFF\", \"WEBP\"):\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.NOT_IMAGE)\n image = image.convert(\"RGBA\")\n red = [0] * 256\n green = [0] * 256\n blue = [0] * 256\n\n\n\n\n for pixel in image.getdata():\n red[int((pixel[0] * pixel[3]) / 255)] += 1\n green[int((pixel[1] * pixel[3]) / 255)] += 1\n blue[int((pixel[2] * pixel[3]) / 255)] += 1\n histogram = response.mutable_histogram()\n for value in red:\n histogram.add_red(value)\n for value in green:\n histogram.add_green(value)\n for value in blue:\n histogram.add_blue(value)", "metadata": "root.ImagesServiceStub._Dynamic_Histogram", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 214 }, { "content": " def _Dynamic_Transform(self, request, response):\n \"\"\"Trivial implementation of ImagesService::Transform.\n\n Based off documentation of the PIL library at\n http://www.pythonware.com/library/pil/handbook/index.htm\n\n Args:\n request: ImagesTransformRequest, contains image request info.\n response: ImagesTransformResponse, contains transformed image.\n \"\"\"\n original_image = self._OpenImageData(request.image())\n\n input_settings = request.input()\n correct_orientation = (\n input_settings.has_correct_exif_orientation() and\n input_settings.correct_exif_orientation() ==\n images_service_pb.InputSettings.CORRECT_ORIENTATION)\n\n\n\n source_metadata = self._ExtractMetadata(\n original_image, input_settings.parse_metadata())\n if input_settings.parse_metadata():\n logging.info(\n \"Once the application is deployed, a more powerful metadata \"\n \"extraction will be performed which might return many more fields.\")\n\n new_image = self._ProcessTransforms(original_image,\n request.transform_list(),\n correct_orientation)\n\n substitution_rgb = None\n if input_settings.has_transparent_substitution_rgb():\n substitution_rgb = input_settings.transparent_substitution_rgb()\n response_value = self._EncodeImage(new_image,\n request.output(),\n substitution_rgb)\n response.mutable_image().set_content(response_value)\n response.set_source_metadata(source_metadata)", "metadata": "root.ImagesServiceStub._Dynamic_Transform", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 250 }, { "content": " def _Dynamic_GetUrlBase(self, request, response):\n self._blob_stub.GetUrlBase(request, response)", "metadata": "root.ImagesServiceStub._Dynamic_GetUrlBase", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 290 }, { "content": " def _Dynamic_DeleteUrlBase(self, request, response):\n self._blob_stub.DeleteUrlBase(request, response)", "metadata": "root.ImagesServiceStub._Dynamic_DeleteUrlBase", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 293 }, { "content": " def _EncodeImage(self, image, output_encoding, substitution_rgb=None):\n \"\"\"Encode the given image and return it in string form.\n\n Args:\n image: PIL Image object, image to encode.\n output_encoding: ImagesTransformRequest.OutputSettings object.\n substitution_rgb: The color to use for transparent pixels if the output\n format does not support transparency.\n\n Returns:\n str with encoded image information in given encoding format.\n \"\"\"\n image_string = StringIO.StringIO()\n\n image_encoding = \"PNG\"\n\n if (output_encoding.mime_type() == images_service_pb.OutputSettings.WEBP):\n image_encoding = \"WEBP\"\n\n if (output_encoding.mime_type() == images_service_pb.OutputSettings.JPEG):\n image_encoding = \"JPEG\"\n\n\n\n\n\n\n if substitution_rgb:\n\n\n\n blue = substitution_rgb & 0xFF\n green = (substitution_rgb >> 8) & 0xFF\n red = (substitution_rgb >> 16) & 0xFF\n background = Image.new(\"RGB\", image.size, (red, green, blue))\n background.paste(image, mask=image.split()[3])\n image = background\n else:\n image = image.convert(\"RGB\")\n\n image.save(image_string, image_encoding)\n\n return image_string.getvalue()", "metadata": "root.ImagesServiceStub._EncodeImage", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 296 }, { "content": " def _OpenImageData(self, image_data):\n \"\"\"Open image data from ImageData protocol buffer.\n\n Args:\n image_data: ImageData protocol buffer containing image data or blob\n reference.\n\n Returns:\n Image containing the image data passed in or reference by blob-key.\n\n Raises:\n ApplicationError if both content and blob-key are provided.\n NOTE: 'content' must always be set because it is a required field,\n however, it must be the empty string when a blob-key is provided.\n \"\"\"\n if image_data.content() and image_data.has_blob_key():\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.INVALID_BLOB_KEY)\n\n if image_data.has_blob_key():\n image = self._OpenBlob(image_data.blob_key())\n else:\n image = self._OpenImage(image_data.content())\n\n\n img_format = image.format\n if img_format not in (\"BMP\", \"GIF\", \"ICO\", \"JPEG\", \"PNG\", \"TIFF\", \"WEBP\"):\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.NOT_IMAGE)\n return image", "metadata": "root.ImagesServiceStub._OpenImageData", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 340 }, { "content": " def _OpenImage(self, image):\n \"\"\"Opens an image provided as a string.\n\n Args:\n image: image data to be opened\n\n Raises:\n apiproxy_errors.ApplicationError if the image cannot be opened or if it\n is an unsupported format.\n\n Returns:\n Image containing the image data passed in.\n \"\"\"\n if not image:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.NOT_IMAGE)\n\n image = StringIO.StringIO(image)\n try:\n return Image.open(image)\n except IOError:\n\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_IMAGE_DATA)", "metadata": "root.ImagesServiceStub._OpenImage", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 371 }, { "content": " def _OpenBlob(self, blob_key):\n \"\"\"Create an Image from the blob data read from blob_key.\"\"\"\n\n storage_key = None\n\n try:\n gs_info = datastore.Get(\n datastore.Key.from_path(GS_INFO_KIND,\n blob_key,\n namespace=''))\n storage_key = gs_info['storage_key']\n except datastore_errors.EntityNotFoundError:\n pass\n\n if not storage_key:\n try:\n key = datastore_types.Key.from_path(blobstore.BLOB_INFO_KIND,\n blob_key,\n namespace='')\n datastore.Get(key)\n storage_key = blob_key\n except datastore_errors.Error:\n\n\n logging.exception('Blob with key %r does not exist', blob_key)\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.UNSPECIFIED_ERROR)\n\n blobstore_stub = apiproxy_stub_map.apiproxy.GetStub(\"blobstore\")\n\n\n try:\n blob_file = blobstore_stub.storage.OpenBlob(storage_key)\n except IOError:\n logging.exception(\"Could not get file for blob_key %r\", blob_key)\n\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_IMAGE_DATA)\n\n try:\n return Image.open(blob_file)\n except IOError:\n logging.exception(\"Could not open image %r for blob_key %r\",\n blob_file, blob_key)\n\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_IMAGE_DATA)", "metadata": "root.ImagesServiceStub._OpenBlob", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 396 }, { "content": " def _ValidateCropArg(self, arg):\n \"\"\"Check an argument for the Crop transform.\n\n Args:\n arg: float, argument to Crop transform to check.\n\n Raises:\n apiproxy_errors.ApplicationError on problem with argument.\n \"\"\"\n if not isinstance(arg, float):\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n\n if not (0 <= arg <= 1.0):\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)", "metadata": "root.ImagesServiceStub._ValidateCropArg", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 444 }, { "content": " def _CalculateNewDimensions(self,\n current_width,\n current_height,\n req_width,\n req_height,\n crop_to_fit,\n allow_stretch):\n \"\"\"Get new resize dimensions keeping the current aspect ratio.\n\n This uses the more restricting of the two requested values to determine\n the new ratio. See also crop_to_fit.\n\n Args:\n current_width: int, current width of the image.\n current_height: int, current height of the image.\n req_width: int, requested new width of the image, 0 if unspecified.\n req_height: int, requested new height of the image, 0 if unspecified.\n crop_to_fit: bool, True if the less restricting dimension should be used.\n allow_stretch: bool, True is aspect ratio should be ignored.\n\n Raises:\n apiproxy_errors.ApplicationError: if crop_to_fit is True either req_width\n or req_height is 0.\n\n Returns:\n tuple (width, height) which are both ints of the new ratio.\n \"\"\"\n\n\n width_ratio = float(req_width) / current_width\n height_ratio = float(req_height) / current_height\n\n if allow_stretch:\n\n if not req_width or not req_height:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n return req_width, req_height\n elif crop_to_fit:\n\n if not req_width or not req_height:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n if width_ratio > height_ratio:\n return req_width, int(width_ratio * current_height)\n else:\n return int(height_ratio * current_width), req_height\n else:\n\n\n if req_width == 0 or (width_ratio > height_ratio and req_height != 0):\n\n return int(height_ratio * current_width), req_height\n else:\n\n return req_width, int(width_ratio * current_height)", "metadata": "root.ImagesServiceStub._CalculateNewDimensions", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 461 }, { "content": " def _Resize(self, image, transform):\n \"\"\"Use PIL to resize the given image with the given transform.\n\n Args:\n image: PIL.Image.Image object to resize.\n transform: images_service_pb.Transform to use when resizing.\n\n Returns:\n PIL.Image.Image with transforms performed on it.\n\n Raises:\n BadRequestError if the resize data given is bad.\n \"\"\"\n width = 0\n height = 0\n\n if transform.has_width():\n width = transform.width()\n if width < 0 or 4000 < width:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n\n if transform.has_height():\n height = transform.height()\n if height < 0 or 4000 < height:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n\n crop_to_fit = transform.crop_to_fit()\n allow_stretch = transform.allow_stretch()\n\n current_width, current_height = image.size\n new_width, new_height = self._CalculateNewDimensions(current_width,\n current_height,\n width,\n height,\n crop_to_fit,\n allow_stretch)\n new_image = image.resize((new_width, new_height), Image.ANTIALIAS)\n if crop_to_fit and (new_width > width or new_height > height):\n\n left = int((new_width - width) * transform.crop_offset_x())\n top = int((new_height - height) * transform.crop_offset_y())\n right = left + width\n bottom = top + height\n new_image = new_image.crop((left, top, right, bottom))\n\n return new_image", "metadata": "root.ImagesServiceStub._Resize", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 518 }, { "content": " def _Rotate(self, image, transform):\n \"\"\"Use PIL to rotate the given image with the given transform.\n\n Args:\n image: PIL.Image.Image object to rotate.\n transform: images_service_pb.Transform to use when rotating.\n\n Returns:\n PIL.Image.Image with transforms performed on it.\n\n Raises:\n BadRequestError if the rotate data given is bad.\n \"\"\"\n degrees = transform.rotate()\n if degrees < 0 or degrees % 90 != 0:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n degrees %= 360\n\n\n degrees = 360 - degrees\n return image.rotate(degrees)", "metadata": "root.ImagesServiceStub._Rotate", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 567 }, { "content": " def _Crop(self, image, transform):\n \"\"\"Use PIL to crop the given image with the given transform.\n\n Args:\n image: PIL.Image.Image object to crop.\n transform: images_service_pb.Transform to use when cropping.\n\n Returns:\n PIL.Image.Image with transforms performed on it.\n\n Raises:\n BadRequestError if the crop data given is bad.\n \"\"\"\n left_x = 0.0\n top_y = 0.0\n right_x = 1.0\n bottom_y = 1.0\n\n if transform.has_crop_left_x():\n left_x = transform.crop_left_x()\n self._ValidateCropArg(left_x)\n\n if transform.has_crop_top_y():\n top_y = transform.crop_top_y()\n self._ValidateCropArg(top_y)\n\n if transform.has_crop_right_x():\n right_x = transform.crop_right_x()\n self._ValidateCropArg(right_x)\n\n if transform.has_crop_bottom_y():\n bottom_y = transform.crop_bottom_y()\n self._ValidateCropArg(bottom_y)\n\n\n width, height = image.size\n\n box = (int(round(left_x * width)),\n int(round(top_y * height)),\n int(round(right_x * width)),\n int(round(bottom_y * height)))\n\n return image.crop(box)", "metadata": "root.ImagesServiceStub._Crop", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 590 }, { "content": " @staticmethod\n def _GetExifFromImage(image):\n if hasattr(image, \"_getexif\"):\n\n\n\n\n\n try:\n from PIL import TiffImagePlugin\n return image._getexif()\n except ImportError:\n # We have not managed to get this to work in the SDK with Python\n # 2.5, so just catch the ImportError and pretend there is no\n # EXIF information of interest.\n logging.info('Sorry, TiffImagePlugin does not work in this environment')\n return None", "metadata": "root.ImagesServiceStub._GetExifFromImage", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 634 }, { "content": " @staticmethod\n def _ExtractMetadata(image, parse_metadata):\n \"\"\"Extract EXIF metadata from the image.\n\n Note that this is a much simplified version of metadata extraction. After\n deployment applications have access to a more powerful parser that can\n parse hundreds of fields from images.\n\n Args:\n image: PIL Image object.\n parse_metadata: bool, True if metadata parsing has been requested. If\n False the result will contain image dimensions.\n Returns:\n str, JSON encoded values with various metadata fields.\n \"\"\"\n\n def ExifTimeToUnixtime(exif_time):\n \"\"\"Convert time in EXIF to unix time.\n\n Args:\n exif_time: str, the time from the EXIF block formated by EXIF standard.\n E.g., \"2011:02:20 10:23:12\", seconds are optional.\n\n Returns:\n Integer, the time in unix fromat: seconds since the epoch.\n \"\"\"\n regexp = re.compile(r\"^([0-9]{4}):([0-9]{1,2}):([0-9]{1,2})\"\n \" ([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2}))?\")\n match = regexp.match(exif_time)\n if match is None: return None\n try:\n date = datetime.datetime(*map(int, filter(None, match.groups())))\n except ValueError:\n logging.info(\"Invalid date in EXIF: %s\", exif_time)\n return None\n return int(time.mktime(date.timetuple()))\n\n metadata_dict = (\n parse_metadata and ImagesServiceStub._GetExifFromImage(image) or {})\n\n metadata_dict[256], metadata_dict[257] = image.size\n\n\n\n if _EXIF_DATETIMEORIGINAL_TAG in metadata_dict:\n date_ms = ExifTimeToUnixtime(metadata_dict[_EXIF_DATETIMEORIGINAL_TAG])\n if date_ms:\n metadata_dict[_EXIF_DATETIMEORIGINAL_TAG] = date_ms\n else:\n del metadata_dict[_EXIF_DATETIMEORIGINAL_TAG]\n metadata = dict([(_EXIF_TAGS[k], v)\n for k, v in metadata_dict.iteritems()\n if k in _EXIF_TAGS])\n return simplejson.dumps(metadata)", "metadata": "root.ImagesServiceStub._ExtractMetadata", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 652 }, { "content": " def _CorrectOrientation(self, image, orientation):\n \"\"\"Use PIL to correct the image orientation based on its EXIF.\n\n See JEITA CP-3451 at http://www.exif.org/specifications.html,\n Exif 2.2, page 18.\n\n Args:\n image: source PIL.Image.Image object.\n orientation: integer in range (1,8) inclusive, corresponding the image\n orientation from EXIF.\n\n Returns:\n PIL.Image.Image with transforms performed on it. If no correction was\n done, it returns the input image.\n \"\"\"\n\n\n if orientation == 2:\n image = image.transpose(Image.FLIP_LEFT_RIGHT)\n elif orientation == 3:\n image = image.rotate(180)\n elif orientation == 4:\n image = image.transpose(Image.FLIP_TOP_BOTTOM)\n elif orientation == 5:\n image = image.transpose(Image.FLIP_TOP_BOTTOM)\n image = image.rotate(270)\n elif orientation == 6:\n image = image.rotate(270)\n elif orientation == 7:\n image = image.transpose(Image.FLIP_LEFT_RIGHT)\n image = image.rotate(270)\n elif orientation == 8:\n image = image.rotate(90)\n\n return image", "metadata": "root.ImagesServiceStub._CorrectOrientation", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 707 }, { "content": " def _ProcessTransforms(self, image, transforms, correct_orientation):\n \"\"\"Execute PIL operations based on transform values.\n\n Args:\n image: PIL.Image.Image instance, image to manipulate.\n transforms: list of ImagesTransformRequest.Transform objects.\n correct_orientation: True to indicate that image orientation should be\n corrected based on its EXIF.\n Returns:\n PIL.Image.Image with transforms performed on it.\n\n Raises:\n BadRequestError if we are passed more than one of the same type of\n transform.\n \"\"\"\n new_image = image\n if len(transforms) > images.MAX_TRANSFORMS_PER_REQUEST:\n raise apiproxy_errors.ApplicationError(\n images_service_pb.ImagesServiceError.BAD_TRANSFORM_DATA)\n\n orientation = 1\n if correct_orientation:\n\n\n exif = self._GetExifFromImage(image)\n if not exif or _EXIF_ORIENTATION_TAG not in exif:\n correct_orientation = False\n else:\n orientation = exif[_EXIF_ORIENTATION_TAG]\n\n width, height = new_image.size\n if height > width:\n orientation = 1\n\n for transform in transforms:\n\n\n\n\n\n\n\n if (correct_orientation and\n not (transform.has_crop_left_x() or\n transform.has_crop_top_y() or\n transform.has_crop_right_x() or\n transform.has_crop_bottom_y()) and\n not transform.has_horizontal_flip() and\n not transform.has_vertical_flip()):\n new_image = self._CorrectOrientation(new_image, orientation)\n correct_orientation = False\n\n if transform.has_width() or transform.has_height():\n\n new_image = self._Resize(new_image, transform)\n\n elif transform.has_rotate():\n\n new_image = self._Rotate(new_image, transform)\n\n elif transform.has_horizontal_flip():\n\n new_image = new_image.transpose(Image.FLIP_LEFT_RIGHT)\n\n elif transform.has_vertical_flip():\n\n new_image = new_image.transpose(Image.FLIP_TOP_BOTTOM)\n\n elif (transform.has_crop_left_x() or\n transform.has_crop_top_y() or\n transform.has_crop_right_x() or\n transform.has_crop_bottom_y()):\n\n new_image = self._Crop(new_image, transform)\n\n elif transform.has_autolevels():\n\n\n logging.info(\"I'm Feeling Lucky autolevels will be visible once this \"\n \"application is deployed.\")\n else:\n logging.warn(\"Found no transformations found to perform.\")\n\n if correct_orientation:\n\n\n new_image = self._CorrectOrientation(new_image, orientation)\n correct_orientation = False\n\n\n\n\n return new_image", "metadata": "root.ImagesServiceStub._ProcessTransforms", "header": "['class', 'ImagesServiceStub', '(', 'apiproxy_stub', '.', 'APIProxyStub', ')', ':', '___EOS___']", "index": 743 } ]
[ { "span": "import PIL", "start_line": 40, "start_column": 2, "end_line": 40, "end_column": 12 }, { "span": "from PIL import _imaging", "start_line": 41, "start_column": 2, "end_line": 41, "end_column": 26 }, { "span": "import _imaging", "start_line": 44, "start_column": 2, "end_line": 44, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2007", " ", "Goo", "gle", " ", "Inc", "._", "\\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_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Stu", "b", " ", "version", " ", "of", " ", "the", " ", "images", " ", "API", ".\"\"\"_", "\\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\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "json_", "as_", "simplejson_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "simplejson_", "\\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_", "PIL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "PIL_", "import_", "\\u", "imagin", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "\\u", "imagin", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "import", "ing", " ", "the", " ", "'", "Image", "'", " ", "module", " ", "direct", "ly", ".", " ", "If", " ", "tha", "t", " ", "fail", "s", ",", " ", "try_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "import", "ing", " ", "it", " ", "from", " ", "the", " ", "'", "PI", "L", "'", " ", "package", " ", "(", "this", " ", "is", " ", "necessar", "y", " ", "to", " ", "als", "o_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cover", " ", "\"", "pill", "ow", "\"", " ", "package", " ", "installation", "s", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "Image_", "\\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 ", " _", "from_", "PIL_", "import_", "Image_", "\\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_", "google_", "._", "appengine_", "._", "api_", "import_", "api", "proxy", "\\u", "stub_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "api", "proxy", "\\u", "stub", "\\u", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "blobs", "tore_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "datastore_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "datast", "ore", "\\u", "errors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "datast", "ore", "\\u", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "images_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "._", "images_", "import_", "images", "\\u", "blob", "\\u", "stub_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "._", "images_", "import_", "images", "\\u", "service", "\\u", "pb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "runtime_", "import_", "api", "proxy", "\\u", "errors_", "\\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_", "GS", "\\u", "INFO", "\\u", "KIND", "_", "=_", "\"\\u\\u", "Gs", "File", "Info", "\\u\\u\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "BLOB", "\\u", "SERV", "ING", "\\u", "URL", "\\u", "KIND", "_", "=_", "images", "\\u", "blob", "\\u", "stub_", "._", "BLOB", "\\u", "SERV", "ING", "\\u", "URL", "\\u", "KIND", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "MAX", "\\u", "REQUEST", "\\u", "SIZE_", "=_", "32_", "<<_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "EX", "IF", "\\u", "ORIE", "NTA", "TIO", "N", "\\u", "TAG_", "=_", "274", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "EX", "IF", "\\u", "DATETIME", "ORIGIN", "AL", "\\u", "TAG_", "=_", "368", "67_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "EX", "IF", "\\u", "TAGS_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "256_", ":_", "\"", "Image", "Wid", "th", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "257_", ":_", "\"", "Image", "Length", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "271", "_", ":_", "\"", "Make", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "272", "_", ":_", "\"", "Model", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "EX", "IF", "\\u", "ORIE", "NTA", "TIO", "N", "\\u", "TAG_", ":_", "\"", "Orient", "ation", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "305_", ":_", "\"", "Sof", "twa", "re", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "306", "_", ":_", "\"", "Date", "Time", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "348", "55_", ":_", "\"", "ISO", "Spee", "d", "Rati", "ngs", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "EX", "IF", "\\u", "DATETIME", "ORIGIN", "AL", "\\u", "TAG_", ":_", "\"", "Date", "Time", "Origina", "l", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "368", "68_", ":_", "\"", "Date", "Time", "Digit", "ize", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "373", "83_", ":_", "\"", "Meter", "ing", "Mode", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "373", "85_", ":_", "\"", "Fla", "sh", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "419", "87_", ":_", "\"", "White", "Ball", "anc", "e", "\"_", "}_", "\\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\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "Arg", "b", "To", "Rg", "ba", "Tuple_", "(_", "arg", "b_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Convert", " ", "from", " ", "a", " ", "single", " ", "ARG", "B", " ", "value", " ", "to", " ", "a", " ", "tuple", " ", "contain", "ing", " ", "RGB", "A", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "arg", "b", ":", " ", "Signe", "d", " ", "32", " ", "bit", " ", "integ", "er", " ", "contain", "ing", " ", "an", " ", "ARG", "B", " ", "value", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "RGB", "A", " ", "tuple", ".", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "unsigned", "\\u", "arg", "b_", "=_", "arg", "b_", "%_", "0x10000", "0000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "(_", "unsigned", "\\u", "arg", "b_", ">>_", "16_", ")_", "&_", "0xFF_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "unsigned", "\\u", "arg", "b_", ">>_", "8_", ")_", "&_", "0xFF_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unsigned", "\\u", "arg", "b_", "&_", "0xFF_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "unsigned", "\\u", "arg", "b_", ">>_", "24_", ")_", "&_", "0xFF_", ")_", "\\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", "Back", "end", "Prem", "ulti", "pli", "cation", "_", "(_", "color_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Apply", " ", "prem", "ulti", "pli", "cation", " ", "and", " ", "unpr", "emu", "lti", "pli", "cation", " ", "to", " ", "match", " ", "producti", "on", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "color", ":", " ", "color", " ", "tuple", " ", "as", " ", "return", "ed", " ", "by", " ", "\\u", "Arg", "b", "To", "Rg", "ba", "Tup", "le", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "RGB", "A", " ", "tuple", ".", "\\", "10", ";", " ", " ", "\"\"\"_", "\\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_", "alpha_", "=_", "color_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rgb_", "=_", "color_", "[_", "0_", ":_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "multiplie", "d_", "=_", "[_", "(_", "x_", "*_", "(_", "alpha_", "+_", "1_", ")_", ")_", ">>_", "8_", "for_", "x_", "in_", "rgb_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "alpha_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alpha", "\\u", "inverse_", "=_", "0xfff", "fff", "_", "/_", "alpha_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unm", "ulti", "pli", "ed_", "=_", "[_", "(_", "x_", "*_", "alpha", "\\u", "inverse_", ")_", ">>_", "16_", "for_", "x_", "in_", "multiplie", "d_", "]_", "\\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 ", " _", "unm", "ulti", "pli", "ed_", "=_", "[_", "0_", "]_", "*_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "tuple_", "(_", "unm", "ulti", "pli", "ed_", "+_", "[_", "alpha_", "]_", ")_", "\\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_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Stu", "b", " ", "version", " ", "of", " ", "images", " ", "API", " ", "to", " ", "be", " ", "used", " ", "with", " ", "the", " ", "dev", "\\u", "appse", "rver", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "service", "\\u", "name_", "=_", "\"", "images", "\"_", ",_", "host", "\\u", "prefix_", "=_", "\"\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Pre", "load", "s", " ", "PI", "L", " ", "to", " ", "load", " ", "all", " ", "module", "s", " ", "in", " ", "the", " ", "unh", "ard", "ened", " ", "environ", "ment", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "service", "\\u", "name", ":", " ", "Service", " ", "name", " ", "expected", " ", "for", " ", "all", " ", "calls", ".", "\\", "10", ";", " ", " ", "host", "\\u", "prefix", ":", " ", "the", " ", "URL", " ", "prefix", " ", "(", "protoc", "ol", "://", "host", ":", "port", ")", " ", "to", " ", "prep", "rend", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "image", " ", "urls", " ", "on", " ", "a", " ", "call", " ", "to", " ", "Get", "Ur", "l", "Base", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Image", "s", "Service", "Stub_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "service", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "request", "\\u", "size_", "=_", "MAX", "\\u", "REQUEST", "\\u", "SIZE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "blob", "\\u", "stub_", "=_", "images", "\\u", "blob", "\\u", "stub_", "._", "Image", "s", "Blo", "b", "Stub_", "(_", "host", "\\u", "prefix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Image_", "._", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Dynamic", "\\u", "Composit", "e_", "(_", "self_", ",_", "request_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Implementation", " ", "of", " ", "Image", "s", "Service", "::", "Composit", "e", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Base", "d", " ", "off", " ", "documentation", " ", "of", " ", "the", " ", "PI", "L", " ", "librar", "y", " ", "at", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", ".", "python", "ware", ".", "com", "/", "librar", "y", "/", "pil", "/", "hand", "book", "/", "index", ".", "ht", "m", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "request", ":", " ", "Image", "s", "Composit", "e", "Request", ",", " ", "contain", "s", " ", "image", " ", "request", " ", "info", ".", "\\", "10", ";", " ", " ", "response", ":", " ", "Image", "s", "Composit", "e", "Respons", "e", ",", " ", "contain", "s", " ", "transforme", "d", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "width_", "=_", "request_", "._", "canvas_", "(_", ")_", "._", "width_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "height_", "=_", "request_", "._", "canvas_", "(_", ")_", "._", "height_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "color_", "=_", "\\u", "Arg", "b", "To", "Rg", "ba", "Tuple_", "(_", "request_", "._", "canvas_", "(_", ")_", "._", "color_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "\\u", "Back", "end", "Prem", "ulti", "pli", "cation", "_", "(_", "color_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "canvas_", "=_", "Image_", "._", "new_", "(_", "\"", "RGB", "A", "\"_", ",_", "(_", "width_", ",_", "height_", ")_", ",_", "color_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sources_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "request_", "._", "canvas_", "(_", ")_", "._", "width_", "(_", ")_", "or_", "request_", "._", "canvas_", "(_", ")_", "._", "width_", "(_", ")_", ">_", "4000_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "request_", "._", "canvas_", "(_", ")_", "._", "height_", "(_", ")_", "or_", "request_", "._", "canvas_", "(_", ")_", "._", "height_", "(_", ")_", ">_", "4000_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "request_", "._", "image", "\\u", "size_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "request_", "._", "options", "\\u", "size_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "options", "\\u", "size_", "(_", ")_", ">_", "images_", "._", "MAX", "\\u", "COMPO", "SITE", "S", "\\u", "PER", "\\u", "REQUEST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "image_", "in_", "request_", "._", "image", "\\u", "list_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sources_", "._", "append_", "(_", "self_", "._", "\\u", "Open", "Image", "Data_", "(_", "image_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "options_", "in_", "request_", "._", "options", "\\u", "list_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "options_", "._", "anchor_", "(_", ")_", "<_", "images_", "._", "TOP", "\\u", "LEFT_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "options_", "._", "anchor_", "(_", ")_", ">_", "images_", "._", "BOT", "TOM", "\\u", "RIGHT_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "source", "\\u", "index_", "(_", ")_", ">=_", "len_", "(_", "sources_", ")_", "or_", "options_", "._", "source", "\\u", "index_", "(_", ")_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "opacity_", "(_", ")_", "<_", "0_", "or_", "options_", "._", "opacity_", "(_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "source_", "=_", "sources_", "[_", "options_", "._", "source", "\\u", "index_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "\\u", "anchor_", "=_", "(_", "options_", "._", "anchor_", "(_", ")_", "%_", "3_", ")_", "*_", "0.5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y", "\\u", "anchor_", "=_", "(_", "options_", "._", "anchor_", "(_", ")_", "/_", "3_", ")_", "*_", "0.5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "\\u", "offset_", "=_", "int_", "(_", "options_", "._", "x", "\\u", "offset_", "(_", ")_", "+_", "x", "\\u", "anchor_", "*_", "(_", "width_", "-_", "source_", "._", "size_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y", "\\u", "offset_", "=_", "int_", "(_", "options_", "._", "y", "\\u", "offset_", "(_", ")_", "+_", "y", "\\u", "anchor_", "*_", "(_", "height_", "-_", "source_", "._", "size_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "source_", "._", "mode_", "==_", "\"", "RGB", "A", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "canvas_", "._", "paste_", "(_", "source_", ",_", "(_", "x", "\\u", "offset_", ",_", "y", "\\u", "offset_", ")_", ",_", "source_", ")_", "\\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 ", " _", "alpha_", "=_", "options_", "._", "opacity_", "(_", ")_", "*_", "255_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mask_", "=_", "Image_", "._", "new_", "(_", "\"", "L", "\"_", ",_", "source_", "._", "size_", ",_", "alpha_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "canvas_", "._", "paste_", "(_", "source_", ",_", "(_", "x", "\\u", "offset_", ",_", "y", "\\u", "offset_", ")_", ",_", "mask_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "value_", "=_", "self_", "._", "\\u", "Encode", "Image_", "(_", "canvas_", ",_", "request_", "._", "canvas_", "(_", ")_", "._", "output_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "mutable", "\\u", "image_", "(_", ")_", "._", "set\\u", "content_", "(_", "response", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Dynamic", "\\u", "Histogram", "_", "(_", "self_", ",_", "request_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Tri", "via", "l", " ", "implementation", " ", "of", " ", "Image", "s", "Service", "::", "Histogram", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Base", "d", " ", "off", " ", "documentation", " ", "of", " ", "the", " ", "PI", "L", " ", "librar", "y", " ", "at", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", ".", "python", "ware", ".", "com", "/", "librar", "y", "/", "pil", "/", "hand", "book", "/", "index", ".", "ht", "m", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "request", ":", " ", "Image", "s", "Histogram", "Request", ",", " ", "contain", "s", " ", "the", " ", "image", ".", "\\", "10", ";", " ", " ", "response", ":", " ", "Image", "s", "Histogram", "Respons", "e", ",", " ", "contain", "s", " ", "histo", "gram", " ", "of", " ", "the", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image_", "=_", "self_", "._", "\\u", "Open", "Image", "Data_", "(_", "request_", "._", "image_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "img", "\\u", "format_", "=_", "image_", "._", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "img", "\\u", "format_", "not_", "in_", "(_", "\"", "BM", "P", "\"_", ",_", "\"", "GIF", "\"_", ",_", "\"", "IC", "O", "\"_", ",_", "\"", "JP", "EG", "\"_", ",_", "\"", "PNG", "\"_", ",_", "\"", "TIF", "F", "\"_", ",_", "\"", "WEB", "P", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "NOT", "\\u", "IMAGE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "image_", "=_", "image_", "._", "convert_", "(_", "\"", "RGB", "A", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "red_", "=_", "[_", "0_", "]_", "*_", "256_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "green_", "=_", "[_", "0_", "]_", "*_", "256_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blue_", "=_", "[_", "0_", "]_", "*_", "256_", "\\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_", "for_", "pixel_", "in_", "image_", "._", "getdata_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "red_", "[_", "int_", "(_", "(_", "pixel_", "[_", "0_", "]_", "*_", "pixel_", "[_", "3_", "]_", ")_", "/_", "255_", ")_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "green_", "[_", "int_", "(_", "(_", "pixel_", "[_", "1_", "]_", "*_", "pixel_", "[_", "3_", "]_", ")_", "/_", "255_", ")_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blue_", "[_", "int_", "(_", "(_", "pixel_", "[_", "2_", "]_", "*_", "pixel_", "[_", "3_", "]_", ")_", "/_", "255_", ")_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "histogram_", "=_", "response_", "._", "mutable", "\\u", "histogram_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "red_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "histogram_", "._", "add", "\\u", "red_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "value_", "in_", "green_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "histogram_", "._", "add", "\\u", "green_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "value_", "in_", "blue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "histogram_", "._", "add", "\\u", "blue_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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", "Dynamic", "\\u", "Transform_", "(_", "self_", ",_", "request_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Tri", "via", "l", " ", "implementation", " ", "of", " ", "Image", "s", "Service", "::", "Transform", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Base", "d", " ", "off", " ", "documentation", " ", "of", " ", "the", " ", "PI", "L", " ", "librar", "y", " ", "at", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", ".", "python", "ware", ".", "com", "/", "librar", "y", "/", "pil", "/", "hand", "book", "/", "index", ".", "ht", "m", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "request", ":", " ", "Image", "s", "Transform", "Request", ",", " ", "contain", "s", " ", "image", " ", "request", " ", "info", ".", "\\", "10", ";", " ", " ", "response", ":", " ", "Image", "s", "Transform", "Respons", "e", ",", " ", "contain", "s", " ", "transforme", "d", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "self_", "._", "\\u", "Open", "Image", "Data_", "(_", "request_", "._", "image_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "settings_", "=_", "request_", "._", "input_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "correct", "\\u", "orientation_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "settings_", "._", "has", "\\u", "correct", "\\u", "exif", "\\u", "orientation_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "settings_", "._", "correct", "\\u", "exif", "\\u", "orientation_", "(_", ")_", "==_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Inp", "ut", "Settings_", "._", "CORREC", "T", "\\u", "ORIE", "NTA", "TION_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "metadata_", "=_", "self_", "._", "\\u", "Extract", "Metadata_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "original", "\\u", "image_", ",_", "input", "\\u", "settings_", "._", "parse", "\\u", "metadata_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "input", "\\u", "settings_", "._", "parse", "\\u", "metadata_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "info_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "On", "ce", " ", "the", " ", "applica", "tion", " ", "is", " ", "deploye", "d", ",", " ", "a", " ", "more", " ", "power", "ful", " ", "metadata", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "extracti", "on", " ", "will", " ", "be", " ", "perform", "ed", " ", "whi", "ch", " ", "mig", "ht", " ", "return", " ", "many", " ", "more", " ", "fields", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "image_", "=_", "self_", "._", "\\u", "Process", "Transforms", "_", "(_", "original", "\\u", "image_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "transform", "\\u", "list_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "correct", "\\u", "orientation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "substitution", "\\u", "rgb_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "input", "\\u", "settings_", "._", "has", "\\u", "transp", "arent", "\\u", "substitution", "\\u", "rgb_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "substitution", "\\u", "rgb_", "=_", "input", "\\u", "settings_", "._", "transp", "arent", "\\u", "substitution", "\\u", "rgb_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "value_", "=_", "self_", "._", "\\u", "Encode", "Image_", "(_", "new", "\\u", "image_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "output_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "substitution", "\\u", "rgb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "mutable", "\\u", "image_", "(_", ")_", "._", "set\\u", "content_", "(_", "response", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "set\\u", "source", "\\u", "metadata_", "(_", "source", "\\u", "metadata_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Dynamic", "\\u", "Get", "Ur", "l", "Base_", "(_", "self_", ",_", "request_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "blob", "\\u", "stub_", "._", "Get", "Ur", "l", "Base_", "(_", "request_", ",_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Dynamic", "\\u", "Delete", "Ur", "l", "Base_", "(_", "self_", ",_", "request_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "blob", "\\u", "stub_", "._", "Delete", "Ur", "l", "Base_", "(_", "request_", ",_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Encode", "Image_", "(_", "self_", ",_", "image_", ",_", "output", "\\u", "encoding_", ",_", "substitution", "\\u", "rgb_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Encode", " ", "the", " ", "give", "n", " ", "image", " ", "and", " ", "return", " ", "it", " ", "in", " ", "string", " ", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "PI", "L", " ", "Image", " ", "object", ",", " ", "image", " ", "to", " ", "encode", ".", "\\", "10", ";", " ", " ", "output", "\\u", "encoding", ":", " ", "Image", "s", "Transform", "Request", ".", "Output", "Sett", "ings", " ", "object", ".", "\\", "10", ";", " ", " ", "substitution", "\\u", "rgb", ":", " ", "The", " ", "color", " ", "to", " ", "use", " ", "for", " ", "transp", "arent", " ", "pixel", "s", " ", "if", " ", "the", " ", "output", "\\", "10", ";", " ", " ", " ", " ", "format", " ", "doe", "s", " ", "not", " ", "support", " ", "transparency", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "str", " ", "with", " ", "encode", "d", " ", "image", " ", "informati", "on", " ", "in", " ", "give", "n", " ", "encoding", " ", "format", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "string_", "=_", "String", "IO_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "encoding_", "=_", "\"", "PNG", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "output", "\\u", "encoding_", "._", "mime", "\\u", "type_", "(_", ")_", "==_", "images", "\\u", "service", "\\u", "pb_", "._", "Output", "Settings_", "._", "WEB", "P_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image", "\\u", "encoding_", "=_", "\"", "WEB", "P", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "output", "\\u", "encoding_", "._", "mime", "\\u", "type_", "(_", ")_", "==_", "images", "\\u", "service", "\\u", "pb_", "._", "Output", "Settings_", "._", "JP", "EG", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image", "\\u", "encoding_", "=_", "\"", "JP", "EG", "\"_", "\\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_", "if_", "substitution", "\\u", "rgb_", ":_", "\\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\\uINDENT\\u\\u\\u ", " _", "blue_", "=_", "substitution", "\\u", "rgb_", "&_", "0xFF_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "green_", "=_", "(_", "substitution", "\\u", "rgb_", ">>_", "8_", ")_", "&_", "0xFF_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "red_", "=_", "(_", "substitution", "\\u", "rgb_", ">>_", "16_", ")_", "&_", "0xFF_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "background_", "=_", "Image_", "._", "new_", "(_", "\"", "RGB", "\"_", ",_", "image_", "._", "size_", ",_", "(_", "red_", ",_", "green_", ",_", "blue_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "background_", "._", "paste_", "(_", "image_", ",_", "mask_", "=_", "image_", "._", "split_", "(_", ")_", "[_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image_", "=_", "background_", "\\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 ", " _", "image_", "=_", "image_", "._", "convert_", "(_", "\"", "RGB", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "image_", "._", "save_", "(_", "image", "\\u", "string_", ",_", "image", "\\u", "encoding_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "image", "\\u", "string_", "._", "getvalue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Open", "Image", "Data_", "(_", "self_", ",_", "image", "\\u", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Open", " ", "image", " ", "data", " ", "from", " ", "Image", "Data", " ", "protoc", "ol", " ", "buffer", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", "\\u", "data", ":", " ", "Image", "Data", " ", "protoc", "ol", " ", "buffer", " ", "contain", "ing", " ", "image", " ", "data", " ", "or", " ", "blob", "\\", "10", ";", " ", " ", " ", " ", "reference", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "Image", " ", "contain", "ing", " ", "the", " ", "image", " ", "data", " ", "pass", "ed", " ", "in", " ", "or", " ", "reference", " ", "by", " ", "blob", "-", "key", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "Applica", "tion", "Error", " ", "if", " ", "bot", "h", " ", "content", " ", "and", " ", "blob", "-", "key", " ", "are", " ", "provided", ".", "\\", "10", ";", " ", " ", "NOTE", ":", " ", "'", "content", "'", " ", "must", " ", "alw", "ay", "s", " ", "be", " ", "set", " ", "bec", "aus", "e", " ", "it", " ", "is", " ", "a", " ", "require", "d", " ", "field", ",", "\\", "10", ";", " ", " ", "how", "ever", ",", " ", "it", " ", "must", " ", "be", " ", "the", " ", "empty", " ", "string", " ", "whe", "n", " ", "a", " ", "blob", "-", "key", " ", "is", " ", "provided", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "image", "\\u", "data_", "._", "content_", "(_", ")_", "and_", "image", "\\u", "data_", "._", "has", "\\u", "blob", "\\u", "key_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "INVALID", "\\u", "BLOB", "\\u", "KEY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "image", "\\u", "data_", "._", "has", "\\u", "blob", "\\u", "key_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "self_", "._", "\\u", "Open", "Blob_", "(_", "image", "\\u", "data_", "._", "blob", "\\u", "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 ", " _", "image_", "=_", "self_", "._", "\\u", "Open", "Image_", "(_", "image", "\\u", "data_", "._", "content_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "img", "\\u", "format_", "=_", "image_", "._", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "img", "\\u", "format_", "not_", "in_", "(_", "\"", "BM", "P", "\"_", ",_", "\"", "GIF", "\"_", ",_", "\"", "IC", "O", "\"_", ",_", "\"", "JP", "EG", "\"_", ",_", "\"", "PNG", "\"_", ",_", "\"", "TIF", "F", "\"_", ",_", "\"", "WEB", "P", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "NOT", "\\u", "IMAGE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Open", "Image_", "(_", "self_", ",_", "image_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Opens", " ", "an", " ", "image", " ", "provided", " ", "as", " ", "a", " ", "string", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "image", " ", "data", " ", "to", " ", "be", " ", "opene", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "api", "proxy", "\\u", "error", "s", ".", "Applica", "tion", "Error", " ", "if", " ", "the", " ", "image", " ", "cann", "ot", " ", "be", " ", "opene", "d", " ", "or", " ", "if", " ", "it", "\\", "10", ";", " ", " ", "is", " ", "an", " ", "unsup", "porte", "d", " ", "format", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "Image", " ", "contain", "ing", " ", "the", " ", "image", " ", "data", " ", "pass", "ed", " ", "in", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "image_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "NOT", "\\u", "IMAGE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "image_", "=_", "String", "IO_", "._", "String", "IO_", "(_", "image_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Image_", "._", "open_", "(_", "image_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "IMA", "GE", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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", "Open", "Blob_", "(_", "self_", ",_", "blob", "\\u", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "an", " ", "Image", " ", "from", " ", "the", " ", "blob", " ", "data", " ", "read", " ", "from", " ", "blob", "\\u", "key", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "storage", "\\u", "key_", "=_", "None_", "\\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 ", " _", "gs", "\\u", "info_", "=_", "datastore_", "._", "Get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "datastore_", "._", "Key_", "._", "from", "\\u", "path_", "(_", "GS", "\\u", "INFO", "\\u", "KIND", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blob", "\\u", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "namespace_", "=_", "''_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "storage", "\\u", "key_", "=_", "gs", "\\u", "info_", "[_", "'", "storage", "\\u", "key", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "datast", "ore", "\\u", "errors_", "._", "Entit", "y", "Not", "Foun", "d", "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_", "if_", "not_", "storage", "\\u", "key_", ":_", "\\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 ", " _", "key_", "=_", "datast", "ore", "\\u", "types_", "._", "Key_", "._", "from", "\\u", "path_", "(_", "blobs", "tore_", "._", "BLOB", "\\u", "INFO", "\\u", "KIND", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blob", "\\u", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "namespace_", "=_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "datastore_", "._", "Get_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "storage", "\\u", "key_", "=_", "blob", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "datast", "ore", "\\u", "errors_", "._", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "exception_", "(_", "'", "Blo", "b", " ", "with", " ", "key", " ", "%", "r", " ", "doe", "s", " ", "not", " ", "exist", "'_", ",_", "blob", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "UNSPEC", "IFIED", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "blobs", "tore\\u", "stub_", "=_", "api", "proxy", "\\u", "stub", "\\u", "map_", "._", "api", "proxy_", "._", "Get", "Stub_", "(_", "\"", "blobs", "tore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "blob", "\\u", "file_", "=_", "blobs", "tore\\u", "stub_", "._", "storage_", "._", "Open", "Blob_", "(_", "storage", "\\u", "key_", ")_", "\\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 ", " _", "logging_", "._", "exception_", "(_", "\"", "Cou", "ld", " ", "not", " ", "get", " ", "file", " ", "for", " ", "blob", "\\u", "key", " ", "%", "r", "\"_", ",_", "blob", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "IMA", "GE", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Image_", "._", "open_", "(_", "blob", "\\u", "file_", ")_", "\\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 ", " _", "logging_", "._", "exception_", "(_", "\"", "Cou", "ld", " ", "not", " ", "open", " ", "image", " ", "%", "r", " ", "for", " ", "blob", "\\u", "key", " ", "%", "r", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blob", "\\u", "file_", ",_", "blob", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "IMA", "GE", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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", "Validate", "Cro", "p", "Arg_", "(_", "self_", ",_", "arg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Check", " ", "an", " ", "argu", "ment", " ", "for", " ", "the", " ", "Cro", "p", " ", "transform", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "arg", ":", " ", "float", ",", " ", "argu", "ment", " ", "to", " ", "Cro", "p", " ", "transform", " ", "to", " ", "check", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "api", "proxy", "\\u", "error", "s", ".", "Applica", "tion", "Error", " ", "on", " ", "problem", " ", "with", " ", "argu", "ment", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "arg_", ",_", "float_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "(_", "0_", "<=_", "arg_", "<=_", "1.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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", "Calculat", "e", "New", "Dimensions_", "(_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "height_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "req", "\\u", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "req", "\\u", "height_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "crop", "\\u", "to", "\\u", "fit_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "allow", "\\u", "stretch", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "new", " ", "resiz", "e", " ", "dimension", "s", " ", "keep", "ing", " ", "the", " ", "current", " ", "aspect", " ", "ratio", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "use", "s", " ", "the", " ", "more", " ", "restrict", "ing", " ", "of", " ", "the", " ", "two", " ", "request", "ed", " ", "values", " ", "to", " ", "dete", "rmin", "e", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "new", " ", "ratio", ".", " ", "See", " ", "als", "o", " ", "crop", "\\u", "to", "\\u", "fit", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "current", "\\u", "widt", "h", ":", " ", "int", ",", " ", "current", " ", "widt", "h", " ", "of", " ", "the", " ", "image", ".", "\\", "10", ";", " ", " ", "current", "\\u", "height", ":", " ", "int", ",", " ", "current", " ", "height", " ", "of", " ", "the", " ", "image", ".", "\\", "10", ";", " ", " ", "req", "\\u", "widt", "h", ":", " ", "int", ",", " ", "request", "ed", " ", "new", " ", "widt", "h", " ", "of", " ", "the", " ", "image", ",", " ", "0", " ", "if", " ", "unspe", "cif", "ied", ".", "\\", "10", ";", " ", " ", "req", "\\u", "height", ":", " ", "int", ",", " ", "request", "ed", " ", "new", " ", "height", " ", "of", " ", "the", " ", "image", ",", " ", "0", " ", "if", " ", "unspe", "cif", "ied", ".", "\\", "10", ";", " ", " ", "crop", "\\u", "to", "\\u", "fit", ":", " ", "bool", ",", " ", "Tru", "e", " ", "if", " ", "the", " ", "less", " ", "restrict", "ing", " ", "dimension", " ", "shou", "ld", " ", "be", " ", "used", ".", "\\", "10", ";", " ", " ", "allow", "\\u", "stretch", ":", " ", "bool", ",", " ", "Tru", "e", " ", "is", " ", "aspect", " ", "ratio", " ", "shou", "ld", " ", "be", " ", "ignore", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "api", "proxy", "\\u", "error", "s", ".", "Applica", "tion", "Error", ":", " ", "if", " ", "crop", "\\u", "to", "\\u", "fit", " ", "is", " ", "Tru", "e", " ", "eit", "her", " ", "req", "\\u", "widt", "h", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "req", "\\u", "height", " ", "is", " ", "0.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "tuple", " ", "(", "widt", "h", ",", " ", "height", ")", " ", "whi", "ch", " ", "are", " ", "bot", "h", " ", "ints", " ", "of", " ", "the", " ", "new", " ", "ratio", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "widt", "h", "\\u", "ratio_", "=_", "float_", "(_", "req", "\\u", "width_", ")_", "/_", "current", "\\u", "width_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "height", "\\u", "ratio_", "=_", "float_", "(_", "req", "\\u", "height_", ")_", "/_", "current", "\\u", "height_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "allow", "\\u", "stretch", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "req", "\\u", "width_", "or_", "not_", "req", "\\u", "height_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "req", "\\u", "width_", ",_", "req", "\\u", "height_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "crop", "\\u", "to", "\\u", "fit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "req", "\\u", "width_", "or_", "not_", "req", "\\u", "height_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "widt", "h", "\\u", "ratio_", ">_", "height", "\\u", "ratio_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "req", "\\u", "width_", ",_", "int_", "(_", "widt", "h", "\\u", "ratio_", "*_", "current", "\\u", "height_", ")_", "\\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_", "int_", "(_", "height", "\\u", "ratio_", "*_", "current", "\\u", "width_", ")_", ",_", "req", "\\u", "height_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "req", "\\u", "width_", "==_", "0_", "or_", "(_", "widt", "h", "\\u", "ratio_", ">_", "height", "\\u", "ratio_", "and_", "req", "\\u", "height_", "!=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "int_", "(_", "height", "\\u", "ratio_", "*_", "current", "\\u", "width_", ")_", ",_", "req", "\\u", "height_", "\\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_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "req", "\\u", "width_", ",_", "int_", "(_", "widt", "h", "\\u", "ratio_", "*_", "current", "\\u", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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", "Resize", "_", "(_", "self_", ",_", "image_", ",_", "transform_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Us", "e", " ", "PI", "L", " ", "to", " ", "resiz", "e", " ", "the", " ", "give", "n", " ", "image", " ", "with", " ", "the", " ", "give", "n", " ", "transform", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "PI", "L", ".", "Image", ".", "Image", " ", "object", " ", "to", " ", "resiz", "e", ".", "\\", "10", ";", " ", " ", "transform", ":", " ", "images", "\\u", "service", "\\u", "pb", ".", "Transform", " ", "to", " ", "use", " ", "whe", "n", " ", "resiz", "ing", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "PI", "L", ".", "Image", ".", "Image", " ", "with", " ", "transform", "s", " ", "perform", "ed", " ", "on", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "Ba", "d", "Request", "Error", " ", "if", " ", "the", " ", "resiz", "e", " ", "data", " ", "give", "n", " ", "is", " ", "bad", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "width_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "height_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "transform_", "._", "has", "\\u", "width_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "width_", "=_", "transform_", "._", "width_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "width_", "<_", "0_", "or_", "4000_", "<_", "width_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\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_", "if_", "transform_", "._", "has", "\\u", "height_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "height_", "=_", "transform_", "._", "height_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "height_", "<_", "0_", "or_", "4000_", "<_", "height_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\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_", "crop", "\\u", "to", "\\u", "fit_", "=_", "transform_", "._", "crop", "\\u", "to", "\\u", "fit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "\\u", "stretch", "_", "=_", "transform_", "._", "allow", "\\u", "stretch", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "width_", ",_", "current", "\\u", "height_", "=_", "image_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "width_", ",_", "new", "\\u", "height_", "=_", "self_", "._", "\\u", "Calculat", "e", "New", "Dimensions_", "(_", "current", "\\u", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "height_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "height_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "crop", "\\u", "to", "\\u", "fit_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "allow", "\\u", "stretch", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "image_", "=_", "image_", "._", "resize_", "(_", "(_", "new", "\\u", "width_", ",_", "new", "\\u", "height_", ")_", ",_", "Image_", "._", "ANTI", "ALIAS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "crop", "\\u", "to", "\\u", "fit_", "and_", "(_", "new", "\\u", "width_", ">_", "width_", "or_", "new", "\\u", "height_", ">_", "height_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "left_", "=_", "int_", "(_", "(_", "new", "\\u", "width_", "-_", "width_", ")_", "*_", "transform_", "._", "crop", "\\u", "offset", "\\u", "x_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "top_", "=_", "int_", "(_", "(_", "new", "\\u", "height_", "-_", "height_", ")_", "*_", "transform_", "._", "crop", "\\u", "offset", "\\u", "y_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "right_", "=_", "left_", "+_", "width_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bottom_", "=_", "top_", "+_", "height_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "image_", "=_", "new", "\\u", "image_", "._", "crop_", "(_", "(_", "left_", ",_", "top_", ",_", "right_", ",_", "bottom_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "new", "\\u", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Rotate", "_", "(_", "self_", ",_", "image_", ",_", "transform_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Us", "e", " ", "PI", "L", " ", "to", " ", "rota", "te", " ", "the", " ", "give", "n", " ", "image", " ", "with", " ", "the", " ", "give", "n", " ", "transform", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "PI", "L", ".", "Image", ".", "Image", " ", "object", " ", "to", " ", "rota", "te", ".", "\\", "10", ";", " ", " ", "transform", ":", " ", "images", "\\u", "service", "\\u", "pb", ".", "Transform", " ", "to", " ", "use", " ", "whe", "n", " ", "rotati", "ng", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "PI", "L", ".", "Image", ".", "Image", " ", "with", " ", "transform", "s", " ", "perform", "ed", " ", "on", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "Ba", "d", "Request", "Error", " ", "if", " ", "the", " ", "rota", "te", " ", "data", " ", "give", "n", " ", "is", " ", "bad", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "degrees_", "=_", "transform_", "._", "rotate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "degrees_", "<_", "0_", "or_", "degrees_", "%_", "90_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "degrees_", "%=_", "360_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "degrees_", "=_", "360_", "-_", "degrees_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "image_", "._", "rotate_", "(_", "degrees_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Cro", "p_", "(_", "self_", ",_", "image_", ",_", "transform_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Us", "e", " ", "PI", "L", " ", "to", " ", "crop", " ", "the", " ", "give", "n", " ", "image", " ", "with", " ", "the", " ", "give", "n", " ", "transform", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "PI", "L", ".", "Image", ".", "Image", " ", "object", " ", "to", " ", "crop", ".", "\\", "10", ";", " ", " ", "transform", ":", " ", "images", "\\u", "service", "\\u", "pb", ".", "Transform", " ", "to", " ", "use", " ", "whe", "n", " ", "crop", "ping", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "PI", "L", ".", "Image", ".", "Image", " ", "with", " ", "transform", "s", " ", "perform", "ed", " ", "on", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "Ba", "d", "Request", "Error", " ", "if", " ", "the", " ", "crop", " ", "data", " ", "give", "n", " ", "is", " ", "bad", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "left", "\\u", "x_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "top", "\\u", "y_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "right", "\\u", "x_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bottom", "\\u", "y_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "transform_", "._", "has", "\\u", "crop", "\\u", "left", "\\u", "x_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "left", "\\u", "x_", "=_", "transform_", "._", "crop", "\\u", "left", "\\u", "x_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "Validate", "Cro", "p", "Arg_", "(_", "left", "\\u", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "transform_", "._", "has", "\\u", "crop", "\\u", "top", "\\u", "y_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "top", "\\u", "y_", "=_", "transform_", "._", "crop", "\\u", "top", "\\u", "y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "Validate", "Cro", "p", "Arg_", "(_", "top", "\\u", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "transform_", "._", "has", "\\u", "crop", "\\u", "right", "\\u", "x_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "right", "\\u", "x_", "=_", "transform_", "._", "crop", "\\u", "right", "\\u", "x_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "Validate", "Cro", "p", "Arg_", "(_", "right", "\\u", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "transform_", "._", "has", "\\u", "crop", "\\u", "bottom", "\\u", "y_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bottom", "\\u", "y_", "=_", "transform_", "._", "crop", "\\u", "bottom", "\\u", "y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "Validate", "Cro", "p", "Arg_", "(_", "bottom", "\\u", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "width_", ",_", "height_", "=_", "image_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "box_", "=_", "(_", "int_", "(_", "round_", "(_", "left", "\\u", "x_", "*_", "width_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "int_", "(_", "round_", "(_", "top", "\\u", "y_", "*_", "height_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "int_", "(_", "round_", "(_", "right", "\\u", "x_", "*_", "width_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "int_", "(_", "round_", "(_", "bottom", "\\u", "y_", "*_", "height_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "image_", "._", "crop_", "(_", "box_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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_", "\\u", "Get", "Exi", "f", "Fro", "m", "Image_", "(_", "image_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "image_", ",_", "\"\\u", "gete", "xi", "f", "\"_", ")_", ":_", "\\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\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "PIL_", "import_", "Tif", "f", "Image", "Plugin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "image_", "._", "\\u", "gete", "xi", "f_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "have", " ", "not", " ", "manage", "d", " ", "to", " ", "get", " ", "this", " ", "to", " ", "work", " ", "in", " ", "the", " ", "SD", "K", " ", "with", " ", "Python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2.5", ",", " ", "so", " ", "just", " ", "catch", " ", "the", " ", "Import", "Error", " ", "and", " ", "prete", "nd", " ", "there", " ", "is", " ", "no_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "EX", "IF", " ", "informati", "on", " ", "of", " ", "interest", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "info_", "(_", "'", "So", "rr", "y", ",", " ", "Tif", "f", "Image", "Plug", "in", " ", "doe", "s", " ", "not", " ", "work", " ", "in", " ", "this", " ", "environ", "ment", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\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_", "\\u", "Extract", "Metadata_", "(_", "image_", ",_", "parse", "\\u", "metadata_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Extract", " ", "EX", "IF", " ", "metadata", " ", "from", " ", "the", " ", "image", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", " ", "tha", "t", " ", "this", " ", "is", " ", "a", " ", "muc", "h", " ", "simplified", " ", "version", " ", "of", " ", "metadata", " ", "extracti", "on", ".", " ", "Af", "ter", "\\", "10", ";", " ", " ", " ", " ", "deploy", "ment", " ", "applica", "tion", "s", " ", "have", " ", "access", " ", "to", " ", "a", " ", "more", " ", "power", "ful", " ", "parser", " ", "tha", "t", " ", "can", "\\", "10", ";", " ", " ", " ", " ", "parse", " ", "hundred", "s", " ", "of", " ", "fields", " ", "from", " ", "images", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "PI", "L", " ", "Image", " ", "object", ".", "\\", "10", ";", " ", " ", "parse", "\\u", "metadata", ":", " ", "bool", ",", " ", "Tru", "e", " ", "if", " ", "metadata", " ", "pars", "ing", " ", "has", " ", "bee", "n", " ", "request", "ed", ".", " ", "If", "\\", "10", ";", " ", " ", " ", " ", "Fal", "se", " ", "the", " ", "result", " ", "will", " ", "contain", " ", "image", " ", "dimension", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "str", ",", " ", "JSO", "N", " ", "encode", "d", " ", "values", " ", "with", " ", "vari", "ous", " ", "metadata", " ", "fields", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "Exi", "f", "Time", "To", "Uni", "xt", "ime_", "(_", "exif", "\\u", "time_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Convert", " ", "time", " ", "in", " ", "EX", "IF", " ", "to", " ", "unix", " ", "time", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "exif", "\\u", "time", ":", " ", "str", ",", " ", "the", " ", "time", " ", "from", " ", "the", " ", "EX", "IF", " ", "block", " ", "formate", "d", " ", "by", " ", "EX", "IF", " ", "standard", ".", "\\", "10", ";", " ", " ", "E", ".", "g", ".,", " ", "\"", "2011", ":", "02", ":", "20", " ", "10", ":", "23", ":", "1", "2", "\",", " ", "second", "s", " ", "are", " ", "option", "al", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "Integer", ",", " ", "the", " ", "time", " ", "in", " ", "unix", " ", "froma", "t", ":", " ", "second", "s", " ", "sinc", "e", " ", "the", " ", "epoch", ".", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "regexp_", "=_", "re_", "._", "compile_", "(_", "r", "\"", "^", "([", "0", "-", "9", "]{", "4", "}):", "([", "0", "-", "9", "]{", "1", ",", "2", "}):", "([", "0", "-", "9", "]{", "1", ",", "2", "})\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", " ", "([", "0", "-", "9", "]{", "1", ",", "2", "}):", "([", "0", "-", "9", "]{", "1", ",", "2", "})(", "?:", ":(", "[", "0", "-", "9", "]{", "1", ",", "2", "}))", "?\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match_", "=_", "regexp_", "._", "match_", "(_", "exif", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", "is_", "None_", ":_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "date_", "=_", "datetime_", "._", "datetime_", "(_", "*_", "map_", "(_", "int_", ",_", "filter_", "(_", "None_", ",_", "match_", "._", "groups_", "(_", ")_", ")_", ")_", ")_", "\\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 ", " _", "logging_", "._", "info_", "(_", "\"", "Inva", "lid", " ", "date", " ", "in", " ", "EX", "IF", ":", " ", "%", "s", "\"_", ",_", "exif", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "int_", "(_", "time_", "._", "mktime_", "(_", "date_", "._", "timetuple_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "metadata", "\\u", "dict_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "parse", "\\u", "metadata_", "and_", "Image", "s", "Service", "Stub_", "._", "\\u", "Get", "Exi", "f", "Fro", "m", "Image_", "(_", "image_", ")_", "or_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "metadata", "\\u", "dict_", "[_", "256_", "]_", ",_", "metadata", "\\u", "dict_", "[_", "257_", "]_", "=_", "image_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u", "EX", "IF", "\\u", "DATETIME", "ORIGIN", "AL", "\\u", "TAG_", "in_", "metadata", "\\u", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "date", "\\u", "ms_", "=_", "Exi", "f", "Time", "To", "Uni", "xt", "ime_", "(_", "metadata", "\\u", "dict_", "[_", "\\u", "EX", "IF", "\\u", "DATETIME", "ORIGIN", "AL", "\\u", "TAG_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "date", "\\u", "ms_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metadata", "\\u", "dict_", "[_", "\\u", "EX", "IF", "\\u", "DATETIME", "ORIGIN", "AL", "\\u", "TAG_", "]_", "=_", "date", "\\u", "ms_", "\\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 ", " _", "del_", "metadata", "\\u", "dict_", "[_", "\\u", "EX", "IF", "\\u", "DATETIME", "ORIGIN", "AL", "\\u", "TAG_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "metadata_", "=_", "dict_", "(_", "[_", "(_", "\\u", "EX", "IF", "\\u", "TAGS_", "[_", "k_", "]_", ",_", "v_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "metadata", "\\u", "dict_", "._", "iteritems_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "k_", "in_", "\\u", "EX", "IF", "\\u", "TAGS_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "simplejson_", "._", "dumps_", "(_", "metadata_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Correct", "Orientation_", "(_", "self_", ",_", "image_", ",_", "orientation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Us", "e", " ", "PI", "L", " ", "to", " ", "correct", " ", "the", " ", "image", " ", "orientation", " ", "based", " ", "on", " ", "its", " ", "EX", "IF", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "See", " ", "JE", "ITA", " ", "CP", "-", "345", "1", " ", "at", " ", "http", "://", "www", ".", "exif", ".", "org", "/", "specifica", "tion", "s", ".", "html", ",", "\\", "10", ";", " ", " ", " ", " ", "Exi", "f", " ", "2.2", ",", " ", "page", " ", "18.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "source", " ", "PI", "L", ".", "Image", ".", "Image", " ", "object", ".", "\\", "10", ";", " ", " ", "orientation", ":", " ", "integ", "er", " ", "in", " ", "range", " ", "(", "1", ",", "8", ")", " ", "inclu", "sive", ",", " ", "correspond", "ing", " ", "the", " ", "image", "\\", "10", ";", " ", " ", " ", " ", "orientation", " ", "from", " ", "EX", "IF", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "PI", "L", ".", "Image", ".", "Image", " ", "with", " ", "transform", "s", " ", "perform", "ed", " ", "on", " ", "it", ".", " ", "If", " ", "no", " ", "correcti", "on", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "don", "e", ",", " ", "it", " ", "return", "s", " ", "the", " ", "input", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "orientation_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "transpose_", "(_", "Image_", "._", "FLI", "P", "\\u", "LEF", "T", "\\u", "RIGHT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "orientation_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "rotate_", "(_", "180_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "orientation_", "==_", "4_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "transpose_", "(_", "Image_", "._", "FLI", "P", "\\u", "TOP", "\\u", "BOTTOM_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "orientation_", "==_", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "transpose_", "(_", "Image_", "._", "FLI", "P", "\\u", "TOP", "\\u", "BOTTOM_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image_", "=_", "image_", "._", "rotate_", "(_", "270_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "orientation_", "==_", "6_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "rotate_", "(_", "270_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "orientation_", "==_", "7_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "transpose_", "(_", "Image_", "._", "FLI", "P", "\\u", "LEF", "T", "\\u", "RIGHT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image_", "=_", "image_", "._", "rotate_", "(_", "270_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "orientation_", "==_", "8_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "image_", "._", "rotate_", "(_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Image", "s", "Service", "Stub_", "(_", "api", "proxy", "\\u", "stub_", "._", "API", "Pro", "xy", "Stub_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Process", "Transforms", "_", "(_", "self_", ",_", "image_", ",_", "transforms_", ",_", "correct", "\\u", "orientation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Execut", "e", " ", "PI", "L", " ", "operati", "ons", " ", "based", " ", "on", " ", "transform", " ", "values", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "image", ":", " ", "PI", "L", ".", "Image", ".", "Image", " ", "instance", ",", " ", "image", " ", "to", " ", "manipulate", ".", "\\", "10", ";", " ", " ", "transform", "s", ":", " ", "list", " ", "of", " ", "Image", "s", "Transform", "Request", ".", "Transform", " ", "object", "s", ".", "\\", "10", ";", " ", " ", "correct", "\\u", "orientation", ":", " ", "Tru", "e", " ", "to", " ", "indicat", "e", " ", "tha", "t", " ", "image", " ", "orientation", " ", "shou", "ld", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "corrected", " ", "based", " ", "on", " ", "its", " ", "EX", "IF", ".", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "PI", "L", ".", "Image", ".", "Image", " ", "with", " ", "transform", "s", " ", "perform", "ed", " ", "on", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "Ba", "d", "Request", "Error", " ", "if", " ", "we", " ", "are", " ", "pass", "ed", " ", "more", " ", "than", " ", "one", " ", "of", " ", "the", " ", "same", " ", "type", " ", "of", "\\", "10", ";", " ", " ", "transform", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "image_", "=_", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "transforms_", ")_", ">_", "images_", "._", "MAX", "\\u", "TRANSFORM", "S", "\\u", "PER", "\\u", "REQUEST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "images", "\\u", "service", "\\u", "pb_", "._", "Image", "s", "Service", "Error_", "._", "BAD", "\\u", "TRANSFORM", "\\u", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "orientation_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "correct", "\\u", "orientation_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exif", "_", "=_", "self_", "._", "\\u", "Get", "Exi", "f", "Fro", "m", "Image_", "(_", "image_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "exif", "_", "or_", "\\u", "EX", "IF", "\\u", "ORIE", "NTA", "TIO", "N", "\\u", "TAG_", "not_", "in_", "exif", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "correct", "\\u", "orientation_", "=_", "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 ", " _", "orientation_", "=_", "exif", "_", "[_", "\\u", "EX", "IF", "\\u", "ORIE", "NTA", "TIO", "N", "\\u", "TAG_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "width_", ",_", "height_", "=_", "new", "\\u", "image_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "height_", ">_", "width_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "orientation_", "=_", "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_", "for_", "transform_", "in_", "transforms_", ":_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "correct", "\\u", "orientation_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "(_", "transform_", "._", "has", "\\u", "crop", "\\u", "left", "\\u", "x_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "transform_", "._", "has", "\\u", "crop", "\\u", "top", "\\u", "y_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "transform_", "._", "has", "\\u", "crop", "\\u", "right", "\\u", "x_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "transform_", "._", "has", "\\u", "crop", "\\u", "bottom", "\\u", "y_", "(_", ")_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "transform_", "._", "has", "\\u", "horizon", "tal", "\\u", "flip_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "transform_", "._", "has", "\\u", "vertical", "\\u", "flip_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "self_", "._", "\\u", "Correct", "Orientation_", "(_", "new", "\\u", "image_", ",_", "orientation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "correct", "\\u", "orientation_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "transform_", "._", "has", "\\u", "width_", "(_", ")_", "or_", "transform_", "._", "has", "\\u", "height_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "self_", "._", "\\u", "Resize", "_", "(_", "new", "\\u", "image_", ",_", "transform_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "transform_", "._", "has", "\\u", "rotate_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "self_", "._", "\\u", "Rotate", "_", "(_", "new", "\\u", "image_", ",_", "transform_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "transform_", "._", "has", "\\u", "horizon", "tal", "\\u", "flip_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "new", "\\u", "image_", "._", "transpose_", "(_", "Image_", "._", "FLI", "P", "\\u", "LEF", "T", "\\u", "RIGHT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "transform_", "._", "has", "\\u", "vertical", "\\u", "flip_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "new", "\\u", "image_", "._", "transpose_", "(_", "Image_", "._", "FLI", "P", "\\u", "TOP", "\\u", "BOTTOM_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "transform_", "._", "has", "\\u", "crop", "\\u", "left", "\\u", "x_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "transform_", "._", "has", "\\u", "crop", "\\u", "top", "\\u", "y_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "transform_", "._", "has", "\\u", "crop", "\\u", "right", "\\u", "x_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "transform_", "._", "has", "\\u", "crop", "\\u", "bottom", "\\u", "y_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "self_", "._", "\\u", "Cro", "p_", "(_", "new", "\\u", "image_", ",_", "transform_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "transform_", "._", "has", "\\u", "auto", "levels_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "info_", "(_", "\"", "I", "'", "m", " ", "Fee", "ling", " ", "Luc", "ky", " ", "auto", "level", "s", " ", "will", " ", "be", " ", "visi", "ble", " ", "onc", "e", " ", "this", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "applica", "tion", " ", "is", " ", "deploye", "d", ".\"_", ")_", "\\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 ", " _", "logging_", "._", "warn_", "(_", "\"", "Foun", "d", " ", "no", " ", "transformation", "s", " ", "found", " ", "to", " ", "perform", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "correct", "\\u", "orientation_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "image_", "=_", "self_", "._", "\\u", "Correct", "Orientation_", "(_", "new", "\\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 ]
Unused import
gawel/panoramisk/panoramisk/utils.py
[ { "content": "# -*- coding: utf-8 -*-\nimport re\nimport uuid\nimport collections\n\ntry: # pragma: no cover\n from urllib.parse import unquote\nexcept ImportError: # pragma: no cover\n from urllib import unquote # NOQA\n\n\ntry: # pragma: no cover\n import asyncio\n from asyncio.queues import Queue\nexcept ImportError: # pragma: no cover\n import trollius as asyncio # NOQA\n from trollius.queues import Queue # NOQA\n\ntry:\n from configparser import ConfigParser\nexcept ImportError: # pragma: no cover\n from ConfigParser import ConfigParser # NOQA\n\nEOL = '\\r\\n'\n\nre_code = re.compile(r'(^\\d*)\\s*(.*)')\nre_kv = re.compile(r'(?P<key>\\w+)=(?P<value>[^\\s]+)\\s*(?:\\((?P<data>.*)\\))*')\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def parse_agi_result(line):\n \"\"\"Parse AGI results using Regular expression.\n\n :AGI Result examples:\n\n ::\n\n 200 result=0\n\n 200 result=-1\n\n 200 result=132456\n\n 200 result= (timeout)\n\n 510 Invalid or unknown command\n\n 520-Invalid command syntax. Proper usage follows:\n int() argument must be a string, a bytes-like object or a number, not 'NoneType'\n\n HANGUP\n\n \"\"\"\n # print(\"--------------\\n\", line)\n if line == 'HANGUP':\n return {'error': 'AGIResultHangup', 'msg': 'User hungup during execution'}\n\n code = 0\n m = re_code.search(line)\n if m:\n code, response = m.groups()\n code = int(code)\n\n return agi_code_check(code, response, line)", "metadata": "root.parse_agi_result", "header": "['module', '___EOS___']", "index": 29 }, { "content": "def agi_code_check(code, response, line):\n \"\"\"\n Check the AGI code and return a dict to help on error handling.\n \"\"\"\n result = {'status_code': code, 'result': ('', ''), 'msg': ''}\n if code == 200:\n for key, value, data in re_kv.findall(response):\n result[key] = (value, data)\n # If user hangs up... we get 'hangup' in the data\n if data == 'hangup':\n return {'error': 'AGIResultHangup', 'msg': 'User hungup during execution'}\n if key == 'result' and value == '-1':\n return {'error': 'AGIAppError', 'msg': 'Error executing application, or hangup'}\n return result\n elif code == 510:\n result['error'] = 'AGIInvalidCommand'\n return result\n elif code == 520:\n usage = [line]\n usage = '%s\\n' % '\\n'.join(usage)\n # AGI Usage error\n result['error'] = 'AGIUsageError'\n result['msg'] = 'usage'\n return result\n else:\n # Unhandled code or undefined response\n result['error'] = 'AGIUnknownError'\n return result", "metadata": "root.agi_code_check", "header": "['module', '___EOS___']", "index": 65 }, { "content": "class IdGenerator(object):\n \"\"\"Generate some uuid for actions:\n\n .. code-block:: python\n\n >>> g = IdGenerator('mycounter')\n\n ..\n >>> IdGenerator.reset(uid='an_uuid4')\n\n It increments the counter at each calls:\n\n .. code-block:: python\n\n >>> print(g())\n mycounter/an_uuid4/1/1\n >>> print(g())\n mycounter/an_uuid4/1/2\n \"\"\"\n\n instances = []\n\n\n\n\n\n", "metadata": "root.IdGenerator", "header": "['module', '___EOS___']", "index": 95 }, { "content": " def __init__(self, prefix):\n self.instances.append(self)\n self.prefix = prefix\n self.uid = str(uuid.uuid4())\n self.generator = self.get_generator()", "metadata": "root.IdGenerator.__init__", "header": "['class', 'IdGenerator', '(', 'object', ')', ':', '___EOS___']", "index": 117 }, { "content": " def get_generator(self):\n i = 0\n max_val = 10000\n while True:\n yield \"%s/%s/%d/%d\" % (self.prefix, self.uid, (i // max_val) + 1, (i % max_val) + 1)\n i += 1", "metadata": "root.IdGenerator.get_generator", "header": "['class', 'IdGenerator', '(', 'object', ')', ':', '___EOS___']", "index": 123 }, { "content": " @classmethod\n def reset(cls, uid=None):\n \"\"\"Mostly used for unit testing. Allow to use a static uuid and reset\n all counter\"\"\"\n for instance in cls.instances:\n if uid:\n instance.uid = uid\n instance.generator = instance.get_generator()", "metadata": "root.IdGenerator.reset", "header": "['class', 'IdGenerator', '(', 'object', ')', ':', '___EOS___']", "index": 130 }, { "content": " def get_instances(self):\n \"\"\"Mostly used for debugging\"\"\"\n return [\"<%s prefix:%s (uid:%s)>\" % (self.__class__.__name__, i.prefix, self.uid)\n for i in self.instances]", "metadata": "root.IdGenerator.get_instances", "header": "['class', 'IdGenerator', '(', 'object', ')', ':', '___EOS___']", "index": 139 }, { "content": " def __call__(self):\n return next(self.generator)", "metadata": "root.IdGenerator.__call__", "header": "['class', 'IdGenerator', '(', 'object', ')', ':', '___EOS___']", "index": 144 }, { "content": " def __repr__(self):\n return \"<%s prefix:%s (uid:%s)>\" % (self.__class__.__name__, self.prefix, self.uid)", "metadata": "root.IdGenerator.__repr__", "header": "['class', 'IdGenerator', '(', 'object', ')', ':', '___EOS___']", "index": 147 }, { "content": "class CaseInsensitiveDict(collections.MutableMapping):\n \"\"\"\n A case-insensitive ``dict``-like object.\n\n Implements all methods and operations of ``collections.MutableMapping``.\n\n All keys are expected to be strings. The structure remembers the\n case of the last key to be set, and ``iter(instance)``,\n ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()``\n will contain case-sensitive keys. However, querying and contains\n testing is case insensitive:\n\n .. code-block:: python\n\n cid = CaseInsensitiveDict()\n cid['Action'] = 'SIPnotify'\n cid['aCTION'] == 'SIPnotify' # True\n list(cid) == ['Action'] # True\n\n For example, ``event['actionid']`` will return the\n value of a ``'ActionID'`` response event, regardless\n of how the event name was originally stored.\n \"\"\"\n\n\n\n\n\n\n\n", "metadata": "root.CaseInsensitiveDict", "header": "['module', '___EOS___']", "index": 151 }, { "content": " def __init__(self, data=None, **kwargs):\n self._store = dict()\n self.update(data or {}, **kwargs)", "metadata": "root.CaseInsensitiveDict.__init__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 174 }, { "content": " def __setitem__(self, key, value):\n # Use the lowercased key for lookups, but store the actual\n # key alongside the value.\n self._store[key.lower()] = (key, value)", "metadata": "root.CaseInsensitiveDict.__setitem__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 178 }, { "content": " def __contains__(self, key):\n return key.lower() in self._store", "metadata": "root.CaseInsensitiveDict.__contains__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 183 }, { "content": " def __getattr__(self, attr):\n return self.get(attr, '')", "metadata": "root.CaseInsensitiveDict.__getattr__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 186 }, { "content": " def __getitem__(self, key):\n return self._store[key.lower()][1]", "metadata": "root.CaseInsensitiveDict.__getitem__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 189 }, { "content": " def __delitem__(self, key):\n raise NotImplementedError()", "metadata": "root.CaseInsensitiveDict.__delitem__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 192 }, { "content": " def __iter__(self):\n return (key for key, value in self._store.values())", "metadata": "root.CaseInsensitiveDict.__iter__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 195 }, { "content": " def __len__(self):\n return len(self._store)", "metadata": "root.CaseInsensitiveDict.__len__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 198 }, { "content": " def __repr__(self):\n return str(dict(self.items()))", "metadata": "root.CaseInsensitiveDict.__repr__", "header": "['class', 'CaseInsensitiveDict', '(', 'collections', '.', 'MutableMapping', ')', ':', '___EOS___']", "index": 201 }, { "content": "def config(filename_or_fd, section='asterisk'):\n config = ConfigParser()\n if hasattr(filename_or_fd, 'read'):\n config.readfp(filename_or_fd)\n else:\n config.read(filename_or_fd)\n return dict(config.items(section))", "metadata": "root.config", "header": "['module', '___EOS___']", "index": 205 } ]
[ { "span": "from urllib.parse import unquote", "start_line": 6, "start_column": 4, "end_line": 6, "end_column": 36 }, { "span": "import asyncio", "start_line": 12, "start_column": 4, "end_line": 12, "end_column": 18 }, { "span": "from asyncio.queues import Queue", "start_line": 13, "start_column": 4, "end_line": 13, "end_column": 36 } ]
[]
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_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "collections_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "._", "parse_", "import_", "unquote_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "import_", "unquote_", "#", " ", "NO", "QA", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "asyncio_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "asyncio_", "._", "queues_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "troll", "ius", "_", "as_", "asyncio_", "#", " ", "NO", "QA", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "troll", "ius", "_", "._", "queues_", "import_", "Queue_", "#", " ", "NO", "QA", "_", "\\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 ", " _", "from_", "configparser_", "import_", "Config", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "Config", "Parser_", "import_", "Config", "Parser_", "#", " ", "NO", "QA", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "EO", "L_", "=_", "'\\\\", "r", "\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "re", "\\u", "code_", "=_", "re_", "._", "compile_", "(_", "r", "'(", "^", "\\\\", "d", "*)\\\\", "s", "*(.", "*)'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "re", "\\u", "kv_", "=_", "re_", "._", "compile_", "(_", "r", "'(", "?", "P", "<", "key", ">\\\\", "w", "+)", "=(", "?", "P", "<", "value", ">[", "^", "\\\\", "s", "]+)\\\\", "s", "*(", "?:\\\\", "((", "?", "P", "<", "data", ">.*)", "\\\\)", ")*", "'_", ")_", "\\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_", "parse", "\\u", "agi", "\\u", "result_", "(_", "line_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Pars", "e", " ", "AG", "I", " ", "results", " ", "usi", "ng", " ", "Regula", "r", " ", "express", "ion", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "AG", "I", " ", "Result", " ", "example", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "200", " ", "result", "=", "0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "200", " ", "result", "=-", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "200", " ", "result", "=", "132", "456", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "200", " ", "result", "=", " ", "(", "timeo", "ut", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "510", " ", "Inva", "lid", " ", "or", " ", "unknown", " ", "command", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "520", "-", "Inva", "lid", " ", "command", " ", "synta", "x", ".", " ", " ", "Proper", " ", "usage", " ", "follow", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "int", "()", " ", "argu", "ment", " ", "must", " ", "be", " ", "a", " ", "string", ",", " ", "a", " ", "bytes", "-", "like", " ", "object", " ", "or", " ", "a", " ", "number", ",", " ", "not", " ", "'", "Non", "e", "Type", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "HAN", "GU", "P", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(\"", "--------------", "\\\\", "n", "\",", " ", "line", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "line_", "==_", "'", "HAN", "GU", "P", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "'", "error", "'_", ":_", "'", "AG", "IR", "esult", "Hang", "up", "'_", ",_", "'", "msg", "'_", ":_", "'", "User", " ", "hun", "gu", "p", " ", "dur", "ing", " ", "executi", "on", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "code_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "re", "\\u", "code_", "._", "search_", "(_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code_", ",_", "response_", "=_", "m_", "._", "groups_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "int_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "agi", "\\u", "code", "\\u", "check_", "(_", "code_", ",_", "response_", ",_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "agi", "\\u", "code", "\\u", "check_", "(_", "code_", ",_", "response_", ",_", "line_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "the", " ", "AG", "I", " ", "code", " ", "and", " ", "return", " ", "a", " ", "dict", " ", "to", " ", "help", " ", "on", " ", "error", " ", "handling", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "{_", "'", "status", "\\u", "code", "'_", ":_", "code_", ",_", "'", "result", "'_", ":_", "(_", "''_", ",_", "''_", ")_", ",_", "'", "msg", "'_", ":_", "''_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "code_", "==_", "200_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", ",_", "data_", "in_", "re", "\\u", "kv_", "._", "findall_", "(_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "key_", "]_", "=_", "(_", "value_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "user", " ", "hang", "s", " ", "up", "...", " ", "we", " ", "get", " ", "'", "hang", "up", "'", " ", "in", " ", "the", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "data_", "==_", "'", "hang", "up", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "'", "error", "'_", ":_", "'", "AG", "IR", "esult", "Hang", "up", "'_", ",_", "'", "msg", "'_", ":_", "'", "User", " ", "hun", "gu", "p", " ", "dur", "ing", " ", "executi", "on", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "key_", "==_", "'", "result", "'_", "and_", "value_", "==_", "'-", "1", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "'", "error", "'_", ":_", "'", "AG", "IA", "pp", "Error", "'_", ",_", "'", "msg", "'_", ":_", "'", "Error", " ", "executi", "ng", " ", "applica", "tion", ",", " ", "or", " ", "hang", "up", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "code_", "==_", "510", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "'", "error", "'_", "]_", "=_", "'", "AG", "II", "nval", "id", "Command", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "code_", "==_", "520", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "usage_", "=_", "[_", "line_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "usage_", "=_", "'%", "s", "\\\\", "n", "'_", "%_", "'\\\\", "n", "'_", "._", "join_", "(_", "usage_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "AG", "I", " ", "Us", "age", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "error", "'_", "]_", "=_", "'", "AG", "IU", "sage", "Error", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "msg", "'_", "]_", "=_", "'", "usage", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Unh", "andle", "d", " ", "code", " ", "or", " ", "undefined", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "'", "error", "'_", "]_", "=_", "'", "AG", "IU", "nk", "now", "n", "Error", "'_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Id", "Generator_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Generate", " ", "some", " ", "uuid", " ", "for", " ", "action", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "g", " ", "=", " ", "Id", "Generat", "or", "('", "myco", "unter", "')", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "Id", "Generat", "or", ".", "reset", "(", "uid", "='", "an", "\\u", "uuid", "4", "')", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "It", " ", "increment", "s", " ", "the", " ", "counter", " ", "at", " ", "each", " ", "calls", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "print", "(", "g", "())", "\\", "10", ";", " ", " ", " ", " ", "myco", "unter", "/", "an", "\\u", "uuid", "4", "/", "1", "/", "1", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "print", "(", "g", "())", "\\", "10", ";", " ", " ", " ", " ", "myco", "unter", "/", "an", "\\u", "uuid", "4", "/", "1", "/", "2", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Id", "Generator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "prefix_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "instances_", "._", "append_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prefix_", "=_", "prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "uid_", "=_", "str_", "(_", "uuid_", "._", "uuid4_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "generator_", "=_", "self_", "._", "get", "\\u", "generator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Id", "Generator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "generator_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "val_", "=_", "10000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "\"%", "s", "/", "%", "s", "/", "%", "d", "/", "%", "d", "\"_", "%_", "(_", "self_", "._", "prefix_", ",_", "self_", "._", "uid_", ",_", "(_", "i_", "//_", "max", "\\u", "val_", ")_", "+_", "1_", ",_", "(_", "i_", "%_", "max", "\\u", "val_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Id", "Generator_", "(_", "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_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "reset_", "(_", "cls_", ",_", "uid_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Mos", "tl", "y", " ", "used", " ", "for", " ", "unit", " ", "testi", "ng", ".", " ", "All", "ow", " ", "to", " ", "use", " ", "a", " ", "static", " ", "uuid", " ", "and", " ", "reset", "\\", "10", ";", " ", " ", " ", " ", "all", " ", "counter", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "instance_", "in_", "cls_", "._", "instances_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "uid_", "=_", "uid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "instance_", "._", "generator_", "=_", "instance_", "._", "get", "\\u", "generator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Id", "Generator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "instances_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Mos", "tl", "y", " ", "used", " ", "for", " ", "debugg", "ing", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "\"<", "%", "s", " ", "prefix", ":", "%", "s", " ", "(", "uid", ":", "%", "s", ")>", "\"_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "i_", "._", "prefix_", ",_", "self_", "._", "uid_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "self_", "._", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Id", "Generator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "call\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "next_", "(_", "self_", "._", "generator_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Id", "Generator_", "(_", "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", " ", "prefix", ":", "%", "s", " ", "(", "uid", ":", "%", "s", ")>", "\"_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "self_", "._", "prefix_", ",_", "self_", "._", "uid_", ")_", "\\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_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "case", "-", "inse", "nsitive", " ", "``", "dict", "``-", "like", " ", "object", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Impl", "ement", "s", " ", "all", " ", "method", "s", " ", "and", " ", "operati", "ons", " ", "of", " ", "``", "collection", "s", ".", "Mut", "able", "Map", "ping", "``.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "All", " ", "keys", " ", "are", " ", "expected", " ", "to", " ", "be", " ", "string", "s", ".", " ", "The", " ", "structure", " ", "remember", "s", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "case", " ", "of", " ", "the", " ", "last", " ", "key", " ", "to", " ", "be", " ", "set", ",", " ", "and", " ", "``", "iter", "(", "instance", ")`", "`", ",", "\\", "10", ";", " ", " ", " ", " ", "``", "keys", "()``", ",", " ", "``", "items", "()``", ",", " ", "``", "iter", "keys", "()``", ",", " ", "and", " ", "``", "iter", "items", "()``", "\\", "10", ";", " ", " ", " ", " ", "will", " ", "contain", " ", "case", "-", "sensi", "tiv", "e", " ", "keys", ".", " ", "Ho", "we", "ver", ",", " ", "query", "ing", " ", "and", " ", "contain", "s", "\\", "10", ";", " ", " ", " ", " ", "testi", "ng", " ", "is", " ", "case", " ", "inse", "nsitive", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "cid", " ", "=", " ", "Case", "Inse", "nsitive", "Dict", "()", "\\", "10", ";", " ", " ", " ", " ", "cid", "['", "Action", "']", " ", "=", " ", "'", "SI", "Pn", "oti", "fy", "'", "\\", "10", ";", " ", " ", " ", " ", "cid", "['", "a", "CTION", "']", " ", "==", " ", "'", "SI", "Pn", "oti", "fy", "'", " ", " ", "#", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", "list", "(", "cid", ")", " ", "==", " ", "['", "Action", "']", " ", " ", "#", " ", "Tru", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "example", ",", " ", "``", "event", "['", "action", "id", "']", "``", " ", "will", " ", "return", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "value", " ", "of", " ", "a", " ", "``", "'", "Action", "ID", "'``", " ", "response", " ", "event", ",", " ", "rega", "rd", "less", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "how", " ", "the", " ", "event", " ", "name", " ", "was", " ", "original", "ly", " ", "store", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data_", "=_", "None_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "store_", "=_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update_", "(_", "data_", "or_", "{_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\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_", "#", " ", "Us", "e", " ", "the", " ", "lower", "case", "d", " ", "key", " ", "for", " ", "lookups", ",", " ", "but", " ", "store", " ", "the", " ", "actual_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "key", " ", "along", "side", " ", "the", " ", "value", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "store_", "[_", "key_", "._", "lower_", "(_", ")_", "]_", "=_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "contains\\u\\u_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "key_", "._", "lower_", "(_", ")_", "in_", "self_", "._", "\\u", "store_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getattr\\u\\u_", "(_", "self_", ",_", "attr_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "get_", "(_", "attr_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getitem\\u\\u_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "store_", "[_", "key_", "._", "lower_", "(_", ")_", "]_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "delitem\\u\\u_", "(_", "self_", ",_", "key_", ")_", ":_", "\\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_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "key_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u", "store_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\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_", "len_", "(_", "self_", "._", "\\u", "store_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Case", "Inse", "nsitive", "Dict_", "(_", "collections_", "._", "Mut", "able", "Mapping_", ")_", ":_", "\\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_", "(_", "dict_", "(_", "self_", "._", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "config_", "(_", "filename", "\\u", "or", "\\u", "fd_", ",_", "section_", "=_", "'", "aster", "isk", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "=_", "Config", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "filename", "\\u", "or", "\\u", "fd_", ",_", "'", "read", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "._", "readf", "p_", "(_", "filename", "\\u", "or", "\\u", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "._", "read_", "(_", "filename", "\\u", "or", "\\u", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", "config_", "._", "items_", "(_", "section_", ")_", ")_" ]
[ 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, 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, 0, 1, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
gdmka/django-evercookie/django_evercookie/templatetags/evercookie_js_api.py
[ { "content": "from django import template\nfrom django.core.urlresolvers import reverse\nfrom random import random\nfrom django_evercookie.config import settings\nregister = template.Library()\n\n\n\"\"\"Set evercookie\"\"\"\n\n\n\n\n\"\"\"Cookies will be re-setted with best candidate\"\"\"\n\n\n\"\"\"Cookies won't be not re-setted\"\"\"\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@register.simple_tag\ndef set_evercookie(ec_obj, name, value=None):\n if value is None:\n context_dict = {\"ec_obj\": ec_obj, \"name\": name, \"value\": settings.cookie_value}\n else:\n context_dict = {\"ec_obj\": ec_obj, \"name\": name, \"value\": value}\n\n return '''<script>\nvar %(ec_obj)s=new evercookie();\n%(ec_obj)s.set(\"%(name)s\", \"%(value)s\");\n</script>''' % context_dict", "metadata": "root.set_evercookie", "header": "['module', '___EOS___']", "index": 9 }, { "content": "@register.simple_tag\ndef reactivate_evercookie(ec_obj, name):\n context_dict = {\"ec_obj\": ec_obj, \"name\": name}\n\n return '''<script>\n var %(ec_obj)s=new evercookie();\n function getC(dont) {\n %(ec_obj)s.get(\"%(name)s\", function(best, all) {\n for (var item in all)\n var payload = JSON.stringify({item: all});\n if (!dont)\n getC(1);\n }, dont);\n}\nsetTimeout(getC, 300);\n</script>''' % context_dict", "metadata": "root.reactivate_evercookie", "header": "['module', '___EOS___']", "index": 25 }, { "content": "@register.simple_tag\ndef rediscover_evercookie(ec_obj, name):\n context_dict = {\"ec_obj\": ec_obj, \"name\": name}\n\n return '''<script>\n var %(ec_obj)s=new evercookie();\n function getC(dont) {\n %(ec_obj)s.get(\"%(name)s\", function(best, all) {\n for (var item in all)\n var payload = JSON.stringify({item: all});\n if (!dont)\n getC(1);\n }, dont);\n}\nsetTimeout(getC, 300, 1);\n</script>''' % context_dict", "metadata": "root.rediscover_evercookie", "header": "['module', '___EOS___']", "index": 44 } ]
[ { "span": "from django.core.urlresolvers import reverse", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 44 }, { "span": "from random import random", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 25 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "import_", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "random_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django", "\\u", "ever", "cookie_", "._", "config_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "register_", "=_", "template_", "._", "Library_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Set", " ", "ever", "cookie", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "Cooki", "es", " ", "will", " ", "be", " ", "re", "-", "sette", "d", " ", "with", " ", "best", " ", "candidate", "\"\"\"_", "\\u\\u\\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_", "\"\"\"", "Cooki", "es", " ", "won", "'", "t", " ", "be", " ", "not", " ", "re", "-", "sette", "d", "\"\"\"_", "\\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_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "set\\u", "ever", "cookie_", "(_", "ec", "\\u", "obj_", ",_", "name_", ",_", "value_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "value_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context", "\\u", "dict_", "=_", "{_", "\"", "ec", "\\u", "obj", "\"_", ":_", "ec", "\\u", "obj_", ",_", "\"", "name", "\"_", ":_", "name_", ",_", "\"", "value", "\"_", ":_", "settings_", "._", "cookie", "\\u", "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 ", " _", "context", "\\u", "dict_", "=_", "{_", "\"", "ec", "\\u", "obj", "\"_", ":_", "ec", "\\u", "obj_", ",_", "\"", "name", "\"_", ":_", "name_", ",_", "\"", "value", "\"_", ":_", "value_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "'''", "<", "script", ">", "\\", "10", ";", "var", " ", "%", "(", "ec", "\\u", "obj", ")", "s", "=", "new", " ", "ever", "cookie", "();", "\\", "10", ";", "%", "(", "ec", "\\u", "obj", ")", "s", ".", "set", "(\"", "%", "(", "name", ")", "s", "\",", " ", "\"%", "(", "value", ")", "s", "\");", "\\", "10", ";<", "/", "script", ">'''_", "%_", "context", "\\u", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "reacti", "vat", "e\\u", "ever", "cookie_", "(_", "ec", "\\u", "obj_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context", "\\u", "dict_", "=_", "{_", "\"", "ec", "\\u", "obj", "\"_", ":_", "ec", "\\u", "obj_", ",_", "\"", "name", "\"_", ":_", "name_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "'''", "<", "script", ">", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "%", "(", "ec", "\\u", "obj", ")", "s", "=", "new", " ", "ever", "cookie", "();", "\\", "10", ";", " ", " ", " ", " ", "function", " ", "get", "C", "(", "don", "t", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "ec", "\\u", "obj", ")", "s", ".", "get", "(\"", "%", "(", "name", ")", "s", "\",", " ", "function", "(", "best", ",", " ", "all", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "(", "var", " ", "item", " ", "in", " ", "all", ")", "\\", "10", ";", " ", " ", " ", " ", " ", "var", " ", "payload", " ", "=", " ", "JSO", "N", ".", "stringify", "({", "item", ":", " ", "all", "})", ";", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "don", "t", ")", "\\", "10", ";", " ", " ", " ", " ", "get", "C", "(", "1", ");", "\\", "10", ";", " ", " ", " ", " ", "},", " ", "don", "t", ");", "\\", "10", ";}", "\\", "10", ";", "set", "Time", "out", "(", "get", "C", ",", " ", "300", ");", "\\", "10", ";<", "/", "script", ">'''_", "%_", "context", "\\u", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "redis", "cover", "\\u", "ever", "cookie_", "(_", "ec", "\\u", "obj_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context", "\\u", "dict_", "=_", "{_", "\"", "ec", "\\u", "obj", "\"_", ":_", "ec", "\\u", "obj_", ",_", "\"", "name", "\"_", ":_", "name_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "'''", "<", "script", ">", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "%", "(", "ec", "\\u", "obj", ")", "s", "=", "new", " ", "ever", "cookie", "();", "\\", "10", ";", " ", " ", " ", " ", "function", " ", "get", "C", "(", "don", "t", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "ec", "\\u", "obj", ")", "s", ".", "get", "(\"", "%", "(", "name", ")", "s", "\",", " ", "function", "(", "best", ",", " ", "all", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "(", "var", " ", "item", " ", "in", " ", "all", ")", "\\", "10", ";", " ", " ", " ", " ", " ", "var", " ", "payload", " ", "=", " ", "JSO", "N", ".", "stringify", "({", "item", ":", " ", "all", "})", ";", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "don", "t", ")", "\\", "10", ";", " ", " ", " ", " ", "get", "C", "(", "1", ");", "\\", "10", ";", " ", " ", " ", " ", "},", " ", "don", "t", ");", "\\", "10", ";}", "\\", "10", ";", "set", "Time", "out", "(", "get", "C", ",", " ", "300", ",", " ", "1", ");", "\\", "10", ";<", "/", "script", ">'''_", "%_", "context", "\\u", "dict_" ]
[ 4, 4, 4, 4, 4, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
fp7-ofelia/ocf/expedient/doc/plugins/samples/aggregate/sr_manager/src/communications/XmlRpcServer.py
[ { "content": "\"\"\"\nImplements the server functionality (connection,\nauthentication, etc).\n\n@date: Jun 12, 2013\n@author: Laszlo Nagy, msune, CarolinaFernandez\n\"\"\"\n\n\"\"\"SecureXMLRPCServer.py - simple XML RPC server supporting SSL.\n\nBased on this article: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81549\n\nFor windows users: http://webcleaner.sourceforge.net/pyOpenSSL-0.6.win32-py2.4.exe\n\nImported from http://code.activestate.com/recipes/496786-simple-xml-rpc-server-over-https/ \n\"\"\"\nimport SocketServer\nimport BaseHTTPServer\nimport SimpleHTTPServer\nimport SimpleXMLRPCServer\nimport socket, os\n\nfrom communications import XmlRpcAPI\nfrom OpenSSL import SSL\nfrom utils.Logger import Logger\n\nfrom settings import XMLRPC_SERVER_USER, XMLRPC_SERVER_PASSWORD, \\\n XMLRPC_SERVER_LISTEN_HOST,XMLRPC_SERVER_LISTEN_PORT, \\\n XMLRPC_SERVER_KEYFILE,XMLRPC_SERVER_CERTFILE\n\n\n\n \n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class SecureXMLRPCServer(BaseHTTPServer.HTTPServer,SimpleXMLRPCServer.SimpleXMLRPCDispatcher):\n", "metadata": "root.SecureXMLRPCServer", "header": "['module', '___EOS___']", "index": 31 }, { "content": " def log_request(self, code='-', size='-'): \n pass", "metadata": "root.SecureXMLRPCServer.log_request", "header": "['class', 'SecureXMLRPCServer', '(', 'BaseHTTPServer', '.', 'HTTPServer', ',', 'SimpleXMLRPCServer', '.', 'SimpleXMLRPCDispatcher', ')', ':', '___EOS___']", "index": 32 }, { "content": " def __init__(self, server_address, HandlerClass, logRequests=False):\n \"\"\"Secure XML-RPC server.\n\n It it very similar to SimpleXMLRPCServer but it uses HTTPS for transporting XML data.\n \"\"\"\n self.logRequests = logRequests\n\n SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)\n SocketServer.BaseServer.__init__(self, server_address, HandlerClass)\n ctx = SSL.Context(SSL.SSLv23_METHOD)\n\n ctx.use_privatekey_file (XMLRPC_SERVER_KEYFILE)\n ctx.use_certificate_file(XMLRPC_SERVER_CERTFILE)\n self.socket = SSL.Connection(ctx, socket.socket(self.address_family,\n self.socket_type))\n self.server_bind()\n self.server_activate()", "metadata": "root.SecureXMLRPCServer.__init__", "header": "['class', 'SecureXMLRPCServer', '(', 'BaseHTTPServer', '.', 'HTTPServer', ',', 'SimpleXMLRPCServer', '.', 'SimpleXMLRPCDispatcher', ')', ':', '___EOS___']", "index": 35 }, { "content": "class SecureXMLRpcRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):\n \"\"\"Secure XML-RPC request handler class.\n\n It it very similar to SimpleXMLRPCRequestHandler but it uses HTTPS for transporting XML data.\n \"\"\"\n\n '''\n Request Handler that verifies username and password passed to\n XML RPC server in HTTP URL sent by client.\n '''\n # this is the method we must override\n\n", "metadata": "root.SecureXMLRpcRequestHandler", "header": "['module', '___EOS___']", "index": 53 }, { "content": " def setup(self):\n self.connection = self.request\n self.rfile = socket._fileobject(self.request, \"rb\", self.rbufsize)\n self.wfile = socket._fileobject(self.request, \"wb\", self.wbufsize)", "metadata": "root.SecureXMLRpcRequestHandler.setup", "header": "['class', 'SecureXMLRpcRequestHandler', '(', 'SimpleXMLRPCServer', '.', 'SimpleXMLRPCRequestHandler', ')', ':', '___EOS___']", "index": 58 }, { "content": " def parse_request(self):\n if SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.parse_request(self):\n if self.authenticate(self.headers):\n return True\n else:\n self.send_error(401, 'Authentication failed')\n return False", "metadata": "root.SecureXMLRpcRequestHandler.parse_request", "header": "['class', 'SecureXMLRpcRequestHandler', '(', 'SimpleXMLRPCServer', '.', 'SimpleXMLRPCRequestHandler', ')', ':', '___EOS___']", "index": 68 }, { "content": " def authenticate(self, headers):\n \"\"\"\n Authenticates the headers against the credentials set in the\n configuration file. This method overrides the one with the\n same name in SimpleXMLRPCRequestHandler.\n\n @return whether authentication was successful or not\n\t\t\"\"\"\n try:\n from base64 import b64decode\n (basic, _, encoded) = headers.get('Authorization').partition(' ')\n assert basic == 'Basic', 'Only basic authentication supported'\n encodedByteString = encoded.encode()\n decodedBytes = b64decode(encodedByteString)\n decodedString = decodedBytes.decode()\n (username, _, password) = decodedString.partition(':')\n return (username == XMLRPC_SERVER_USER and password == XMLRPC_SERVER_PASSWORD)\n except:\n return False", "metadata": "root.SecureXMLRpcRequestHandler.authenticate", "header": "['class', 'SecureXMLRpcRequestHandler', '(', 'SimpleXMLRPCServer', '.', 'SimpleXMLRPCRequestHandler', ')', ':', '___EOS___']", "index": 76 }, { "content": " def do_POST(self):\n \"\"\"Handles the HTTPS POST request.\n\n It was copied out from SimpleXMLRPCServer.py and modified to shutdown the socket cleanly.\n \"\"\"\n\n try:\n # get arguments\n data = self.rfile.read(int(self.headers[\"content-length\"]))\n # In previous versions of SimpleXMLRPCServer, _dispatch\n # could be overridden in this class, instead of in\n # SimpleXMLRPCDispatcher. To maintain backwards compatibility,\n # check to see if a subclass implements _dispatch and dispatch\n # using that method if present.\n response = self.server._marshaled_dispatch(\n data, getattr(self, '_dispatch', None)\n )\n except: # This should only happen if the module is buggy\n # internal error, report as HTTP server error\n self.send_response(500)\n self.end_headers()\n else:\n # got a valid XML RPC response\n self.send_response(200)\n self.send_header(\"Content-type\", \"text/xml\")\n self.send_header(\"Content-length\", str(len(response)))\n self.end_headers()\n self.wfile.write(response)\n\n # shut down the connection\n self.wfile.flush()\n self.connection.shutdown() # Modified here!", "metadata": "root.SecureXMLRpcRequestHandler.do_POST", "header": "['class', 'SecureXMLRpcRequestHandler', '(', 'SimpleXMLRPCServer', '.', 'SimpleXMLRPCRequestHandler', ')', ':', '___EOS___']", "index": 96 }, { "content": "class XmlRpcServer():\n\t\n\tlogger = Logger.getLogger()\n", "metadata": "root.XmlRpcServer", "header": "['module', '___EOS___']", "index": 129 }, { "content": "\t@staticmethod\n\tdef createInstanceAndEngage(callBackFunction,HandlerClass = SecureXMLRpcRequestHandler,ServerClass = SecureXMLRPCServer):\n server_address = (XMLRPC_SERVER_LISTEN_HOST, XMLRPC_SERVER_LISTEN_PORT) # (address, port)\n server = ServerClass(server_address, HandlerClass)\n server.register_instance(XmlRpcAPI.xmlrpc_wrappers(callBackFunction))\n sa = server.socket.getsockname()\n XmlRpcServer.logger.debug(\"Serving HTTPS XMLRPC requests on \"+str(sa[0])+\":\"+ str(sa[1]))\n server.serve_forever()", "metadata": "root.XmlRpcServer.createInstanceAndEngage", "header": "['class', 'XmlRpcServer', '(', ')', ':', '___EOS___']", "index": 133 } ]
[ { "span": "import SimpleHTTPServer", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 23 }, { "span": "import socket, os", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Impl", "ement", "s", " ", "the", " ", "server", " ", "functional", "it", "y", " ", "(", "connecti", "on", ",", "\\", "10", ";", "authenticat", "ion", ",", " ", "etc", ").", "\\", "10", ";", "\\", "10", ";", "@", "date", ":", " ", "Jun", " ", "1", "2", ",", " ", "2013", "\\", "10", ";", "@", "author", ":", " ", "Las", "zl", "o", " ", "Nag", "y", ",", " ", "ms", "une", ",", " ", "Carol", "ina", "Fer", "nand", "ez", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Secur", "e", "XMLRPC", "Server", ".", "py", " ", "-", " ", "simple", " ", "XML", " ", "RP", "C", " ", "server", " ", "support", "ing", " ", "SS", "L", ".", "\\", "10", ";", "\\", "10", ";", "Base", "d", " ", "on", " ", "this", " ", "article", ":", " ", "http", "://", "asp", "n", ".", "active", "state", ".", "com", "/", "ASP", "N", "/", "Coo", "kb", "ook", "/", "Pyth", "on", "/", "Recip", "e", "/", "815", "4", "9", "\\", "10", ";", "\\", "10", ";", "For", " ", "windows", " ", "users", ":", " ", "http", "://", "webc", "lean", "er", ".", "sourcef", "org", "e", ".", "net", "/", "py", "Open", "SS", "L", "-0", ".6", ".", "win32", "-", "py2", ".4", ".", "exe", "\\", "10", ";", "\\", "10", ";", "Imported", " ", "from", " ", "http", "://", "code", ".", "active", "state", ".", "com", "/", "recip", "es", "/", "496", "786", "-", "simple", "-", "xml", "-", "rpc", "-", "server", "-", "over", "-", "https", "/", " ", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Sock", "et", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Base", "HTTP", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Simple", "HTTP", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Simple", "XMLRPC", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", ",_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "communication", "s_", "import_", "Xm", "l", "Rp", "c", "API_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Open", "SSL_", "import_", "SSL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "utils_", "._", "Logger_", "import_", "Logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "settings_", "import_", "XMLRPC", "\\u", "SERVER", "\\u", "USER_", ",_", "XMLRPC", "\\u", "SERVER", "\\u", "PASSWORD_", ",_", "XMLRPC", "\\u", "SERVER", "\\u", "LISTEN", "\\u", "HOST_", ",_", "XMLRPC", "\\u", "SERVER", "\\u", "LISTEN", "\\u", "PORT_", ",_", "XMLRPC", "\\u", "SERVER", "\\u", "KEY", "FILE_", ",_", "XMLRPC", "\\u", "SERVER", "\\u", "CERT", "FILE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Secur", "e", "XMLRPC", "Server_", "(_", "Base", "HTTP", "Server_", "._", "HTTP", "Server_", ",_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Dispatcher_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Secur", "e", "XMLRPC", "Server_", "(_", "Base", "HTTP", "Server_", "._", "HTTP", "Server_", ",_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Dispatcher_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "log", "\\u", "request_", "(_", "self_", ",_", "code_", "=_", "'-'_", ",_", "size_", "=_", "'-'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Secur", "e", "XMLRPC", "Server_", "(_", "Base", "HTTP", "Server_", "._", "HTTP", "Server_", ",_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Dispatcher_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "server", "\\u", "address_", ",_", "Handle", "r", "Class_", ",_", "log", "Requests_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Secur", "e", " ", "XML", "-", "RP", "C", " ", "server", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "It", " ", "it", " ", "very", " ", "similar", " ", "to", " ", "Simple", "XMLRPC", "Server", " ", "but", " ", "it", " ", "use", "s", " ", "HTTP", "S", " ", "for", " ", "transport", "ing", " ", "XML", " ", "data", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log", "Requests_", "=_", "log", "Requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Dispatcher_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Sock", "et", "Server_", "._", "Base", "Server_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "server", "\\u", "address_", ",_", "Handle", "r", "Class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "SSL_", "._", "Context_", "(_", "SSL_", "._", "SS", "Lv", "23", "\\u", "METHOD_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "._", "use", "\\u", "private", "key", "\\u", "file_", "(_", "XMLRPC", "\\u", "SERVER", "\\u", "KEY", "FILE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "._", "use", "\\u", "certifica", "te", "\\u", "file_", "(_", "XMLRPC", "\\u", "SERVER", "\\u", "CERT", "FILE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "=_", "SSL_", "._", "Connection_", "(_", "ctx_", ",_", "socket_", "._", "socket_", "(_", "self_", "._", "address", "\\u", "family_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "socket", "\\u", "type_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "\\u", "bind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "\\u", "activate_", "(_", ")_", "\\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_", "Secur", "e", "XML", "Rp", "c", "Request", "Handler_", "(_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Request", "Handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Secur", "e", " ", "XML", "-", "RP", "C", " ", "request", " ", "handler", " ", "class", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "It", " ", "it", " ", "very", " ", "similar", " ", "to", " ", "Simple", "XMLRPC", "Request", "Handle", "r", " ", "but", " ", "it", " ", "use", "s", " ", "HTTP", "S", " ", "for", " ", "transport", "ing", " ", "XML", " ", "data", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", "\\", "10", ";", " ", " ", " ", " ", "Request", " ", "Handle", "r", " ", "tha", "t", " ", "verifie", "s", " ", "user", "name", " ", "and", " ", "password", " ", "pass", "ed", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "XML", " ", "RP", "C", " ", "server", " ", "in", " ", "HTTP", " ", "URL", " ", "sent", " ", "by", " ", "client", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "the", " ", "method", " ", "we", " ", "must", " ", "override_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Secur", "e", "XML", "Rp", "c", "Request", "Handler_", "(_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "setup_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "connection_", "=_", "self_", "._", "request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "rfile_", "=_", "socket_", "._", "\\u", "fileo", "bject_", "(_", "self_", "._", "request_", ",_", "\"", "rb", "\"_", ",_", "self_", "._", "rbu", "fsize_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "=_", "socket_", "._", "\\u", "fileo", "bject_", "(_", "self_", "._", "request_", ",_", "\"", "wb", "\"_", ",_", "self_", "._", "wb", "uf", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Secur", "e", "XML", "Rp", "c", "Request", "Handler_", "(_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "parse", "\\u", "request_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Request", "Handler_", "._", "parse", "\\u", "request_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "authenticate_", "(_", "self_", "._", "headers_", ")_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "error_", "(_", "401_", ",_", "'", "Auth", "entica", "tion", " ", "fail", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Secur", "e", "XML", "Rp", "c", "Request", "Handler_", "(_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Request", "Handler_", ")_", ":_", "\\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_", "authenticate_", "(_", "self_", ",_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Auth", "entica", "tes", " ", "the", " ", "header", "s", " ", "against", " ", "the", " ", "cred", "ential", "s", " ", "set", " ", "in", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "configura", "tion", " ", "file", ".", " ", "Thi", "s", " ", "method", " ", "override", "s", " ", "the", " ", "one", " ", "with", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "same", " ", "name", " ", "in", " ", "Simple", "XMLRPC", "Request", "Handle", "r", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", " ", "whe", "ther", " ", "authenticat", "ion", " ", "was", " ", "success", "ful", " ", "or", " ", "not", "\\", "10", ";", "\t", "\t", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "base64_", "import_", "b64decode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "basic_", ",_", "\\u_", ",_", "encoded_", ")_", "=_", "headers_", "._", "get_", "(_", "'", "Authoriz", "ation", "'_", ")_", "._", "partition_", "(_", "'", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "basic_", "==_", "'", "Basic", "'_", ",_", "'", "On", "ly", " ", "basic", " ", "authenticat", "ion", " ", "support", "ed", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encode", "d", "Byte", "String_", "=_", "encoded_", "._", "encode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "decode", "d", "Bytes_", "=_", "b64decode_", "(_", "encode", "d", "Byte", "String_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "decode", "d", "String_", "=_", "decode", "d", "Bytes_", "._", "decode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "username_", ",_", "\\u_", ",_", "password_", ")_", "=_", "decode", "d", "String_", "._", "partition_", "(_", "':'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "username_", "==_", "XMLRPC", "\\u", "SERVER", "\\u", "USER_", "and_", "password_", "==_", "XMLRPC", "\\u", "SERVER", "\\u", "PASSWORD_", ")_", "\\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_", "Secur", "e", "XML", "Rp", "c", "Request", "Handler_", "(_", "Simple", "XMLRPC", "Server_", "._", "Simple", "XMLRPC", "Request", "Handler_", ")_", ":_", "\\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_", "do", "\\u", "POST_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", "s", " ", "the", " ", "HTTP", "S", " ", "POST", " ", "request", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "It", " ", "was", " ", "copie", "d", " ", "out", " ", "from", " ", "Simple", "XMLRPC", "Server", ".", "py", " ", "and", " ", "modifi", "ed", " ", "to", " ", "shut", "down", " ", "the", " ", "socket", " ", "clean", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "self_", "._", "rfile_", "._", "read_", "(_", "int_", "(_", "self_", "._", "headers_", "[_", "\"", "content", "-", "length", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "In", " ", "previ", "ous", " ", "version", "s", " ", "of", " ", "Simple", "XMLRPC", "Server", ",", " ", "\\u", "dispatch_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "coul", "d", " ", "be", " ", "overrid", "den", " ", "in", " ", "this", " ", "class", ",", " ", "inst", "ead", " ", "of", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Simple", "XMLRPC", "Dispatcher", ".", " ", "To", " ", "maintain", " ", "back", "ward", "s", " ", "compatibility", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "to", " ", "see", " ", "if", " ", "a", " ", "subclass", " ", "implement", "s", " ", "\\u", "dispatch", " ", "and", " ", "dispatch_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "usi", "ng", " ", "tha", "t", " ", "method", " ", "if", " ", "presen", "t", "._", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "self_", "._", "server_", "._", "\\u", "marshal", "ed", "\\u", "dispatch_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "data_", ",_", "getattr_", "(_", "self_", ",_", "'\\u", "dispatch", "'_", ",_", "None_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "only", " ", "happ", "en", " ", "if", " ", "the", " ", "module", " ", "is", " ", "bug", "gy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "internal", " ", "error", ",", " ", "report", " ", "as", " ", "HTTP", " ", "server", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "got", " ", "a", " ", "valid", " ", "XML", " ", "RP", "C", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "type", "\"_", ",_", "\"", "text", "/", "xml", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "length", "\"_", ",_", "str_", "(_", "len_", "(_", "response_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "._", "write_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "shut", " ", "down", " ", "the", " ", "connection_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "wfile_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connection_", "._", "shutdown_", "(_", ")_", "#", " ", "Modifie", "d", " ", "here", "!", "_", "\\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_", "Xm", "l", "Rp", "c", "Server_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "logger_", "=_", "Logger_", "._", "get", "Logger_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Xm", "l", "Rp", "c", "Server_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create", "Insta", "nce", "And", "Eng", "age_", "(_", "call", "Back", "Function_", ",_", "Handle", "r", "Class_", "=_", "Secur", "e", "XML", "Rp", "c", "Request", "Handler_", ",_", "Server", "Class_", "=_", "Secur", "e", "XMLRPC", "Server_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "server", "\\u", "address_", "=_", "(_", "XMLRPC", "\\u", "SERVER", "\\u", "LISTEN", "\\u", "HOST_", ",_", "XMLRPC", "\\u", "SERVER", "\\u", "LISTEN", "\\u", "PORT_", ")_", "#", " ", "(", "address", ",", " ", "port", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "=_", "Server", "Class_", "(_", "server", "\\u", "address_", ",_", "Handle", "r", "Class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "._", "register", "\\u", "instance_", "(_", "Xm", "l", "Rp", "c", "API_", "._", "xmlrpc", "\\u", "wrappers_", "(_", "call", "Back", "Function_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sa_", "=_", "server_", "._", "socket_", "._", "getsockname", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Xm", "l", "Rp", "c", "Server_", "._", "logger_", "._", "debug_", "(_", "\"", "Servi", "ng", " ", "HTTP", "S", " ", "XMLRPC", " ", "request", "s", " ", "on", " ", "\"_", "+_", "str_", "(_", "sa_", "[_", "0_", "]_", ")_", "+_", "\":\"_", "+_", "str_", "(_", "sa_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "._", "serve", "\\u", "forever_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 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, 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 ]
Unused import
estevaofon/angry-birds-python/pymunk-4.0.0/examples/pyglet_util_demo.py
[ { "content": "\"\"\"Showcase what the output of pymunk.pyglet_util draw methods will look like.\n\nSee pygame_util_demo.py for a comparison to pygame.\n\"\"\"\n\n__version__ = \"$Id:$\"\n__docformat__ = \"reStructuredText\"\n\nimport sys\n\nimport pyglet\n \nimport pymunk\nfrom pymunk.vec2d import Vec2d\nimport pymunk.pyglet_util\n\nfrom shapes_for_draw_demos import add_objects\n\nwindow = pyglet.window.Window(600, 600)\nspace = pymunk.Space()\n\nadd_objects(space)\n\n\ntextbatch = pyglet.graphics.Batch()\npyglet.text.Label('Demo example of shapes drawn by pyglet_util.draw()',\n x=5, y=5, batch=textbatch, color=(200,200,200,200))\npyglet.text.Label('Static shapes', x=50, y=570, batch=textbatch)\npyglet.text.Label('Dynamic shapes', x=250, y=570, batch=textbatch)\npyglet.text.Label('Constraints', x=450, y=570, batch=textbatch)\npyglet.text.Label('Other', x=450, y=290, batch=textbatch)\n\n\nbatch = pyglet.graphics.Batch()\n\n \n \n\npyglet.app.run()", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@window.event\ndef on_draw():\n pyglet.gl.glClearColor(0,0,0,1)\n window.clear()\n \n pymunk.pyglet_util.draw(space)\n textbatch.draw()", "metadata": "root.on_draw", "header": "['module', '___EOS___']", "index": 35 }, { "content": "@window.event\ndef on_key_press(symbol, modifiers):\n if symbol == pyglet.window.key.P:\n pyglet.image.get_buffer_manager().get_color_buffer().save(\"pyglet_util_demo.png\")", "metadata": "root.on_key_press", "header": "['module', '___EOS___']", "index": 43 } ]
[ { "span": "import sys", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 10 }, { "span": "from pymunk.vec2d import Vec2d", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 30 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Show", "case", " ", "what", " ", "the", " ", "output", " ", "of", " ", "pym", "unk", ".", "pyg", "let", "\\u", "util", " ", "draw", " ", "method", "s", " ", "will", " ", "look", " ", "like", ".", "\\", "10", ";", "\\", "10", ";", "See", " ", "pyga", "me", "\\u", "util", "\\u", "demo", ".", "py", " ", "for", " ", "a", " ", "compa", "ris", "on", " ", "to", " ", "pyga", "me", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "version\\u\\u_", "=_", "\"$", "Id", ":$", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "docformat", "\\u\\u_", "=_", "\"", "re", "Structur", "ed", "Text", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pyglet_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pym", "unk", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pym", "unk", "_", "._", "vec2", "d_", "import_", "Vec2", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pym", "unk", "_", "._", "pyg", "let", "\\u", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "shape", "s", "\\u", "for", "\\u", "draw", "\\u", "demo", "s_", "import_", "add", "\\u", "objects_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "window_", "=_", "pyglet_", "._", "window_", "._", "Window_", "(_", "600_", ",_", "600_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "space_", "=_", "pym", "unk", "_", "._", "Space_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "add", "\\u", "objects_", "(_", "space_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "textb", "atch_", "=_", "pyglet_", "._", "graphics_", "._", "Batch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyglet_", "._", "text_", "._", "Label_", "(_", "'", "Demo", " ", "example", " ", "of", " ", "shape", "s", " ", "draw", "n", " ", "by", " ", "pyg", "let", "\\u", "util", ".", "draw", "()'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "=_", "5_", ",_", "y_", "=_", "5_", ",_", "batch_", "=_", "textb", "atch_", ",_", "color_", "=_", "(_", "200_", ",_", "200_", ",_", "200_", ",_", "200_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyglet_", "._", "text_", "._", "Label_", "(_", "'", "Static", " ", "shape", "s", "'_", ",_", "x_", "=_", "50_", ",_", "y_", "=_", "570", "_", ",_", "batch_", "=_", "textb", "atch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyglet_", "._", "text_", "._", "Label_", "(_", "'", "Dynamic", " ", "shape", "s", "'_", ",_", "x_", "=_", "250_", ",_", "y_", "=_", "570", "_", ",_", "batch_", "=_", "textb", "atch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyglet_", "._", "text_", "._", "Label_", "(_", "'", "Constr", "aint", "s", "'_", ",_", "x_", "=_", "450_", ",_", "y_", "=_", "570", "_", ",_", "batch_", "=_", "textb", "atch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyglet_", "._", "text_", "._", "Label_", "(_", "'", "Ot", "her", "'_", ",_", "x_", "=_", "450_", ",_", "y_", "=_", "290_", ",_", "batch_", "=_", "textb", "atch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "batch_", "=_", "pyglet_", "._", "graphics_", "._", "Batch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pyglet_", "._", "app_", "._", "run_", "(_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "window_", "._", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "on", "\\u", "draw_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pyglet_", "._", "gl_", "._", "gl", "Clear", "Color_", "(_", "0_", ",_", "0_", ",_", "0_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "window_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pym", "unk", "_", "._", "pyg", "let", "\\u", "util_", "._", "draw_", "(_", "space_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "textb", "atch_", "._", "draw_", "(_", ")_", "\\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_", "@_", "window_", "._", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "on", "\\u", "key", "\\u", "press_", "(_", "symbol_", ",_", "modifiers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "symbol_", "==_", "pyglet_", "._", "window_", "._", "key_", "._", "P_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pyglet_", "._", "image_", "._", "get", "\\u", "buffer", "\\u", "manager_", "(_", ")_", "._", "get", "\\u", "color", "\\u", "buffer_", "(_", ")_", "._", "save_", "(_", "\"", "pyg", "let", "\\u", "util", "\\u", "demo", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 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, 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, 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 ]
Unused import
nasa/CrisisMappingToolkit/bin/detect_flood_modis.py
[ { "content": "# -----------------------------------------------------------------------------\n# Copyright * 2014, United States Government, as represented by the\n# Administrator of the National Aeronautics and Space Administration. All\n# rights reserved.\n#\n# The Crisis Mapping Toolkit (CMT) v1 platform is licensed under the Apache\n# License, Version 2.0 (the \"License\"); you may not use this file except in\n# compliance with the License. You may obtain a copy of the License at\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, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations under\n# the License.\n# -----------------------------------------------------------------------------\n\nimport logging\nlogging.basicConfig(level=logging.ERROR)\ntry:\n import cmt.ee_authenticate\nexcept:\n import sys\n import os.path\n sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))\n import cmt.ee_authenticate\n\nimport matplotlib\n# matplotlib.use('tkagg')\n\nimport sys\nimport os\nimport ee\nimport functools\n\nimport cmt.domain\nfrom cmt.modis.flood_algorithms import *\n\nfrom cmt.mapclient_qt import centerMap, addToMap\nimport cmt.util.evaluation\nimport cmt.util.gui_util\n\n'''\nTool for testing MODIS based flood detection algorithms using a simple GUI.\n'''\n\n# --------------------------------------------------------------\n# Configuration\n\n# Specify each algorithm to be concurrently run on the data set - see /modis/flood_algorithms.py\n# ALGORITHMS = [DARTMOUTH, DART_LEARNED, DIFFERENCE, DIFF_LEARNED, FAI, FAI_LEARNED, EVI, XIAO, SVM, RANDOM_FORESTS, CART, DNNS, DNNS_DEM]\n# ALGORITHMS = [DART_LEARNED, DIFF_LEARNED, FAI_LEARNED, MODNDWI_LEARNED, EVI, XIAO, MARTINIS_TREE, SVM, RANDOM_FORESTS, CART, DNNS, DNNS_DEM, ADABOOST, ADABOOST_DEM]\n# ALGORITHMS = [DNNS, DNNS_DEM]\n# ALGORITHMS = [SVM, RANDOM_FORESTS, CART]\n# ALGORITHMS = [ADABOOST, ADABOOST_DEM]\n# ALGORITHMS = [ACTIVE_CONTOUR]\n\n#ALGORITHMS = [DART_LEARNED, EVI, XIAO, MARTINIS_TREE, CART, ADABOOST, ADABOOST_DEM]\nALGORITHMS = [DIFFERENCE, EVI, XIAO, ADABOOST]\n#ALGORITHMS = []\n\n# --------------------------------------------------------------\n# Functions\n\n\n\n# --------------------------------------------------------------\n# main()\n\n# Get the domain XML file from the command line arguments\nif len(sys.argv) < 2:\n print 'Usage: detect_flood_modis.py domain.xml'\n sys.exit(0)\n\ncmt.ee_authenticate.initialize()\n\n\n# Fetch data set information\ndomain = cmt.domain.Domain()\ndomain.load_xml(sys.argv[1])\n\n# Display the Landsat and MODIS data for the data set\ncmt.util.gui_util.visualizeDomain(domain)\n\n#\n# import cmt.modis.adaboost\n# cmt.modis.adaboost.adaboost_learn() # Adaboost training\n# #cmt.modis.adaboost.adaboost_dem_learn(None) # Adaboost DEM stats collection\n# raise Exception('DEBUG')\n\nwaterMask = ee.Image(\"MODIS/MOD44W/MOD44W_005_2000_02_24\").select(['water_mask'], ['b1'])\naddToMap(waterMask.mask(waterMask), {'min': 0, 'max': 1}, 'Permanent Water Mask', False)\n\n# For each of the algorithms\nfor a in range(len(ALGORITHMS)):\n # Run the algorithm on the data and get the results\n try:\n (alg, result) = detect_flood(domain, ALGORITHMS[a])\n if result is None:\n continue\n\n # These lines are needed for certain data sets which EE is not properly masking!!!\n # result = result.mask(domain.skybox_nir.image.reduce(ee.Reducer.allNonZero()))\n # result = result.mask(domain.skybox.image.reduce(ee.Reducer.allNonZero()))\n\n # Get a color pre-associated with the algorithm, then draw it on the map\n color = get_algorithm_color(ALGORITHMS[a])\n addToMap(result.mask(result), {'min': 0, 'max': 1, 'opacity': 0.5, 'palette': '000000, ' + color},\n alg, False)\n\n # Compare the algorithm output to the ground truth and print the results\n if domain.ground_truth:\n cmt.util.evaluation.evaluate_approach_thread(functools.partial(\n evaluation_function, alg=ALGORITHMS[a]), result, domain.ground_truth, domain.bounds,\n is_algorithm_fractional(ALGORITHMS[a]))\n except Exception, e:\n print('Caught exception running algorithm: ' + get_algorithm_name(ALGORITHMS[a]) + '\\n' +\n str(e) + '\\n')\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def evaluation_function(pair, alg):\n '''Pretty print an algorithm and its statistics'''\n (precision, recall, evalRes, noTruth) = pair\n print '%s: (%4g, %4g, %4g)' % (get_algorithm_name(alg), precision, recall, noTruth)", "metadata": "root.evaluation_function", "header": "['module', '___EOS___']", "index": 65 } ]
[ { "span": "import matplotlib", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 17 }, { "span": "from cmt.mapclient_qt import centerMap, addToMap", "start_line": 38, "start_column": 0, "end_line": 38, "end_column": 48 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "*", " ", "2014", ",", " ", "Unit", "ed", " ", "State", "s", " ", "Gov", "ern", "ment", ",", " ", "as", " ", "represent", "ed", " ", "by", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Administra", "tor", " ", "of", " ", "the", " ", "Nat", "ional", " ", "Aer", "ona", "uti", "cs", " ", "and", " ", "Spac", "e", " ", "Administrati", "on", ".", " ", "All_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Cri", "sis", " ", "Map", "ping", " ", "Tool", "kit", " ", "(", "CM", "T", ")", " ", "v1", " ", "platform", " ", "is", " ", "license", "d", " ", "under", " ", "the", " ", "Ap", "ache_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", ".", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\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", ",", " ", "WITH", "OUT_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", " ", "See", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", " ", "limit", "ation", "s", " ", "under", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "basic", "Config_", "(_", "level_", "=_", "logging_", "._", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "cmt", "_", "._", "ee", "\\u", "authenticate_", "\\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_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "realpath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ",_", "'..'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cmt", "_", "._", "ee", "\\u", "authenticate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "matplotlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "mat", "plotlib", ".", "use", "('", "tk", "agg", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "ee_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "functools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "cmt", "_", "._", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cmt", "_", "._", "modi", "s_", "._", "flood", "\\u", "algorithms_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "cmt", "_", "._", "map", "client", "\\u", "qt_", "import_", "center", "Map_", ",_", "add", "To", "Map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cmt", "_", "._", "util_", "._", "evaluation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cmt", "_", "._", "util_", "._", "gui", "\\u", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", "Tool", " ", "for", " ", "testi", "ng", " ", "MODI", "S", " ", "based", " ", "flood", " ", "detect", "ion", " ", "algo", "rit", "hms", " ", "usi", "ng", " ", "a", " ", "simple", " ", "GU", "I", ".", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Configuration_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Speci", "fy", " ", "each", " ", "algo", "rit", "hm", " ", "to", " ", "be", " ", "concurrent", "ly", " ", "run", " ", "on", " ", "the", " ", "data", " ", "set", " ", "-", " ", "see", " ", "/", "modi", "s", "/", "flood", "\\u", "algo", "rit", "hms", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "DAR", "TM", "OUT", "H", ",", " ", "DAR", "T", "\\u", "LEA", "RN", "ED", ",", " ", "DIFF", "ERE", "NCE", ",", " ", "DIFF", "\\u", "LEA", "RN", "ED", ",", " ", "FA", "I", ",", " ", "FA", "I", "\\u", "LEA", "RN", "ED", ",", " ", "EV", "I", ",", " ", "XI", "AO", ",", " ", "SV", "M", ",", " ", "RANDOM", "\\u", "FORE", "ST", "S", ",", " ", "CAR", "T", ",", " ", "DNN", "S", ",", " ", "DNN", "S", "\\u", "DEM", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "DAR", "T", "\\u", "LEA", "RN", "ED", ",", " ", "DIFF", "\\u", "LEA", "RN", "ED", ",", " ", "FA", "I", "\\u", "LEA", "RN", "ED", ",", " ", "MOD", "ND", "WI", "\\u", "LEA", "RN", "ED", ",", " ", "EV", "I", ",", " ", "XI", "AO", ",", " ", "MAR", "TIN", "IS", "\\u", "TREE", ",", " ", "SV", "M", ",", " ", "RANDOM", "\\u", "FORE", "ST", "S", ",", " ", "CAR", "T", ",", " ", "DNN", "S", ",", " ", "DNN", "S", "\\u", "DEM", ",", " ", "ADA", "BOO", "ST", ",", " ", "ADA", "BOO", "ST", "\\u", "DEM", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "DNN", "S", ",", " ", "DNN", "S", "\\u", "DEM", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "SV", "M", ",", " ", "RANDOM", "\\u", "FORE", "ST", "S", ",", " ", "CAR", "T", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "ADA", "BOO", "ST", ",", " ", "ADA", "BOO", "ST", "\\u", "DEM", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "ACTI", "VE", "\\u", "CONT", "OUR", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[", "DAR", "T", "\\u", "LEA", "RN", "ED", ",", " ", "EV", "I", ",", " ", "XI", "AO", ",", " ", "MAR", "TIN", "IS", "\\u", "TREE", ",", " ", "CAR", "T", ",", " ", "ADA", "BOO", "ST", ",", " ", "ADA", "BOO", "ST", "\\u", "DEM", "]_", "\\u\\u\\uNL\\u\\u\\u_", "ALGO", "RIT", "HM", "S_", "=_", "[_", "DIFF", "ERE", "NCE_", ",_", "EV", "I_", ",_", "XI", "AO", "_", ",_", "ADA", "BOO", "ST_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "ALGO", "RIT", "HM", "S", " ", "=", " ", "[]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Functions_", "\\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_", "#", " ", "main", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "domain", " ", "XML", " ", "file", " ", "from", " ", "the", " ", "command", " ", "line", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "sys_", "._", "argv_", ")_", "<_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Us", "age", ":", " ", "detect", "\\u", "flood", "\\u", "modi", "s", ".", "py", " ", "domain", ".", "xml", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmt", "_", "._", "ee", "\\u", "authenticate_", "._", "initialize_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fe", "tch", " ", "data", " ", "set", " ", "information_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "cmt", "_", "._", "domain_", "._", "Domain_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain_", "._", "load", "\\u", "xml_", "(_", "sys_", "._", "argv_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Display", " ", "the", " ", "Land", "sat", " ", "and", " ", "MODI", "S", " ", "data", " ", "for", " ", "the", " ", "data", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "cmt", "_", "._", "util_", "._", "gui", "\\u", "util_", "._", "visualize", "Domain_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "import", " ", "cmt", ".", "modi", "s", ".", "ada", "boost", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cmt", ".", "modi", "s", ".", "ada", "boost", ".", "ada", "boost", "\\u", "learn", "()", " ", " ", " ", " ", " ", "#", " ", "Ada", "boost", " ", "training_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "#", "cmt", ".", "modi", "s", ".", "ada", "boost", ".", "ada", "boost", "\\u", "dem", "\\u", "learn", "(", "Non", "e", ")", " ", "#", " ", "Ada", "boost", " ", "DEM", " ", "stats", " ", "collection_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "raise", " ", "Except", "ion", "('", "DEBU", "G", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "water", "Mask_", "=_", "ee_", "._", "Image_", "(_", "\"", "MODI", "S", "/", "MOD", "4", "4", "W", "/", "MOD", "4", "4", "W", "\\u", "005", "\\u", "2000", "\\u", "02", "\\u", "24", "\"_", ")_", "._", "select_", "(_", "[_", "'", "water", "\\u", "mask", "'_", "]_", ",_", "[_", "'", "b1", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "To", "Map_", "(_", "water", "Mask_", "._", "mask_", "(_", "water", "Mask_", ")_", ",_", "{_", "'", "min", "'_", ":_", "0_", ",_", "'", "max", "'_", ":_", "1_", "}_", ",_", "'", "Permanent", " ", "Water", " ", "Mask", "'_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "each", " ", "of", " ", "the", " ", "algorithms_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "a_", "in_", "range_", "(_", "len_", "(_", "ALGO", "RIT", "HM", "S_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Run", " ", "the", " ", "algo", "rit", "hm", " ", "on", " ", "the", " ", "data", " ", "and", " ", "get", " ", "the", " ", "results_", "\\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 ", " _", "(_", "alg_", ",_", "result_", ")_", "=_", "detect", "\\u", "flood", "_", "(_", "domain_", ",_", "ALGO", "RIT", "HM", "S_", "[_", "a_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "se", " ", "lines", " ", "are", " ", "need", "ed", " ", "for", " ", "cert", "ain", " ", "data", " ", "sets", " ", "whi", "ch", " ", "EE", " ", "is", " ", "not", " ", "proper", "ly", " ", "masking", "!!!", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "result", " ", "=", " ", "result", ".", "mask", "(", "domain", ".", "sky", "box", "\\u", "ni", "r", ".", "image", ".", "reduce", "(", "ee", ".", "Reduce", "r", ".", "all", "Non", "Zero", "())", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "result", " ", "=", " ", "result", ".", "mask", "(", "domain", ".", "sky", "box", ".", "image", ".", "reduce", "(", "ee", ".", "Reduce", "r", ".", "all", "Non", "Zero", "())", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "a", " ", "color", " ", "pre", "-", "associate", "d", " ", "with", " ", "the", " ", "algo", "rit", "hm", ",", " ", "then", " ", "draw", " ", "it", " ", "on", " ", "the", " ", "map_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "color_", "=_", "get", "\\u", "algo", "rit", "hm", "\\u", "color_", "(_", "ALGO", "RIT", "HM", "S_", "[_", "a_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "To", "Map_", "(_", "result_", "._", "mask_", "(_", "result_", ")_", ",_", "{_", "'", "min", "'_", ":_", "0_", ",_", "'", "max", "'_", ":_", "1_", ",_", "'", "opa", "city", "'_", ":_", "0.5_", ",_", "'", "palette", "'_", ":_", "'", "000000", ",", " ", "'_", "+_", "color_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "alg_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compare", " ", "the", " ", "algo", "rit", "hm", " ", "output", " ", "to", " ", "the", " ", "ground", " ", "truth", " ", "and", " ", "print", " ", "the", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "domain_", "._", "ground", "\\u", "truth_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmt", "_", "._", "util_", "._", "evaluation_", "._", "evaluate", "\\u", "appro", "ach", "\\u", "thread_", "(_", "functools_", "._", "partial_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "evaluat", "ion", "\\u", "function_", ",_", "alg_", "=_", "ALGO", "RIT", "HM", "S_", "[_", "a_", "]_", ")_", ",_", "result_", ",_", "domain_", "._", "ground", "\\u", "truth_", ",_", "domain_", "._", "bounds_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "algo", "rit", "hm", "\\u", "fractional", "_", "(_", "ALGO", "RIT", "HM", "S_", "[_", "a_", "]_", ")_", ")_", "\\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_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Cau", "ght", " ", "exception", " ", "runn", "ing", " ", "algo", "rit", "hm", ":", " ", "'_", "+_", "get", "\\u", "algo", "rit", "hm", "\\u", "name_", "(_", "ALGO", "RIT", "HM", "S_", "[_", "a_", "]_", ")_", "+_", "'\\\\", "n", "'_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "str_", "(_", "e_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\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_", "evaluat", "ion", "\\u", "function_", "(_", "pair_", ",_", "alg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Pret", "ty", " ", "print", " ", "an", " ", "algo", "rit", "hm", " ", "and", " ", "its", " ", "statistic", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "precision_", ",_", "recall_", ",_", "eval", "Res_", ",_", "no", "Tru", "th_", ")_", "=_", "pair_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'%", "s", ":", " ", "(%", "4", "g", ",", " ", "%", "4", "g", ",", " ", "%", "4", "g", ")'_", "%_", "(_", "get", "\\u", "algo", "rit", "hm", "\\u", "name_", "(_", "alg_", ")_", ",_", "precision_", ",_", "recall_", ",_", "no", "Tru", "th_", ")_", "\\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,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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 ]
Wrong number of arguments in a call
benbaptist/minecraft-wrapper/example-plugins/SmallBrother.py
[ { "content": "\tdef write(self, id, expressions, payload):\n\t\tb = self.pack_byte(id)\n\t\tb += self.pack_double(time.time())\n\t\tfor i,v in enumerate(expressions.split(\"|\")):\n\t\t\ttype, value = v, payload[i]\n\t\t\tif type == \"byte\": b += self.pack_byte(value)\n\t\t\tif type == \"short\": b += self.pack_short(value)\n\t\t\tif type == \"ushort\": b += self.pack_ushort(value)\n\t\t\tif type == \"int\": b += self.pack_int(value)\n\t\t\tif type == \"string\": b += self.pack_string(value)\n\t\t\tif type == \"double\": b += self.pack_double(value)\n\t\t\tif type == \"bytearray\": b += self.pack_bytearray(value)\n\t\t\tif type == \"position\": b += self.pack_position(value)\n\t\treturn b", "metadata": "root.Logger.write", "header": "['class', 'Logger', ':', '___EOS___']", "index": 257 }, { "content": "\tdef close_chest(self, x, y, z):\n\t\treturn self.write(uuid, 0x05, \"int|int|int\", (x, y, z))", "metadata": "root.Logger.close_chest", "header": "['class', 'Logger', ':', '___EOS___']", "index": 278 }, { "content": "\tdef chest_action(self, x, y, z, action, slot, itemid, damage):\n\t\treturn self.write(uuid, 0x04, \"position|byte|byte|short|short\", ((x, y, z), action, slot, itemid, damage))", "metadata": "root.Logger.chest_action", "header": "['class', 'Logger', ':', '___EOS___']", "index": 280 } ]
[ { "span": "self.write(uuid, 0x05, \"int|int|int\", (x, y, z))", "start_line": 279, "start_column": 9, "end_line": 279, "end_column": 57 }, { "span": "self.write(uuid, 0x04, \"position|byte|byte|short|short\", ((x, y, z), action, slot, itemid, damage))", "start_line": 281, "start_column": 9, "end_line": 281, "end_column": 108 } ]
[ { "span": "def write(self, id, expressions, payload):", "start_line": 257, "start_column": 1, "end_line": 257, "end_column": 43 } ]
1
false
[ "[CLS]_", "Wro", "ng_", "number_", "of_", "arguments_", "in_", "a_", "call_", "[SEP]_", "class_", "Logger_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write_", "(_", "self_", ",_", "id_", ",_", "expressions_", ",_", "payload_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "b_", "=_", "self_", "._", "pack", "\\u", "byte_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "+=_", "self_", "._", "pack", "\\u", "double_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "v_", "in_", "enumerate_", "(_", "expressions_", "._", "split_", "(_", "\"|\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "type_", ",_", "value_", "=_", "v_", ",_", "payload_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "byte", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "byte_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "short", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "short_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "ushort", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "ushort", "_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "int", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "int_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "string", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "string_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "double", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "double_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "bytea", "rray", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "bytearray_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "==_", "\"", "position", "\"_", ":_", "b_", "+=_", "self_", "._", "pack", "\\u", "position_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Logger_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "close", "\\u", "chest", "_", "(_", "self_", ",_", "x_", ",_", "y_", ",_", "z_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "write_", "(_", "uuid_", ",_", "0x05_", ",_", "\"", "int", "|", "int", "|", "int", "\"_", ",_", "(_", "x_", ",_", "y_", ",_", "z_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Logger_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "chest", "\\u", "action_", "(_", "self_", ",_", "x_", ",_", "y_", ",_", "z_", ",_", "action_", ",_", "slot_", ",_", "itemi", "d_", ",_", "damage_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "write_", "(_", "uuid_", ",_", "0x04_", ",_", "\"", "position", "|", "byte", "|", "byte", "|", "short", "|", "short", "\"_", ",_", "(_", "(_", "x_", ",_", "y_", ",_", "z_", ")_", ",_", "action_", ",_", "slot_", ",_", "itemi", "d_", ",_", "damage_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused local variable
openeventdata/petrarch2/petrarch2/PETRtree.py
[ { "content": " def mix_codes(self,agents,actors):\n \"\"\"\n Combine the actor codes and agent codes addressing duplicates\n and removing the general \"~PPL\" if there's a better option.\n \n Parameters\n -----------\n agents, actors : Lists of their respective codes\n \n \n Returns\n -------\n codes: list\n [Agent codes] x [Actor codes]\n \n \"\"\"\n \n \n# -- print('mc-entry',actors,agents)\n codes = set()\n mix = lambda a, b : a + b if not b in a else a\n actors = actors if actors else ['~']\n for ag in agents:\n if ag == '~PPL' and len(agents) > 1:\n continue\n# actors = map( lambda a : mix( a[0], ag[1:]), actors)\n actors = map( lambda a : mix( a, ag[1:]), actors)\n \n# -- print('mc-1',actors)\n return filter(lambda a : a not in ['','~','~~',None],actors)\n \n \n \n # 16.04.25 hmmm, this is either a construct of utterly phenomenal subtlety or else we never hit this code...\n codes = set()\n print('WTF-1')\n for act in (actors if actors else ['~']):\n for ag in (agents if agents else ['~']) :\n if ag == \"~PPL\" and len(agents) > 1:\n continue\n code = act\n if not ag[1:] in act:\n code += ag[1:]\n if not code in ['~','~~',\"\"]:\n codes.add(code)\n return list(codes)", "metadata": "root.Phrase.mix_codes", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 158 }, { "content": " def is_valid(self):\n \"\"\"\n This method is largely to overcome frequently made Stanford errors, where phrases like \"exiled dissidents\" were\n marked as verb phrases, and treating them as such would yield weird parses.\n \n Once such a phrase is identified because of its weird distribution, it is converted to \n a NounPhrase object\n \n \"\"\"\n try:\n if self.children[0].label == \"VBN\":\n helping = [\"HAVE\",\"HAD\",\"HAVING\",\"HAS\"]\n if ((not (self.parent.get_head()[0] in helping or self.parent.children[0].text in helping)) and\n len(filter(lambda a: isinstance(a,VerbPhrase),self.parent.children)) <= 1 and\n not self.check_passive()):\n \n self.valid = False\n \n np_replacement = NounPhrase(\"NP\",self.date,self.sentence)\n np_replacement.children = self.children\n np_replacement.parent = self.parent\n np_replacement.index = self.index\n \n self.parent.children.remove(self)\n self.parent.children.insert(self.index,np_replacement)\n del(self)\n self = np_replacement\n return False\n self.valid = True\n except IndexError as e:\n self.valid = True\n return True", "metadata": "root.VerbPhrase.is_valid", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 594 }, { "content": " def get_meaning(self):\n \"\"\"\n This determines the event coding of the subtree rooted in this verb phrase.\n \n Four methods are key in this process: get_upper(), get_lower(), get_code() \n and match_transform().\n \n First, get_meaning() gets the verb code from get_code()\n \n Then, it checks passivity. If the verb is passive, then it looks within \n verb phrases headed by [by, from, in] for the source, and for an explicit target\n in verb phrases headed by [at,against,into,towards]. If no target is found,\n this space is filled with 'passive', a flag used later to assign a target\n if it is in the grammatical subject position. \n \n If the verb is not passive, then the process goes:\n \n 1) call get_upper() and get_lower() to check for a grammatical subject \n and find the coding of the subtree and children, respectively.\n \n 2) If get_lower returned a list of events, combine those events with\n the upper and code, add to event list.\n \n 3) Otherwise, combine upper, lower, and code and add to event list\n \n 4) Check to see if there are S-level children, if so, combine with\n upper and code, add to list. \n \n 5) call match_transform() on all events in the list\n \n \n Parameters\n ----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n events: list\n List of events coded by the subtree rooted in this phrase.\n \n \"\"\"\n time1 = time.time()\n self.get_meaning = self.return_meaning\n \n c, passive,meta = self.get_code()\n s_options = filter(lambda a: a.label in \"SBAR\",self.children)\n\n def resolve_events(event):\n \"\"\"\n Helper method to combine events, accounting for \n missing sources, and targets, passives, multiple-\n target passives, and codeless verbs.\n \n Parameters\n ----------\n event: tuple\n (source, target, code) of lower event\n \n Returns\n -------\n returns: [tuple]\n list of resolved event tuples\n \"\"\"\n returns = []\n first,second,third = [up,\"\",\"\"]\n if not (up or c) :\n return [event]\n if not isinstance(event,tuple):\n second = event\n third = c\n if passive:\n for item in first:\n e2 = ([second],item,passive)\n self.sentence.metadata[id(e2)] = [event,meta,7]\n returns.append(e2)\n elif event[1] == 'passive':\n first = event[0]\n third = utilities.combine_code(c,event[2])\n if up:\n returns = []\n for source in up:\n e = (first,source,third)\n self.sentence.metadata[id(e)] = [event,up,1]\n returns.append(e)\n return returns\n second = 'passive'\n elif not event[0] in ['',[],[\"\"],[\"~\"],[\"~~\"]]:\n second = event\n third = c\n else:\n second = event[1]\n third = utilities.combine_code(c,event[2])\n e = (first,second,third)\n self.sentence.metadata[id(e)] = [event,c,meta ,2]\n return returns + [e]\n\n events = []\n up = self.get_upper()\n if self.check_passive() or (passive and not c):\n # Check for source in preps\n source_options = []\n target_options = up\n for child in self.children:\n if isinstance(child,PrepPhrase):\n if child.get_prep() in [\"BY\",\"FROM\",\"IN\"]:\n source_options += child.get_meaning()\n meta.append((child.prep, child.get_meaning()))\n elif child.get_prep() in [\"AT\",\"AGAINST\",\"INTO\",\"TOWARDS\"]:\n target_options += child.get_meaning()\n meta.append((child.prep, child.get_meaning()))\n if not target_options:\n target_options = [\"passive\"]\n if source_options or c:\n \n for i in target_options:\n e = (source_options, i ,c if self.check_passive() else passive)\n events.append(e)\n self.sentence.metadata[id(e)] = [None,e,meta,3]\n self.meaning = events\n return events\n \n up = \"\" if up in ['',[],[\"\"],[\"~\"],[\"~~\"]] else up\n low,neg = self.get_lower()\n if not low:\n low = \"\"\n if neg:\n c = 0\n \n if isinstance(low,list):\n for event in low:\n events += resolve_events(event)\n elif not s_options:\n if up or c:\n e = (up,low,c)\n self.sentence.metadata[id(e)] = [None,e,4]\n events.append(e)\n elif low:\n events.append(low)\n\n lower = map(lambda a: a.get_meaning(),s_options)\n sents = []\n\n for item in lower:\n sents += item\n \n if sents and not events: # Only if nothing else has been found do we look at lower NP's?\n # This decreases our coding frequency, but removes many false positives\n for event in sents:\n if isinstance(event,tuple) and (event[1] or event[2]):\n for ev in resolve_events(event):\n if isinstance(ev[1],list):\n for item in ev[1]:\n local = (ev[0],item,ev[2])\n self.sentence.metadata[id(local)] = [ev,item,5]\n events.append(local)\n else:\n events += resolve_events(event)\n maps = []\n for i in events:\n evs = self.match_transform(i)\n if isinstance(evs,tuple):\n for j in evs[0]:\n maps.append(j)\n self.sentence.metadata[id(j)] = [i,evs[1],6]\n else:\n maps += evs\n self.meaning = maps\n return maps", "metadata": "root.VerbPhrase.get_meaning", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 642 }, { "content": " def get_code(self):\n \"\"\"\n Match the codes from the Verb Dictionary.\n \n Step 1. Check for compound verb matches\n \n Step 2. Check for pattern matches via match_pattern() method\n \n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n code: int\n Code described by this verb, best read in hex\n \"\"\"\n \n self.get_code = self.return_code\n meta = []\n dict = PETRglobals.VerbDict['verbs']\n if 'AND' in map(lambda a: a.text, self.children):\n return 0,0,['and']\n patterns = PETRglobals.VerbDict['phrases']\n verb = \"TO\" if self.children[0].label == \"TO\" else self.get_head()[0]\n meta.append(verb)\n meaning = \"\"\n path = dict\n passive = False\n if verb in dict:\n code = 0\n path = dict[verb]\n if ['#'] == path.keys():\n path = path['#']\n if True or path.keys() == ['#']: # Pre-compounds are weird\n try:\n code = path['#']['code']\n meaning = path['#']['meaning']\n \n self.verbclass = meaning if not meaning == \"\" else verb\n if not code == '':\n active, passive = utilities.convert_code(code)\n self.code = active\n except:\n self.code = (0,0,[])\n else:\n # Post - compounds\n for child in self.children:\n if child.label in [\"PRT\",\"ADVP\"]:\n if child.children[0].text in path:\n meta.append(child.children[0].text)\n path = path[child.children[0].text]\n if \"#\" in path:\n try:\n code = path['#']['#']['code']\n meaning = path['#']['#']['meaning']\n self.verbclass = meaning if not meaning == \"\" else verb\n if not code == '':\n active, passive = utilities.convert_code(code)\n self.code = active\n except:\n pass\n \n# -- print('++1')\n match = self.match_pattern()\n# -- print('++2')\n if match:\n# -- print('++4',match)\n# -- print('++3',match['line'])\n meta.append(match['line'])\n# -- print(match)\n active, passive = utilities.convert_code(match['code'])\n self.code = active\n if passive and not active:\n self.check_passive = lambda : True\n self.code = passive\n return self.code, passive,meta", "metadata": "root.VerbPhrase.get_code", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 1016 }, { "content": " def match_pattern(self):\n \"\"\" \n Match the tree against patterns specified in the dictionary. For a more illustrated explanation\n of how this process works, see the Petrarch2.pdf file in the documentation. \n \n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n False if no match, dict of match if present.\n \n \"\"\"\n meaning = self.verbclass\n code = self.code\n\n def match_phrase(path,phrase):\n # Having matched the head of the phrase, this matches the full noun phrase, if specified\n# -- print('mph-entry')\n if not phrase:\n# -- print('mph-False')\n return False\n for item in filter(lambda b: b.text in path,phrase.children):\n subpath = path[item.text]\n# -- print('mph-rr-1')\n match = reroute(subpath,lambda a: match_phrase(a,item.head_phrase))\n if match:\n item.color = True\n return match\n# -- print('mph-reroute') \n return reroute(path,lambda a: match_phrase(a,phrase.head_phrase))\n \n def match_noun(path,phrase = self if not self.check_passive() else self.get_S(),preplimit = 0):\n # Matches a noun or head of noun phrase\n# -- print('mn-entry')\n noun_phrases = []\n if not phrase:\n return False\n if preplimit:\n for sib in phrase.children:\n if isinstance(sib,PrepPhrase) and len(sib.children) > 1 and sib.get_prep() in [\"BY\",\"FROM\"] :\n noun_phrases.append(sib.children[1])\n else:\n for child in phrase.children:\n if child.label in (\"NP\",\"ADVP\"):\n noun_phrases.append(child)\n if isinstance(phrase,NounPhrase):\n noun_phrases.append(phrase)\n \n for item in noun_phrases:\n head,headphrase = item.get_head()\n \n if head and head in path:\n subpath = path[head]\n \n # First check within the NP for PP's\n skip = lambda a: False\n match = reroute(subpath, skip , skip , lambda a: match_prep(a,item), skip ,0)\n if match:\n headphrase.children[-1].color = True\n return match\n\n # Then check the other siblings\n match = reroute(subpath,(lambda a : match_phrase(a,item.head_phrase))\n if isinstance(item,NounPhrase) else None ) # pas 16.04.21: Trapped None by having reroute return False\n if match:\n headphrase.children[-1].color = True\n return match\n if '^' in path:\n phrase.color = True\n# -- print('mn-reroute1')\n return reroute(path['^'], lambda a: match_phrase(a,phrase.head_phrase))\n# -- print('mn-reroute2')\n return reroute(path,lambda a: match_phrase(a,phrase.head_phrase))\n\n def match_prep(path,phrase=self):\n # Matches preposition\n# -- print('mp-entry')\n for item in filter(lambda b: isinstance(b,PrepPhrase),phrase.children):\n prep = item.children[0].text\n if prep in path:\n subpath = path[prep]\n# -- print('mp-reroute1') \n match = reroute(subpath,\n lambda a : match_noun(a,item.children[1])if len(item.children) > 1 else False,\n match_prep)\n if match:\n# -- print('mp-False')\n return match\n# -- print('mp-reroute2') \n return reroute(path, o2 = match_prep)\n\n def reroute(subpath, o1 = match_noun, o2 = match_noun, o3 = match_prep, o4 = match_noun, exit = 1):\n# -- print('rr-entry:') # ,subpath\n if not o1: # match_noun() can call reroute() with o1 == None; guessing returning False is the appropriate response pas 16.04.21\n return False\n if '-' in subpath:\n match = o1(subpath['-'])\n if match:\n# -- print('rr-- match')\n return match\n \n if ',' in subpath:\n# -- print('rr-,')\n match = o2(subpath[','])\n if match:\n return match\n \n if '|' in subpath:\n# -- print('rr-|')\n match = o3(subpath['|'])\n if match:\n return match\n \n if '*' in subpath:\n# -- print('rr-*')\n match = o4(subpath['*'])\n if match:\n return match\n \n if '#' in subpath and exit:\n# -- print('rr-#')\n return subpath['#']\n \n# -- print('rr-False')\n return False\n \n # Match pattern\n if meaning in PETRglobals.VerbDict['phrases']:\n path = PETRglobals.VerbDict['phrases'][meaning]\n if self.check_passive():\n return match_noun(path,self,1)\n else:\n return match_noun(path,self.get_S())\n return False", "metadata": "root.VerbPhrase.match_pattern", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 1188 } ]
[ { "span": "codes ", "start_line": 177, "start_column": 8, "end_line": 177, "end_column": 13 }, { "span": "self ", "start_line": 620, "start_column": 20, "end_line": 620, "end_column": 24 }, { "span": "time1 ", "start_line": 683, "start_column": 8, "end_line": 683, "end_column": 13 }, { "span": "patterns ", "start_line": 1040, "start_column": 8, "end_line": 1040, "end_column": 16 }, { "span": "code ", "start_line": 1204, "start_column": 8, "end_line": 1204, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mix", "\\u", "codes_", "(_", "self_", ",_", "agents_", ",_", "actors_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Combine", " ", "the", " ", "actor", " ", "codes", " ", "and", " ", "agent", " ", "codes", " ", "address", "ing", " ", "duplicat", "es", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "remo", "ving", " ", "the", " ", "genera", "l", " ", "\"", "~", "PP", "L", "\"", " ", "if", " ", "there", "'", "s", " ", "a", " ", "bett", "er", " ", "option", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "agent", "s", ",", " ", "actors", " ", ":", " ", "List", "s", " ", "of", " ", "thei", "r", " ", "respec", "tiv", "e", " ", "codes", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "codes", ":", " ", "list", "\\", "10", ";", " ", " ", " ", "[", "Agent", " ", "codes", "]", " ", "x", " ", "[", "Act", "or", " ", "codes", "]", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "mc", "-", "entry", "',", "actors", ",", "agent", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "codes_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mix_", "=_", "lambda_", "a_", ",_", "b_", ":_", "a_", "+_", "b_", "if_", "not_", "b_", "in_", "a_", "else_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actors_", "=_", "actors_", "if_", "actors_", "else_", "[_", "'~'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ag_", "in_", "agents_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ag_", "==_", "'", "~", "PP", "L", "'_", "and_", "len_", "(_", "agents_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "actors", " ", "=", " ", "map", "(", " ", "lambda", " ", "a", " ", ":", " ", "mix", "(", " ", "a", "[", "0", "],", " ", "ag", "[", "1", ":]", "),", " ", "actors", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "actors_", "=_", "map_", "(_", "lambda_", "a_", ":_", "mix_", "(_", "a_", ",_", "ag_", "[_", "1_", ":_", "]_", ")_", ",_", "actors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "mc", "-1", "',", "actors", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "not_", "in_", "[_", "''_", ",_", "'~'_", ",_", "'", "~~", "'_", ",_", "None_", "]_", ",_", "actors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "16.", "04", ".2", "5", " ", "hmm", "m", ",", " ", "this", " ", "is", " ", "eit", "her", " ", "a", " ", "construct", " ", "of", " ", "utt", "erl", "y", " ", "pheno", "men", "al", " ", "subt", "let", "y", " ", "or", " ", "else", " ", "we", " ", "neve", "r", " ", "hit", " ", "this", " ", "code", "..._", "\\u\\u\\uNL\\u\\u\\u_", "codes_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "WT", "F", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "act_", "in_", "(_", "actors_", "if_", "actors_", "else_", "[_", "'~'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ag_", "in_", "(_", "agents_", "if_", "agents_", "else_", "[_", "'~'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ag_", "==_", "\"", "~", "PP", "L", "\"_", "and_", "len_", "(_", "agents_", ")_", ">_", "1_", ":_", "\\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_", "code_", "=_", "act_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "ag_", "[_", "1_", ":_", "]_", "in_", "act_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "code_", "+=_", "ag_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "code_", "in_", "[_", "'~'_", ",_", "'", "~~", "'_", ",_", "\"\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "codes_", "._", "add_", "(_", "code_", ")_", "\\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_", "list_", "(_", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "valid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "is", " ", "large", "ly", " ", "to", " ", "over", "come", " ", "frequent", "ly", " ", "made", " ", "Stan", "for", "d", " ", "error", "s", ",", " ", "where", " ", "phrase", "s", " ", "like", " ", "\"", "exi", "led", " ", "diss", "ident", "s", "\"", " ", "wer", "e", "\\", "10", ";", " ", " ", " ", " ", "marked", " ", "as", " ", "verb", " ", "phrase", "s", ",", " ", "and", " ", "treat", "ing", " ", "them", " ", "as", " ", "suc", "h", " ", "wou", "ld", " ", "yield", " ", "weird", " ", "parse", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "On", "ce", " ", "suc", "h", " ", "a", " ", "phrase", " ", "is", " ", "identifi", "ed", " ", "bec", "aus", "e", " ", "of", " ", "its", " ", "weird", " ", "distribu", "tion", ",", " ", "it", " ", "is", " ", "convert", "ed", " ", "to", " ", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "Nou", "n", "Phrase", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "children_", "[_", "0_", "]_", "._", "label_", "==_", "\"", "VB", "N", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "help", "ing_", "=_", "[_", "\"", "HA", "VE", "\"_", ",_", "\"", "HA", "D", "\"_", ",_", "\"", "HA", "VING", "\"_", ",_", "\"", "HAS", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "(_", "not_", "(_", "self_", "._", "parent_", "._", "get", "\\u", "head_", "(_", ")_", "[_", "0_", "]_", "in_", "help", "ing_", "or_", "self_", "._", "parent_", "._", "children_", "[_", "0_", "]_", "._", "text_", "in_", "help", "ing_", ")_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "filter_", "(_", "lambda_", "a_", ":_", "isinstance_", "(_", "a_", ",_", "Verb", "Phrase", "_", ")_", ",_", "self_", "._", "parent_", "._", "children_", ")_", ")_", "<=_", "1_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "valid_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "np", "\\u", "replacement_", "=_", "Nou", "n", "Phrase", "_", "(_", "\"", "NP", "\"_", ",_", "self_", "._", "date_", ",_", "self_", "._", "sentence_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "\\u", "replacement_", "._", "children_", "=_", "self_", "._", "children_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "\\u", "replacement_", "._", "parent_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "\\u", "replacement_", "._", "index_", "=_", "self_", "._", "index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "parent_", "._", "children_", "._", "remove_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "._", "children_", "._", "insert_", "(_", "self_", "._", "index_", ",_", "np", "\\u", "replacement_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "=_", "np", "\\u", "replacement_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "valid_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Index", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "valid_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "dete", "rmin", "es", " ", "the", " ", "event", " ", "codi", "ng", " ", "of", " ", "the", " ", "subtree", " ", "root", "ed", " ", "in", " ", "this", " ", "verb", " ", "phrase", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Four", " ", "method", "s", " ", "are", " ", "key", " ", "in", " ", "this", " ", "process", ":", " ", "get", "\\u", "upper", "()", ",", " ", "get", "\\u", "lower", "()", ",", " ", "get", "\\u", "code", "()", " ", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "match", "\\u", "transform", "()", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Fi", "rst", ",", " ", "get", "\\u", "meaning", "()", " ", "gets", " ", "the", " ", "verb", " ", "code", " ", "from", " ", "get", "\\u", "code", "()", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "The", "n", ",", " ", "it", " ", "checks", " ", "passi", "vity", ".", " ", "If", " ", "the", " ", "verb", " ", "is", " ", "passive", ",", " ", "then", " ", "it", " ", "look", "s", " ", "within", " ", "\\", "10", ";", " ", " ", " ", " ", "verb", " ", "phrase", "s", " ", "head", "ed", " ", "by", " ", "[", "by", ",", " ", "from", ",", " ", "in", "]", " ", "for", " ", "the", " ", "source", ",", " ", "and", " ", "for", " ", "an", " ", "explicit", " ", "target", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "verb", " ", "phrase", "s", " ", "head", "ed", " ", "by", " ", "[", "at", ",", "against", ",", "int", "o", ",", "towards", "].", " ", "If", " ", "no", " ", "target", " ", "is", " ", "found", ",", "\\", "10", ";", " ", " ", " ", " ", "this", " ", "space", " ", "is", " ", "filled", " ", "with", " ", "'", "passive", "',", " ", "a", " ", "flag", " ", "used", " ", "late", "r", " ", "to", " ", "assign", " ", "a", " ", "target", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "it", " ", "is", " ", "in", " ", "the", " ", "gram", "matical", " ", "subject", " ", "position", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "verb", " ", "is", " ", "not", " ", "passive", ",", " ", "then", " ", "the", " ", "process", " ", "go", "es", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "1", ")", " ", "call", " ", "get", "\\u", "upper", "()", " ", "and", " ", "get", "\\u", "lower", "()", " ", "to", " ", "check", " ", "for", " ", "a", " ", "gram", "matical", " ", "subject", " ", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "find", " ", "the", " ", "codi", "ng", " ", "of", " ", "the", " ", "subtree", " ", "and", " ", "child", "ren", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "2", ")", " ", "If", " ", "get", "\\u", "lower", " ", "return", "ed", " ", "a", " ", "list", " ", "of", " ", "events", ",", " ", "combin", "e", " ", "tho", "se", " ", "events", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "upper", " ", "and", " ", "code", ",", " ", "add", " ", "to", " ", "event", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "3", ")", " ", "Ot", "her", "wis", "e", ",", " ", "combin", "e", " ", "upper", ",", " ", "lower", ",", " ", "and", " ", "code", " ", " ", "and", " ", "add", " ", "to", " ", "event", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "4", ")", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "there", " ", "are", " ", "S", "-", "level", " ", "child", "ren", ",", " ", "if", " ", "so", ",", " ", "combin", "e", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "upper", " ", "and", " ", "code", ",", " ", "add", " ", "to", " ", "list", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "5", ")", " ", "call", " ", "match", "\\u", "transform", "()", " ", "on", " ", "all", " ", "events", " ", "in", " ", "the", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "events", ":", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "of", " ", "events", " ", "code", "d", " ", "by", " ", "the", " ", "subtree", " ", "root", "ed", " ", "in", " ", "this", " ", "phrase", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "meaning", "_", "=_", "self_", "._", "return", "\\u", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", ",_", "passive", "_", ",_", "meta_", "=_", "self_", "._", "get", "\\u", "code_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s", "\\u", "options_", "=_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "._", "label_", "in_", "\"", "SB", "AR", "\"_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "resolve", "\\u", "events_", "(_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Help", "er", " ", "method", " ", "to", " ", "combin", "e", " ", "events", ",", " ", "accounti", "ng", " ", "for", " ", "\\", "10", ";", " ", " ", " ", " ", "missi", "ng", " ", "source", "s", ",", " ", "and", " ", " ", "target", "s", ",", " ", "passive", "s", ",", " ", "multiple", "-", "\\", "10", ";", " ", " ", " ", " ", "target", " ", "passive", "s", ",", " ", "and", " ", "code", "less", " ", "verbs", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "event", ":", " ", "tuple", "\\", "10", ";", " ", "(", "source", ",", " ", "target", ",", " ", "code", ")", " ", "of", " ", "lower", " ", "event", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "return", "s", ":", " ", "[", "tuple", "]", "\\", "10", ";", " ", " ", " ", "list", " ", "of", " ", "resolve", "d", " ", "event", " ", "tuple", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "returns_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first_", ",_", "second_", ",_", "third_", "=_", "[_", "up_", ",_", "\"\"_", ",_", "\"\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "(_", "up_", "or_", "c_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "event_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "second_", "=_", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "passive", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "item_", "in_", "first_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e2_", "=_", "(_", "[_", "second_", "]_", ",_", "item_", ",_", "passive", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e2_", ")_", "]_", "=_", "[_", "event_", ",_", "meta_", ",_", "7_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "returns_", "._", "append_", "(_", "e2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "event_", "[_", "1_", "]_", "==_", "'", "passive", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "first_", "=_", "event_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "utilities_", "._", "combin", "e\\u", "code_", "(_", "c_", ",_", "event_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "up_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "returns_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "source_", "in_", "up_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "=_", "(_", "first_", ",_", "source_", ",_", "third_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "event_", ",_", "up_", ",_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "returns_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "returns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "second_", "=_", "'", "passive", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "event_", "[_", "0_", "]_", "in_", "[_", "''_", ",_", "[_", "]_", ",_", "[_", "\"\"_", "]_", ",_", "[_", "\"~\"_", "]_", ",_", "[_", "\"", "~~", "\"_", "]_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "second_", "=_", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "second_", "=_", "event_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "utilities_", "._", "combin", "e\\u", "code_", "(_", "c_", ",_", "event_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "e_", "=_", "(_", "first_", ",_", "second_", ",_", "third_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "event_", ",_", "c_", ",_", "meta_", ",_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "returns_", "+_", "[_", "e_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "events_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "up_", "=_", "self_", "._", "get", "\\u", "upper_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", "or_", "(_", "passive", "_", "and_", "not_", "c_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "for", " ", "source", " ", "in", " ", "prep", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "source", "\\u", "options_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target", "\\u", "options_", "=_", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Prep", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "child_", "._", "get", "\\u", "prep_", "(_", ")_", "in_", "[_", "\"", "BY", "\"_", ",_", "\"", "FROM", "\"_", ",_", "\"", "IN", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "source", "\\u", "options_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "(_", "child_", "._", "prep_", ",_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "child_", "._", "get", "\\u", "prep_", "(_", ")_", "in_", "[_", "\"", "AT", "\"_", ",_", "\"", "AGA", "INST", "\"_", ",_", "\"", "INT", "O", "\"_", ",_", "\"", "TO", "WARD", "S", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "target", "\\u", "options_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "(_", "child_", "._", "prep_", ",_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "target", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "options_", "=_", "[_", "\"", "passive", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "source", "\\u", "options_", "or_", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "target", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "=_", "(_", "source", "\\u", "options_", ",_", "i_", ",_", "c_", "if_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", "else_", "passive", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "None_", ",_", "e_", ",_", "meta_", ",_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "events_", "\\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_", "up_", "=_", "\"\"_", "if_", "up_", "in_", "[_", "''_", ",_", "[_", "]_", ",_", "[_", "\"\"_", "]_", ",_", "[_", "\"~\"_", "]_", ",_", "[_", "\"", "~~", "\"_", "]_", "]_", "else_", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "low_", ",_", "neg_", "=_", "self_", "._", "get", "\\u", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "low_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "low_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "neg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "low_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "event_", "in_", "low_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "events_", "+=_", "resolve", "\\u", "events_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "s", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "up_", "or_", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "=_", "(_", "up_", ",_", "low_", ",_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "None_", ",_", "e_", ",_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "low_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "events_", "._", "append_", "(_", "low_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lower_", "=_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ",_", "s", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sents_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "item_", "in_", "lower_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sents_", "+=_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sents_", "and_", "not_", "events_", ":_", "#", " ", "On", "ly", " ", "if", " ", "not", "hing", " ", "else", " ", "has", " ", "bee", "n", " ", "found", " ", "do", " ", "we", " ", "look", " ", "at", " ", "lower", " ", "NP", "'", "s", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "decrease", "s", " ", "our", " ", "codi", "ng", " ", "freque", "nc", "y", ",", " ", "but", " ", "remove", "s", " ", "many", " ", "fal", "se", " ", "positives", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "event_", "in_", "sents_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", "and_", "(_", "event_", "[_", "1_", "]_", "or_", "event_", "[_", "2_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "ev_", "in_", "resolve", "\\u", "events_", "(_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "isinstance_", "(_", "ev_", "[_", "1_", "]_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "item_", "in_", "ev_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "local_", "=_", "(_", "ev_", "[_", "0_", "]_", ",_", "item_", ",_", "ev_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "local_", ")_", "]_", "=_", "[_", "ev_", ",_", "item_", ",_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "._", "append_", "(_", "local_", ")_", "\\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 ", " ", " _", "events_", "+=_", "resolve", "\\u", "events_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "maps_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "evs", "_", "=_", "self_", "._", "match", "\\u", "transform_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "evs", "_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "evs", "_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "maps_", "._", "append_", "(_", "j_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "j_", ")_", "]_", "=_", "[_", "i_", ",_", "evs", "_", "[_", "1_", "]_", ",_", "6_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "maps_", "+=_", "evs", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "code_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Match", " ", "the", " ", "codes", " ", "from", " ", "the", " ", "Verb", " ", "Dict", "ionar", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Step", " ", "1", ".", " ", " ", "Check", " ", "for", " ", "compo", "und", " ", "verb", " ", "matche", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Step", " ", "2", ".", " ", " ", "Check", " ", "for", " ", "pattern", " ", "matche", "s", " ", "via", " ", "match", "\\u", "pattern", "()", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "code", ":", " ", " ", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Code", " ", "descri", "bed", " ", "by", " ", "this", " ", "verb", ",", " ", "best", " ", "read", " ", "in", " ", "hex", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "code_", "=_", "self_", "._", "return", "\\u", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dict_", "=_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "verbs", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "AND", "'_", "in_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "text_", ",_", "self_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0_", ",_", "0_", ",_", "[_", "'", "and", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "patterns_", "=_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "phrase", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verb_", "=_", "\"", "TO", "\"_", "if_", "self_", "._", "children_", "[_", "0_", "]_", "._", "label_", "==_", "\"", "TO", "\"_", "else_", "self_", "._", "get", "\\u", "head_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "verb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "passive", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verb_", "in_", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "dict_", "[_", "verb_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "[_", "'#'_", "]_", "==_", "path_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "path_", "[_", "'#'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "True_", "or_", "path_", "._", "keys_", "(_", ")_", "==_", "[_", "'#'_", "]_", ":_", "#", " ", "Pre", "-", "compounds", " ", "are", " ", "weird", "_", "\\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 ", " ", " _", "code_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'", "code", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'", "meaning", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "verb", "class_", "=_", "meaning", "_", "if_", "not_", "meaning", "_", "==_", "\"\"_", "else_", "verb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "code_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "active_", ",_", "passive", "_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "active_", "\\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_", "._", "code_", "=_", "(_", "0_", ",_", "0_", ",_", "[_", "]_", ")_", "\\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_", "#", " ", "Post", " ", "-", " ", "compounds", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "child_", "._", "label_", "in_", "[_", "\"", "PR", "T", "\"_", ",_", "\"", "ADV", "P", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "child_", "._", "children_", "[_", "0_", "]_", "._", "text_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "meta_", "._", "append_", "(_", "child_", "._", "children_", "[_", "0_", "]_", "._", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "path_", "[_", "child_", "._", "children_", "[_", "0_", "]_", "._", "text_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\"#\"_", "in_", "path_", ":_", "\\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 ", " ", " _", "code_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'#'_", "]_", "[_", "'", "code", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'#'_", "]_", "[_", "'", "meaning", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verb", "class_", "=_", "meaning", "_", "if_", "not_", "meaning", "_", "==_", "\"\"_", "else_", "verb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "code_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "active_", ",_", "passive", "_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "active_", "\\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 ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "++", "1", "')", "_", "\\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_", "match_", "=_", "self_", "._", "match", "\\u", "pattern_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "++", "2", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "++", "4", "',", "match", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "++", "3", "',", "match", "['", "line", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "meta_", "._", "append_", "(_", "match_", "[_", "'", "line", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "(", "match", ")_", "\\u\\u\\uNL\\u\\u\\u_", "active_", ",_", "passive", "_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "match_", "[_", "'", "code", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "active_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "passive", "_", "and_", "not_", "active_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "check", "\\u", "passive", "_", "=_", "lambda_", ":_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "passive", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "code_", ",_", "passive", "_", ",_", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "pattern_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "\\", "10", ";", " ", " ", " ", " ", "Match", " ", "the", " ", "tree", " ", "against", " ", "pattern", "s", " ", "specified", " ", "in", " ", "the", " ", "dictionar", "y", ".", " ", "For", " ", "a", " ", "more", " ", "illust", "rated", " ", "expl", "anat", "ion", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "how", " ", "this", " ", "process", " ", "works", ",", " ", "see", " ", "the", " ", "Pet", "rar", "ch", "2", ".", "pdf", " ", "file", " ", "in", " ", "the", " ", "documentation", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "Fal", "se", " ", "if", " ", "no", " ", "match", ",", " ", "dict", " ", "of", " ", "match", " ", "if", " ", "presen", "t", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "self_", "._", "verb", "class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "self_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "match", "\\u", "phrase_", "(_", "path_", ",_", "phrase_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ha", "ving", " ", "matche", "d", " ", "the", " ", "head", " ", "of", " ", "the", " ", "phrase", ",", " ", "this", " ", "matche", "s", " ", "the", " ", "full", " ", "noun", " ", "phrase", ",", " ", "if", " ", "specified", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "phrase_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "Fal", "se", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "item_", "in_", "filter_", "(_", "lambda_", "b_", ":_", "b_", "._", "text_", "in_", "path_", ",_", "phrase_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subpath_", "=_", "path_", "[_", "item_", "._", "text_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "rr", "-1", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "item_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "item_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "rer", "oute", "')", " ", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "phrase_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "noun", "_", "(_", "path_", ",_", "phrase_", "=_", "self_", "if_", "not_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", "else_", "self_", "._", "get", "\\u", "S_", "(_", ")_", ",_", "prep", "limit_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Match", "es", " ", "a", " ", "noun", " ", "or", " ", "head", " ", "of", " ", "noun", " ", "phrase_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mn", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "noun", "\\u", "phrases_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "phrase_", ":_", "\\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_", "if_", "prep", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "sib", "_", "in_", "phrase_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "isinstance_", "(_", "sib", "_", ",_", "Prep", "Phrase", "_", ")_", "and_", "len_", "(_", "sib", "_", "._", "children_", ")_", ">_", "1_", "and_", "sib", "_", "._", "get", "\\u", "prep_", "(_", ")_", "in_", "[_", "\"", "BY", "\"_", ",_", "\"", "FROM", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noun", "\\u", "phrases_", "._", "append_", "(_", "sib", "_", "._", "children_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "child_", "in_", "phrase_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "child_", "._", "label_", "in_", "(_", "\"", "NP", "\"_", ",_", "\"", "ADV", "P", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noun", "\\u", "phrases_", "._", "append_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "phrase_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "noun", "\\u", "phrases_", "._", "append_", "(_", "phrase_", ")_", "\\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_", "item_", "in_", "noun", "\\u", "phrases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "head_", ",_", "head", "phrase_", "=_", "item_", "._", "get", "\\u", "head_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "head_", "and_", "head_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "subpath_", "=_", "path_", "[_", "head_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "check", " ", "within", " ", "the", " ", "NP", " ", "for", " ", "PP", "'", "s_", "\\u\\u\\uNL\\u\\u\\u_", "skip_", "=_", "lambda_", "a_", ":_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "skip_", ",_", "skip_", ",_", "lambda_", "a_", ":_", "match", "\\u", "prep_", "(_", "a_", ",_", "item_", ")_", ",_", "skip_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "head", "phrase_", "._", "children_", "[_", "-_", "1_", "]_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "n", " ", "check", " ", "the", " ", "other", " ", "siblings", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "(_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "item_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "item_", ",_", "Nou", "n", "Phrase", "_", ")_", "else_", "None_", ")_", "#", " ", "pas", " ", "16.", "04", ".2", "1", ":", " ", "Tra", "pped", " ", "Non", "e", " ", "by", " ", "hav", "ing", " ", "rer", "oute", " ", "return", " ", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "head", "phrase_", "._", "children_", "[_", "-_", "1_", "]_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "^", "'_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "phrase_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mn", "-", "rer", "oute", "1", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", "[_", "'", "^", "'_", "]_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "phrase_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mn", "-", "rer", "oute", "2", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "phrase_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "prep_", "(_", "path_", ",_", "phrase_", "=_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Match", "es", " ", "prepo", "sition", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mp", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "filter_", "(_", "lambda_", "b_", ":_", "isinstance_", "(_", "b_", ",_", "Prep", "Phrase", "_", ")_", ",_", "phrase_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prep_", "=_", "item_", "._", "children_", "[_", "0_", "]_", "._", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "prep_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "subpath_", "=_", "path_", "[_", "prep_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "mp", "-", "rer", "oute", "1", "')", " ", " _", "\\u\\u\\uNL\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "a_", ":_", "match", "\\u", "noun", "_", "(_", "a_", ",_", "item_", "._", "children_", "[_", "1_", "]_", ")_", "if_", "len_", "(_", "item_", "._", "children_", ")_", ">_", "1_", "else_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "match", "\\u", "prep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "mp", "-", "Fal", "se", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mp", "-", "rer", "oute", "2", "')", " ", " _", "\\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_", "rer", "oute", "_", "(_", "path_", ",_", "o2_", "=_", "match", "\\u", "prep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rer", "oute", "_", "(_", "subpath_", ",_", "o1_", "=_", "match", "\\u", "noun", "_", ",_", "o2_", "=_", "match", "\\u", "noun", "_", ",_", "o3", "_", "=_", "match", "\\u", "prep_", ",_", "o", "4_", "=_", "match", "\\u", "noun", "_", ",_", "exit_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "rr", "-", "entry", ":'", ")", " ", "#", " ", ",", "subpath_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "o1_", ":_", "#", " ", "match", "\\u", "noun", "()", " ", "can", " ", "call", " ", "rer", "oute", "()", " ", "with", " ", "o", "1", " ", "==", " ", "Non", "e", ";", " ", "guess", "ing", " ", "return", "ing", " ", "Fal", "se", " ", "is", " ", "the", " ", "appropr", "iate", " ", "response", " ", "pas", " ", "16.", "04", ".2", "1_", "\\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_", "if_", "'-'_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o1_", "(_", "subpath_", "[_", "'-'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "--", " ", "match", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\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_", "','_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-", ",'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o2_", "(_", "subpath_", "[_", "','_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\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_", "'|'_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-|", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o3", "_", "(_", "subpath_", "[_", "'|'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\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_", "'*'_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-*", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o", "4_", "(_", "subpath_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\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_", "'#'_", "in_", "subpath_", "and_", "exit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-", "#'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "subpath_", "[_", "'#'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "rr", "-", "Fal", "se", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Match", " ", "pattern_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "meaning", "_", "in_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "phrase", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "phrase", "s", "'_", "]_", "[_", "meaning", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "match", "\\u", "noun", "_", "(_", "path_", ",_", "self_", ",_", "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 ", " _", "return_", "match", "\\u", "noun", "_", "(_", "path_", ",_", "self_", "._", "get", "\\u", "S_", "(_", ")_", ")_", "\\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_" ]
[ 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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{ "content": "import time\nimport os\nimport sys\nimport re\nimport urllib\nimport cgi\nimport difflib\nimport shutil\nimport stat\nimport socket\n\nfrom textwrap import dedent\n\ntry:\n from mercurial import ui, hg, cmdutil\n try:\n from mercurial.scmutil import addremove\n except:\n from mercurial.cmdutil import addremove\n have_mercurial = True\nexcept ImportError:\n have_mercurial = False\n\nfrom gluon.utils import md5_hash\nfrom gluon.fileutils import listdir, cleanpath, up\nfrom gluon.fileutils import tar, tar_compiled, untar, fix_newlines\nfrom gluon.languages import findT, update_all_languages\nfrom gluon.myregex import *\nfrom gluon.restricted import *\nfrom gluon.compileapp import compile_application, remove_compiled_application\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import time", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 11 }, { "span": "import os", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 9 }, { "span": "import sys", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 10 }, { "span": "import re", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 9 }, { "span": "import urllib", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 13 }, { "span": "import cgi", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 10 }, { "span": "import difflib", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 14 }, { "span": "import shutil", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 13 }, { "span": "import stat", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 11 }, { "span": "import socket", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 13 }, { "span": "from textwrap import dedent", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 27 }, { "span": "from mercurial import ui, hg, cmdutil", "start_line": 14, "start_column": 4, "end_line": 14, "end_column": 41 }, { "span": "from mercurial.scmutil import addremove", "start_line": 16, "start_column": 8, "end_line": 16, "end_column": 47 }, { "span": "from mercurial.cmdutil import addremove", "start_line": 18, "start_column": 8, "end_line": 18, "end_column": 47 }, { "span": "from gluon.utils import md5_hash", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 32 }, { "span": "from gluon.fileutils import listdir, cleanpath, up", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 50 }, { "span": "from gluon.fileutils import tar, tar_compiled, untar, fix_newlines", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 66 }, { "span": "from gluon.languages import findT, update_all_languages", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 55 }, { "span": "from gluon.compileapp import compile_application, remove_compiled_application", "start_line": 29, "start_column": 0, "end_line": 29, "end_column": 77 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cgi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "difflib", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "stat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "textwrap_", "import_", "dedent_", "\\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_", "mercur", "ial_", "import_", "ui_", ",_", "hg_", ",_", "cmd", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "mercur", "ial_", "._", "scm", "util_", "import_", "addre", "move_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "mercur", "ial_", "._", "cmd", "util_", "import_", "addre", "move_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "have", "\\u", "mercur", "ial_", "=_", "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 ", " _", "have", "\\u", "mercur", "ial_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "gluon_", "._", "utils_", "import_", "md5", "\\u", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "fileu", "tils_", "import_", "listdir_", ",_", "clean", "path_", ",_", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "fileu", "tils_", "import_", "tar_", ",_", "tar", "\\u", "compiled_", ",_", "unta", "r_", ",_", "fix", "\\u", "newlines_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "languages_", "import_", "find", "T_", ",_", "update", "\\u", "all", "\\u", "languages_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "myre", "gex", "_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "restricted_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "compile", "app_", "import_", "compile", "\\u", "application_", ",_", "remove", "\\u", "compile", "d\\u", "application_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Unused import
arachnys/cabot/cabot/cabotapp/models.py
[ { "content": "from django.db import models\nfrom django.conf import settings\nfrom django.core.exceptions import ValidationError\nfrom polymorphic import PolymorphicModel\nfrom django.db.models import F\nfrom django.core.urlresolvers import reverse\nfrom django.contrib.auth.models import User\nfrom celery.exceptions import SoftTimeLimitExceeded\n\nfrom .jenkins import get_job_status\nfrom .alert import (\n send_alert,\n send_alert_update,\n AlertPlugin,\n AlertPluginUserData,\n update_alert_plugins\n)\nfrom .calendar import get_events\nfrom .graphite import parse_metric\nfrom .graphite import get_data\nfrom .tasks import update_service, update_instance\nfrom datetime import datetime, timedelta\nfrom django.utils import timezone\n\nimport json\nimport re\nimport time\nimport os\nimport subprocess\nimport itertools\n\nimport requests\nfrom celery.utils.log import get_task_logger\n\nRAW_DATA_LIMIT = 5000\n\nlogger = get_task_logger(__name__)\n\nCHECK_TYPES = (\n ('>', 'Greater than'),\n ('>=', 'Greater than or equal'),\n ('<', 'Less than'),\n ('<=', 'Less than or equal'),\n ('==', 'Equal to'),\n)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def serialize_recent_results(recent_results):\n if not recent_results:\n return ''\n\n def result_to_value(result):\n if result.succeeded:\n return '1'\n else:\n return '-1'\n vals = [result_to_value(r) for r in recent_results]\n vals.reverse()\n return ','.join(vals)", "metadata": "root.serialize_recent_results", "header": "['module', '___EOS___']", "index": 46 }, { "content": "def calculate_debounced_passing(recent_results, debounce=0):\n \"\"\"\n `debounce` is the number of previous failures we need (not including this)\n to mark a search as passing or failing\n Returns:\n True if passing given debounce factor\n False if failing\n \"\"\"\n if not recent_results:\n return True\n debounce_window = recent_results[:debounce + 1]\n for r in debounce_window:\n if r.succeeded:\n return True\n return False", "metadata": "root.calculate_debounced_passing", "header": "['module', '___EOS___']", "index": 60 }, { "content": "class CheckGroupMixin(models.Model):\n\n class Meta:\n abstract = True\n\n PASSING_STATUS = 'PASSING'\n WARNING_STATUS = 'WARNING'\n ERROR_STATUS = 'ERROR'\n CRITICAL_STATUS = 'CRITICAL'\n\n CALCULATED_PASSING_STATUS = 'passing'\n CALCULATED_INTERMITTENT_STATUS = 'intermittent'\n CALCULATED_FAILING_STATUS = 'failing'\n\n STATUSES = (\n (CALCULATED_PASSING_STATUS, CALCULATED_PASSING_STATUS),\n (CALCULATED_INTERMITTENT_STATUS, CALCULATED_INTERMITTENT_STATUS),\n (CALCULATED_FAILING_STATUS, CALCULATED_FAILING_STATUS),\n )\n\n IMPORTANCES = (\n (WARNING_STATUS, 'Warning'),\n (ERROR_STATUS, 'Error'),\n (CRITICAL_STATUS, 'Critical'),\n )\n\n name = models.TextField()\n\n users_to_notify = models.ManyToManyField(\n User,\n blank=True,\n help_text='Users who should receive alerts.',\n )\n alerts_enabled = models.BooleanField(\n default=True,\n help_text='Alert when this service is not healthy.',\n )\n status_checks = models.ManyToManyField(\n 'StatusCheck',\n blank=True,\n help_text='Checks used to calculate service status.',\n )\n last_alert_sent = models.DateTimeField(\n null=True,\n blank=True,\n )\n\n alerts = models.ManyToManyField(\n 'AlertPlugin',\n blank=True,\n help_text='Alerts channels through which you wish to be notified'\n )\n\n email_alert = models.BooleanField(default=False)\n hipchat_alert = models.BooleanField(default=True)\n sms_alert = models.BooleanField(default=False)\n telephone_alert = models.BooleanField(\n default=False,\n help_text='Must be enabled, and check importance set to Critical, to receive telephone alerts.',\n )\n overall_status = models.TextField(default=PASSING_STATUS)\n old_overall_status = models.TextField(default=PASSING_STATUS)\n hackpad_id = models.TextField(\n null=True,\n blank=True,\n verbose_name='Recovery instructions',\n help_text='Gist, Hackpad or Refheap js embed with recovery instructions e.g. https://you.hackpad.com/some_document.js'\n )\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.CheckGroupMixin", "header": "['module', '___EOS___']", "index": 77 }, { "content": " def __unicode__(self):\n return self.name", "metadata": "root.CheckGroupMixin.__unicode__", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 147 }, { "content": " def most_severe(self, check_list):\n failures = [c.importance for c in check_list]\n if self.CRITICAL_STATUS in failures:\n return self.CRITICAL_STATUS\n if self.ERROR_STATUS in failures:\n return self.ERROR_STATUS\n if self.WARNING_STATUS in failures:\n return self.WARNING_STATUS\n return self.PASSING_STATUS", "metadata": "root.CheckGroupMixin.most_severe", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 151 }, { "content": " @property\n def is_critical(self):\n \"\"\"\n Break out separately because it's a bit of a pain to\n get wrong.\n \"\"\"\n if self.old_overall_status != self.CRITICAL_STATUS and self.overall_status == self.CRITICAL_STATUS:\n return True\n return False", "metadata": "root.CheckGroupMixin.is_critical", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 161 }, { "content": " def alert(self):\n if not self.alerts_enabled:\n return\n if self.overall_status != self.PASSING_STATUS:\n # Don't alert every time\n if self.overall_status == self.WARNING_STATUS:\n if self.last_alert_sent and (timezone.now() - timedelta(minutes=settings.NOTIFICATION_INTERVAL)) < self.last_alert_sent:\n return\n elif self.overall_status in (self.CRITICAL_STATUS, self.ERROR_STATUS):\n if self.last_alert_sent and (timezone.now() - timedelta(minutes=settings.ALERT_INTERVAL)) < self.last_alert_sent:\n return\n self.last_alert_sent = timezone.now()\n else:\n # We don't count \"back to normal\" as an alert\n self.last_alert_sent = None\n self.save()\n if self.unexpired_acknowledgement():\n send_alert_update(self, duty_officers=get_duty_officers())\n else:\n self.snapshot.did_send_alert = True\n self.snapshot.save()\n send_alert(self, duty_officers=get_duty_officers())", "metadata": "root.CheckGroupMixin.alert", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 171 }, { "content": " def unexpired_acknowledgements(self):\n acknowledgements = self.alertacknowledgement_set.all().filter(\n time__gte=timezone.now()-timedelta(minutes=settings.ACKNOWLEDGEMENT_EXPIRY),\n cancelled_time__isnull=True,\n ).order_by('-time')\n return acknowledgements", "metadata": "root.CheckGroupMixin.unexpired_acknowledgements", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 194 }, { "content": " def acknowledge_alert(self, user):\n if self.unexpired_acknowledgements(): # Don't allow users to jump on each other\n return None\n acknowledgement = AlertAcknowledgement.objects.create(\n user=user,\n time=timezone.now(),\n service=self,\n )", "metadata": "root.CheckGroupMixin.acknowledge_alert", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 201 }, { "content": " def remove_acknowledgement(self, user):\n self.unexpired_acknowledgements().update(\n cancelled_time=timezone.now(),\n cancelled_user=user,\n )", "metadata": "root.CheckGroupMixin.remove_acknowledgement", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 210 }, { "content": " def unexpired_acknowledgement(self):\n try:\n return self.unexpired_acknowledgements()[0]\n except:\n return None", "metadata": "root.CheckGroupMixin.unexpired_acknowledgement", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 216 }, { "content": " @property\n def recent_snapshots(self):\n snapshots = self.snapshots.filter(\n time__gt=(timezone.now() - timedelta(minutes=60 * 24)))\n snapshots = list(snapshots.values())\n for s in snapshots:\n s['time'] = time.mktime(s['time'].timetuple())\n return snapshots", "metadata": "root.CheckGroupMixin.recent_snapshots", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 222 }, { "content": " def graphite_status_checks(self):\n return self.status_checks.filter(polymorphic_ctype__model='graphitestatuscheck')", "metadata": "root.CheckGroupMixin.graphite_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 231 }, { "content": " def http_status_checks(self):\n return self.status_checks.filter(polymorphic_ctype__model='httpstatuscheck')", "metadata": "root.CheckGroupMixin.http_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 234 }, { "content": " def jenkins_status_checks(self):\n return self.status_checks.filter(polymorphic_ctype__model='jenkinsstatuscheck')", "metadata": "root.CheckGroupMixin.jenkins_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 237 }, { "content": " def active_graphite_status_checks(self):\n return self.graphite_status_checks().filter(active=True)", "metadata": "root.CheckGroupMixin.active_graphite_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 240 }, { "content": " def active_http_status_checks(self):\n return self.http_status_checks().filter(active=True)", "metadata": "root.CheckGroupMixin.active_http_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 243 }, { "content": " def active_jenkins_status_checks(self):\n return self.jenkins_status_checks().filter(active=True)", "metadata": "root.CheckGroupMixin.active_jenkins_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 246 }, { "content": " def active_status_checks(self):\n return self.status_checks.filter(active=True)", "metadata": "root.CheckGroupMixin.active_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 249 }, { "content": " def inactive_status_checks(self):\n return self.status_checks.filter(active=False)", "metadata": "root.CheckGroupMixin.inactive_status_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 252 }, { "content": " def all_passing_checks(self):\n return self.active_status_checks().filter(calculated_status=self.CALCULATED_PASSING_STATUS)", "metadata": "root.CheckGroupMixin.all_passing_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 255 }, { "content": " def all_failing_checks(self):\n return self.active_status_checks().exclude(calculated_status=self.CALCULATED_PASSING_STATUS)", "metadata": "root.CheckGroupMixin.all_failing_checks", "header": "['class', 'CheckGroupMixin', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 258 }, { "content": "class Service(CheckGroupMixin):\n\n instances = models.ManyToManyField(\n 'Instance',\n blank=True,\n help_text='Instances this service is running on.',\n )\n\n url = models.TextField(\n blank=True,\n help_text=\"URL of service.\"\n )\n\n class Meta:\n ordering = ['name']", "metadata": "root.Service", "header": "['module', '___EOS___']", "index": 262 }, { "content": " def update_status(self):\n self.old_overall_status = self.overall_status\n # Only active checks feed into our calculation\n status_checks_failed_count = self.all_failing_checks().count()\n self.overall_status = self.most_severe(self.all_failing_checks())\n self.snapshot = ServiceStatusSnapshot(\n service=self,\n num_checks_active=self.active_status_checks().count(),\n num_checks_passing=self.active_status_checks(\n ).count() - status_checks_failed_count,\n num_checks_failing=status_checks_failed_count,\n overall_status=self.overall_status,\n time=timezone.now(),\n )\n self.snapshot.save()\n self.save()\n if not (self.overall_status == Service.PASSING_STATUS and self.old_overall_status == Service.PASSING_STATUS):\n self.alert()", "metadata": "root.Service.update_status", "header": "['class', 'Service', '(', 'CheckGroupMixin', ')', ':', '___EOS___']", "index": 264 }, { "content": "class Instance(CheckGroupMixin):\n\n\n\n\n class Meta:\n ordering = ['name']\n\n address = models.TextField(\n blank=True,\n help_text=\"Address (IP/Hostname) of service.\"\n )\n\n\n", "metadata": "root.Instance", "header": "['module', '___EOS___']", "index": 297 }, { "content": " def duplicate(self):\n checks = self.status_checks.all()\n new_instance = self\n new_instance.pk = None\n new_instance.id = None\n new_instance.name = u\"Copy of %s\" % self.name\n\n new_instance.save()\n\n for check in checks:\n check.duplicate(inst_set=(new_instance,), serv_set=())\n\n return new_instance.pk", "metadata": "root.Instance.duplicate", "header": "['class', 'Instance', '(', 'CheckGroupMixin', ')', ':', '___EOS___']", "index": 300 }, { "content": " def update_status(self):\n self.old_overall_status = self.overall_status\n # Only active checks feed into our calculation\n status_checks_failed_count = self.all_failing_checks().count()\n self.overall_status = self.most_severe(self.all_failing_checks())\n self.snapshot = InstanceStatusSnapshot(\n instance=self,\n num_checks_active=self.active_status_checks().count(),\n num_checks_passing=self.active_status_checks(\n ).count() - status_checks_failed_count,\n num_checks_failing=status_checks_failed_count,\n overall_status=self.overall_status,\n time=timezone.now(),\n )\n self.snapshot.save()\n self.save()", "metadata": "root.Instance.update_status", "header": "['class', 'Instance', '(', 'CheckGroupMixin', ')', ':', '___EOS___']", "index": 314 }, { "content": " def icmp_status_checks(self):\n return self.status_checks.filter(polymorphic_ctype__model='icmpstatuscheck')", "metadata": "root.Instance.icmp_status_checks", "header": "['class', 'Instance', '(', 'CheckGroupMixin', ')', ':', '___EOS___']", "index": 339 }, { "content": " def active_icmp_status_checks(self):\n return self.icmp_status_checks().filter(active=True)", "metadata": "root.Instance.active_icmp_status_checks", "header": "['class', 'Instance', '(', 'CheckGroupMixin', ')', ':', '___EOS___']", "index": 342 }, { "content": " def delete(self, *args, **kwargs):\n self.icmp_status_checks().delete()\n return super(Instance, self).delete(*args, **kwargs)", "metadata": "root.Instance.delete", "header": "['class', 'Instance', '(', 'CheckGroupMixin', ')', ':', '___EOS___']", "index": 345 }, { "content": "class Snapshot(models.Model):\n\n class Meta:\n abstract = True\n\n time = models.DateTimeField(db_index=True)\n num_checks_active = models.IntegerField(default=0)\n num_checks_passing = models.IntegerField(default=0)\n num_checks_failing = models.IntegerField(default=0)\n overall_status = models.TextField(default=Service.PASSING_STATUS)\n did_send_alert = models.IntegerField(default=False)", "metadata": "root.Snapshot", "header": "['module', '___EOS___']", "index": 350 }, { "content": "class ServiceStatusSnapshot(Snapshot):\n service = models.ForeignKey(Service, related_name='snapshots')\n", "metadata": "root.ServiceStatusSnapshot", "header": "['module', '___EOS___']", "index": 363 }, { "content": " def __unicode__(self):\n return u\"%s: %s\" % (self.service.name, self.overall_status)", "metadata": "root.ServiceStatusSnapshot.__unicode__", "header": "['class', 'ServiceStatusSnapshot', '(', 'Snapshot', ')', ':', '___EOS___']", "index": 366 }, { "content": "class InstanceStatusSnapshot(Snapshot):\n instance = models.ForeignKey(Instance, related_name='snapshots')\n", "metadata": "root.InstanceStatusSnapshot", "header": "['module', '___EOS___']", "index": 370 }, { "content": " def __unicode__(self):\n return u\"%s: %s\" % (self.instance.name, self.overall_status)", "metadata": "root.InstanceStatusSnapshot.__unicode__", "header": "['class', 'InstanceStatusSnapshot', '(', 'Snapshot', ')', ':', '___EOS___']", "index": 373 }, { "content": "class StatusCheck(PolymorphicModel):\n\n \"\"\"\n Base class for polymorphic models. We're going to use\n proxy models for inheriting because it makes life much simpler,\n but this allows us to stick different methods etc on subclasses.\n\n You can work out what (sub)class a model is an instance of by accessing `instance.polymorphic_ctype.model`\n\n We are using django-polymorphic for polymorphism\n \"\"\"\n\n # Common attributes to all\n name = models.TextField()\n active = models.BooleanField(\n default=True,\n help_text='If not active, check will not be used to calculate service status and will not trigger alerts.',\n )\n importance = models.CharField(\n max_length=30,\n choices=Service.IMPORTANCES,\n default=Service.ERROR_STATUS,\n help_text='Severity level of a failure. Critical alerts are for failures you want to wake you up at 2am, Errors are things you can sleep through but need to fix in the morning, and warnings for less important things.'\n )\n frequency = models.IntegerField(\n default=5,\n help_text='Minutes between each check.',\n )\n debounce = models.IntegerField(\n default=0,\n null=True,\n help_text='Number of successive failures permitted before check will be marked as failed. Default is 0, i.e. fail on first failure.'\n )\n created_by = models.ForeignKey(User, null=True)\n calculated_status = models.CharField(\n max_length=50, choices=Service.STATUSES, default=Service.CALCULATED_PASSING_STATUS, blank=True)\n last_run = models.DateTimeField(null=True)\n cached_health = models.TextField(editable=False, null=True)\n\n # Graphite checks\n metric = models.TextField(\n null=True,\n help_text='fully.qualified.name of the Graphite metric you want to watch. This can be any valid Graphite expression, including wildcards, multiple hosts, etc.',\n )\n check_type = models.CharField(\n choices=CHECK_TYPES,\n max_length=100,\n null=True,\n )\n value = models.TextField(\n null=True,\n help_text='If this expression evaluates to true, the check will fail (possibly triggering an alert).',\n )\n expected_num_hosts = models.IntegerField(\n default=0,\n null=True,\n help_text='The minimum number of data series (hosts) you expect to see.',\n )\n allowed_num_failures = models.IntegerField(\n default=0,\n null=True,\n help_text='The maximum number of data series (metrics) you expect to fail. For example, you might be OK with 2 out of 3 webservers having OK load (1 failing), but not 1 out of 3 (2 failing).',\n )\n\n # HTTP checks\n endpoint = models.TextField(\n null=True,\n help_text='HTTP(S) endpoint to poll.',\n )\n username = models.TextField(\n blank=True,\n null=True,\n help_text='Basic auth username.',\n )\n password = models.TextField(\n blank=True,\n null=True,\n help_text='Basic auth password.',\n )\n text_match = models.TextField(\n blank=True,\n null=True,\n help_text='Regex to match against source of page.',\n )\n status_code = models.TextField(\n default=200,\n null=True,\n help_text='Status code expected from endpoint.'\n )\n timeout = models.IntegerField(\n default=30,\n null=True,\n help_text='Time out after this many seconds.',\n )\n verify_ssl_certificate = models.BooleanField(\n default=True,\n help_text='Set to false to allow not try to verify ssl certificates (default True)',\n )\n\n # Jenkins checks\n max_queued_build_time = models.IntegerField(\n null=True,\n blank=True,\n help_text='Alert if build queued for more than this many minutes.',\n )\n\n class Meta(PolymorphicModel.Meta):\n ordering = ['name']\n\n\n\n\n\n\n\n\n", "metadata": "root.StatusCheck", "header": "['module', '___EOS___']", "index": 377 }, { "content": " def __unicode__(self):\n return self.name", "metadata": "root.StatusCheck.__unicode__", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 486 }, { "content": " def recent_results(self):\n # Not great to use id but we are getting lockups, possibly because of something to do with index\n # on time_complete\n return StatusCheckResult.objects.filter(check=self).order_by('-id').defer('raw_data')[:10]", "metadata": "root.StatusCheck.recent_results", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 489 }, { "content": " def last_result(self):\n try:\n return StatusCheckResult.objects.filter(check=self).order_by('-id').defer('raw_data')[0]\n except:\n return None", "metadata": "root.StatusCheck.last_result", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 494 }, { "content": " def run(self):\n start = timezone.now()\n try:\n result = self._run()\n except SoftTimeLimitExceeded as e:\n result = StatusCheckResult(check=self)\n result.error = u'Error in performing check: Celery soft time limit exceeded'\n result.succeeded = False\n except Exception as e:\n result = StatusCheckResult(check=self)\n logger.error(u\"Error performing check: %s\" % (e.message,))\n result.error = u'Error in performing check: %s' % (e.message,)\n result.succeeded = False\n finish = timezone.now()\n result.time = start\n result.time_complete = finish\n result.save()\n self.last_run = finish\n self.save()", "metadata": "root.StatusCheck.run", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 500 }, { "content": " def _run(self):\n \"\"\"\n Implement on subclasses. Should return a `CheckResult` instance.\n \"\"\"\n raise NotImplementedError('Subclasses should implement')", "metadata": "root.StatusCheck._run", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 520 }, { "content": " def save(self, *args, **kwargs):\n if self.last_run:\n recent_results = list(self.recent_results())\n if calculate_debounced_passing(recent_results, self.debounce):\n self.calculated_status = Service.CALCULATED_PASSING_STATUS\n else:\n self.calculated_status = Service.CALCULATED_FAILING_STATUS\n self.cached_health = serialize_recent_results(recent_results)\n try:\n updated = StatusCheck.objects.get(pk=self.pk)\n except StatusCheck.DoesNotExist as e:\n logger.error('Cannot find myself (check %s) in the database, presumably have been deleted' % self.pk)\n return\n else:\n self.cached_health = ''\n self.calculated_status = Service.CALCULATED_PASSING_STATUS\n ret = super(StatusCheck, self).save(*args, **kwargs)\n self.update_related_services()\n self.update_related_instances()\n return ret", "metadata": "root.StatusCheck.save", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 526 }, { "content": " def duplicate(self, inst_set=(), serv_set=()):\n new_check = self\n new_check.pk = None\n new_check.id = None\n new_check.last_run = None\n new_check.save()\n for linked in list(inst_set) + list(serv_set):\n linked.status_checks.add(new_check)\n return new_check.pk", "metadata": "root.StatusCheck.duplicate", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 547 }, { "content": " def update_related_services(self):\n services = self.service_set.all()\n for service in services:\n update_service.delay(service.id)", "metadata": "root.StatusCheck.update_related_services", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 557 }, { "content": " def update_related_instances(self):\n instances = self.instance_set.all()\n for instance in instances:\n update_instance.delay(instance.id)", "metadata": "root.StatusCheck.update_related_instances", "header": "['class', 'StatusCheck', '(', 'PolymorphicModel', ')', ':', '___EOS___']", "index": 562 }, { "content": "class ICMPStatusCheck(StatusCheck):\n\n class Meta(StatusCheck.Meta):\n proxy = True\n\n", "metadata": "root.ICMPStatusCheck", "header": "['module', '___EOS___']", "index": 568 }, { "content": " @property\n def check_category(self):\n return \"ICMP/Ping Check\"", "metadata": "root.ICMPStatusCheck.check_category", "header": "['class', 'ICMPStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 573 }, { "content": " def _run(self):\n result = StatusCheckResult(check=self)\n instances = self.instance_set.all()\n target = self.instance_set.get().address\n\n # We need to read both STDOUT and STDERR because ping can write to both, depending on the kind of error. Thanks a lot, ping.\n ping_process = subprocess.Popen(\"ping -c 1 \" + target, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)\n response = ping_process.wait()\n\n if response == 0:\n result.succeeded = True\n else:\n output = ping_process.stdout.read()\n result.succeeded = False\n result.error = output\n\n return result", "metadata": "root.ICMPStatusCheck._run", "header": "['class', 'ICMPStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 577 }, { "content": "def minimize_targets(targets):\n split = [target.split(\".\") for target in targets]\n\n prefix_nodes_in_common = 0\n for i, nodes in enumerate(itertools.izip(*split)):\n if any(node != nodes[0] for node in nodes):\n prefix_nodes_in_common = i\n break\n split = [nodes[prefix_nodes_in_common:] for nodes in split]\n\n suffix_nodes_in_common = 0\n for i, nodes in enumerate(reversed(zip(*split))):\n if any(node != nodes[0] for node in nodes):\n suffix_nodes_in_common = i\n break\n if suffix_nodes_in_common:\n split = [nodes[:-suffix_nodes_in_common] for nodes in split]\n\n return [\".\".join(nodes) for nodes in split]", "metadata": "root.minimize_targets", "header": "['module', '___EOS___']", "index": 596 }, { "content": "class GraphiteStatusCheck(StatusCheck):\n\n class Meta(StatusCheck.Meta):\n proxy = True\n\n\n", "metadata": "root.GraphiteStatusCheck", "header": "['module', '___EOS___']", "index": 617 }, { "content": " @property\n def check_category(self):\n return \"Metric check\"", "metadata": "root.GraphiteStatusCheck.check_category", "header": "['class', 'GraphiteStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 622 }, { "content": " def format_error_message(self, failures, actual_hosts, hosts_by_target):\n if actual_hosts < self.expected_num_hosts:\n return \"Hosts missing | %d/%d hosts\" % (\n actual_hosts, self.expected_num_hosts)\n elif actual_hosts > 1:\n threshold = float(self.value)\n failures_by_host = [\"%s: %s %s %0.1f\" % (\n hosts_by_target[target], value, self.check_type, threshold)\n for target, value in failures]\n return \", \".join(failures_by_host)\n else:\n target, value = failures[0]\n return \"%s %s %0.1f\" % (value, self.check_type, float(self.value))", "metadata": "root.GraphiteStatusCheck.format_error_message", "header": "['class', 'GraphiteStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 626 }, { "content": " def _run(self):\n result = StatusCheckResult(check=self)\n\n failures = []\n graphite_output = parse_metric(self.metric, mins_to_check=self.frequency)\n\n try:\n result.raw_data = json.dumps(graphite_output['raw'])\n except:\n result.raw_data = graphite_output['raw']\n\n if graphite_output[\"error\"]:\n result.succeeded = False\n result.error = graphite_output[\"error\"]\n return result\n\n if graphite_output['num_series_with_data'] > 0:\n result.average_value = graphite_output['average_value']\n for s in graphite_output['series']:\n if not s[\"values\"]:\n continue\n failure_value = None\n if self.check_type == '<':\n if float(s['min']) < float(self.value):\n failure_value = s['min']\n elif self.check_type == '<=':\n if float(s['min']) <= float(self.value):\n failure_value = s['min']\n elif self.check_type == '>':\n if float(s['max']) > float(self.value):\n failure_value = s['max']\n elif self.check_type == '>=':\n if float(s['max']) >= float(self.value):\n failure_value = s['max']\n elif self.check_type == '==':\n if float(self.value) in s['values']:\n failure_value = float(self.value)\n else:\n raise Exception(u'Check type %s not supported' %\n self.check_type)\n\n if not failure_value is None:\n failures.append((s[\"target\"], failure_value))\n\n if len(failures) > self.allowed_num_failures:\n result.succeeded = False\n elif graphite_output['num_series_with_data'] < self.expected_num_hosts:\n result.succeeded = False\n else:\n result.succeeded = True\n\n if not result.succeeded:\n targets = [s[\"target\"] for s in graphite_output[\"series\"]]\n hosts = minimize_targets(targets)\n hosts_by_target = dict(zip(targets, hosts))\n\n result.error = self.format_error_message(\n failures,\n graphite_output['num_series_with_data'],\n hosts_by_target,\n )\n\n return result", "metadata": "root.GraphiteStatusCheck._run", "header": "['class', 'GraphiteStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 640 }, { "content": "class HttpStatusCheck(StatusCheck):\n\n class Meta(StatusCheck.Meta):\n proxy = True\n\n", "metadata": "root.HttpStatusCheck", "header": "['module', '___EOS___']", "index": 705 }, { "content": " @property\n def check_category(self):\n return \"HTTP check\"", "metadata": "root.HttpStatusCheck.check_category", "header": "['class', 'HttpStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 710 }, { "content": " def _run(self):\n result = StatusCheckResult(check=self)\n\n auth = None\n if self.username or self.password:\n auth = (self.username, self.password)\n\n try:\n resp = requests.get(\n self.endpoint,\n timeout=self.timeout,\n verify=self.verify_ssl_certificate,\n auth=auth,\n headers={\n \"User-Agent\": settings.HTTP_USER_AGENT,\n },\n )\n except requests.RequestException as e:\n result.error = u'Request error occurred: %s' % (e.message,)\n result.succeeded = False\n else:\n if self.status_code and resp.status_code != int(self.status_code):\n result.error = u'Wrong code: got %s (expected %s)' % (\n resp.status_code, int(self.status_code))\n result.succeeded = False\n result.raw_data = resp.content\n elif self.text_match:\n if not re.search(self.text_match, resp.content):\n result.error = u'Failed to find match regex /%s/ in response body' % self.text_match\n result.raw_data = resp.content\n result.succeeded = False\n else:\n result.succeeded = True\n else:\n result.succeeded = True\n return result", "metadata": "root.HttpStatusCheck._run", "header": "['class', 'HttpStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 714 }, { "content": "class JenkinsStatusCheck(StatusCheck):\n\n class Meta(StatusCheck.Meta):\n proxy = True\n\n\n", "metadata": "root.JenkinsStatusCheck", "header": "['module', '___EOS___']", "index": 752 }, { "content": " @property\n def check_category(self):\n return \"Jenkins check\"", "metadata": "root.JenkinsStatusCheck.check_category", "header": "['class', 'JenkinsStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 757 }, { "content": " @property\n def failing_short_status(self):\n return 'Job failing on Jenkins'", "metadata": "root.JenkinsStatusCheck.failing_short_status", "header": "['class', 'JenkinsStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 761 }, { "content": " def _run(self):\n result = StatusCheckResult(check=self)\n try:\n status = get_job_status(self.name)\n active = status['active']\n result.job_number = status['job_number']\n if status['status_code'] == 404:\n result.error = u'Job %s not found on Jenkins' % self.name\n result.succeeded = False\n return result\n elif status['status_code'] > 400:\n # Will fall through to next block\n raise Exception(u'returned %s' % status['status_code'])\n except Exception as e:\n # If something else goes wrong, we will *not* fail - otherwise\n # a lot of services seem to fail all at once.\n # Ugly to do it here but...\n result.error = u'Error fetching from Jenkins - %s' % e.message\n result.succeeded = True\n return result\n\n if not active:\n # We will fail if the job has been disabled\n result.error = u'Job \"%s\" disabled on Jenkins' % self.name\n result.succeeded = False\n else:\n if self.max_queued_build_time and status['blocked_build_time']:\n if status['blocked_build_time'] > self.max_queued_build_time * 60:\n result.succeeded = False\n result.error = u'Job \"%s\" has blocked build waiting for %ss (> %sm)' % (\n self.name,\n int(status['blocked_build_time']),\n self.max_queued_build_time,\n )\n else:\n result.succeeded = status['succeeded']\n else:\n result.succeeded = status['succeeded']\n if not status['succeeded']:\n if result.error:\n result.error += u'; Job \"%s\" failing on Jenkins' % self.name\n else:\n result.error = u'Job \"%s\" failing on Jenkins' % self.name\n result.raw_data = status\n return result", "metadata": "root.JenkinsStatusCheck._run", "header": "['class', 'JenkinsStatusCheck', '(', 'StatusCheck', ')', ':', '___EOS___']", "index": 765 }, { "content": "class StatusCheckResult(models.Model):\n\n \"\"\"\n We use the same StatusCheckResult model for all check types,\n because really they are not so very different.\n\n Checks don't have to use all the fields, so most should be\n nullable\n \"\"\"\n check = models.ForeignKey(StatusCheck)\n time = models.DateTimeField(null=False, db_index=True)\n time_complete = models.DateTimeField(null=True, db_index=True)\n raw_data = models.TextField(null=True)\n succeeded = models.BooleanField(default=False)\n error = models.TextField(null=True)\n\n # Jenkins specific\n job_number = models.PositiveIntegerField(null=True)\n\n class Meta:\n ordering = ['-time_complete']\n index_together = (('check', 'time_complete'),)\n\n\n\n\n", "metadata": "root.StatusCheckResult", "header": "['module', '___EOS___']", "index": 812 }, { "content": " def __unicode__(self):\n return '%s: %s @%s' % (self.status, self.check.name, self.time)", "metadata": "root.StatusCheckResult.__unicode__", "header": "['class', 'StatusCheckResult', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 835 }, { "content": " @property\n def status(self):\n if self.succeeded:\n return 'succeeded'\n else:\n return 'failed'", "metadata": "root.StatusCheckResult.status", "header": "['class', 'StatusCheckResult', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 838 }, { "content": " @property\n def took(self):\n \"\"\"\n Time taken by check in ms\n \"\"\"\n try:\n diff = self.time_complete - self.time\n return (diff.microseconds + (diff.seconds + diff.days * 24 * 3600) * 10**6) / 1000\n except:\n return None", "metadata": "root.StatusCheckResult.took", "header": "['class', 'StatusCheckResult', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 845 }, { "content": " @property\n def short_error(self):\n snippet_len = 30\n if len(self.error) > snippet_len:\n return u\"%s...\" % self.error[:snippet_len - 3]\n else:\n return self.error", "metadata": "root.StatusCheckResult.short_error", "header": "['class', 'StatusCheckResult', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 856 }, { "content": " def save(self, *args, **kwargs):\n if isinstance(self.raw_data, basestring):\n self.raw_data = self.raw_data[:RAW_DATA_LIMIT]\n return super(StatusCheckResult, self).save(*args, **kwargs)", "metadata": "root.StatusCheckResult.save", "header": "['class', 'StatusCheckResult', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 864 }, { "content": "class AlertAcknowledgement(models.Model):\n\n time = models.DateTimeField()\n user = models.ForeignKey(User)\n service = models.ForeignKey(Service)\n cancelled_time = models.DateTimeField(null=True, blank=True)\n cancelled_user = models.ForeignKey(\n User,\n null=True,\n blank=True,\n related_name='cancelleduser_set'\n )\n\n", "metadata": "root.AlertAcknowledgement", "header": "['module', '___EOS___']", "index": 870 }, { "content": " def unexpired(self):\n return self.expires() > timezone.now()", "metadata": "root.AlertAcknowledgement.unexpired", "header": "['class', 'AlertAcknowledgement', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 883 }, { "content": " def expires(self):\n return self.time + timedelta(minutes=settings.ACKNOWLEDGEMENT_EXPIRY)", "metadata": "root.AlertAcknowledgement.expires", "header": "['class', 'AlertAcknowledgement', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 886 }, { "content": "class UserProfile(models.Model):\n user = models.OneToOneField(User, related_name='profile')\n\n\n\n\n\n mobile_number = models.CharField(max_length=20, blank=True, default='')\n hipchat_alias = models.CharField(max_length=50, blank=True, default='')\n fallback_alert_user = models.BooleanField(default=False)", "metadata": "root.UserProfile", "header": "['module', '___EOS___']", "index": 889 }, { "content": " def user_data(self):\n for user_data_subclass in AlertPluginUserData.__subclasses__():\n user_data = user_data_subclass.objects.get_or_create(user=self, title=user_data_subclass.name)\n return AlertPluginUserData.objects.filter(user=self)", "metadata": "root.UserProfile.user_data", "header": "['class', 'UserProfile', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 892 }, { "content": " def __unicode__(self):\n return 'User profile: %s' % self.user.username", "metadata": "root.UserProfile.__unicode__", "header": "['class', 'UserProfile', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 897 }, { "content": " def save(self, *args, **kwargs):\n # Enforce uniqueness\n if self.fallback_alert_user:\n profiles = UserProfile.objects.exclude(id=self.id)\n profiles.update(fallback_alert_user=False)\n return super(UserProfile, self).save(*args, **kwargs)", "metadata": "root.UserProfile.save", "header": "['class', 'UserProfile', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 900 }, { "content": " @property\n def prefixed_mobile_number(self):\n return '+%s' % self.mobile_number", "metadata": "root.UserProfile.prefixed_mobile_number", "header": "['class', 'UserProfile', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 907 }, { "content": "class Shift(models.Model):\n start = models.DateTimeField()\n end = models.DateTimeField()\n user = models.ForeignKey(User)\n uid = models.TextField()\n deleted = models.BooleanField(default=False)\n", "metadata": "root.Shift", "header": "['module', '___EOS___']", "index": 916 }, { "content": " def __unicode__(self):\n deleted = ''\n if self.deleted:\n deleted = ' (deleted)'\n return \"%s: %s to %s%s\" % (self.user.username, self.start, self.end, deleted)", "metadata": "root.Shift.__unicode__", "header": "['class', 'Shift', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 923 }, { "content": "def get_duty_officers(at_time=None):\n \"\"\"Returns a list of duty officers for a given time or now if none given\"\"\"\n duty_officers = []\n if not at_time:\n at_time = timezone.now()\n current_shifts = Shift.objects.filter(\n deleted=False,\n start__lt=at_time,\n end__gt=at_time,\n )\n if current_shifts:\n duty_officers = [shift.user for shift in current_shifts]\n return duty_officers\n else:\n try:\n u = UserProfile.objects.get(fallback_alert_user=True)\n return [u.user]\n except UserProfile.DoesNotExist:\n return []", "metadata": "root.get_duty_officers", "header": "['module', '___EOS___']", "index": 930 }, { "content": "def update_shifts():\n events = get_events()\n users = User.objects.filter(is_active=True)\n user_lookup = {}\n for u in users:\n user_lookup[u.username.lower()] = u\n future_shifts = Shift.objects.filter(start__gt=timezone.now())\n future_shifts.update(deleted=True)\n\n for event in events:\n e = event['summary'].lower().strip()\n if e in user_lookup:\n user = user_lookup[e]\n try:\n s = Shift.objects.get(uid=event['uid'])\n except Shift.DoesNotExist:\n s = Shift(uid=event['uid'])\n s.start = event['start']\n s.end = event['end']\n s.user = user\n s.deleted = False\n s.save()", "metadata": "root.update_shifts", "header": "['module', '___EOS___']", "index": 951 } ]
[ { "span": "from django.core.exceptions import ValidationError", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 50 }, { "span": "from django.db.models import F", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 30 }, { "span": "from django.core.urlresolvers import reverse", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 44 }, { "span": "import os", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 9 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Validat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "polymorphic", "_", "import_", "Poly", "morphi", "c", "Model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "F_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "celery_", "._", "exceptions_", "import_", "Sof", "t", "Time", "Limit", "Exce", "eded", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "jen", "kins", "_", "import_", "get", "\\u", "job", "\\u", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "alert_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "send", "\\u", "alert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "send", "\\u", "alert", "\\u", "update_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Alert", "Plugin_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Alert", "Plug", "in", "User", "Data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "update", "\\u", "alert", "\\u", "plugins_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "calendar_", "import_", "get", "\\u", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "graphite", "_", "import_", "parse", "\\u", "metric_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "graphite", "_", "import_", "get", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "tasks_", "import_", "update", "\\u", "service_", ",_", "update", "\\u", "instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "datetime_", ",_", "timedelta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "timezone_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "itertools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "celery_", "._", "utils_", "._", "log_", "import_", "get", "\\u", "task", "\\u", "logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "RA", "W", "\\u", "DATA", "\\u", "LIMIT_", "=_", "5000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "=_", "get", "\\u", "task", "\\u", "logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "CHECK", "\\u", "TYPES_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'>'_", ",_", "'", "Great", "er", " ", "than", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'>='_", ",_", "'", "Great", "er", " ", "than", " ", "or", " ", "equal", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'<'_", ",_", "'", "Less", " ", "than", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'<='_", ",_", "'", "Less", " ", "than", " ", "or", " ", "equal", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'=='_", ",_", "'", "Equal", " ", "to", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "def_", "serialize", "\\u", "recent", "\\u", "results_", "(_", "recent", "\\u", "results_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "recent", "\\u", "results_", ":_", "\\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_", "def_", "result", "\\u", "to", "\\u", "value_", "(_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "result_", "._", "succeeded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'", "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 ", " _", "return_", "'-", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vals_", "=_", "[_", "result", "\\u", "to", "\\u", "value_", "(_", "r_", ")_", "for_", "r_", "in_", "recent", "\\u", "results_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "._", "reverse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "','_", "._", "join_", "(_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "calcul", "ate", "\\u", "deb", "oun", "ced", "\\u", "passi", "ng_", "(_", "recent", "\\u", "results_", ",_", "deb", "oun", "ce_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "`", "deb", "oun", "ce", "`", " ", "is", " ", "the", " ", "number", " ", "of", " ", "previ", "ous", " ", "fail", "ure", "s", " ", "we", " ", "need", " ", "(", "not", " ", "inclu", "ding", " ", "this", ")", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "mark", " ", "a", " ", "search", " ", "as", " ", "passi", "ng", " ", "or", " ", "faili", "ng", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", "Tru", "e", " ", "if", " ", "passi", "ng", " ", "give", "n", " ", "deb", "oun", "ce", " ", "factor", "\\", "10", ";", " ", " ", "Fal", "se", " ", "if", " ", "faili", "ng", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "recent", "\\u", "results_", ":_", "\\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_", "deb", "oun", "ce", "\\u", "window_", "=_", "recent", "\\u", "results_", "[_", ":_", "deb", "oun", "ce_", "+_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "r_", "in_", "deb", "oun", "ce", "\\u", "window_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "r_", "._", "succeeded_", ":_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "abstract_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "PASS", "ING", "\\u", "STATUS_", "=_", "'", "PASS", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "WARN", "ING", "\\u", "STATUS_", "=_", "'", "WARN", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ERROR", "\\u", "STATUS_", "=_", "'", "ERROR", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CRIT", "ICAL", "\\u", "STATUS_", "=_", "'", "CRIT", "ICAL", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", "=_", "'", "passi", "ng", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CAL", "CUL", "ATED", "\\u", "INTER", "MIT", "TEN", "T", "\\u", "STATUS_", "=_", "'", "interm", "itte", "nt", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CAL", "CUL", "ATED", "\\u", "FAIL", "ING", "\\u", "STATUS_", "=_", "'", "faili", "ng", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "STATUS", "ES_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", ",_", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "CAL", "CUL", "ATED", "\\u", "INTER", "MIT", "TEN", "T", "\\u", "STATUS_", ",_", "CAL", "CUL", "ATED", "\\u", "INTER", "MIT", "TEN", "T", "\\u", "STATUS_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "CAL", "CUL", "ATED", "\\u", "FAIL", "ING", "\\u", "STATUS_", ",_", "CAL", "CUL", "ATED", "\\u", "FAIL", "ING", "\\u", "STATUS_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "IMPORT", "ANCE", "S_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "WARN", "ING", "\\u", "STATUS_", ",_", "'", "Warn", "ing", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "ERROR", "\\u", "STATUS_", ",_", "'", "Error", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "CRIT", "ICAL", "\\u", "STATUS_", ",_", "'", "Crit", "ical", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "models_", "._", "Text", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users", "\\u", "to", "\\u", "notify_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "User_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "User", "s", " ", "who", " ", "shou", "ld", " ", "receive", " ", "alert", "s", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alert", "s", "\\u", "enabled_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Alert", " ", "whe", "n", " ", "this", " ", "service", " ", "is", " ", "not", " ", "healthy", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status", "\\u", "checks_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Status", "Check", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Check", "s", " ", "used", " ", "to", " ", "calcul", "ate", " ", "service", " ", "status", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "alert", "\\u", "sent_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "alerts_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Alert", "Plug", "in", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Alert", "s", " ", "channel", "s", " ", "through", " ", "whi", "ch", " ", "you", " ", "wish", " ", "to", " ", "be", " ", "notified", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "email", "\\u", "alert_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hip", "chat", "\\u", "alert_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sms", "\\u", "alert_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "telephone", "\\u", "alert_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Mus", "t", " ", "be", " ", "enable", "d", ",", " ", "and", " ", "check", " ", "importance", " ", "set", " ", "to", " ", "Crit", "ical", ",", " ", "to", " ", "receive", " ", "telephone", " ", "alert", "s", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "over", "all", "\\u", "status_", "=_", "models_", "._", "Text", "Field_", "(_", "default_", "=_", "PASS", "ING", "\\u", "STATUS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "over", "all", "\\u", "status_", "=_", "models_", "._", "Text", "Field_", "(_", "default_", "=_", "PASS", "ING", "\\u", "STATUS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hack", "pad", "\\u", "id_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "verbo", "se", "\\u", "name_", "=_", "'", "Recover", "y", " ", "instruct", "ion", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Gis", "t", ",", " ", "Hack", "pad", " ", "or", " ", "Ref", "heap", " ", "js", " ", "embed", " ", "with", " ", "recover", "y", " ", "instruct", "ion", "s", " ", "e", ".", "g", ".", " ", "https", "://", "you", ".", "hack", "pad", ".", "com", "/", "some", "\\u", "document", ".", "js", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "most", "\\u", "sever", "e_", "(_", "self_", ",_", "check", "\\u", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "failures_", "=_", "[_", "c_", "._", "importance", "_", "for_", "c_", "in_", "check", "\\u", "list_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "CRIT", "ICAL", "\\u", "STATUS_", "in_", "failures_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "CRIT", "ICAL", "\\u", "STATUS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "ERROR", "\\u", "STATUS_", "in_", "failures_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "ERROR", "\\u", "STATUS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "WARN", "ING", "\\u", "STATUS_", "in_", "failures_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "WARN", "ING", "\\u", "STATUS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "PASS", "ING", "\\u", "STATUS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "is", "\\u", "critical_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Break", " ", "out", " ", "separately", " ", "bec", "aus", "e", " ", "it", "'", "s", " ", "a", " ", "bit", " ", "of", " ", "a", " ", "pain", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "get", " ", "wrong", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "old", "\\u", "over", "all", "\\u", "status_", "!=_", "self_", "._", "CRIT", "ICAL", "\\u", "STATUS_", "and_", "self_", "._", "over", "all", "\\u", "status_", "==_", "self_", "._", "CRIT", "ICAL", "\\u", "STATUS_", ":_", "\\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]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "alert_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "alert", "s", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "over", "all", "\\u", "status_", "!=_", "self_", "._", "PASS", "ING", "\\u", "STATUS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Don", "'", "t", " ", "alert", " ", "every", " ", "time_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "over", "all", "\\u", "status_", "==_", "self_", "._", "WARN", "ING", "\\u", "STATUS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "last", "\\u", "alert", "\\u", "sent_", "and_", "(_", "timezone_", "._", "now_", "(_", ")_", "-_", "timedelta_", "(_", "minutes_", "=_", "settings_", "._", "NOTIFICATION", "\\u", "INTERVAL_", ")_", ")_", "<_", "self_", "._", "last", "\\u", "alert", "\\u", "sent_", ":_", "\\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_", "elif_", "self_", "._", "over", "all", "\\u", "status_", "in_", "(_", "self_", "._", "CRIT", "ICAL", "\\u", "STATUS_", ",_", "self_", "._", "ERROR", "\\u", "STATUS_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "last", "\\u", "alert", "\\u", "sent_", "and_", "(_", "timezone_", "._", "now_", "(_", ")_", "-_", "timedelta_", "(_", "minutes_", "=_", "settings_", "._", "ALERT", "\\u", "INTERVAL_", ")_", ")_", "<_", "self_", "._", "last", "\\u", "alert", "\\u", "sent_", ":_", "\\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_", "self_", "._", "last", "\\u", "alert", "\\u", "sent_", "=_", "timezone_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "don", "'", "t", " ", "count", " ", "\"", "back", " ", "to", " ", "normal", "\"", " ", "as", " ", "an", " ", "alert_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "last", "\\u", "alert", "\\u", "sent_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "une", "xp", "ired", "\\u", "acknowledge", "ment_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "send", "\\u", "alert", "\\u", "update_", "(_", "self_", ",_", "duty", "\\u", "office", "rs_", "=_", "get", "\\u", "duty", "\\u", "office", "rs_", "(_", ")_", ")_", "\\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_", "._", "snapshot_", "._", "did", "\\u", "send", "\\u", "alert_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "snapshot_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "alert_", "(_", "self_", ",_", "duty", "\\u", "office", "rs_", "=_", "get", "\\u", "duty", "\\u", "office", "rs_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "une", "xp", "ired", "\\u", "acknowledge", "ments_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "acknowledge", "ments_", "=_", "self_", "._", "alert", "acknowledge", "ment", "\\u", "set_", "._", "all_", "(_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "time", "\\u\\u", "gte_", "=_", "timezone_", "._", "now_", "(_", ")_", "-_", "timedelta_", "(_", "minutes_", "=_", "settings_", "._", "AC", "KN", "OWL", "EDGE", "MENT", "\\u", "EXP", "IR", "Y_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cancel", "led", "\\u", "time", "\\u\\u", "isnull_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "acknowledge", "ments_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "acknowledge", "\\u", "alert_", "(_", "self_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "une", "xp", "ired", "\\u", "acknowledge", "ments_", "(_", ")_", ":_", "#", " ", "Don", "'", "t", " ", "allow", " ", "users", " ", "to", " ", "jump", " ", "on", " ", "each", " ", "other_", "\\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_", "acknowledge", "ment_", "=_", "Alert", "Ack", "nowl", "edge", "ment_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "=_", "timezone_", "._", "now_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "service_", "=_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "acknowledge", "ment_", "(_", "self_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "une", "xp", "ired", "\\u", "acknowledge", "ments_", "(_", ")_", "._", "update_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "cancel", "led", "\\u", "time_", "=_", "timezone_", "._", "now_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cancel", "led", "\\u", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "une", "xp", "ired", "\\u", "acknowledge", "ment_", "(_", "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_", "._", "une", "xp", "ired", "\\u", "acknowledge", "ments_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "recent", "\\u", "snapshots_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "snapshots_", "=_", "self_", "._", "snapshots_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "time", "\\u\\u", "gt_", "=_", "(_", "timezone_", "._", "now_", "(_", ")_", "-_", "timedelta_", "(_", "minutes_", "=_", "60_", "*_", "24_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "snapshots_", "=_", "list_", "(_", "snapshots_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "s_", "in_", "snapshots_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "[_", "'", "time", "'_", "]_", "=_", "time_", "._", "mktime_", "(_", "s_", "[_", "'", "time", "'_", "]_", "._", "timetuple_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "snapshots_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "graphite", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status", "\\u", "checks_", "._", "filter_", "(_", "polymorphic", "\\u", "ctype", "\\u\\u", "model_", "=_", "'", "graphite", "statusc", "heck", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "http", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status", "\\u", "checks_", "._", "filter_", "(_", "polymorphic", "\\u", "ctype", "\\u\\u", "model_", "=_", "'", "https", "tat", "usc", "heck", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "jen", "kins", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status", "\\u", "checks_", "._", "filter_", "(_", "polymorphic", "\\u", "ctype", "\\u\\u", "model_", "=_", "'", "jen", "kins", "statusc", "heck", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "active", "\\u", "graphite", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "graphite", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "active", "\\u", "http", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "http", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "active", "\\u", "jen", "kins", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "jen", "kins", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "active", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status", "\\u", "checks_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "inact", "ive", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status", "\\u", "checks_", "._", "filter_", "(_", "active_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "all", "\\u", "passi", "ng", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "active", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "filter_", "(_", "calculated", "\\u", "status_", "=_", "self_", "._", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "Group", "Mixin_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "all", "\\u", "faili", "ng", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "active", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "exclude_", "(_", "calculated", "\\u", "status_", "=_", "self_", "._", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", ")_", "\\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_", "Service_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "instances_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Insta", "nce", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Insta", "nce", "s", " ", "this", " ", "service", " ", "is", " ", "runn", "ing", " ", "on", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "\"", "URL", " ", "of", " ", "service", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ordering_", "=_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Service_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "update", "\\u", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "old", "\\u", "over", "all", "\\u", "status_", "=_", "self_", "._", "over", "all", "\\u", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", "ly", " ", "active", " ", "checks", " ", "feed", " ", "int", "o", " ", "our", " ", "calculati", "on_", "\\u\\u\\uNL\\u\\u\\u_", "status", "\\u", "checks", "\\u", "fail", "ed", "\\u", "count_", "=_", "self_", "._", "all", "\\u", "faili", "ng", "\\u", "checks_", "(_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "over", "all", "\\u", "status_", "=_", "self_", "._", "most", "\\u", "sever", "e_", "(_", "self_", "._", "all", "\\u", "faili", "ng", "\\u", "checks_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "snapshot_", "=_", "Service", "Status", "Snapshot_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "service_", "=_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "checks", "\\u", "active_", "=_", "self_", "._", "active", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "checks", "\\u", "passi", "ng_", "=_", "self_", "._", "active", "\\u", "status", "\\u", "checks_", "(_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "count_", "(_", ")_", "-_", "status", "\\u", "checks", "\\u", "fail", "ed", "\\u", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "checks", "\\u", "faili", "ng_", "=_", "status", "\\u", "checks", "\\u", "fail", "ed", "\\u", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "over", "all", "\\u", "status_", "=_", "self_", "._", "over", "all", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "=_", "timezone_", "._", "now_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "snapshot_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "(_", "self_", "._", "over", "all", "\\u", "status_", "==_", "Service_", "._", "PASS", "ING", "\\u", "STATUS_", "and_", "self_", "._", "old", "\\u", "over", "all", "\\u", "status_", "==_", "Service_", "._", "PASS", "ING", "\\u", "STATUS_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "alert_", "(_", ")_", "\\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_", "Instance_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ordering_", "=_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "address_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "\"", "Address", " ", "(", "IP", "/", "Host", "name", ")", " ", "of", " ", "service", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Instance_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "duplicate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checks_", "=_", "self_", "._", "status", "\\u", "checks_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "instance_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "instance_", "._", "pk_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "instance_", "._", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "instance_", "._", "name_", "=_", "u", "\"", "Copy", " ", "of", " ", "%", "s", "\"_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "instance_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "check_", "in_", "checks_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "check_", "._", "duplicate_", "(_", "inst", "\\u", "set_", "=_", "(_", "new", "\\u", "instance_", ",_", ")_", ",_", "serv", "\\u", "set_", "=_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "new", "\\u", "instance_", "._", "pk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Instance_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "old", "\\u", "over", "all", "\\u", "status_", "=_", "self_", "._", "over", "all", "\\u", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", "ly", " ", "active", " ", "checks", " ", "feed", " ", "int", "o", " ", "our", " ", "calculati", "on_", "\\u\\u\\uNL\\u\\u\\u_", "status", "\\u", "checks", "\\u", "fail", "ed", "\\u", "count_", "=_", "self_", "._", "all", "\\u", "faili", "ng", "\\u", "checks_", "(_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "over", "all", "\\u", "status_", "=_", "self_", "._", "most", "\\u", "sever", "e_", "(_", "self_", "._", "all", "\\u", "faili", "ng", "\\u", "checks_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "snapshot_", "=_", "Insta", "nce", "Status", "Snapshot_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "instance_", "=_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "checks", "\\u", "active_", "=_", "self_", "._", "active", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "checks", "\\u", "passi", "ng_", "=_", "self_", "._", "active", "\\u", "status", "\\u", "checks_", "(_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "count_", "(_", ")_", "-_", "status", "\\u", "checks", "\\u", "fail", "ed", "\\u", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "checks", "\\u", "faili", "ng_", "=_", "status", "\\u", "checks", "\\u", "fail", "ed", "\\u", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "over", "all", "\\u", "status_", "=_", "self_", "._", "over", "all", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "=_", "timezone_", "._", "now_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "snapshot_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Instance_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "icmp", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status", "\\u", "checks_", "._", "filter_", "(_", "polymorphic", "\\u", "ctype", "\\u\\u", "model_", "=_", "'", "icmp", "statusc", "heck", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Instance_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "active", "\\u", "icmp", "\\u", "status", "\\u", "checks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "icmp", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Instance_", "(_", "Check", "Group", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "icmp", "\\u", "status", "\\u", "checks_", "(_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "super_", "(_", "Instance_", ",_", "self_", ")_", "._", "delete_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Snapshot_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "abstract_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "db", "\\u", "index_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "checks", "\\u", "active_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "checks", "\\u", "passi", "ng_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "checks", "\\u", "faili", "ng_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "over", "all", "\\u", "status_", "=_", "models_", "._", "Text", "Field_", "(_", "default_", "=_", "Service_", "._", "PASS", "ING", "\\u", "STATUS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "did", "\\u", "send", "\\u", "alert_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "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_", "class_", "Service", "Status", "Snapshot_", "(_", "Snapshot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "service_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Service_", ",_", "relate", "d\\u", "name_", "=_", "'", "snapshot", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Service", "Status", "Snapshot_", "(_", "Snapshot_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "u", "\"%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "self_", "._", "service_", "._", "name_", ",_", "self_", "._", "over", "all", "\\u", "status_", ")_", "\\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_", "Insta", "nce", "Status", "Snapshot_", "(_", "Snapshot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Instance_", ",_", "relate", "d\\u", "name_", "=_", "'", "snapshot", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Insta", "nce", "Status", "Snapshot_", "(_", "Snapshot_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "u", "\"%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "self_", "._", "instance_", "._", "name_", ",_", "self_", "._", "over", "all", "\\u", "status_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Base", " ", "class", " ", "for", " ", "polymorphic", " ", "model", "s", ".", " ", "We", "'", "re", " ", "goi", "ng", " ", "to", " ", "use", "\\", "10", ";", " ", " ", " ", " ", "proxy", " ", "model", "s", " ", "for", " ", "inherit", "ing", " ", "bec", "aus", "e", " ", "it", " ", "make", "s", " ", "life", " ", "muc", "h", " ", "simple", "r", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "this", " ", "allow", "s", " ", "us", " ", "to", " ", "stick", " ", "different", " ", "method", "s", " ", "etc", " ", "on", " ", "subclasses", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "You", " ", "can", " ", "work", " ", "out", " ", "what", " ", "(", "sub", ")", "class", " ", "a", " ", "model", " ", "is", " ", "an", " ", "instance", " ", "of", " ", "by", " ", "accessi", "ng", " ", "`", "instance", ".", "polymorphic", "\\u", "ctype", ".", "model", "`", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "are", " ", "usi", "ng", " ", "django", "-", "polymorphic", " ", "for", " ", "poly", "morphi", "sm", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Common", " ", "attribute", "s", " ", "to", " ", "all_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "models_", "._", "Text", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "active_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "If", " ", "not", " ", "active", ",", " ", "check", " ", "will", " ", "not", " ", "be", " ", "used", " ", "to", " ", "calcul", "ate", " ", "service", " ", "status", " ", "and", " ", "will", " ", "not", " ", "trigger", " ", "alert", "s", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "importance", "_", "=_", "models_", "._", "Char", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "length_", "=_", "30_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "choices_", "=_", "Service_", "._", "IMPORT", "ANCE", "S_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "Service_", "._", "ERROR", "\\u", "STATUS_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Severity", " ", "level", " ", "of", " ", "a", " ", "fail", "ure", ".", " ", "Crit", "ical", " ", "alert", "s", " ", "are", " ", "for", " ", "fail", "ure", "s", " ", "you", " ", "want", " ", "to", " ", "wake", " ", "you", " ", "up", " ", "at", " ", "2a", "m", ",", " ", "Error", "s", " ", "are", " ", "thing", "s", " ", "you", " ", "can", " ", "sleep", " ", "through", " ", "but", " ", "need", " ", "to", " ", "fix", " ", "in", " ", "the", " ", "mor", "ning", ",", " ", "and", " ", "warn", "ings", " ", "for", " ", "less", " ", "importa", "nt", " ", "thing", "s", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frequency_", "=_", "models_", "._", "Integer", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Minute", "s", " ", "bet", "ween", " ", "each", " ", "check", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "deb", "oun", "ce_", "=_", "models_", "._", "Integer", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Number", " ", "of", " ", "success", "ive", " ", "fail", "ure", "s", " ", "permit", "ted", " ", "bef", "ore", " ", "check", " ", "will", " ", "be", " ", "marked", " ", "as", " ", "fail", "ed", ".", " ", "Default", " ", "is", " ", "0", ",", " ", "i", ".", "e", ".", " ", "fail", " ", "on", " ", "first", " ", "fail", "ure", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "created", "\\u", "by_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calculated", "\\u", "status_", "=_", "models_", "._", "Char", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "length_", "=_", "50_", ",_", "choices_", "=_", "Service_", "._", "STATUS", "ES_", ",_", "default_", "=_", "Service_", "._", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", ",_", "blank_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "run_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cache", "d\\u", "health_", "=_", "models_", "._", "Text", "Field_", "(_", "editable_", "=_", "False_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Graph", "ite", " ", "checks_", "\\u\\u\\uNL\\u\\u\\u_", "metric_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "full", "y", ".", "qualified", ".", "name", " ", "of", " ", "the", " ", "Graph", "ite", " ", "metric", " ", "you", " ", "want", " ", "to", " ", "watch", ".", " ", "Thi", "s", " ", "can", " ", "be", " ", "any", " ", "valid", " ", "Graph", "ite", " ", "express", "ion", ",", " ", "inclu", "ding", " ", "wildcards", ",", " ", "multiple", " ", "host", "s", ",", " ", "etc", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "check", "\\u", "type_", "=_", "models_", "._", "Char", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "choices_", "=_", "CHECK", "\\u", "TYPES_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "length_", "=_", "100_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "If", " ", "this", " ", "express", "ion", " ", "evaluate", "s", " ", "to", " ", "true", ",", " ", "the", " ", "check", " ", "will", " ", "fail", " ", "(", "possib", "ly", " ", "trigger", "ing", " ", "an", " ", "alert", ").'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "num", "\\u", "hosts_", "=_", "models_", "._", "Integer", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "The", " ", "minim", "um", " ", "number", " ", "of", " ", "data", " ", "series", " ", "(", "host", "s", ")", " ", "you", " ", "expect", " ", "to", " ", "see", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "ed", "\\u", "num", "\\u", "failures_", "=_", "models_", "._", "Integer", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "The", " ", "maxim", "um", " ", "number", " ", "of", " ", "data", " ", "series", " ", "(", "metric", "s", ")", " ", "you", " ", "expect", " ", "to", " ", "fail", ".", " ", "For", " ", "example", ",", " ", "you", " ", "mig", "ht", " ", "be", " ", "OK", " ", "with", " ", "2", " ", "out", " ", "of", " ", "3", " ", "webse", "rver", "s", " ", "hav", "ing", " ", "OK", " ", "load", " ", "(", "1", " ", "faili", "ng", "),", " ", "but", " ", "not", " ", "1", " ", "out", " ", "of", " ", "3", " ", "(", "2", " ", "faili", "ng", ").'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "HTTP", " ", "checks_", "\\u\\u\\uNL\\u\\u\\u_", "endpoint_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "HTTP", "(", "S", ")", " ", "endpoint", " ", "to", " ", "poll", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "username_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Basic", " ", "auth", " ", "user", "name", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Basic", " ", "auth", " ", "password", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "\\u", "match_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Rege", "x", " ", "to", " ", "match", " ", "against", " ", "source", " ", "of", " ", "page", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status", "\\u", "code_", "=_", "models_", "._", "Text", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "200_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Status", " ", "code", " ", "expected", " ", "from", " ", "endpoint", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timeout_", "=_", "models_", "._", "Integer", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "30_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Time", " ", "out", " ", "after", " ", "this", " ", "many", " ", "second", "s", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verify", "\\u", "ssl", "\\u", "certificate_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Set", " ", "to", " ", "fal", "se", " ", "to", " ", "allow", " ", "not", " ", "try", " ", "to", " ", "verify", " ", "ssl", " ", "certificates", " ", "(", "default", " ", "Tru", "e", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jen", "kins", " ", "checks_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "queue", "d\\u", "build", "\\u", "time_", "=_", "models_", "._", "Integer", "Field_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "text_", "=_", "'", "Alert", " ", "if", " ", "build", " ", "queue", "d", " ", "for", " ", "more", " ", "than", " ", "this", " ", "many", " ", "minute", "s", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", "(_", "Poly", "morphi", "c", "Model_", "._", "Meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ordering_", "=_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "recent", "\\u", "results_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", " ", "great", " ", "to", " ", "use", " ", "id", " ", "but", " ", "we", " ", "are", " ", "getti", "ng", " ", "lock", "ups", ",", " ", "possib", "ly", " ", "bec", "aus", "e", " ", "of", " ", "somet", "hing", " ", "to", " ", "do", " ", "with", " ", "index_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "on", " ", "time", "\\u", "complete_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Status", "Check", "Result_", "._", "objects_", "._", "filter_", "(_", "check_", "=_", "self_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "id", "'_", ")_", "._", "defer_", "(_", "'", "raw", "\\u", "data", "'_", ")_", "[_", ":_", "10_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "last", "\\u", "result_", "(_", "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_", "Status", "Check", "Result_", "._", "objects_", "._", "filter_", "(_", "check_", "=_", "self_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "id", "'_", ")_", "._", "defer_", "(_", "'", "raw", "\\u", "data", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "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_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "timezone_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "self_", "._", "\\u", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sof", "t", "Time", "Limit", "Exce", "eded", "_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "Status", "Check", "Result_", "(_", "check_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "error_", "=_", "u", "'", "Error", " ", "in", " ", "perform", "ing", " ", "check", ":", " ", "Celery", " ", "soft", " ", "time", " ", "limit", " ", "exceed", "ed", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "False_", "\\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 ", " _", "result_", "=_", "Status", "Check", "Result_", "(_", "check_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "error_", "(_", "u", "\"", "Error", " ", "perform", "ing", " ", "check", ":", " ", "%", "s", "\"_", "%_", "(_", "e_", "._", "message_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "error_", "=_", "u", "'", "Error", " ", "in", " ", "perform", "ing", " ", "check", ":", " ", "%", "s", "'_", "%_", "(_", "e_", "._", "message_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finish_", "=_", "timezone_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "time_", "=_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "time", "\\u", "complete_", "=_", "finish_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "\\u", "run_", "=_", "finish_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Impl", "ement", " ", "on", " ", "subclasses", ".", " ", "Sho", "ul", "d", " ", "return", " ", "a", " ", "`", "Check", "Result", "`", " ", "instance", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", "'", "Subc", "lasse", "s", " ", "shou", "ld", " ", "implement", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "last", "\\u", "run_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "recent", "\\u", "results_", "=_", "list_", "(_", "self_", "._", "recent", "\\u", "results_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "calcul", "ate", "\\u", "deb", "oun", "ced", "\\u", "passi", "ng_", "(_", "recent", "\\u", "results_", ",_", "self_", "._", "deb", "oun", "ce_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "calculated", "\\u", "status_", "=_", "Service_", "._", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", "\\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_", "._", "calculated", "\\u", "status_", "=_", "Service_", "._", "CAL", "CUL", "ATED", "\\u", "FAIL", "ING", "\\u", "STATUS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "cache", "d\\u", "health_", "=_", "serialize", "\\u", "recent", "\\u", "results_", "(_", "recent", "\\u", "results_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "updated_", "=_", "Status", "Check_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "self_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Status", "Check_", "._", "Do", "es", "Not", "Exist_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "error_", "(_", "'", "Cann", "ot", " ", "find", " ", "mysel", "f", " ", "(", "check", " ", "%", "s", ")", " ", "in", " ", "the", " ", "databa", "se", ",", " ", "presu", "mab", "ly", " ", "have", " ", "bee", "n", " ", "delete", "d", "'_", "%_", "self_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "cache", "d\\u", "health_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "calculated", "\\u", "status_", "=_", "Service_", "._", "CAL", "CUL", "ATED", "\\u", "PASS", "ING", "\\u", "STATUS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ret_", "=_", "super_", "(_", "Status", "Check_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "\\u", "relate", "d\\u", "services_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "\\u", "relate", "d\\u", "instances_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "ret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "duplicate_", "(_", "self_", ",_", "inst", "\\u", "set_", "=_", "(_", ")_", ",_", "serv", "\\u", "set_", "=_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "check_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "check_", "._", "pk_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "check_", "._", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "check_", "._", "last", "\\u", "run_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "check_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "linked_", "in_", "list_", "(_", "inst", "\\u", "set_", ")_", "+_", "list_", "(_", "serv", "\\u", "set_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "linked_", "._", "status", "\\u", "checks_", "._", "add_", "(_", "new", "\\u", "check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "new", "\\u", "check_", "._", "pk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "relate", "d\\u", "services_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "services_", "=_", "self_", "._", "service", "\\u", "set_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "service_", "in_", "services_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "update", "\\u", "service_", "._", "delay_", "(_", "service_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check_", "(_", "Poly", "morphi", "c", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "relate", "d\\u", "instances_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instances_", "=_", "self_", "._", "instance", "\\u", "set_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "instance_", "in_", "instances_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "update", "\\u", "instance_", "._", "delay_", "(_", "instance_", "._", "id_", ")_", "\\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_", "ICM", "PS", "tat", "us", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", "(_", "Status", "Check_", "._", "Meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "proxy_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "ICM", "PS", "tat", "us", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "check", "\\u", "category_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "ICM", "P", "/", "Ping", " ", "Check", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ICM", "PS", "tat", "us", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "Status", "Check", "Result_", "(_", "check_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instances_", "=_", "self_", "._", "instance", "\\u", "set_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target_", "=_", "self_", "._", "instance", "\\u", "set_", "._", "get_", "(_", ")_", "._", "address_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "need", " ", "to", " ", "read", " ", "bot", "h", " ", "STD", "OUT", " ", "and", " ", "STD", "ERR", " ", "bec", "aus", "e", " ", "ping", " ", "can", " ", "write", " ", "to", " ", "bot", "h", ",", " ", "depend", "ing", " ", "on", " ", "the", " ", "kind", " ", "of", " ", "error", ".", " ", "Thanks", " ", "a", " ", "lot", ",", " ", "ping", "._", "\\u\\u\\uNL\\u\\u\\u_", "ping", "\\u", "process_", "=_", "subprocess_", "._", "Popen_", "(_", "\"", "ping", " ", "-", "c", " ", "1", " ", "\"_", "+_", "target_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ",_", "stderr_", "=_", "subprocess_", "._", "STDOUT_", ",_", "shell_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "ping", "\\u", "process_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "response_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "succeeded_", "=_", "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 ", " _", "output_", "=_", "ping", "\\u", "process_", "._", "stdout_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "error_", "=_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "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_", "minimize", "\\u", "targets_", "(_", "targets_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "split_", "=_", "[_", "target_", "._", "split_", "(_", "\".\"_", ")_", "for_", "target_", "in_", "targets_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prefix", "\\u", "nodes", "\\u", "in", "\\u", "common_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "nodes_", "in_", "enumerate_", "(_", "itertools_", "._", "izip_", "(_", "*_", "split_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "any_", "(_", "node_", "!=_", "nodes_", "[_", "0_", "]_", "for_", "node_", "in_", "nodes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prefix", "\\u", "nodes", "\\u", "in", "\\u", "common_", "=_", "i_", "\\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_", "split_", "=_", "[_", "nodes_", "[_", "prefix", "\\u", "nodes", "\\u", "in", "\\u", "common_", ":_", "]_", "for_", "nodes_", "in_", "split_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "suff", "ix", "\\u", "nodes", "\\u", "in", "\\u", "common_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "nodes_", "in_", "enumerate_", "(_", "reversed_", "(_", "zip_", "(_", "*_", "split_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "any_", "(_", "node_", "!=_", "nodes_", "[_", "0_", "]_", "for_", "node_", "in_", "nodes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "suff", "ix", "\\u", "nodes", "\\u", "in", "\\u", "common_", "=_", "i_", "\\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_", "if_", "suff", "ix", "\\u", "nodes", "\\u", "in", "\\u", "common_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "split_", "=_", "[_", "nodes_", "[_", ":_", "-_", "suff", "ix", "\\u", "nodes", "\\u", "in", "\\u", "common_", "]_", "for_", "nodes_", "in_", "split_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "\".\"_", "._", "join_", "(_", "nodes_", ")_", "for_", "nodes_", "in_", "split_", "]_", "\\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_", "Graph", "ite", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", "(_", "Status", "Check_", "._", "Meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "proxy_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Graph", "ite", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "check", "\\u", "category_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Met", "ric", " ", "check", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Graph", "ite", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "format\\u", "error", "\\u", "message_", "(_", "self_", ",_", "failures_", ",_", "actual", "\\u", "hosts_", ",_", "host", "s", "\\u", "by", "\\u", "target_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "actual", "\\u", "hosts_", "<_", "self_", "._", "expected", "\\u", "num", "\\u", "hosts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Host", "s", " ", "missi", "ng", " ", "|", " ", "%", "d", "/", "%", "d", " ", "host", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "actual", "\\u", "hosts_", ",_", "self_", "._", "expected", "\\u", "num", "\\u", "hosts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "actual", "\\u", "hosts_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshold_", "=_", "float_", "(_", "self_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fail", "ure", "s", "\\u", "by", "\\u", "host_", "=_", "[_", "\"%", "s", ":", " ", "%", "s", " ", "%", "s", " ", "%", "0.", "1f", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "host", "s", "\\u", "by", "\\u", "target_", "[_", "target_", "]_", ",_", "value_", ",_", "self_", "._", "check", "\\u", "type_", ",_", "threshold_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "target_", ",_", "value_", "in_", "failures_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\",", " ", "\"_", "._", "join_", "(_", "fail", "ure", "s", "\\u", "by", "\\u", "host_", ")_", "\\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 ", " _", "target_", ",_", "value_", "=_", "failures_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"%", "s", " ", "%", "s", " ", "%", "0.", "1f", "\"_", "%_", "(_", "value_", ",_", "self_", "._", "check", "\\u", "type_", ",_", "float_", "(_", "self_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Graph", "ite", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\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", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "Status", "Check", "Result_", "(_", "check_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "failures_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "graphite", "\\u", "output_", "=_", "parse", "\\u", "metric_", "(_", "self_", "._", "metric_", ",_", "mins", "\\u", "to", "\\u", "check_", "=_", "self_", "._", "frequency_", ")_", "\\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 ", " _", "result_", "._", "raw", "\\u", "data_", "=_", "json_", "._", "dumps_", "(_", "graphite", "\\u", "output_", "[_", "'", "raw", "'_", "]_", ")_", "\\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_", "._", "raw", "\\u", "data_", "=_", "graphite", "\\u", "output_", "[_", "'", "raw", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "graphite", "\\u", "output_", "[_", "\"", "error", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "error_", "=_", "graphite", "\\u", "output_", "[_", "\"", "error", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "graphite", "\\u", "output_", "[_", "'", "num", "\\u", "series", "\\u", "with", "\\u", "data", "'_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "averag", "e\\u", "value_", "=_", "graphite", "\\u", "output_", "[_", "'", "averag", "e\\u", "value", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "s_", "in_", "graphite", "\\u", "output_", "[_", "'", "series", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "s_", "[_", "\"", "values", "\"_", "]_", ":_", "\\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_", "fail", "ure", "\\u", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "check", "\\u", "type_", "==_", "'<'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "float_", "(_", "s_", "[_", "'", "min", "'_", "]_", ")_", "<_", "float_", "(_", "self_", "._", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fail", "ure", "\\u", "value_", "=_", "s_", "[_", "'", "min", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "check", "\\u", "type_", "==_", "'<='_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "float_", "(_", "s_", "[_", "'", "min", "'_", "]_", ")_", "<=_", "float_", "(_", "self_", "._", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fail", "ure", "\\u", "value_", "=_", "s_", "[_", "'", "min", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "check", "\\u", "type_", "==_", "'>'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "float_", "(_", "s_", "[_", "'", "max", "'_", "]_", ")_", ">_", "float_", "(_", "self_", "._", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fail", "ure", "\\u", "value_", "=_", "s_", "[_", "'", "max", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "check", "\\u", "type_", "==_", "'>='_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "float_", "(_", "s_", "[_", "'", "max", "'_", "]_", ")_", ">=_", "float_", "(_", "self_", "._", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fail", "ure", "\\u", "value_", "=_", "s_", "[_", "'", "max", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "check", "\\u", "type_", "==_", "'=='_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "float_", "(_", "self_", "._", "value_", ")_", "in_", "s_", "[_", "'", "values", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fail", "ure", "\\u", "value_", "=_", "float_", "(_", "self_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Exception_", "(_", "u", "'", "Check", " ", "type", " ", "%", "s", " ", "not", " ", "support", "ed", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "fail", "ure", "\\u", "value_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "failures_", "._", "append_", "(_", "(_", "s_", "[_", "\"", "target", "\"_", "]_", ",_", "fail", "ure", "\\u", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "failures_", ")_", ">_", "self_", "._", "allow", "ed", "\\u", "num", "\\u", "failures_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "graphite", "\\u", "output_", "[_", "'", "num", "\\u", "series", "\\u", "with", "\\u", "data", "'_", "]_", "<_", "self_", "._", "expected", "\\u", "num", "\\u", "hosts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "succeeded_", "=_", "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 ", " _", "result_", "._", "succeeded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "result_", "._", "succeeded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "targets_", "=_", "[_", "s_", "[_", "\"", "target", "\"_", "]_", "for_", "s_", "in_", "graphite", "\\u", "output_", "[_", "\"", "series", "\"_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hosts_", "=_", "minimize", "\\u", "targets_", "(_", "targets_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "s", "\\u", "by", "\\u", "target_", "=_", "dict_", "(_", "zip_", "(_", "targets_", ",_", "hosts_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "error_", "=_", "self_", "._", "format\\u", "error", "\\u", "message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "failures_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "graphite", "\\u", "output_", "[_", "'", "num", "\\u", "series", "\\u", "with", "\\u", "data", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "host", "s", "\\u", "by", "\\u", "target_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Http", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", "(_", "Status", "Check_", "._", "Meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "proxy_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Http", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "check", "\\u", "category_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "HTTP", " ", "check", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Http", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "Status", "Check", "Result_", "(_", "check_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "auth_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "username_", "or_", "self_", "._", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "auth_", "=_", "(_", "self_", "._", "username_", ",_", "self_", "._", "password_", ")_", "\\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 ", " _", "resp_", "=_", "requests_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "endpoint_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "timeout_", "=_", "self_", "._", "timeout_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "verify_", "=_", "self_", "._", "verify", "\\u", "ssl", "\\u", "certificate_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "auth_", "=_", "auth_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "User", "-", "Agent", "\"_", ":_", "settings_", "._", "HTTP", "\\u", "USER", "\\u", "AGENT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "requests_", "._", "Request", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "error_", "=_", "u", "'", "Request", " ", "error", " ", "occur", "red", ":", " ", "%", "s", "'_", "%_", "(_", "e_", "._", "message_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "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 ", " _", "if_", "self_", "._", "status", "\\u", "code_", "and_", "resp_", "._", "status", "\\u", "code_", "!=_", "int_", "(_", "self_", "._", "status", "\\u", "code_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "error_", "=_", "u", "'", "Wro", "ng", " ", "code", ":", " ", "got", " ", "%", "s", " ", "(", "expected", " ", "%", "s", ")'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "resp_", "._", "status", "\\u", "code_", ",_", "int_", "(_", "self_", "._", "status", "\\u", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "raw", "\\u", "data_", "=_", "resp_", "._", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "text", "\\u", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "re_", "._", "search_", "(_", "self_", "._", "text", "\\u", "match_", ",_", "resp_", "._", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "result_", "._", "error_", "=_", "u", "'", "Fail", "ed", " ", "to", " ", "find", " ", "match", " ", "regex", " ", "/", "%", "s", "/", " ", "in", " ", "response", " ", "body", "'_", "%_", "self_", "._", "text", "\\u", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "raw", "\\u", "data_", "=_", "resp_", "._", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "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 ", " ", "_", "result_", "._", "succeeded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "succeeded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Jen", "kins", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", "(_", "Status", "Check_", "._", "Meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "proxy_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Jen", "kins", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "check", "\\u", "category_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Jen", "kins", " ", "check", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Jen", "kins", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "faili", "ng", "\\u", "short", "\\u", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'", "Jo", "b", " ", "faili", "ng", " ", "on", " ", "Jen", "kins", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Jen", "kins", "Status", "Check_", "(_", "Status", "Check_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "Status", "Check", "Result_", "(_", "check_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "get", "\\u", "job", "\\u", "status_", "(_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "active_", "=_", "status_", "[_", "'", "active", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "job", "\\u", "number_", "=_", "status_", "[_", "'", "job", "\\u", "number", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "status_", "[_", "'", "status", "\\u", "code", "'_", "]_", "==_", "404_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "error_", "=_", "u", "'", "Jo", "b", " ", "%", "s", " ", "not", " ", "found", " ", "on", " ", "Jen", "kins", "'_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "status_", "[_", "'", "status", "\\u", "code", "'_", "]_", ">_", "400_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Wil", "l", " ", "fall", " ", "through", " ", "to", " ", "next", " ", "block_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "u", "'", "return", "ed", " ", "%", "s", "'_", "%_", "status_", "[_", "'", "status", "\\u", "code", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "somet", "hing", " ", "else", " ", "go", "es", " ", "wrong", ",", " ", "we", " ", "will", " ", "*", "not", "*", " ", "fail", " ", "-", " ", "other", "wise_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "lot", " ", "of", " ", "service", "s", " ", "see", "m", " ", "to", " ", "fail", " ", "all", " ", "at", " ", "onc", "e", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ug", "ly", " ", "to", " ", "do", " ", "it", " ", "here", " ", "but", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "error_", "=_", "u", "'", "Error", " ", "fetch", "ing", " ", "from", " ", "Jen", "kins", " ", "-", " ", "%", "s", "'_", "%_", "e_", "._", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "active_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "will", " ", "fail", " ", "if", " ", "the", " ", "job", " ", "has", " ", "bee", "n", " ", "disabled_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "error_", "=_", "u", "'", "Jo", "b", " ", "\"%", "s", "\"", " ", "disable", "d", " ", "on", " ", "Jen", "kins", "'_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "succeeded_", "=_", "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 ", " _", "if_", "self_", "._", "max", "\\u", "queue", "d\\u", "build", "\\u", "time_", "and_", "status_", "[_", "'", "block", "ed", "\\u", "build", "\\u", "time", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "status_", "[_", "'", "block", "ed", "\\u", "build", "\\u", "time", "'_", "]_", ">_", "self_", "._", "max", "\\u", "queue", "d\\u", "build", "\\u", "time_", "*_", "60_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "result_", "._", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "._", "error_", "=_", "u", "'", "Jo", "b", " ", "\"%", "s", "\"", " ", "has", " ", "block", "ed", " ", "build", " ", "wait", "ing", " ", "for", " ", "%", "ss", " ", "(>", " ", "%", "sm", ")'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "int_", "(_", "status_", "[_", "'", "block", "ed", "\\u", "build", "\\u", "time", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "max", "\\u", "queue", "d\\u", "build", "\\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 ", " ", "_", "result_", "._", "succeeded_", "=_", "status_", "[_", "'", "succe", "eded", "'_", "]_", "\\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 ", " _", "result_", "._", "succeeded_", "=_", "status_", "[_", "'", "succe", "eded", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "status_", "[_", "'", "succe", "eded", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "result_", "._", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "result_", "._", "error_", "+=_", "u", "';", " ", "Jo", "b", " ", "\"%", "s", "\"", " ", "faili", "ng", " ", "on", " ", "Jen", "kins", "'_", "%_", "self_", "._", "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 ", " ", "_", "result_", "._", "error_", "=_", "u", "'", "Jo", "b", " ", "\"%", "s", "\"", " ", "faili", "ng", " ", "on", " ", "Jen", "kins", "'_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "._", "raw", "\\u", "data_", "=_", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Status", "Check", "Result_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "use", " ", "the", " ", "same", " ", "Status", "Check", "Result", " ", "model", " ", "for", " ", "all", " ", "check", " ", "types", ",", "\\", "10", ";", " ", " ", " ", " ", "bec", "aus", "e", " ", "reall", "y", " ", "the", "y", " ", "are", " ", "not", " ", "so", " ", "very", " ", "different", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Check", "s", " ", "don", "'", "t", " ", "have", " ", "to", " ", "use", " ", "all", " ", "the", " ", "fields", ",", " ", "so", " ", "most", " ", "shou", "ld", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "null", "able", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "check_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Status", "Check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "null_", "=_", "False_", ",_", "db", "\\u", "index_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time", "\\u", "complete_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "null_", "=_", "True_", ",_", "db", "\\u", "index_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raw", "\\u", "data_", "=_", "models_", "._", "Text", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "succeeded_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "models_", "._", "Text", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jen", "kins", " ", "specific_", "\\u\\u\\uNL\\u\\u\\u_", "job", "\\u", "number_", "=_", "models_", "._", "Posi", "tiv", "e", "Integer", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ordering_", "=_", "[_", "'-", "time", "\\u", "complete", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "together_", "=_", "(_", "(_", "'", "check", "'_", ",_", "'", "time", "\\u", "complete", "'_", ")_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Status", "Check", "Result_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'%", "s", ":", " ", "%", "s", " ", "@", "%", "s", "'_", "%_", "(_", "self_", "._", "status_", ",_", "self_", "._", "check_", "._", "name_", ",_", "self_", "._", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check", "Result_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "succeeded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'", "succe", "eded", "'_", "\\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_", "'", "fail", "ed", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check", "Result_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "too", "k_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Time", " ", "take", "n", " ", "by", " ", "check", " ", "in", " ", "ms", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "diff_", "=_", "self_", "._", "time", "\\u", "complete_", "-_", "self_", "._", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "diff_", "._", "microseconds_", "+_", "(_", "diff_", "._", "seconds_", "+_", "diff_", "._", "days_", "*_", "24_", "*_", "3600_", ")_", "*_", "10_", "**_", "6_", ")_", "/_", "1000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check", "Result_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "short", "\\u", "error_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "snippet", "\\u", "len_", "=_", "30_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "error_", ")_", ">_", "snippet", "\\u", "len_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "u", "\"%", "s", "...\"_", "%_", "self_", "._", "error_", "[_", ":_", "snippet", "\\u", "len_", "-_", "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 ", " _", "return_", "self_", "._", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Check", "Result_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "self_", "._", "raw", "\\u", "data_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "raw", "\\u", "data_", "=_", "self_", "._", "raw", "\\u", "data_", "[_", ":_", "RA", "W", "\\u", "DATA", "\\u", "LIMIT_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "Status", "Check", "Result_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Alert", "Ack", "nowl", "edge", "ment_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "service_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Service_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cancel", "led", "\\u", "time_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "null_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cancel", "led", "\\u", "user_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "User_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blank_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "relate", "d\\u", "name_", "=_", "'", "cancel", "led", "user", "\\u", "set", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\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_", "Alert", "Ack", "nowl", "edge", "ment_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "une", "xp", "ired", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "expires_", "(_", ")_", ">_", "timezone_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Alert", "Ack", "nowl", "edge", "ment_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "expires_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "time_", "+_", "timedelta_", "(_", "minutes_", "=_", "settings_", "._", "AC", "KN", "OWL", "EDGE", "MENT", "\\u", "EXP", "IR", "Y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "User", "Profile_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "models_", "._", "One", "To", "One", "Field_", "(_", "User_", ",_", "relate", "d\\u", "name_", "=_", "'", "profile", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "mobile", "\\u", "number_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "20_", ",_", "blank_", "=_", "True_", ",_", "default_", "=_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hip", "chat", "\\u", "alias_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "50_", ",_", "blank_", "=_", "True_", ",_", "default_", "=_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fall", "back", "\\u", "alert", "\\u", "user_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Profile_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "user", "\\u", "data_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "user", "\\u", "data\\u", "subclass_", "in_", "Alert", "Plug", "in", "User", "Data_", "._", "\\u\\u", "subclasses", "\\u\\u_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "data_", "=_", "user", "\\u", "data\\u", "subclass_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "user_", "=_", "self_", ",_", "title_", "=_", "user", "\\u", "data\\u", "subclass_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Alert", "Plug", "in", "User", "Data_", "._", "objects_", "._", "filter_", "(_", "user_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Profile_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'", "User", " ", "profile", ":", " ", "%", "s", "'_", "%_", "self_", "._", "user_", "._", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Profile_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Enf", "orce", " ", "unique", "ness_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "fall", "back", "\\u", "alert", "\\u", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "profiles_", "=_", "User", "Profile_", "._", "objects_", "._", "exclude_", "(_", "id_", "=_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profiles_", "._", "update_", "(_", "fall", "back", "\\u", "alert", "\\u", "user_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "User", "Profile_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Profile_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "prefixed", "\\u", "mobile", "\\u", "number_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'+", "%", "s", "'_", "%_", "self_", "._", "mobile", "\\u", "number_", "\\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_", "Shift_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uid_", "=_", "models_", "._", "Text", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "deleted_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Shift_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "deleted_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "deleted_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "deleted_", "=_", "'", " ", "(", "delete", "d", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"%", "s", ":", " ", "%", "s", " ", "to", " ", "%", "s", "%", "s", "\"_", "%_", "(_", "self_", "._", "user_", "._", "username_", ",_", "self_", "._", "start_", ",_", "self_", "._", "end_", ",_", "deleted_", ")_", "\\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", "duty", "\\u", "office", "rs_", "(_", "at", "\\u", "time_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "a", " ", "list", " ", "of", " ", "duty", " ", "office", "rs", " ", "for", " ", "a", " ", "give", "n", " ", "time", " ", "or", " ", "now", " ", "if", " ", "none", " ", "give", "n", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duty", "\\u", "office", "rs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "at", "\\u", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "at", "\\u", "time_", "=_", "timezone_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "current", "\\u", "shifts_", "=_", "Shift_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "deleted_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u\\u", "lt_", "=_", "at", "\\u", "time_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "end", "\\u\\u", "gt_", "=_", "at", "\\u", "time_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "current", "\\u", "shifts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "duty", "\\u", "office", "rs_", "=_", "[_", "shift_", "._", "user_", "for_", "shift_", "in_", "current", "\\u", "shifts_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "duty", "\\u", "office", "rs_", "\\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 ", " _", "u_", "=_", "User", "Profile_", "._", "objects_", "._", "get_", "(_", "fall", "back", "\\u", "alert", "\\u", "user_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "u_", "._", "user_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "User", "Profile_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "]_", "\\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_", "update", "\\u", "shifts_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "events_", "=_", "get", "\\u", "events_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "=_", "User_", "._", "objects_", "._", "filter_", "(_", "is", "\\u", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "lookup_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "u_", "in_", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "lookup_", "[_", "u_", "._", "username_", "._", "lower_", "(_", ")_", "]_", "=_", "u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "future", "\\u", "shifts_", "=_", "Shift_", "._", "objects_", "._", "filter_", "(_", "start", "\\u\\u", "gt_", "=_", "timezone_", "._", "now_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "future", "\\u", "shifts_", "._", "update_", "(_", "deleted_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "event_", "in_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "=_", "event_", "[_", "'", "summar", "y", "'_", "]_", "._", "lower_", "(_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "e_", "in_", "user", "\\u", "lookup_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "user", "\\u", "lookup_", "[_", "e_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Shift_", "._", "objects_", "._", "get_", "(_", "uid_", "=_", "event_", "[_", "'", "uid", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Shift_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Shift_", "(_", "uid_", "=_", "event_", "[_", "'", "uid", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "s_", "._", "start_", "=_", "event_", "[_", "'", "start", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "end_", "=_", "event_", "[_", "'", "end", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "user_", "=_", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "deleted_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "save_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 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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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, 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 ]
Unused import
open-cloud/xos/xos/tools/ansible_hosts.py
[ { "content": "#! /usr/bin/env python\n\nimport json\nimport os\nimport requests\nimport sys\n\nfrom operator import itemgetter, attrgetter\n\nopencloud_auth = None\n\nREST_API=\"http://portal.opencloud.us/xos/\"\n\nNODES_API = REST_API + \"nodes/\"\nSITES_API = REST_API + \"sites/\"\nSLICES_API = REST_API + \"slices/\"\nSLIVERS_API = REST_API + \"instance/\"\n\n\n\"\"\"\n WIP\n\ndef get_nodes_by_slice():\n r = requests.get(SLICES_API + \"?no_hyperlinks=1\", auth=opencloud_auth)\n sites_list = r.json()\n slices = {}\n for slice in slices_list:\n slice[\"hostnames\"] = []\n slices[str(slices[\"id\"])] = slice\n\n r = requests.get(NODES_API + \"?no_hyperlinks=1\", auth=opencloud_auth)\n nodes_list = r.json()\n nodes = {}\n for node in nodes_list:\n nodes[str(nodes[\"id\"])] = node\n\n r = requests.get(SLIVERS_API + \"?no_hyperlinks=1\", auth=opencloud_auth)\n instances = r.json()\n for instances in nodes:\n if instance[\"node\"] not in nodes:\n continue\n if instance[\"slice\"] not in slices:\n continue\n\n hostname = nodes[instance[\"node\"]].name\n\n slices[instance[\"slice\"]][\"hostnames\"].append(hostname)\n\n return slices\n\"\"\"\n\n\nif __name__ == \"__main__\":\n main()\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_nodes_by_site():\n r = requests.get(SITES_API + \"?no_hyperlinks=1\", auth=opencloud_auth)\n sites_list = r.json()\n sites = {}\n for site in sites_list:\n site[\"hostnames\"] = []\n sites[str(site[\"id\"])] = site\n\n r = requests.get(NODES_API + \"?no_hyperlinks=1\", auth=opencloud_auth)\n nodes = r.json()\n for node in nodes:\n site_id = str(node[\"site\"])\n if site_id in sites:\n sites[site_id][\"hostnames\"].append(node[\"name\"])\n\n return sites", "metadata": "root.get_nodes_by_site", "header": "['module', '___EOS___']", "index": 18 }, { "content": "def main():\n global opencloud_auth\n\n if len(sys.argv)!=3:\n print >> sys.stderr, \"syntax: get_instance_name.py <username>, <password>\"\n sys.exit(-1)\n\n username = sys.argv[1]\n password = sys.argv[2]\n\n opencloud_auth=(username, password)\n\n sites = get_nodes_by_site()\n\n for site in sites.values():\n if not site[\"hostnames\"]:\n continue\n\n print \"[%s]\" % site[\"name\"]\n for hostname in site[\"hostnames\"]:\n print hostname\n print \"\"\n\n print \"[all-opencloud:children]\"\n for site in sites.values():\n if not site[\"hostnames\"]:\n continue\n print site[\"name\"]", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 67 } ]
[ { "span": "import json", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 11 }, { "span": "import os", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 9 }, { "span": "from operator import itemgetter, attrgetter", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 43 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", " ", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "operator_", "import_", "itemgetter_", ",_", "attrgetter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "openc", "loud", "\\u", "auth_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "REST", "\\u", "API_", "=_", "\"", "http", "://", "portal", ".", "openc", "loud", ".", "us", "/", "xo", "s", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "NODES", "\\u", "API_", "=_", "REST", "\\u", "API_", "+_", "\"", "nodes", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SITE", "S", "\\u", "API_", "=_", "REST", "\\u", "API_", "+_", "\"", "sites", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SLI", "CES", "\\u", "API_", "=_", "REST", "\\u", "API_", "+_", "\"", "slice", "s", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SLI", "VER", "S", "\\u", "API_", "=_", "REST", "\\u", "API_", "+_", "\"", "instance", "/\"_", "\\u\\u\\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_", "\"\"\"", "\\", "10", ";", " ", " ", " ", "WI", "P", "\\", "10", ";", "\\", "10", ";", "def", " ", "get", "\\u", "nodes", "\\u", "by", "\\u", "slice", "():", "\\", "10", ";", " ", " ", " ", " ", "r", " ", "=", " ", "request", "s", ".", "get", "(", "SLI", "CES", "\\u", "API", " ", "+", " ", "\"?", "no", "\\u", "hyperlink", "s", "=", "1", "\",", " ", "auth", "=", "openc", "loud", "\\u", "auth", ")", "\\", "10", ";", " ", " ", " ", " ", "sites", "\\u", "list", " ", "=", " ", "r", ".", "json", "()", "\\", "10", ";", " ", " ", " ", " ", "slice", "s", " ", "=", " ", "{}", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "slice", " ", "in", " ", "slice", "s", "\\u", "list", ":", "\\", "10", ";", " ", " ", " ", " ", "slice", "[\"", "hostnames", "\"]", " ", "=", " ", "[]", "\\", "10", ";", " ", " ", " ", " ", "slice", "s", "[", "str", "(", "slice", "s", "[\"", "id", "\"]", ")]", " ", "=", " ", "slice", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "r", " ", "=", " ", "request", "s", ".", "get", "(", "NODES", "\\u", "API", " ", "+", " ", "\"?", "no", "\\u", "hyperlink", "s", "=", "1", "\",", " ", "auth", "=", "openc", "loud", "\\u", "auth", ")", "\\", "10", ";", " ", " ", " ", " ", "nodes", "\\u", "list", " ", "=", " ", "r", ".", "json", "()", "\\", "10", ";", " ", " ", " ", " ", "nodes", " ", "=", " ", "{}", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "node", " ", "in", " ", "nodes", "\\u", "list", ":", "\\", "10", ";", " ", " ", " ", " ", "nodes", "[", "str", "(", "nodes", "[\"", "id", "\"]", ")]", " ", "=", " ", "node", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "r", " ", "=", " ", "request", "s", ".", "get", "(", "SLI", "VER", "S", "\\u", "API", " ", "+", " ", "\"?", "no", "\\u", "hyperlink", "s", "=", "1", "\",", " ", "auth", "=", "openc", "loud", "\\u", "auth", ")", "\\", "10", ";", " ", " ", " ", " ", "instance", "s", " ", "=", " ", "r", ".", "json", "()", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "instance", "s", " ", "in", " ", "nodes", ":", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "instance", "[\"", "node", "\"]", " ", "not", " ", "in", " ", "nodes", ":", "\\", "10", ";", " ", " ", " ", " ", "continue", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "instance", "[\"", "slice", "\"]", " ", "not", " ", "in", " ", "slice", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "continue", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "host", "name", " ", "=", " ", "nodes", "[", "instance", "[\"", "node", "\"]", "].", "name", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "slice", "s", "[", "instance", "[\"", "slice", "\"]", "][", "\"", "hostnames", "\"]", ".", "append", "(", "host", "name", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "slice", "s", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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 ", " _", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "nodes", "\\u", "by", "\\u", "site_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "requests_", "._", "get_", "(_", "SITE", "S", "\\u", "API_", "+_", "\"?", "no", "\\u", "hyperlink", "s", "=", "1", "\"_", ",_", "auth_", "=_", "openc", "loud", "\\u", "auth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sites", "\\u", "list_", "=_", "r_", "._", "json_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sites_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "site_", "in_", "sites", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "site_", "[_", "\"", "hostnames", "\"_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sites_", "[_", "str_", "(_", "site_", "[_", "\"", "id", "\"_", "]_", ")_", "]_", "=_", "site_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "=_", "requests_", "._", "get_", "(_", "NODES", "\\u", "API_", "+_", "\"?", "no", "\\u", "hyperlink", "s", "=", "1", "\"_", ",_", "auth_", "=_", "openc", "loud", "\\u", "auth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nodes_", "=_", "r_", "._", "json_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node_", "in_", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "site", "\\u", "id_", "=_", "str_", "(_", "node_", "[_", "\"", "site", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "site", "\\u", "id_", "in_", "sites_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sites_", "[_", "site", "\\u", "id_", "]_", "[_", "\"", "hostnames", "\"_", "]_", "._", "append_", "(_", "node_", "[_", "\"", "name", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "sites_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "openc", "loud", "\\u", "auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "sys_", "._", "argv_", ")_", "!=_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "synta", "x", ":", " ", "get", "\\u", "instance", "\\u", "name", ".", "py", " ", "<", "user", "name", ">", ",", " ", "<", "password", ">\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "username_", "=_", "sys_", "._", "argv_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "sys_", "._", "argv_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "openc", "loud", "\\u", "auth_", "=_", "(_", "username_", ",_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sites_", "=_", "get", "\\u", "nodes", "\\u", "by", "\\u", "site_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "site_", "in_", "sites_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "site_", "[_", "\"", "hostnames", "\"_", "]_", ":_", "\\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_", "print_", "\"[", "%", "s", "]\"_", "%_", "site_", "[_", "\"", "name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "hostname_", "in_", "site_", "[_", "\"", "hostnames", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "hostname_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\"[", "all", "-", "openc", "loud", ":", "child", "ren", "]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "site_", "in_", "sites_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "site_", "[_", "\"", "hostnames", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE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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
mne-tools/mne-python/mne/inverse_sparse/mxne_optim.py
[ { "content": "@verbose\ndef _mixed_norm_solver_cd(M, G, alpha, lipschitz_constant, maxit=10000,\n tol=1e-8, verbose=None, init=None, n_orient=1):\n \"\"\"Solves L21 inverse problem with coordinate descent\"\"\"\n from sklearn.linear_model.coordinate_descent import MultiTaskLasso\n\n n_sensors, n_times = M.shape\n n_sensors, n_sources = G.shape\n\n if init is not None:\n init = init.T\n\n clf = MultiTaskLasso(alpha=alpha / len(M), tol=tol, normalize=False,\n fit_intercept=False, max_iter=maxit,\n warm_start=True)\n clf.coef_ = init\n clf.fit(G, M)\n\n X = clf.coef_.T\n active_set = np.any(X, axis=1)\n X = X[active_set]\n gap, pobj, dobj, _ = dgap_l21(M, G, X, active_set, alpha, n_orient)\n return X, active_set, pobj", "metadata": "root._mixed_norm_solver_cd", "header": "['module', '___EOS___']", "index": 239 } ]
[ { "span": "n_sensors,", "start_line": 246, "start_column": 4, "end_line": 246, "end_column": 13 }, { "span": "n_sources ", "start_line": 246, "start_column": 15, "end_line": 246, "end_column": 24 } ]
[]
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_", "@_", "verbose_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "mixed", "\\u", "norm", "\\u", "solve", "r", "\\u", "cd_", "(_", "M_", ",_", "G_", ",_", "alpha_", ",_", "lip", "sch", "it", "z", "\\u", "constant_", ",_", "maxi", "t_", "=_", "10000_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tol_", "=_", "1e-8_", ",_", "verbose_", "=_", "None_", ",_", "init_", "=_", "None_", ",_", "n", "\\u", "orient_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Solve", "s", " ", "L", "21", " ", "inv", "erse", " ", "problem", " ", "with", " ", "coordinate", " ", "descent", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sklearn_", "._", "linear", "\\u", "model_", "._", "coordinate", "\\u", "descent", "_", "import_", "Multi", "Task", "Las", "so_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "sensors_", ",_", "n", "\\u", "times_", "=_", "M_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "\\u", "sensors_", ",_", "n", "\\u", "sources_", "=_", "G_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "init_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "init_", "=_", "init_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "clf_", "=_", "Multi", "Task", "Las", "so_", "(_", "alpha_", "=_", "alpha_", "/_", "len_", "(_", "M_", ")_", ",_", "tol_", "=_", "tol_", ",_", "normalize_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fit", "\\u", "intercept_", "=_", "False_", ",_", "max", "\\u", "iter_", "=_", "maxi", "t_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "warm", "\\u", "start_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clf_", "._", "coef\\u", "_", "=_", "init_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clf_", "._", "fit_", "(_", "G_", ",_", "M_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "X_", "=_", "clf_", "._", "coef\\u", "_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "active", "\\u", "set_", "=_", "np_", "._", "any_", "(_", "X_", ",_", "axis_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "X_", "=_", "X_", "[_", "active", "\\u", "set_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gap_", ",_", "pob", "j_", ",_", "dob", "j_", ",_", "\\u_", "=_", "dg", "ap", "\\u", "l2", "1_", "(_", "M_", ",_", "G_", ",_", "X_", ",_", "active", "\\u", "set_", ",_", "alpha_", ",_", "n", "\\u", "orient_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "X_", ",_", "active", "\\u", "set_", ",_", "pob", "j_", "\\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, 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 ]
'import *' may pollute namespace
danilop/yas3fs/yas3fs/RecoverYas3fsPlugin.py
[ { "content": "#!/usr/bin/python\n\nfrom yas3fs.YAS3FSPlugin import YAS3FSPlugin\nimport json\nimport os\nimport re\nimport errno\nfrom stat import *\n\nimport datetime\nimport time\n\n'''\nUpon upload failure\n- a log entry is written w/ metadata\n- the cache file is mirrored into a recovery directory ajacent to the cache directory\n'''\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from stat import *", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "'", "import", " ", "*'_", "may", "_", "poll", "ute", "_", "namespace_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ya", "s3", "fs_", "._", "YA", "S", "3", "FS", "Plugin_", "import_", "YA", "S", "3", "FS", "Plugin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "errno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "stat_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", "Up", "on", " ", "upload", " ", "fail", "ure", "\\", "10", ";", "-", " ", "a", " ", "log", " ", "entry", " ", "is", " ", "writt", "en", " ", "w", "/", " ", "metadata", "\\", "10", ";", "-", " ", "the", " ", "cache", " ", "file", " ", "is", " ", "mirrore", "d", " ", "int", "o", " ", "a", " ", "recover", "y", " ", "director", "y", " ", "aja", "cent", " ", "to", " ", "the", " ", "cache", " ", "director", "y", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
limodou/ido/ido/_compat.py
[ { "content": " def exec_(code, globs=None, locs=None):\n \"\"\"Execute code in a namespace.\"\"\"\n if globs is None:\n frame = sys._getframe(1)\n globs = frame.f_globals\n if locs is None:\n locs = frame.f_locals\n del frame\n elif locs is None:\n locs = globs\n exec(\"\"\"exec code in globs, locs\"\"\")", "metadata": "root.exec_", "header": "['module', '___EOS___']", "index": 111 } ]
[ { "span": "globs ", "start_line": 115, "start_column": 12, "end_line": 115, "end_column": 17 }, { "span": "locs ", "start_line": 117, "start_column": 16, "end_line": 117, "end_column": 20 }, { "span": "locs ", "start_line": 120, "start_column": 12, "end_line": 120, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "exec\\u_", "(_", "code_", ",_", "globs_", "=_", "None_", ",_", "locs_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Execut", "e", " ", "code", " ", "in", " ", "a", " ", "namespace", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "globs_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "frame_", "=_", "sys_", "._", "\\u", "getframe_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "globs_", "=_", "frame_", "._", "f", "\\u", "globals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "locs_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "locs_", "=_", "frame_", "._", "f", "\\u", "locals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "frame_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "locs_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "locs_", "=_", "globs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "exec_", "(_", "\"\"\"", "exec", " ", "code", " ", "in", " ", "glob", "s", ",", " ", "locs", "\"\"\"_", ")_", "\\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, 0, 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, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Constant in conditional expression or statement
lsaffre/lino/lino/api/doctest.py
[ { "content": "def demo_get(\n username, url_base, json_fields,\n expected_rows=None, **kwargs):\n from django.conf import settings\n case = HttpQuery(username, url_base, json_fields,\n expected_rows, kwargs)\n # Django test client does not like future pseudo-unicode strings\n # See #870\n url = str(settings.SITE.buildurl(case.url_base, **case.kwargs))\n # print(20160329, url)\n if True:\n msg = 'Using remote authentication, but no user credentials found.'\n try:\n response = self.client.get(url)\n raise Exception(\"Expected '%s'\" % msg)\n except Exception:\n pass\n #~ self.tc.assertEqual(str(e),msg)\n #~ if str(e) != msg:\n #~ raise Exception(\"Expected %r but got %r\" % (msg,str(e)))\n\n response = test_client.get(url, REMOTE_USER=str('foo'))\n if response.status_code != 403:\n raise Exception(\n \"Status code %s other than 403 for anonymous on GET %s\" % (\n response.status_code, url))\n\n response = test_client.get(url, REMOTE_USER=str(case.username))\n # try:\n if True:\n user = settings.SITE.user_model.objects.get(\n username=case.username)\n result = check_json_result(\n response, case.json_fields,\n \"GET %s for user %s\" % (url, user))\n\n num = case.expected_rows\n if num is not None:\n if not isinstance(num, tuple):\n num = [num]\n if result['count'] not in num:\n msg = \"%s got %s rows instead of %s\" % (\n url, result['count'], num)\n raise Exception(msg)\n\n # except Exception as e:\n # print(\"%s:\\n%s\" % (url, e))\n # raise", "metadata": "root.demo_get", "header": "['module', '___EOS___']", "index": 84 } ]
[ { "span": "True:", "start_line": 94, "start_column": 7, "end_line": 94, "end_column": 11 }, { "span": "True:", "start_line": 113, "start_column": 7, "end_line": 113, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Constant_", "in_", "conditional", "_", "expression_", "or_", "statement_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "demo", "\\u", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "username_", ",_", "url", "\\u", "base_", ",_", "json", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "rows_", "=_", "None_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case_", "=_", "Http", "Query_", "(_", "username_", ",_", "url", "\\u", "base_", ",_", "json", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "rows_", ",_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Dj", "ang", "o", " ", "test", " ", "client", " ", "doe", "s", " ", "not", " ", "like", " ", "future", " ", "pseudo", "-", "unicode", " ", "strings_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "#", "870", "_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "str_", "(_", "settings_", "._", "SITE", "_", "._", "build", "url_", "(_", "case_", "._", "url", "\\u", "base_", ",_", "**_", "case_", "._", "kwargs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(", "20160", "329", ",", " ", "url", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "'", "Us", "ing", " ", "remote", " ", "authenticat", "ion", ",", " ", "but", " ", "no", " ", "user", " ", "cred", "ential", "s", " ", "found", ".'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "\"", "Expect", "ed", " ", "'%", "s", "'\"_", "%_", "msg_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "self", ".", "tc", ".", "assert", "Equal", "(", "str", "(", "e", "),", "msg", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "if", " ", "str", "(", "e", ")", " ", "!=", " ", "msg", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "raise", " ", "Except", "ion", "(\"", "Expect", "ed", " ", "%", "r", " ", "but", " ", "got", " ", "%", "r", "\"", " ", "%", " ", "(", "msg", ",", "str", "(", "e", ")))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "test\\u", "client_", "._", "get_", "(_", "url_", ",_", "REMO", "TE", "\\u", "USER_", "=_", "str_", "(_", "'", "foo", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "response_", "._", "status", "\\u", "code_", "!=_", "403_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Status", " ", "code", " ", "%", "s", " ", "other", " ", "than", " ", "403", " ", "for", " ", "anonym", "ous", " ", "on", " ", "GET", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "._", "status", "\\u", "code_", ",_", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "test\\u", "client_", "._", "get_", "(_", "url_", ",_", "REMO", "TE", "\\u", "USER_", "=_", "str_", "(_", "case_", "._", "username_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "settings_", "._", "SITE", "_", "._", "user", "\\u", "model_", "._", "objects_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "case_", "._", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "check", "\\u", "json", "\\u", "result_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "response_", ",_", "case_", "._", "json", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "GET", " ", "%", "s", " ", "for", " ", "user", " ", "%", "s", "\"_", "%_", "(_", "url_", ",_", "user_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num_", "=_", "case_", "._", "expected", "\\u", "rows_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "num_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "num_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "num_", "=_", "[_", "num_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "result_", "[_", "'", "count", "'_", "]_", "not_", "in_", "num_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "\"%", "s", " ", "got", " ", "%", "s", " ", "rows", " ", "inst", "ead", " ", "of", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "url_", ",_", "result_", "[_", "'", "count", "'_", "]_", ",_", "num_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "except", " ", "Except", "ion", " ", "as", " ", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", "(\"", "%", "s", ":\\\\", "n", "%", "s", "\"", " ", "%", " ", "(", "url", ",", " ", "e", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "raise_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
cleesmith/sentdex_scikit_machine_learning_tutorial_for_investing/p09.py
[ { "content": "import pandas as pd\nimport os\nimport time\nfrom datetime import datetime\nimport re\nfrom time import mktime\nimport matplotlib\nimport matplotlib.pyplot as plt\nfrom matplotlib import style\nstyle.use(\"dark_background\")\n\n# path = \"X:/Backups/intraQuarter\" # for Windows with X files :)\n# if git clone'ed then use relative path,\n# assuming you extracted the downloaded zip into this project's folder:\npath = \"intraQuarter\"\n\n\nKey_Stats()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def Key_Stats(gather=\"Total Debt/Equity (mrq)\"):\n statspath = path+'/_KeyStats'\n stock_list = [x[0] for x in os.walk(statspath)]\n df = pd.DataFrame(\n columns = [\n 'Date',\n 'Unix',\n 'Ticker',\n 'DE Ratio',\n 'Price',\n 'stock_p_change',\n 'SP500',\n 'sp500_p_change',\n 'Difference'\n ]\n )\n\n sp500_df = pd.DataFrame.from_csv(\"YAHOO-INDEX_GSPC.csv\")\n\n ticker_list = []\n\n for each_dir in stock_list[1:25]:\n each_file = os.listdir(each_dir)\n\n # ticker = each_dir.split(\"\\\\\")[1] # Windows only\n # ticker = each_dir.split(\"/\")[1] # this didn't work so do this:\n ticker = os.path.basename(os.path.normpath(each_dir))\n # print(ticker) # uncomment to verify\n ticker_list.append(ticker)\n\n starting_stock_value = False\n starting_sp500_value = False\n \n if len(each_file) > 0:\n for file in each_file:\n date_stamp = datetime.strptime(file, '%Y%m%d%H%M%S.html')\n unix_time = time.mktime(date_stamp.timetuple())\n full_file_path = each_dir+'/'+file\n source = open(full_file_path,'r').read()\n try:\n try:\n value = float(source.split(gather+':</td><td class=\"yfnc_tabledata1\">')[1].split('</td>')[0])\n except Exception as e:\n\n try:\n value = float(source.split(gather+':</td>\\n<td class=\"yfnc_tabledata1\">')[1].split('</td>')[0])\n #print(str(e),ticker, file)\n except Exception as e:\n pass\n #print(str(e),ticker, file)\n #time.sleep(15)\n #value = float(source.split(gather+':</td>\\n<td class=\"yfnc_tabledata1\">')[1].split('</td>')[0])\n\n try:\n sp500_date = datetime.fromtimestamp(unix_time).strftime('%Y-%m-%d')\n row = sp500_df[(sp500_df.index == sp500_date)]\n sp500_value = float(row[\"Adj Close\"])\n except:\n sp500_date = datetime.fromtimestamp(unix_time-259200).strftime('%Y-%m-%d')\n row = sp500_df[(sp500_df.index == sp500_date)]\n sp500_value = float(row[\"Adj Close\"])\n\n try:\n stock_price = float(source.split('</small><big><b>')[1].split('</b></big>')[0])\n except Exception as e:\n # <span id=\"yfs_l10_afl\">43.27</span>\n try:\n stock_price = (source.split('</small><big><b>')[1].split('</b></big>')[0])\n stock_price = re.search(r'(\\d{1,8}\\.\\d{1,8})',stock_price)\n stock_price = float(stock_price.group(1))\n #print(stock_price)\n except Exception as e:\n try:\n stock_price = (source.split('<span class=\"time_rtq_ticker\">')[1].split('</span>')[0])\n stock_price = re.search(r'(\\d{1,8}\\.\\d{1,8})',stock_price)\n stock_price = float(stock_price.group(1))\n except Exception as e:\n print(str(e),'a;lsdkfh',file,ticker)\n\n #print('Latest:',stock_price)\n #print('stock price',str(e),ticker,file)\n #time.sleep(15)\n \n #print(\"stock_price:\",stock_price,\"ticker:\", ticker)\n\n if not starting_stock_value:\n starting_stock_value = stock_price\n if not starting_sp500_value:\n starting_sp500_value = sp500_value\n\n stock_p_change = ((stock_price - starting_stock_value) / starting_stock_value) * 100\n sp500_p_change = ((sp500_value - starting_sp500_value) / starting_sp500_value) * 100\n\n df = df.append({'Date':date_stamp,\n 'Unix':unix_time,\n 'Ticker':ticker,\n 'DE Ratio':value,\n 'Price':stock_price,\n 'stock_p_change':stock_p_change,\n 'SP500':sp500_value,\n 'sp500_p_change':sp500_p_change,\n 'Difference':stock_p_change - sp500_p_change},\n ignore_index = True\n )\n except Exception as e:\n pass\n #print(str(e))\n\n for each_ticker in ticker_list:\n try:\n # print(\"each_ticker=%s\"%each_ticker)\n plot_df = df[(df['Ticker'] == each_ticker)]\n plot_df = plot_df.set_index(['Date'])\n plot_df['Difference'].plot(label=each_ticker)\n plt.legend()\n except:\n pass\n\n plt.show()\n\n save = gather.replace(' ','').replace(')','').replace('(','').replace('/','')+('.csv')\n print(save)\n df.to_csv(save)", "metadata": "root.Key_Stats", "header": "['module', '___EOS___']", "index": 16 } ]
[ { "span": "from time import mktime", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 23 }, { "span": "import matplotlib", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "pandas_", "as_", "pd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "time_", "import_", "mktime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "._", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "matplotlib_", "import_", "style_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "style_", "._", "use_", "(_", "\"", "dark", "\\u", "background", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "path", " ", "=", " ", "\"", "X", ":/", "Back", "ups", "/", "intra", "Quart", "er", "\"", " ", "#", " ", "for", " ", "Window", "s", " ", "with", " ", "X", " ", "files", " ", ":)", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "git", " ", "clone", "'", "ed", " ", "then", " ", "use", " ", "relative", " ", "path", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ass", "umi", "ng", " ", "you", " ", "extracted", " ", "the", " ", "download", "ed", " ", "zip", " ", "int", "o", " ", "this", " ", "project", "'", "s", " ", "folder", ":_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "intra", "Quart", "er", "\"_", "\\u\\u\\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_", "Key", "\\u", "Stats_", "(_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "Key", "\\u", "Stats_", "(_", "gather_", "=_", "\"", "Total", " ", "Deb", "t", "/", "Equi", "ty", " ", "(", "mr", "q", ")\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stats", "path_", "=_", "path_", "+_", "'/\\", "u", "Key", "Stat", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stock", "\\u", "list_", "=_", "[_", "x_", "[_", "0_", "]_", "for_", "x_", "in_", "os_", "._", "walk_", "(_", "stats", "path_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "df_", "=_", "pd_", "._", "Data", "Frame_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "columns_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Date", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Uni", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Ticke", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "DE", " ", "Rati", "o", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Price", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stock", "\\u", "p", "\\u", "change", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SP", "500", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sp", "500", "\\u", "p", "\\u", "change", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Difference", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sp", "500", "\\u", "df_", "=_", "pd_", "._", "Data", "Frame_", "._", "from", "\\u", "csv_", "(_", "\"", "YA", "HO", "O", "-", "INDE", "X", "\\u", "GS", "PC", ".", "csv", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ticker", "\\u", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "each", "\\u", "dir_", "in_", "stock", "\\u", "list_", "[_", "1_", ":_", "25_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "each", "\\u", "file_", "=_", "os_", "._", "listdir_", "(_", "each", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ticker", " ", "=", " ", "each", "\\u", "dir", ".", "split", "(\"", "\\\\\\\\\"", ")[", "1", "]", " ", "#", " ", "Window", "s", " ", "only_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ticker", " ", "=", " ", "each", "\\u", "dir", ".", "split", "(\"", "/\"", ")[", "1", "]", " ", "#", " ", "this", " ", "did", "n", "'", "t", " ", "work", " ", "so", " ", "do", " ", "this", ":_", "\\u\\u\\uNL\\u\\u\\u_", "ticker_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "os_", "._", "path_", "._", "normpath_", "(_", "each", "\\u", "dir_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(", "ticker", ")", " ", "#", " ", "uncomm", "ent", " ", "to", " ", "verify_", "\\u\\u\\uNL\\u\\u\\u_", "ticker", "\\u", "list_", "._", "append_", "(_", "ticker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "startin", "g", "\\u", "stock", "\\u", "value_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "startin", "g", "\\u", "sp", "500", "\\u", "value_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "each", "\\u", "file_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "file_", "in_", "each", "\\u", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "date", "\\u", "stamp_", "=_", "datetime_", "._", "strptime_", "(_", "file_", ",_", "'%", "Y", "%", "m", "%", "d", "%", "H", "%", "M", "%", "S", ".", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unix", "\\u", "time_", "=_", "time_", "._", "mktime_", "(_", "date", "\\u", "stamp_", "._", "timetuple_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "full", "\\u", "file", "\\u", "path_", "=_", "each", "\\u", "dir_", "+_", "'/'_", "+_", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source_", "=_", "open_", "(_", "full", "\\u", "file", "\\u", "path_", ",_", "'", "r", "'_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "float_", "(_", "source_", "._", "split_", "(_", "gather_", "+_", "':", "</", "td", "><", "td", " ", "class", "=\"", "yf", "nc", "\\u", "table", "data", "1", "\">'_", ")_", "[_", "1_", "]_", "._", "split_", "(_", "'<", "/", "td", ">'_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\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 ", " _", "value_", "=_", "float_", "(_", "source_", "._", "split_", "(_", "gather_", "+_", "':", "</", "td", ">\\\\", "n", "<", "td", " ", "class", "=\"", "yf", "nc", "\\u", "table", "data", "1", "\">'_", ")_", "[_", "1_", "]_", "._", "split_", "(_", "'<", "/", "td", ">'_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "str", "(", "e", "),", "ticker", ",", " ", "file", ")_", "\\u\\u\\uNL\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "str", "(", "e", "),", "ticker", ",", " ", "file", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "time", ".", "sleep", "(", "15", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "value", " ", "=", " ", "float", "(", "source", ".", "split", "(", "gather", "+'", ":", "</", "td", ">\\\\", "n", "<", "td", " ", "class", "=\"", "yf", "nc", "\\u", "table", "data", "1", "\">", "')", "[", "1", "].", "split", "('", "</", "td", ">'", ")[", "0", "])", "_", "\\u\\u\\uNL\\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 ", " _", "sp", "500", "\\u", "date_", "=_", "datetime_", "._", "fromtimestamp_", "(_", "unix", "\\u", "time_", ")_", "._", "strftime_", "(_", "'%", "Y", "-%", "m", "-%", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "sp", "500", "\\u", "df_", "[_", "(_", "sp", "500", "\\u", "df_", "._", "index_", "==_", "sp", "500", "\\u", "date_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sp", "500", "\\u", "value_", "=_", "float_", "(_", "row_", "[_", "\"", "Adj", " ", "Clos", "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 ", " _", "sp", "500", "\\u", "date_", "=_", "datetime_", "._", "fromtimestamp_", "(_", "unix", "\\u", "time_", "-_", "259", "200_", ")_", "._", "strftime_", "(_", "'%", "Y", "-%", "m", "-%", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "sp", "500", "\\u", "df_", "[_", "(_", "sp", "500", "\\u", "df_", "._", "index_", "==_", "sp", "500", "\\u", "date_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sp", "500", "\\u", "value_", "=_", "float_", "(_", "row_", "[_", "\"", "Adj", " ", "Clos", "e", "\"_", "]_", ")_", "\\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 ", " _", "stock", "\\u", "price_", "=_", "float_", "(_", "source_", "._", "split_", "(_", "'<", "/", "small", "><", "big", "><", "b", ">'_", ")_", "[_", "1_", "]_", "._", "split_", "(_", "'<", "/", "b", "><", "/", "big", ">'_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "<", "span", " ", "id", "=\"", "yf", "s", "\\u", "l10", "\\u", "af", "l", "\">", "43.", "2", "7", "</", "span", ">_", "\\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 ", " _", "stock", "\\u", "price_", "=_", "(_", "source_", "._", "split_", "(_", "'<", "/", "small", "><", "big", "><", "b", ">'_", ")_", "[_", "1_", "]_", "._", "split_", "(_", "'<", "/", "b", "><", "/", "big", ">'_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stock", "\\u", "price_", "=_", "re_", "._", "search_", "(_", "r", "'(\\\\", "d", "{", "1", ",", "8", "}\\\\.", "\\\\", "d", "{", "1", ",", "8", "})'_", ",_", "stock", "\\u", "price_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stock", "\\u", "price_", "=_", "float_", "(_", "stock", "\\u", "price_", "._", "group_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "stock", "\\u", "price", ")_", "\\u\\u\\uNL\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stock", "\\u", "price_", "=_", "(_", "source_", "._", "split_", "(_", "'<", "span", " ", "class", "=\"", "time", "\\u", "rt", "q", "\\u", "ticker", "\">'_", ")_", "[_", "1_", "]_", "._", "split_", "(_", "'<", "/", "span", ">'_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stock", "\\u", "price_", "=_", "re_", "._", "search_", "(_", "r", "'(\\\\", "d", "{", "1", ",", "8", "}\\\\.", "\\\\", "d", "{", "1", ",", "8", "})'_", ",_", "stock", "\\u", "price_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stock", "\\u", "price_", "=_", "float_", "(_", "stock", "\\u", "price_", "._", "group_", "(_", "1_", ")_", ")_", "\\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_", "(_", "str_", "(_", "e_", ")_", ",_", "'", "a", ";", "ls", "dk", "fh", "'_", ",_", "file_", ",_", "ticker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "('", "Late", "st", ":'", ",", "stock", "\\u", "price", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "('", "stock", " ", "price", "',", "str", "(", "e", "),", "ticker", ",", "file", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "time", ".", "sleep", "(", "15", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "stock", "\\u", "price", ":\"", ",", "stock", "\\u", "price", ",\"", "ticker", ":\"", ",", " ", "ticker", ")_", "\\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_", "if_", "not_", "startin", "g", "\\u", "stock", "\\u", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "startin", "g", "\\u", "stock", "\\u", "value_", "=_", "stock", "\\u", "price_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "startin", "g", "\\u", "sp", "500", "\\u", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "startin", "g", "\\u", "sp", "500", "\\u", "value_", "=_", "sp", "500", "\\u", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stock", "\\u", "p", "\\u", "change_", "=_", "(_", "(_", "stock", "\\u", "price_", "-_", "startin", "g", "\\u", "stock", "\\u", "value_", ")_", "/_", "startin", "g", "\\u", "stock", "\\u", "value_", ")_", "*_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sp", "500", "\\u", "p", "\\u", "change_", "=_", "(_", "(_", "sp", "500", "\\u", "value_", "-_", "startin", "g", "\\u", "sp", "500", "\\u", "value_", ")_", "/_", "startin", "g", "\\u", "sp", "500", "\\u", "value_", ")_", "*_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "df_", "=_", "df_", "._", "append_", "(_", "{_", "'", "Date", "'_", ":_", "date", "\\u", "stamp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Uni", "x", "'_", ":_", "unix", "\\u", "time_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Ticke", "r", "'_", ":_", "ticker_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "DE", " ", "Rati", "o", "'_", ":_", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Price", "'_", ":_", "stock", "\\u", "price_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stock", "\\u", "p", "\\u", "change", "'_", ":_", "stock", "\\u", "p", "\\u", "change_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SP", "500", "'_", ":_", "sp", "500", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sp", "500", "\\u", "p", "\\u", "change", "'_", ":_", "sp", "500", "\\u", "p", "\\u", "change_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Difference", "'_", ":_", "stock", "\\u", "p", "\\u", "change_", "-_", "sp", "500", "\\u", "p", "\\u", "change_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ignore", "\\u", "index_", "=_", "True_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "str", "(", "e", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "each", "\\u", "ticker_", "in_", "ticker", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(\"", "each", "\\u", "ticker", "=", "%", "s", "\"%", "each", "\\u", "ticker", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plot", "\\u", "df_", "=_", "df_", "[_", "(_", "df_", "[_", "'", "Ticke", "r", "'_", "]_", "==_", "each", "\\u", "ticker_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot", "\\u", "df_", "=_", "plot", "\\u", "df_", "._", "set\\u", "index_", "(_", "[_", "'", "Date", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot", "\\u", "df_", "[_", "'", "Difference", "'_", "]_", "._", "plot_", "(_", "label_", "=_", "each", "\\u", "ticker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "legend_", "(_", ")_", "\\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_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "save_", "=_", "gather_", "._", "replace_", "(_", "'", " ", "'_", ",_", "''_", ")_", "._", "replace_", "(_", "')'_", ",_", "''_", ")_", "._", "replace_", "(_", "'('_", ",_", "''_", ")_", "._", "replace_", "(_", "'/'_", ",_", "''_", ")_", "+_", "(_", "'.", "csv", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "save_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "df_", "._", "to", "\\u", "csv_", "(_", "save_", ")_", "\\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, 0, 1, 1, 1, 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, 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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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 ]
Unused import
lonelycode/Mojo/Mojo/RequestHandlers/MojoHandler.py
[ { "content": "# Managed request handler that will also\n# specify app-level template directories\n# as part of it's init procedure.\n\nfrom tornado.web import RequestHandler\nimport datetime, logging, os\nfrom tornado import gen\nfrom Mojo.RequestHandlers.PrettyOutputMixin import UncaughtExceptionMixin\n\nfrom Mojo.Auth.models import Session, User\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class MojoRequestHandler(RequestHandler, UncaughtExceptionMixin):\n \"\"\"\n The ``MojoRequestHandler`` is the starting point of any request in Mojo, subclass this for every URL\n you want to serve in Mojo.\n\n The ``MojoRequestHandler`` has some handy properties:\n\n - ``application``: This is a reference to the server object, and give access to project settings\n - ``application.mojo_settings``: All variables declared in your ``settings.py`` file\n - ``db``: the database Session object (for direct access to the DB you can get to the driver through ``db._db.<function>``)\n\n If you are using the ``MojoAuthMixin`` or ``SessionMixin``, the request handlers expand with many more management functions to make life\n easier for the developer.\n \"\"\"\n", "metadata": "root.MojoRequestHandler", "header": "['module', '___EOS___']", "index": 11 }, { "content": " def __init__(self, application, request, **kwargs):\n\n #TODO: This is really hacky, must be a more elegant wy to build up the path name\n thisModule = __import__(self.__module__)\n mods = self.__module__.split('.')\n thisAppName = mods[mods.index('Apps') +1]\n template_path = 'Apps/%s/templates/' % (thisAppName)\n\n self.module_template_path = template_path\n self.application = application\n\n\n RequestHandler.__init__(self, application, request,**kwargs)", "metadata": "root.MojoRequestHandler.__init__", "header": "['class', 'MojoRequestHandler', '(', 'RequestHandler', ',', 'UncaughtExceptionMixin', ')', ':', '___EOS___']", "index": 25 }, { "content": " def get_template_path(self):\n return self.module_template_path", "metadata": "root.MojoRequestHandler.get_template_path", "header": "['class', 'MojoRequestHandler', '(', 'RequestHandler', ',', 'UncaughtExceptionMixin', ')', ':', '___EOS___']", "index": 39 } ]
[ { "span": "import datetime, logging, os", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 28 }, { "span": "from tornado import gen", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 23 }, { "span": "from Mojo.Auth.models import Session, User", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 42 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Manage", "d", " ", "request", " ", "handler", " ", "tha", "t", " ", "will", " ", "als", "o_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "speci", "fy", " ", "app", "-", "level", " ", "template", " ", "directories_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "as", " ", "part", " ", "of", " ", "it", "'", "s", " ", "init", " ", "procedure", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "tornado_", "._", "web_", "import_", "Request", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", ",_", "logging_", ",_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tornado_", "import_", "gen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Mo", "jo", "_", "._", "Request", "Handlers_", "._", "Pret", "ty", "Output", "Mixin_", "import_", "Unc", "aug", "ht", "Except", "ion", "Mixin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "Mo", "jo", "_", "._", "Auth_", "._", "models_", "import_", "Session_", ",_", "User_", "\\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_", "class_", "Mo", "jo", "Request", "Handler_", "(_", "Request", "Handler_", ",_", "Unc", "aug", "ht", "Except", "ion", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "``", "Mo", "jo", "Request", "Handle", "r", "``", " ", "is", " ", "the", " ", "startin", "g", " ", "point", " ", "of", " ", "any", " ", "request", " ", "in", " ", "Mo", "jo", ",", " ", "subclass", " ", "this", " ", "for", " ", "every", " ", "URL", "\\", "10", ";", " ", " ", " ", " ", "you", " ", "want", " ", "to", " ", "serve", " ", "in", " ", "Mo", "jo", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "``", "Mo", "jo", "Request", "Handle", "r", "``", " ", "has", " ", "some", " ", "hand", "y", " ", "proper", "ties", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "``", "applica", "tion", "``", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "reference", " ", "to", " ", "the", " ", "server", " ", "object", ",", " ", "and", " ", "give", " ", "access", " ", "to", " ", "project", " ", "settings", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "``", "applica", "tion", ".", "mo", "jo", "\\u", "settings", "``", ":", " ", "All", " ", "variab", "les", " ", "declared", " ", "in", " ", "your", " ", "``", "settings", ".", "py", "``", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "``", "db", "``", ":", " ", "the", " ", "databa", "se", " ", "Sess", "ion", " ", "object", " ", "(", "for", " ", "direct", " ", "access", " ", "to", " ", "the", " ", "DB", " ", "you", " ", "can", " ", "get", " ", "to", " ", "the", " ", "driver", " ", "through", " ", "``", "db", ".\\u", "db", ".", "<", "function", ">`", "`)", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "you", " ", "are", " ", "usi", "ng", " ", "the", " ", "``", "Mo", "jo", "Auth", "Mix", "in", "``", " ", "or", " ", "``", "Sess", "ion", "Mix", "in", "``", ",", " ", "the", " ", "request", " ", "handler", "s", " ", "expand", " ", "with", " ", "many", " ", "more", " ", "manage", "ment", " ", "function", "s", " ", "to", " ", "make", " ", "life", "\\", "10", ";", " ", " ", " ", " ", "easi", "er", " ", "for", " ", "the", " ", "developer", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Mo", "jo", "Request", "Handler_", "(_", "Request", "Handler_", ",_", "Unc", "aug", "ht", "Except", "ion", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "application_", ",_", "request_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "Thi", "s", " ", "is", " ", "reall", "y", " ", "hack", "y", ",", " ", "must", " ", "be", " ", "a", " ", "more", " ", "ele", "gan", "t", " ", "wy", " ", "to", " ", "build", " ", "up", " ", "the", " ", "path", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "this", "Module_", "=_", "\\u\\u", "import\\u\\u_", "(_", "self_", "._", "\\u\\u", "module\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mods_", "=_", "self_", "._", "\\u\\u", "module\\u\\u_", "._", "split_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "this", "App", "Name_", "=_", "mods_", "[_", "mods_", "._", "index_", "(_", "'", "App", "s", "'_", ")_", "+_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "path_", "=_", "'", "App", "s", "/", "%", "s", "/", "template", "s", "/'_", "%_", "(_", "this", "App", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "module", "\\u", "template", "\\u", "path_", "=_", "template", "\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "application_", "=_", "application_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Request", "Handler_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "application_", ",_", "request_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Mo", "jo", "Request", "Handler_", "(_", "Request", "Handler_", ",_", "Unc", "aug", "ht", "Except", "ion", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "template", "\\u", "path_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "module", "\\u", "template", "\\u", "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,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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, 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, 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 ]
Nested loops with same variable
Yelp/mrjob/mrjob/local.py
[ { "content": " def _process_stderr_from_script(self, stderr, step_num=0):\n \"\"\"Handle stderr a line at time:\n\n * for counter lines, store counters\n * for status message, log the status change\n * for all other lines, log an error, and yield the lines\n \"\"\"\n for line in stderr:\n # just pass one line at a time to parse_mr_job_stderr(),\n # so we can print error and status messages in realtime\n parsed = parse_mr_job_stderr(\n [line], counters=self._counters[step_num])\n\n # in practice there's only going to be at most one line in\n # one of these lists, but the code is cleaner this way\n for status in parsed['statuses']:\n log.info('Status: %s' % status)\n\n for line in parsed['other']:\n log.debug('STDERR: %s' % line.rstrip('\\r\\n'))\n yield line", "metadata": "root.LocalMRJobRunner._process_stderr_from_script", "header": "['class', 'LocalMRJobRunner', '(', 'SimMRJobRunner', ')', ':', '___EOS___']", "index": 269 } ]
[ { "span": "for line in parsed['other']:", "start_line": 287, "start_column": 12, "end_line": 287, "end_column": 40 } ]
[ { "span": "for line in stderr:", "start_line": 276, "start_column": 8, "end_line": 276, "end_column": 27 } ]
1
true
[ "[CLS]_", "Nest", "ed_", "loops_", "with_", "same_", "variable_", "[SEP]_", "class_", "Local", "MR", "Jo", "b", "Runner_", "(_", "Sim", "MR", "Jo", "b", "Runner_", ")_", ":_", "\\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", "process", "\\u", "std", "err", "\\u", "from", "\\u", "script_", "(_", "self_", ",_", "stderr_", ",_", "step", "\\u", "num_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "std", "err", " ", "a", " ", "line", " ", "at", " ", "time", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "for", " ", "counter", " ", "lines", ",", " ", "store", " ", "counter", "s", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "for", " ", "status", " ", "message", ",", " ", "log", " ", "the", " ", "status", " ", "change", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "for", " ", "all", " ", "other", " ", "lines", ",", " ", "log", " ", "an", " ", "error", ",", " ", "and", " ", "yield", " ", "the", " ", "lines", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "stderr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "just", " ", "pass", " ", "one", " ", "line", " ", "at", " ", "a", " ", "time", " ", "to", " ", "parse", "\\u", "mr", "\\u", "job", "\\u", "std", "err", "()", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "so", " ", "we", " ", "can", " ", "print", " ", "error", " ", "and", " ", "status", " ", "message", "s", " ", "in", " ", "realtime", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parsed_", "=_", "parse", "\\u", "mr", "\\u", "job", "\\u", "stderr_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "line_", "]_", ",_", "counters_", "=_", "self_", "._", "\\u", "counters_", "[_", "step", "\\u", "num_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "practic", "e", " ", "there", "'", "s", " ", "only", " ", "goi", "ng", " ", "to", " ", "be", " ", "at", " ", "most", " ", "one", " ", "line", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "one", " ", "of", " ", "these", " ", "lists", ",", " ", "but", " ", "the", " ", "code", " ", "is", " ", "cleaner", " ", "this", " ", "way_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "status_", "in_", "parsed_", "[_", "'", "status", "es", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "info_", "(_", "'", "Status", ":", " ", "%", "s", "'_", "%_", "status_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "line_", "in_", "parsed_", "[_", "'", "other", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "debug_", "(_", "'", "STD", "ERR", ":", " ", "%", "s", "'_", "%_", "line_", "._", "rstrip_", "(_", "'\\\\", "r", "\\\\", "n", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
adblockplus/gyp/test/ninja/s-needs-no-depfiles/gyptest-s-needs-no-depfiles.py
[ { "content": "#!/usr/bin/env python\n\n# Copyright (c) 2012 Google Inc. All rights reserved.\n# Use of this source code is governed by a BSD-style license that can be\n# found in the LICENSE file.\n\n\"\"\"\nVerify that .s files don't always trigger a rebuild, as would happen if depfiles\nwere used for them (since clang & gcc ignore -MMD when building .s->.o on\nlinux).\n\"\"\"\n\nimport os\nimport sys\nimport TestCommon\nimport TestGyp\n\n# NOTE(fischman): Each generator uses depfiles (or not) differently, so this is\n# a ninja-specific test.\ntest = TestGyp.TestGyp(formats=['ninja'])\n\nif sys.platform == 'win32' or sys.platform == 'win64':\n # This test is about clang/gcc vs. depfiles; VS gets a pass.\n test.pass_test()\n sys.exit(0)\n\ntest.run_gyp('s-needs-no-depfiles.gyp')\n\n# Build the library, grab its timestamp, rebuild the library, ensure timestamp\n# hasn't changed.\ntest.build('s-needs-no-depfiles.gyp', 'empty')\nempty_dll = test.built_file_path('empty', test.SHARED_LIB)\ntest.built_file_must_exist(empty_dll)\npre_stat = os.stat(test.built_file_path(empty_dll))\ntest.sleep()\ntest.build('s-needs-no-depfiles.gyp', 'empty')\npost_stat = os.stat(test.built_file_path(empty_dll))\n\nif pre_stat.st_mtime != post_stat.st_mtime:\n test.fail_test()\nelse:\n test.pass_test()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import TestCommon", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2012", " ", "Goo", "gle", " ", "Inc", ".", " ", "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", " ", "LICENSE", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Verify", " ", "tha", "t", " ", ".", "s", " ", "files", " ", "don", "'", "t", " ", "alw", "ay", "s", " ", "trigger", " ", "a", " ", "rebu", "ild", ",", " ", "as", " ", "wou", "ld", " ", "happ", "en", " ", "if", " ", "dep", "files", "\\", "10", ";", "wer", "e", " ", "used", " ", "for", " ", "them", " ", "(", "sinc", "e", " ", "clang", " ", "&", " ", "gcc", " ", "ignore", " ", "-", "MM", "D", " ", "whe", "n", " ", "buildi", "ng", " ", ".", "s", "->", ".", "o", " ", "on", "\\", "10", ";", "linux", ").", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Test", "Common_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Test", "Gy", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", "(", "fis", "chm", "an", "):", " ", "Ea", "ch", " ", "generat", "or", " ", "use", "s", " ", "dep", "files", " ", "(", "or", " ", "not", ")", " ", "different", "ly", ",", " ", "so", " ", "this", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "ninja", "-", "specific", " ", "test", "._", "\\u\\u\\uNL\\u\\u\\u_", "test_", "=_", "Test", "Gy", "p_", "._", "Test", "Gy", "p_", "(_", "formats_", "=_", "[_", "'", "ninja", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "platform_", "==_", "'", "win32", "'_", "or_", "sys_", "._", "platform_", "==_", "'", "win", "64", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "test", " ", "is", " ", "abo", "ut", " ", "clang", "/", "gcc", " ", "vs", ".", " ", "dep", "files", ";", " ", "VS", " ", "gets", " ", "a", " ", "pass", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test_", "._", "pass", "\\u", "test_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "test_", "._", "run", "\\u", "gyp", "_", "(_", "'", "s", "-", "need", "s", "-", "no", "-", "dep", "files", ".", "gyp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Build", " ", "the", " ", "librar", "y", ",", " ", "gra", "b", " ", "its", " ", "timestamp", ",", " ", "rebu", "ild", " ", "the", " ", "librar", "y", ",", " ", "ensure", " ", "timestamp_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hasn", "'", "t", " ", "change", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "test_", "._", "build_", "(_", "'", "s", "-", "need", "s", "-", "no", "-", "dep", "files", ".", "gyp", "'_", ",_", "'", "empty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "empty", "\\u", "dll_", "=_", "test_", "._", "bui", "lt", "\\u", "file", "\\u", "path_", "(_", "'", "empty", "'_", ",_", "test_", "._", "SHARED", "\\u", "LIB_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "._", "bui", "lt", "\\u", "file", "\\u", "must", "\\u", "exist_", "(_", "empty", "\\u", "dll_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pre", "\\u", "stat_", "=_", "os_", "._", "stat_", "(_", "test_", "._", "bui", "lt", "\\u", "file", "\\u", "path_", "(_", "empty", "\\u", "dll_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "._", "sleep_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "._", "build_", "(_", "'", "s", "-", "need", "s", "-", "no", "-", "dep", "files", ".", "gyp", "'_", ",_", "'", "empty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post", "\\u", "stat_", "=_", "os_", "._", "stat_", "(_", "test_", "._", "bui", "lt", "\\u", "file", "\\u", "path_", "(_", "empty", "\\u", "dll_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "pre", "\\u", "stat_", "._", "st", "\\u", "mtime_", "!=_", "post", "\\u", "stat_", "._", "st", "\\u", "mtime_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test_", "._", "fail", "\\u", "test_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
gkno/gkno_launcher/src/networkx/algorithms/link_analysis/tests/test_hits.py
[ { "content": " def test_hits_nstart(self):\n G = self.G\n nstart = dict([(i, 1./2) for i in G])\n h, a = networkx.hits(G, nstart = nstart)", "metadata": "root.TestHITS.test_hits_nstart", "header": "['class', 'TestHITS', ':', '___EOS___']", "index": 39 } ]
[ { "span": "h,", "start_line": 42, "start_column": 8, "end_line": 42, "end_column": 9 }, { "span": "a ", "start_line": 42, "start_column": 11, "end_line": 42, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "HIT", "S_", ":_", "\\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", "hits", "\\u", "nsta", "rt_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "G_", "=_", "self_", "._", "G_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nsta", "rt_", "=_", "dict_", "(_", "[_", "(_", "i_", ",_", "1._", "/_", "2_", ")_", "for_", "i_", "in_", "G_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", ",_", "a_", "=_", "networkx_", "._", "hits_", "(_", "G_", ",_", "nsta", "rt_", "=_", "nsta", "rt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
grow/grow/grow/pods/routes_test.py
[ { "content": " def test_match(self):\n controller, params = self.pod.match('/')\n controller.render(params)\n controller, params = self.pod.match('/fr/about/')\n controller.render(params)\n controller, params = self.pod.match('/de_alias/about/')\n controller.render(params)\n self.assertRaises(webob.exc.HTTPNotFound, self.pod.match, '/dummy/')\n controller, params = self.pod.match('/app/static/file with spaces.txt')", "metadata": "root.RoutesTest.test_match", "header": "['class', 'RoutesTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 14 } ]
[ { "span": "controller,", "start_line": 22, "start_column": 8, "end_line": 22, "end_column": 18 }, { "span": "params ", "start_line": 22, "start_column": 20, "end_line": 22, "end_column": 26 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Route", "s", "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", "match_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "controller_", ",_", "params_", "=_", "self_", "._", "pod_", "._", "match_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", "._", "render_", "(_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", ",_", "params_", "=_", "self_", "._", "pod_", "._", "match_", "(_", "'/", "fr", "/", "abo", "ut", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", "._", "render_", "(_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", ",_", "params_", "=_", "self_", "._", "pod_", "._", "match_", "(_", "'/", "de", "\\u", "alias", "/", "abo", "ut", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", "._", "render_", "(_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "webob_", "._", "exc_", "._", "HTTP", "Not", "Found_", ",_", "self_", "._", "pod_", "._", "match_", ",_", "'/", "dummy", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", ",_", "params_", "=_", "self_", "._", "pod_", "._", "match_", "(_", "'/", "app", "/", "static", "/", "file", " ", "with", " ", "space", "s", ".", "txt", "'_", ")_", "\\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, 0, 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 ]
Constant in conditional expression or statement
meejah/txtorcon/examples/tor_info.py
[ { "content": "@defer.inlineCallbacks\ndef setup_complete(info):\n print \"Top-Level Things:\", dir(info)\n\n if True:\n # some examples of getting specific GETINFO callbacks\n v = yield info.version()\n ip = yield info.ip_to_country('1.2.3.4')\n boot_phase = yield info.status.bootstrap_phase()\n ns = yield info.ns.name('moria1')\n guards = yield info.entry_guards()\n\n print 'version:', v\n print '1.2.3.4 is in', ip\n print 'bootstrap-phase:', boot_phase\n print 'moria1:', ns\n print 'entry guards:', guards\n\n # now we dump everything, one at a time\n d = recursive_dump('', info)\n d.addCallback(lambda x: reactor.stop())\n d.addErrback(error)", "metadata": "root.setup_complete", "header": "['module', '___EOS___']", "index": 49 } ]
[ { "span": "True:", "start_line": 53, "start_column": 7, "end_line": 53, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Constant_", "in_", "conditional", "_", "expression_", "or_", "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_", "@_", "defer_", "._", "inline", "Callbacks_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "setup", "\\u", "complete_", "(_", "info_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Top", "-", "Leve", "l", " ", "Thin", "gs", ":\"_", ",_", "dir_", "(_", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "some", " ", "example", "s", " ", "of", " ", "getti", "ng", " ", "specific", " ", "GET", "INFO", " ", "callbacks_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "yield_", "info_", "._", "version_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ip_", "=_", "yield_", "info_", "._", "ip", "\\u", "to", "\\u", "country_", "(_", "'", "1.2", ".3", ".4", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "boot", "\\u", "phase_", "=_", "yield_", "info_", "._", "status_", "._", "boots", "trap", "\\u", "phase_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ns_", "=_", "yield_", "info_", "._", "ns_", "._", "name_", "(_", "'", "mor", "ia", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "guard", "s_", "=_", "yield_", "info_", "._", "entry", "\\u", "guard", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "version", ":'_", ",_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "1.2", ".3", ".4", " ", "is", " ", "in", "'_", ",_", "ip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "boots", "trap", "-", "phase", ":'_", ",_", "boot", "\\u", "phase_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "mor", "ia", "1", ":'_", ",_", "ns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "entry", " ", "guard", "s", ":'_", ",_", "guard", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "we", " ", "dump", " ", "every", "thing", ",", " ", "one", " ", "at", " ", "a", " ", "time_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d_", "=_", "recurs", "ive", "\\u", "dump_", "(_", "''_", ",_", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "add", "Callback_", "(_", "lambda_", "x_", ":_", "reactor_", "._", "stop_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "add", "Errback_", "(_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
google/simian/src/simian/mac/cron/maintenance.py
[ { "content": " def get(self):\n \"\"\"Handle GET\"\"\"\n asd = gaeserver.AuthSessionSimianServer()\n expired_sessions_count = asd.ExpireAll()\n #logging.debug(\n # 'AuthSessionCleanup: %d sessions expired.', expired_sessions_count)", "metadata": "root.AuthSessionCleanup.get", "header": "['class', 'AuthSessionCleanup', '(', 'webapp2', '.', 'RequestHandler', ')', ':', '___EOS___']", "index": 39 }, { "content": " def get(self):\n \"\"\"Handle GET.\"\"\"\n #logging.debug('Marking inactive computers....')\n count = models.Computer.MarkInactive()\n #logging.debug('Complete! Marked %s inactive.' % count)", "metadata": "root.MarkComputersInactive.get", "header": "['class', 'MarkComputersInactive', '(', 'webapp2', '.', 'RequestHandler', ')', ':', '___EOS___']", "index": 50 } ]
[ { "span": "expired_sessions_count ", "start_line": 42, "start_column": 4, "end_line": 42, "end_column": 26 }, { "span": "count ", "start_line": 53, "start_column": 4, "end_line": 53, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Auth", "Sess", "ion", "Cleanup_", "(_", "webapp2_", "._", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "GET", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "asd", "_", "=_", "gae", "server_", "._", "Auth", "Sess", "ion", "Sim", "ian", "Server_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expir", "ed", "\\u", "session", "s", "\\u", "count_", "=_", "asd", "_", "._", "Expire", "All_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "ing", ".", "debug", "(_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "'", "Auth", "Sess", "ion", "Clean", "up", ":", " ", "%", "d", " ", "session", "s", " ", "expir", "ed", ".'", ",", " ", "expir", "ed", "\\u", "session", "s", "\\u", "count", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Mark", "Compute", "rs", "Ina", "ctive", "_", "(_", "webapp2_", "._", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "GET", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "ing", ".", "debug", "('", "Mark", "ing", " ", "inact", "ive", " ", "computer", "s", "....", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "count_", "=_", "models_", "._", "Compute", "r_", "._", "Mark", "Ina", "ctive", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "ing", ".", "debug", "('", "Complete", "!", " ", "Mark", "ed", " ", "%", "s", " ", "inact", "ive", ".'", " ", "%", " ", "count", ")_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Except block handles 'BaseException'
Azure/azure-sdk-for-python/azure-servicemanagement-legacy/tests/test_legacy_mgmt_servicebus.py
[ { "content": " def tearDown(self):\n if not self.is_playback():\n try:\n self.sms.delete_namespace(self.sb_namespace)\n except:\n pass\n return super(LegacyMgmtServiceBusTest, self).tearDown()", "metadata": "root.LegacyMgmtServiceBusTest.tearDown", "header": "['class', 'LegacyMgmtServiceBusTest', '(', 'LegacyMgmtTestCase', ')', ':', '___EOS___']", "index": 38 }, { "content": " def _namespace_exists(self, name):\n try:\n ns = self.sms.get_namespace(name)\n # treat it as non-existent if it is in process of being removed\n return ns.status != 'Removing'\n except:\n return False", "metadata": "root.LegacyMgmtServiceBusTest._namespace_exists", "header": "['class', 'LegacyMgmtServiceBusTest', '(', 'LegacyMgmtTestCase', ')', ':', '___EOS___']", "index": 47 } ]
[ { "span": "except:", "start_line": 42, "start_column": 12, "end_line": 42, "end_column": 19 }, { "span": "except:", "start_line": 52, "start_column": 8, "end_line": 52, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Leg", "ac", "y", "Mgmt", "Service", "Bus", "Test_", "(_", "Leg", "ac", "y", "Mgmt", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tear", "Down_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "is", "\\u", "playback", "_", "(_", ")_", ":_", "\\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_", "._", "sms_", "._", "delete", "\\u", "namespace_", "(_", "self_", "._", "sb", "\\u", "namespace_", ")_", "\\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_", "return_", "super_", "(_", "Leg", "ac", "y", "Mgmt", "Service", "Bus", "Test_", ",_", "self_", ")_", "._", "tear", "Down_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Leg", "ac", "y", "Mgmt", "Service", "Bus", "Test_", "(_", "Leg", "ac", "y", "Mgmt", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "namespace", "\\u", "exists_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ns_", "=_", "self_", "._", "sms_", "._", "get", "\\u", "namespace_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "treat", " ", "it", " ", "as", " ", "non", "-", "existen", "t", " ", "if", " ", "it", " ", "is", " ", "in", " ", "process", " ", "of", " ", "bei", "ng", " ", "removed_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "ns_", "._", "status_", "!=_", "'", "Remo", "ving", "'_", "\\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_" ]
[ 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, 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, 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, 0, 1, 1, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
bread-and-pepper/django-userena/userena/tests/tests_models.py
[ { "content": " def test_html_email(self):\n \"\"\"\n If HTML emails are enabled, check outgoings emails are multipart and\n that different html and plain text templates are used\n \"\"\"\n userena_settings.USERENA_HTML_EMAIL = True\n userena_settings.USERENA_USE_PLAIN_TEMPLATE = True\n\n new_user = UserenaSignup.objects.create_user(**self.user_info)\n\n # Reset configuration\n userena_settings.USERENA_HTML_EMAIL = False\n self.assertEqual(len(mail.outbox), 1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"multipart/alternative\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/plain\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/html\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"<html>\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"<p>Thank you for signing up\")>-1)\n self.assertFalse(mail.outbox[0].body.find(\"<p>Thank you for signing up\")>-1)", "metadata": "root.UserenaSignupModelTests.test_html_email", "header": "['class', 'UserenaSignupModelTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 116 }, { "content": " def test_generated_plain_email(self):\n \"\"\"\n If HTML emails are enabled and plain text template are disabled,\n check outgoings emails are multipart and that plain text is generated\n from html body\n \"\"\"\n userena_settings.USERENA_HTML_EMAIL = True\n userena_settings.USERENA_USE_PLAIN_TEMPLATE = False\n\n new_user = UserenaSignup.objects.create_user(**self.user_info)\n\n # Reset configuration\n userena_settings.USERENA_HTML_EMAIL = False\n userena_settings.USERENA_USE_PLAIN_TEMPLATE = True\n\n self.assertEqual(len(mail.outbox), 1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"multipart/alternative\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/plain\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/html\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"<html>\")>-1)\n self.assertTrue(text_type(mail.outbox[0].message()).find(\"<p>Thank you for signing up\")>-1)\n self.assertTrue(mail.outbox[0].body.find(\"Thank you for signing up\")>-1)", "metadata": "root.UserenaSignupModelTests.test_generated_plain_email", "header": "['class', 'UserenaSignupModelTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 136 } ]
[ { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"multipart/alternative\")>-1)", "start_line": 129, "start_column": 8, "end_line": 129, "end_column": 93 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/plain\")>-1)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 82 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/html\")>-1)", "start_line": 131, "start_column": 8, "end_line": 131, "end_column": 81 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"<html>\")>-1)", "start_line": 132, "start_column": 8, "end_line": 132, "end_column": 78 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"<p>Thank you for signing up\")>-1)", "start_line": 133, "start_column": 8, "end_line": 133, "end_column": 99 }, { "span": "self.assertFalse(mail.outbox[0].body.find(\"<p>Thank you for signing up\")>-1)", "start_line": 134, "start_column": 8, "end_line": 134, "end_column": 84 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"multipart/alternative\")>-1)", "start_line": 152, "start_column": 8, "end_line": 152, "end_column": 93 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/plain\")>-1)", "start_line": 153, "start_column": 8, "end_line": 153, "end_column": 82 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"text/html\")>-1)", "start_line": 154, "start_column": 8, "end_line": 154, "end_column": 81 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"<html>\")>-1)", "start_line": 155, "start_column": 8, "end_line": 155, "end_column": 78 }, { "span": "self.assertTrue(text_type(mail.outbox[0].message()).find(\"<p>Thank you for signing up\")>-1)", "start_line": 156, "start_column": 8, "end_line": 156, "end_column": 99 }, { "span": "self.assertTrue(mail.outbox[0].body.find(\"Thank you for signing up\")>-1)", "start_line": 157, "start_column": 8, "end_line": 157, "end_column": 80 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "User", "ena", "Sign", "up", "Model", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "html", "\\u", "email_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "HTM", "L", " ", "email", "s", " ", "are", " ", "enable", "d", ",", " ", "check", " ", "outgoing", "s", " ", "email", "s", " ", "are", " ", "multip", "art", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "different", " ", "html", " ", "and", " ", "plain", " ", "text", " ", "template", "s", " ", "are", " ", "used", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "HTM", "L", "\\u", "EMAIL_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "USE", "\\u", "PLAIN", "\\u", "TEMPLATE_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "user_", "=_", "User", "ena", "Sign", "up_", "._", "objects_", "._", "create", "\\u", "user_", "(_", "**_", "self_", "._", "user", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Reset", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "HTM", "L", "\\u", "EMAIL_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "mail_", "._", "outbox_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"", "multip", "art", "/", "alternative", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"", "text", "/", "plain", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"", "text", "/", "html", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"<", "html", ">\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"<", "p", ">", "Than", "k", " ", "you", " ", "for", " ", "signin", "g", " ", "up", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "body_", "._", "find_", "(_", "\"<", "p", ">", "Than", "k", " ", "you", " ", "for", " ", "signin", "g", " ", "up", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "ena", "Sign", "up", "Model", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "generat", "ed", "\\u", "plain", "\\u", "email_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "HTM", "L", " ", "email", "s", " ", "are", " ", "enable", "d", " ", "and", " ", "plain", " ", "text", " ", "template", " ", "are", " ", "disable", "d", ",", "\\", "10", ";", " ", " ", " ", " ", "check", " ", "outgoing", "s", " ", "email", "s", " ", "are", " ", "multip", "art", " ", "and", " ", "tha", "t", " ", "plain", " ", "text", " ", "is", " ", "generat", "ed", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "html", " ", "body", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "HTM", "L", "\\u", "EMAIL_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "USE", "\\u", "PLAIN", "\\u", "TEMPLATE_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "user_", "=_", "User", "ena", "Sign", "up_", "._", "objects_", "._", "create", "\\u", "user_", "(_", "**_", "self_", "._", "user", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Reset", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "HTM", "L", "\\u", "EMAIL_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "ena", "\\u", "settings_", "._", "USER", "EN", "A", "\\u", "USE", "\\u", "PLAIN", "\\u", "TEMPLATE_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "mail_", "._", "outbox_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"", "multip", "art", "/", "alternative", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"", "text", "/", "plain", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"", "text", "/", "html", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"<", "html", ">\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "text", "\\u", "type_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "message_", "(_", ")_", ")_", "._", "find_", "(_", "\"<", "p", ">", "Than", "k", " ", "you", " ", "for", " ", "signin", "g", " ", "up", "\"_", ")_", ">_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "mail_", "._", "outbox_", "[_", "0_", "]_", "._", "body_", "._", "find_", "(_", "\"", "Than", "k", " ", "you", " ", "for", " ", "signin", "g", " ", "up", "\"_", ")_", ">_", "-_", "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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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('section1', 'foo2')\n\n c.set('section1', 'foo2', 'bar2')\n self.assertFalse(s_option in c._unsaved)\n\n c.remove_option('section1', 'foo2')\n self.assertFalse(s_option in c._unsaved)\n\n c.set_secure('section1', 'foo2', 'bar2')\n self.assertTrue(s_option in c._unsaved)\n self.assertTrue(c._unsaved[s_option][0] == 'set')\n self.assertTrue(c._unsaved[s_option][1] == 'bar2')\n\n c.remove_option('section1', 'foo2')\n self.assertTrue(s_option in c._unsaved)\n self.assertTrue(c._unsaved[s_option][0] == 'delete')\n self.assertTrue(c._unsaved[s_option][1] is None)", "metadata": "root.IdentifySecureOptionTests.testUnsavedOptions", "header": "['class', 'IdentifySecureOptionTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 80 } ]
[ { "span": "self.assertFalse(s_option in c._unsaved)", "start_line": 85, "start_column": 8, "end_line": 85, "end_column": 48 }, { "span": "self.assertFalse(s_option in c._unsaved)", "start_line": 88, "start_column": 8, "end_line": 88, "end_column": 48 }, { "span": "self.assertTrue(s_option in c._unsaved)", "start_line": 91, "start_column": 8, "end_line": 91, "end_column": 47 }, { "span": "self.assertTrue(c._unsaved[s_option][0] == 'set')", "start_line": 92, "start_column": 8, "end_line": 92, "end_column": 57 }, { "span": "self.assertTrue(c._unsaved[s_option][1] == 'bar2')", "start_line": 93, "start_column": 8, "end_line": 93, "end_column": 58 }, { "span": "self.assertTrue(s_option in c._unsaved)", "start_line": 96, "start_column": 8, "end_line": 96, "end_column": 47 }, { "span": "self.assertTrue(c._unsaved[s_option][0] == 'delete')", "start_line": 97, "start_column": 8, "end_line": 97, "end_column": 60 }, { "span": "self.assertTrue(c._unsaved[s_option][1] is None)", "start_line": 98, "start_column": 8, "end_line": 98, "end_column": 56 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Identif", "y", "Secur", "e", "Optio", "n", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Uns", "ave", "d", "Options_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "make", "Config_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s", "\\u", "option_", "=_", "\"%", "s", "%", "s", "\"_", "%_", "(_", "'", "section", "1", "'_", ",_", "'", "foo", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "._", "set_", "(_", "'", "section", "1", "'_", ",_", "'", "foo", "2", "'_", ",_", "'", "bar", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "s", "\\u", "option_", "in_", "c_", "._", "\\u", "unsa", "ved", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "._", "remove", "\\u", "option_", "(_", "'", "section", "1", "'_", ",_", "'", "foo", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "s", "\\u", "option_", "in_", "c_", "._", "\\u", "unsa", "ved", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "._", "set\\u", "secure_", "(_", "'", "section", "1", "'_", ",_", "'", "foo", "2", "'_", ",_", "'", "bar", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s", "\\u", "option_", "in_", "c_", "._", "\\u", "unsa", "ved", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "\\u", "unsa", "ved", "_", "[_", "s", "\\u", "option_", "]_", "[_", "0_", "]_", "==_", "'", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "\\u", "unsa", "ved", "_", "[_", "s", "\\u", "option_", "]_", "[_", "1_", "]_", "==_", "'", "bar", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "._", "remove", "\\u", "option_", "(_", "'", "section", "1", "'_", ",_", "'", "foo", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s", "\\u", "option_", "in_", "c_", "._", "\\u", "unsa", "ved", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "\\u", "unsa", "ved", "_", "[_", "s", "\\u", "option_", "]_", "[_", "0_", "]_", "==_", "'", "delete", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "\\u", "unsa", "ved", "_", "[_", "s", "\\u", "option_", "]_", "[_", "1_", "]_", "is_", "None_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 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, 2 ]
Unused import
kivy/kivy-ios/recipes/ios/src/setup.py
[ { "content": "from distutils.core import setup, Extension\nimport os\n\nsetup(name='ios',\n version='1.0',\n ext_modules=[\n Extension(\n 'ios', ['ios.c', 'ios_mail.m', 'ios_browser.m'],\n libraries=[ ],\n library_dirs=[],\n )\n ]\n )\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import os", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 9 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "distutils_", "._", "core_", "import_", "setup_", ",_", "Extension_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "setup_", "(_", "name_", "=_", "'", "ios", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "1.0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ext", "\\u", "modules_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ios", "'_", ",_", "[_", "'", "ios", ".", "c", "'_", ",_", "'", "ios", "\\u", "mail", ".", "m", "'_", ",_", "'", "ios", "\\u", "browse", "r", ".", "m", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "libraries_", "=_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "librar", "y", "\\u", "dirs_", "=_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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'
wakatime/sublime-wakatime/packages/wakatime/stats.py
[ { "content": "def guess_lexer_using_filename(file_name, text):\n \"\"\"Guess lexer for given text, limited to lexers for this file's extension.\n\n Returns a tuple of (lexer, accuracy).\n \"\"\"\n\n lexer, accuracy = None, None\n\n try:\n lexer = guess_lexer_for_filename(file_name, text)\n except: # pragma: nocover\n pass\n\n if lexer is not None:\n try:\n accuracy = lexer.analyse_text(text)\n except: # pragma: nocover\n pass\n\n return lexer, accuracy", "metadata": "root.guess_lexer_using_filename", "header": "['module', '___EOS___']", "index": 71 }, { "content": "def guess_lexer_using_modeline(text):\n \"\"\"Guess lexer for given text using Vim modeline.\n\n Returns a tuple of (lexer, accuracy).\n \"\"\"\n\n lexer, accuracy = None, None\n\n file_type = None\n try:\n file_type = get_filetype_from_buffer(text)\n except: # pragma: nocover\n pass\n\n if file_type is not None:\n try:\n lexer = get_lexer_by_name(file_type)\n except ClassNotFound: # pragma: nocover\n pass\n\n if lexer is not None:\n try:\n accuracy = lexer.analyse_text(text)\n except: # pragma: nocover\n pass\n\n return lexer, accuracy", "metadata": "root.guess_lexer_using_modeline", "header": "['module', '___EOS___']", "index": 93 }, { "content": "def number_lines_in_file(file_name):\n lines = 0\n try:\n with open(file_name, 'r', encoding='utf-8') as fh:\n for line in fh:\n lines += 1\n except: # pragma: nocover\n try:\n with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:\n for line in fh:\n lines += 1\n except:\n return None\n return lines", "metadata": "root.number_lines_in_file", "header": "['module', '___EOS___']", "index": 145 }, { "content": "def get_language_from_json(language, key):\n \"\"\"Finds the given language in a json file.\"\"\"\n\n file_name = os.path.join(\n os.path.dirname(__file__),\n 'languages',\n '{0}.json').format(key.lower())\n\n try:\n with open(file_name, 'r', encoding='utf-8') as fh:\n languages = json.loads(fh.read())\n if language in languages.values():\n return language\n if languages.get(language):\n return languages[language]\n except:\n pass\n\n return None", "metadata": "root.get_language_from_json", "header": "['module', '___EOS___']", "index": 205 }, { "content": "def get_file_head(file_name):\n \"\"\"Returns the first 512000 bytes of the file's contents.\"\"\"\n\n text = None\n try:\n with open(file_name, 'r', encoding='utf-8') as fh:\n text = fh.read(512000)\n except: # pragma: nocover\n try:\n with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:\n text = fh.read(512000)\n except:\n log.traceback('debug')\n return text", "metadata": "root.get_file_head", "header": "['module', '___EOS___']", "index": 226 } ]
[ { "span": "except: ", "start_line": 81, "start_column": 4, "end_line": 81, "end_column": 11 }, { "span": "except: ", "start_line": 87, "start_column": 8, "end_line": 87, "end_column": 15 }, { "span": "except: ", "start_line": 104, "start_column": 4, "end_line": 104, "end_column": 11 }, { "span": "except: ", "start_line": 116, "start_column": 8, "end_line": 116, "end_column": 15 }, { "span": "except: ", "start_line": 151, "start_column": 4, "end_line": 151, "end_column": 11 }, { "span": "except:", "start_line": 156, "start_column": 8, "end_line": 156, "end_column": 15 }, { "span": "except:", "start_line": 220, "start_column": 4, "end_line": 220, "end_column": 11 }, { "span": "except: ", "start_line": 233, "start_column": 4, "end_line": 233, "end_column": 11 }, { "span": "except:", "start_line": 237, "start_column": 8, "end_line": 237, "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_", "guess", "\\u", "lexer", "\\u", "usi", "ng", "\\u", "filename_", "(_", "file", "\\u", "name_", ",_", "text_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Guess", " ", "lexer", " ", "for", " ", "give", "n", " ", "text", ",", " ", "limited", " ", "to", " ", "lexer", "s", " ", "for", " ", "this", " ", "file", "'", "s", " ", "extensi", "on", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "tuple", " ", "of", " ", "(", "lexer", ",", " ", "accu", "rac", "y", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lexer_", ",_", "accuracy_", "=_", "None_", ",_", "None_", "\\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 ", " _", "lexer_", "=_", "guess", "\\u", "lexer", "\\u", "for", "\\u", "filename_", "(_", "file", "\\u", "name_", ",_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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_", "lexer_", "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 ", " _", "accuracy_", "=_", "lexer_", "._", "analyse", "\\u", "text_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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_", "lexer_", ",_", "accuracy_", "\\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_", "guess", "\\u", "lexer", "\\u", "usi", "ng", "\\u", "model", "ine_", "(_", "text_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Guess", " ", "lexer", " ", "for", " ", "give", "n", " ", "text", " ", "usi", "ng", " ", "Vi", "m", " ", "model", "ine", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "tuple", " ", "of", " ", "(", "lexer", ",", " ", "accu", "rac", "y", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lexer_", ",_", "accuracy_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "file", "\\u", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file", "\\u", "type_", "=_", "get", "\\u", "filet", "ype", "\\u", "from", "\\u", "buffer_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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_", "file", "\\u", "type_", "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 ", " _", "lexer_", "=_", "get", "\\u", "lexer", "\\u", "by", "\\u", "name_", "(_", "file", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Class", "Not", "Found_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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_", "if_", "lexer_", "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 ", " _", "accuracy_", "=_", "lexer_", "._", "analyse", "\\u", "text_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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_", "lexer_", ",_", "accuracy_", "\\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_", "number", "\\u", "lines", "\\u", "in", "\\u", "file_", "(_", "file", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "file", "\\u", "name_", ",_", "'", "r", "'_", ",_", "encoding_", "=_", "'", "utf", "-", "8", "'_", ")_", "as_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lines_", "+=_", "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_", "except_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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 ", " _", "with_", "open_", "(_", "file", "\\u", "name_", ",_", "'", "r", "'_", ",_", "encoding_", "=_", "sys_", "._", "getfile", "system", "encoding_", "(_", ")_", ")_", "as_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "lines_", "+=_", "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_", "except_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "lines_", "\\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", "language", "\\u", "from", "\\u", "json_", "(_", "language_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Fin", "ds", " ", "the", " ", "give", "n", " ", "language", " ", "in", " ", "a", " ", "json", " ", "file", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "file", "\\u", "name_", "=_", "os_", "._", "path_", "._", "join_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "language", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "0", "}.", "json", "'_", ")_", "._", "format_", "(_", "key_", "._", "lower_", "(_", ")_", ")_", "\\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 ", " _", "with_", "open_", "(_", "file", "\\u", "name_", ",_", "'", "r", "'_", ",_", "encoding_", "=_", "'", "utf", "-", "8", "'_", ")_", "as_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "languages_", "=_", "json_", "._", "loads_", "(_", "fh_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "language_", "in_", "languages_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "language_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "languages_", "._", "get_", "(_", "language_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "languages_", "[_", "language_", "]_", "\\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 ", " _", "pass_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "file", "\\u", "head_", "(_", "file", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "first", " ", "512", "000", " ", "bytes", " ", "of", " ", "the", " ", "file", "'", "s", " ", "content", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "file", "\\u", "name_", ",_", "'", "r", "'_", ",_", "encoding_", "=_", "'", "utf", "-", "8", "'_", ")_", "as_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "=_", "fh_", "._", "read_", "(_", "512", "000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "pragma", ":", " ", "noco", "ver_", "\\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 ", " _", "with_", "open_", "(_", "file", "\\u", "name_", ",_", "'", "r", "'_", ",_", "encoding_", "=_", "sys_", "._", "getfile", "system", "encoding_", "(_", ")_", ")_", "as_", "fh_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "=_", "fh_", "._", "read_", "(_", "512", "000_", ")_", "\\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 ", " _", "log_", "._", "traceback_", "(_", "'", "debug", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "text_" ]
[ 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, 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, 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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, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
jesolem/PCV/PCV/tools/pca.py
[ { "content": "from PIL import Image\nfrom numpy import *\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def pca(X):\n \"\"\" Principal Component Analysis\n input: X, matrix with training data stored as flattened arrays in rows\n return: projection matrix (with important dimensions first), variance and mean.\n \"\"\"\n \n # get dimensions\n num_data,dim = X.shape\n \n # center data\n mean_X = X.mean(axis=0)\n X = X - mean_X\n \n if dim>num_data:\n # PCA - compact trick used\n M = dot(X,X.T) # covariance matrix\n e,EV = linalg.eigh(M) # eigenvalues and eigenvectors\n tmp = dot(X.T,EV).T # this is the compact trick\n V = tmp[::-1] # reverse since last eigenvectors are the ones we want\n S = sqrt(e)[::-1] # reverse since eigenvalues are in increasing order\n for i in range(V.shape[1]):\n V[:,i] /= S\n else:\n # PCA - SVD used\n U,S,V = linalg.svd(X)\n V = V[:num_data] # only makes sense to return the first num_data\n \n # return the projection matrix, the variance and the mean\n return V,S,mean_X", "metadata": "root.pca", "header": "['module', '___EOS___']", "index": 4 }, { "content": "def center(X):\n \"\"\" Center the square matrix X (subtract col and row means). \"\"\"\n \n n,m = X.shape\n if n != m:\n raise Exception('Matrix is not square.')\n \n colsum = X.sum(axis=0) / n\n rowsum = X.sum(axis=1) / n\n totalsum = X.sum() / (n**2)\n \n #center\n Y = array([[ X[i,j]-rowsum[i]-colsum[j]+totalsum for i in range(n) ] for j in range(n)])\n \n return Y", "metadata": "root.center", "header": "['module', '___EOS___']", "index": 35 } ]
[ { "span": "from PIL import Image", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 21 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numpy_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "pca_", "(_", "X_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", " ", " ", " ", "Princip", "al", " ", "Compo", "nent", " ", "Analy", "sis", "\\", "10", ";", " ", " ", " ", " ", "input", ":", " ", "X", ",", " ", "matrix", " ", "with", " ", "train", "ing", " ", "data", " ", "store", "d", " ", "as", " ", "flattened", " ", "arrays", " ", "in", " ", "rows", "\\", "10", ";", " ", " ", " ", " ", "return", ":", " ", "projecti", "on", " ", "matrix", " ", "(", "with", " ", "importa", "nt", " ", "dimension", "s", " ", "first", "),", " ", "varian", "ce", " ", "and", " ", "mean", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "dimensions_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "data_", ",_", "dim_", "=_", "X_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "center", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "mean", "\\u", "X_", "=_", "X_", "._", "mean_", "(_", "axis_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "X_", "=_", "X_", "-_", "mean", "\\u", "X_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "dim_", ">_", "num", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PCA", " ", "-", " ", "compact", " ", "trick", " ", "used_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "M_", "=_", "dot_", "(_", "X_", ",_", "X_", "._", "T_", ")_", "#", " ", "covariance", " ", "matrix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", ",_", "EV", "_", "=_", "linalg_", "._", "eig", "h_", "(_", "M_", ")_", "#", " ", "eigenvalues", " ", "and", " ", "eigenvector", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp_", "=_", "dot_", "(_", "X_", "._", "T_", ",_", "EV", "_", ")_", "._", "T_", "#", " ", "this", " ", "is", " ", "the", " ", "compact", " ", "trick", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "V_", "=_", "tmp_", "[_", ":_", ":_", "-_", "1_", "]_", "#", " ", "reverse", " ", "sinc", "e", " ", "last", " ", "eigenvector", "s", " ", "are", " ", "the", " ", "ones", " ", "we", " ", "want_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "S_", "=_", "sqrt_", "(_", "e_", ")_", "[_", ":_", ":_", "-_", "1_", "]_", "#", " ", "reverse", " ", "sinc", "e", " ", "eigenvalues", " ", "are", " ", "in", " ", "incr", "easi", "ng", " ", "order_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "V_", "._", "shape_", "[_", "1_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "V_", "[_", ":_", ",_", "i_", "]_", "/=_", "S_", "\\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_", "#", " ", "PCA", " ", "-", " ", "SV", "D", " ", "used_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "U_", ",_", "S_", ",_", "V_", "=_", "linalg_", "._", "svd_", "(_", "X_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "V_", "=_", "V_", "[_", ":_", "num", "\\u", "data_", "]_", "#", " ", "only", " ", "make", "s", " ", "sense", " ", "to", " ", "return", " ", "the", " ", "first", " ", "num", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "return", " ", "the", " ", "projecti", "on", " ", "matrix", ",", " ", "the", " ", "varian", "ce", " ", "and", " ", "the", " ", "mean_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "V_", ",_", "S_", ",_", "mean", "\\u", "X_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "center_", "(_", "X_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", " ", " ", " ", "Center", " ", "the", " ", "square", " ", "matrix", " ", "X", " ", "(", "subtract", " ", "col", " ", "and", " ", "row", " ", "means", ").", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", ",_", "m_", "=_", "X_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "n_", "!=_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "Matrix", " ", "is", " ", "not", " ", "square", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cols", "um_", "=_", "X_", "._", "sum_", "(_", "axis_", "=_", "0_", ")_", "/_", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows", "um_", "=_", "X_", "._", "sum_", "(_", "axis_", "=_", "1_", ")_", "/_", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "totals", "um_", "=_", "X_", "._", "sum_", "(_", ")_", "/_", "(_", "n_", "**_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "center_", "\\u\\u\\uNL\\u\\u\\u_", "Y_", "=_", "array_", "(_", "[_", "[_", "X_", "[_", "i_", ",_", "j_", "]_", "-_", "rows", "um_", "[_", "i_", "]_", "-_", "cols", "um_", "[_", "j_", "]_", "+_", "totals", "um_", "for_", "i_", "in_", "range_", "(_", "n_", ")_", "]_", "for_", "j_", "in_", "range_", "(_", "n_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Y_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 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,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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 ]
Unused local variable
logpy/logpy/logpy/facts.py
[ { "content": " def __call__(self, *args):\n def f(s):\n args2 = reify(args, s)\n subsets = [self.index[key] for key in enumerate(args)\n if key in self.index]\n if subsets: # we are able to reduce the pool early\n facts = intersection(*sorted(subsets, key=len))\n else:\n facts = self.facts\n varinds = [i for i, arg in enumerate(args2) if isvar(arg)]\n valinds = [i for i, arg in enumerate(args2) if not isvar(arg)]\n vars = index(args2, varinds)\n vals = index(args2, valinds)\n assert not any(var in s for var in vars)\n\n return (merge(dict(zip(vars, index(fact, varinds))), s)\n for fact in self.facts\n if vals == index(fact, valinds))\n return f", "metadata": "root.Relation.__call__", "header": "['class', 'Relation', '(', 'object', ')', ':', '___EOS___']", "index": 30 } ]
[ { "span": "facts ", "start_line": 36, "start_column": 16, "end_line": 36, "end_column": 21 }, { "span": "facts ", "start_line": 38, "start_column": 16, "end_line": 38, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Relation_", "(_", "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", "call\\u\\u_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "f_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args", "2_", "=_", "rei", "fy_", "(_", "args_", ",_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subsets", "_", "=_", "[_", "self_", "._", "index_", "[_", "key_", "]_", "for_", "key_", "in_", "enumerate_", "(_", "args_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "key_", "in_", "self_", "._", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "subsets", "_", ":_", "#", " ", "we", " ", "are", " ", "able", " ", "to", " ", "reduce", " ", "the", " ", "pool", " ", "ear", "ly_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "facts_", "=_", "intersection_", "(_", "*_", "sorted_", "(_", "subsets", "_", ",_", "key_", "=_", "len_", ")_", ")_", "\\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 ", " _", "facts_", "=_", "self_", "._", "facts_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vari", "nds_", "=_", "[_", "i_", "for_", "i_", ",_", "arg_", "in_", "enumerate_", "(_", "args", "2_", ")_", "if_", "is", "var_", "(_", "arg_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vali", "nds_", "=_", "[_", "i_", "for_", "i_", ",_", "arg_", "in_", "enumerate_", "(_", "args", "2_", ")_", "if_", "not_", "is", "var_", "(_", "arg_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vars_", "=_", "index_", "(_", "args", "2_", ",_", "vari", "nds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "index_", "(_", "args", "2_", ",_", "vali", "nds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "any_", "(_", "var_", "in_", "s_", "for_", "var_", "in_", "vars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "merge_", "(_", "dict_", "(_", "zip_", "(_", "vars_", ",_", "index_", "(_", "fact_", ",_", "vari", "nds_", ")_", ")_", ")_", ",_", "s_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "fact_", "in_", "self_", "._", "facts_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "vals_", "==_", "index_", "(_", "fact_", ",_", "vali", "nds_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "f_", "\\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, 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 ]
Except block handles 'BaseException'
google/anvil-build/anvil/commands/overlay_command.py
[ { "content": " def execute(self, args, cwd):\n # Build everything first\n (result, all_target_outputs) = commandutil.run_build(cwd, args)\n if not result:\n # Failed - don't copy anything\n return False\n\n # Delete output, if desired\n if args.clean:\n try:\n shutil.rmtree(args.output)\n except:\n pass\n\n # Ensure output exists\n if not os.path.isdir(args.output):\n os.makedirs(args.output)\n\n # Sort all outputs by path, as it makes things prettier\n all_target_outputs = list(all_target_outputs)\n all_target_outputs.sort()\n\n # Tracks all exists checks on link parent paths\n checked_dirs = {}\n\n # Copy results\n print ''\n print 'Symlinking results to %s:' % (args.output)\n skipped_links = 0\n for target_output in all_target_outputs:\n # Get path relative to root\n # This will contain the build-out/ etc\n rel_path = os.path.relpath(target_output, cwd)\n\n # Strip the build-*/\n # TODO(benvanik): a more reliable strip\n rel_path_parts = rel_path.split(os.sep)\n if rel_path_parts[0].startswith('build-'):\n rel_path = os.path.join(*(rel_path_parts[1:]))\n\n # Make output path\n deploy_path = os.path.normpath(os.path.join(args.output, rel_path))\n\n # Ensure directory exists\n # Ensure parent of link path exists\n deploy_dir = os.path.dirname(deploy_path)\n if not checked_dirs.get(deploy_dir, False):\n if not os.path.exists(deploy_dir):\n os.makedirs(deploy_dir)\n checked_dirs[deploy_dir] = True\n\n # Link!\n if not os.path.exists(deploy_path):\n print '%s -> %s' % (rel_path, deploy_path)\n os.symlink(target_output, deploy_path)\n else:\n skipped_links += 1\n\n if skipped_links:\n print '(%s skipped)' % (skipped_links)\n\n return 0 if result else 1", "metadata": "root.OverlayCommand.execute", "header": "['class', 'OverlayCommand', '(', 'ManageCommand', ')', ':', '___EOS___']", "index": 63 } ]
[ { "span": "except:", "start_line": 74, "start_column": 6, "end_line": 74, "end_column": 13 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Overla", "y", "Command_", "(_", "Manage", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "execute_", "(_", "self_", ",_", "args_", ",_", "cwd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Build", " ", "every", "thing", " ", "first_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "result_", ",_", "all", "\\u", "target", "\\u", "outputs_", ")_", "=_", "command", "util_", "._", "run", "\\u", "build_", "(_", "cwd_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fail", "ed", " ", "-", " ", "don", "'", "t", " ", "copy", " ", "anyt", "hing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "output", ",", " ", "if", " ", "desired_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "args_", "._", "clean_", ":_", "\\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 ", " _", "shutil_", "._", "rmtree_", "(_", "args_", "._", "output_", ")_", "\\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_", "#", " ", "Ensur", "e", " ", "output", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "isdir_", "(_", "args_", "._", "output_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "args_", "._", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sort", " ", "all", " ", "output", "s", " ", "by", " ", "path", ",", " ", "as", " ", "it", " ", "make", "s", " ", "thing", "s", " ", "pret", "tier_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "all", "\\u", "target", "\\u", "outputs_", "=_", "list_", "(_", "all", "\\u", "target", "\\u", "outputs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "target", "\\u", "outputs_", "._", "sort_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Track", "s", " ", "all", " ", "exist", "s", " ", "checks", " ", "on", " ", "link", " ", "parent", " ", "paths_", "\\u\\u\\uNL\\u\\u\\u_", "checke", "d\\u", "dirs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Sym", "linking", " ", "results", " ", "to", " ", "%", "s", ":'_", "%_", "(_", "args_", "._", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "skip", "ped", "\\u", "links_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "target", "\\u", "output_", "in_", "all", "\\u", "target", "\\u", "outputs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "path", " ", "relative", " ", "to", " ", "root_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "will", " ", "contain", " ", "the", " ", "build", "-", "out", "/", " ", "etc", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rel", "\\u", "path_", "=_", "os_", "._", "path_", "._", "relpath_", "(_", "target", "\\u", "output_", ",_", "cwd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Strip", " ", "the", " ", "build", "-*", "/_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "ben", "vani", "k", "):", " ", "a", " ", "more", " ", "reliab", "le", " ", "strip_", "\\u\\u\\uNL\\u\\u\\u_", "rel", "\\u", "path", "\\u", "parts_", "=_", "rel", "\\u", "path_", "._", "split_", "(_", "os_", "._", "sep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rel", "\\u", "path", "\\u", "parts_", "[_", "0_", "]_", "._", "startswith_", "(_", "'", "build", "-'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rel", "\\u", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "*_", "(_", "rel", "\\u", "path", "\\u", "parts_", "[_", "1_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "output", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "deploy", "\\u", "path_", "=_", "os_", "._", "path_", "._", "normpath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "args_", "._", "output_", ",_", "rel", "\\u", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "director", "y", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "parent", " ", "of", " ", "link", " ", "path", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "deploy", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "deploy", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "checke", "d\\u", "dirs_", "._", "get_", "(_", "deploy", "\\u", "dir_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "deploy", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "deploy", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "checke", "d\\u", "dirs_", "[_", "deploy", "\\u", "dir_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Link", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "deploy", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'%", "s", " ", "->", " ", "%", "s", "'_", "%_", "(_", "rel", "\\u", "path_", ",_", "deploy", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "symlink_", "(_", "target", "\\u", "output_", ",_", "deploy", "\\u", "path_", ")_", "\\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 ", " _", "skip", "ped", "\\u", "links_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "skip", "ped", "\\u", "links_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'(", "%", "s", " ", "skip", "ped", ")'_", "%_", "(_", "skip", "ped", "\\u", "links_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "0_", "if_", "result_", "else_", "1_" ]
[ 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,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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 ]
Unused import
resync/resync/resync/explorer.py
[ { "content": "\"\"\"ResourceSync explorer\n\nThis is the guts of a client designed to 'explore' the ResourceSync\nfacilities offered by a source. Will use standard practices to \nlook for and interpret capabilities.\n\"\"\"\n\nimport sys\nimport urllib\ntry: #python3\n from urllib.parse import urlparse, urlunparse, urljoin\nexcept ImportError: #python2\n from urlparse import urlparse, urlunparse, urljoin\nimport os.path\nimport datetime\nimport distutils.dir_util \nimport re\nimport time\nimport logging\nimport requests\n\nfrom .mapper import Mapper\nfrom .sitemap import Sitemap\nfrom .client import Client,ClientFatalError\nfrom .client_state import ClientState\nfrom .resource import Resource\nfrom .w3c_datetime import str_to_datetime,datetime_to_str\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class XResource(object):\n \"\"\"Information about a resource for the explorer\n\n Must have a uri but may also store:\n \n acceptable_capabilities - None for any acceptable, 'resource' if a \n resource rather than a capability document is expected, else \n a list of capability names\n checks - a set of information to check when then XResource is inspected\n base_uri - on creation interpret any relative URI specified in the \n context of base_uri, store the resulting full URI\n \"\"\"", "metadata": "root.XResource", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def __init__(self, uri, acceptable_capabilities=None, checks=None, context=None):\n self.uri=urljoin(context,uri)\n self.acceptable_capabilities=acceptable_capabilities\n self.checks=checks", "metadata": "root.XResource.__init__", "header": "['class', 'XResource', '(', 'object', ')', ':', '___EOS___']", "index": 40 }, { "content": "class HeadResponse(object):\n \"\"\"Object to mock up requests.head(...) response\"\"\"", "metadata": "root.HeadResponse", "header": "['module', '___EOS___']", "index": 45 }, { "content": " def __init__(self):\n self.status_code=None\n self.headers={}", "metadata": "root.HeadResponse.__init__", "header": "['class', 'HeadResponse', '(', 'object', ')', ':', '___EOS___']", "index": 47 }, { "content": "class ExplorerQuit(Exception):\n \"\"\"Exception raised when user quits normally, no error\"\"\"\n pass", "metadata": "root.ExplorerQuit", "header": "['module', '___EOS___']", "index": 51 }, { "content": "class Explorer(Client):\n \"\"\"Extension of the client code to explore a ResourceSync source\n\n Designed to support a text-based command-line client that starts from\n a given URI, server, or local file, and then allows interactive \n exploration of ResourceSync capabilities offered by the source.\n \"\"\"\n\n\n\n\n\n\n", "metadata": "root.Explorer", "header": "['module', '___EOS___']", "index": 55 }, { "content": " def explore(self):\n \"\"\"INTERACTIVE exploration source capabilities\n \n Will use sitemap URI taken either from explicit self.sitemap_name\n or derived from the mappings supplied.\n \"\"\"\n # Where do we start? Build options in starts which has entries\n # that are a pair comprised of the uri and a list of acceptable\n # capabilities\n starts = []\n if (self.sitemap_name is not None):\n print(\"Starting from explicit --sitemap %s\" % (uri))\n starts.append( XResource(uri) )\n elif (len(self.mapper)>0):\n uri = self.mapper.default_src_uri()\n (scheme, netloc, path, params, query, fragment) = urlparse(uri)\n if (not scheme and not netloc):\n if (os.path.isdir(path)):\n # have a dir, look for 'likely' file names\n print(\"Looking for capability documents in local directory %s\" % (path))\n for name in ['resourcesync','capabilities.xml',\n 'resourcelist.xml','changelist.xml']:\n file = os.path.join(path,name)\n if (os.path.isfile(file)):\n starts.append( XResource(file) )\n if (len(starts)==0):\n raise ClientFatalError( \"No likely capability files found in local directory %s\" %\n (path) )\n else:\n # local file, might be anything (or not exist)\n print(\"Starting from local file %s\" % (path))\n starts.append( XResource(path) )\n else:\n # remote, can't tell whether we have a sitemap or a server name or something \n # else, build list of options depending on whether there is a path and whether\n # there is an extension/name\n well_known = urlunparse( [ scheme,netloc,'/.well-known/resourcesync','','','' ] )\n if (not path):\n # root, just look for .well-known\n starts.append( XResource(well_known, ['capabilitylist','capabilitylistindex']) )\n else:\n starts.append( XResource(uri) )\n starts.append( XResource(well_known, ['capabilitylist','capabilitylistindex']) )\n print(\"Looking for discovery information based on mappings\")\n else:\n raise ClientFatalError(\"No source information (server base uri or capability uri) specified, use -h for help\")\n # \n # Have list of one or more possible starting point, try them in turn\n try:\n for start in starts:\n # For each starting point we create a fresh history\n history = [ start ]\n input = None\n while (len(history)>0):\n print\n xr = history.pop()\n new_xr = self.explore_uri(xr,len(history)>0)\n if (new_xr):\n # Add current and new to history\n history.append( xr )\n history.append( new_xr )\n except ExplorerQuit:\n pass # expected way to exit\n print(\"\\nresync-explorer done, bye...\\n\")", "metadata": "root.Explorer.explore", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 63 }, { "content": " def explore_uri(self, explorer_resource, show_back=True):\n \"\"\"INTERACTIVE exploration of capabilities document(s) starting at a given URI\n\n Will flag warnings if the document is not of type listed in caps\n \"\"\"\n uri = explorer_resource.uri\n caps = explorer_resource.acceptable_capabilities\n checks = explorer_resource.checks\n print(\"Reading %s\" % (uri))\n options={}\n capability=None\n try:\n if (caps=='resource'):\n # Not expecting a capability document\n self.explore_show_head(uri,check_headers=checks)\n else: \n s=Sitemap()\n list = s.parse_xml(urllib.urlopen(uri))\n (options,capability)=self.explore_show_summary(list,s.parsed_index,caps,context=uri)\n except IOError as e:\n print(\"Cannot read %s (%s)\" % (uri,str(e)))\n except Exception as e:\n print(\"Cannot parse %s (%s)\" % (uri,str(e)))\n #\n # Loop until we have some valide input\n #\n while (True):\n # don't offer number option for no resources/capabilities\n num_prompt = '' if (len(options)==0) else 'number, '\n up_prompt = 'b(ack), ' if (show_back) else ''\n input = raw_input( \"Follow [%s%sq(uit)]?\" % (num_prompt,up_prompt) )\n if (input in options.keys()):\n break\n if (input == 'q'):\n raise ExplorerQuit()\n if (input == 'b'):\n return(None)\n #\n # Got input that is one of the options\n #\n checks = {}\n r = options[input]\n if ( r.capability is None ):\n if (capability in ['resourcelist','changelist',\n 'resourcedump','changedump']):\n caps = 'resource'\n else:\n caps = self.allowed_entries(capability)\n elif (r.capability is 'resource'):\n caps = r.capability\n else:\n caps = [r.capability]\n # Record anything we know about the resource to check\n if (r.length is not None):\n checks['content-length']=r.length\n if (r.lastmod is not None):\n checks['last-modified']=r.lastmod\n if (r.mime_type is not None):\n checks['content-type']=r.mime_type\n # FIXME - could add fixity checks here too\n return( XResource(options[input].uri, caps, checks) )", "metadata": "root.Explorer.explore_uri", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 128 }, { "content": " def explore_show_summary(self, list, index=False, expected=None, context=None):\n \"\"\"Show summary of one capability document\n\n Given a capability document or index (in list, index True if it is an \n index), write out a simply textual summary of the document with all \n related documents shown as numbered options (of the form \n [#] ...description...) which will then form a menu for the next \n exploration.\n\n If expected is not None then it should be a list of expected document\n types. If this is set then a warning will be printed if list is not\n one of these document types.\n\n Look for certain top-level link types including rel=\"up\".\n \"\"\"\n num_entries = len(list.resources)\n capability = '(unknown capability)'\n if ('capability' in list.md):\n capability = list.md['capability']\n if (index):\n capability += 'index'\n print(\"Parsed %s document with %d entries:\" % (capability,num_entries))\n if (expected is not None and capability not in expected):\n print(\"WARNING - expected a %s document\" % (','.join(expected)))\n if (capability not in ['description','descriptionoindex','capabilitylist',\n 'resourcelist','resourcelistindex','changelist','changelistindex',\n 'resourcedump','resourcedumpindex','changedump','changedumpindex',\n 'resourcelist-archive', 'resourcedump-archive',\n 'changelist-archive', 'changedump-archive']):\n print(\"WARNING - unknown %s document type\" % (capability))\n to_show = num_entries\n if (num_entries>21):\n to_show = 20\n # What capability entries are allowed/expected? \n entry_caps = self.allowed_entries(capability);\n options = {}\n n=0\n # Look for <rs:ln> elements in this document\n ln_describedby = list.link('describedby')\n if (ln_describedby):\n if ('href' in ln_describedby):\n uri = ln_describedby['href']\n print(\"[%s] rel='describedby' link to %s\" % ('d',uri))\n uri = self.expand_relative_uri(context,uri)\n options['d']=Resource(uri,capability='resource')\n else:\n print(\"WARNING - describedby link with no href, ignoring\")\n ln_up = list.link('up')\n if (ln_up):\n if ('href' in ln_up):\n uri = ln_up['href']\n print(\"[%s] rel='up' link to %s\" % ('u',uri))\n uri = self.expand_relative_uri(context,uri)\n options['u']=Resource(uri)\n else:\n print(\"WARNING - up link with no href, ignoring\")\n ln_index = list.link('index')\n if (ln_index):\n if ('href' in ln_index):\n uri = ln_index['href']\n print(\"[%s] rel='index' link to %s\" % ('i',uri))\n uri = self.expand_relative_uri(context,uri)\n options['i']=Resource(uri)\n else:\n print(\"WARNING - index link with no href, ignoring\")\n # Show listed resources as numbered options\n for r in list.resources:\n if (n>=to_show):\n print(\"(not showing remaining %d entries)\" % (num_entries-n))\n break\n n+=1\n options[str(n)]=r\n print(\"[%d] %s\" % (n,r.uri))\n if (self.verbose):\n print(\" \" + str(r))\n r.uri = self.expand_relative_uri(context,r.uri)\n if (r.capability is not None):\n warning = ''\n if (r.capability not in entry_caps):\n warning = \" (EXPECTED %s)\" % (' or '.join(entry_caps))\n print(\" %s%s\" % (r.capability,warning))\n elif (len(entry_caps)==1):\n r.capability=entry_caps[0]\n print(\" capability not specified, should be %s\" % (r.capability))\n return(options,capability)", "metadata": "root.Explorer.explore_show_summary", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 190 }, { "content": " def explore_show_head(self,uri,check_headers=None):\n \"\"\"Do HEAD on uri and show infomation\n\n Will also check headers against any values specified in \n check_headers.\n \"\"\"\n print(\"HEAD %s\" % (uri))\n if (re.match(r'^\\w+:', uri)):\n # Looks like a URI\n response = requests.head(uri)\n else:\n # Mock up response if we have a local file\n response = self.head_on_file(uri)\n print(\" status: %s\" % (response.status_code))\n if (response.status_code=='200'):\n # generate normalized lastmod\n# if ('last-modified' in response.headers):\n# response.headers.add['lastmod'] = datetime_to_str(str_to_datetime(response.headers['last-modified']))\n # print some of the headers\n for header in ['content-length','last-modified','lastmod','content-type','etag']:\n if header in response.headers:\n check_str=''\n if (check_headers is not None and\n header in check_headers):\n if (response.headers[header] == check_headers[header]):\n check_str=' MATCHES EXPECTED VALUE'\n else:\n check_str=' EXPECTED %s' % (check_headers[header])\n print(\" %s: %s%s\" % (header, response.headers[header], check_str))", "metadata": "root.Explorer.explore_show_head", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 276 }, { "content": " def head_on_file(self,file):\n \"\"\"Mock up requests.head(..) response on local file\n \"\"\"\n response = HeadResponse()\n if (not os.path.isfile(file)):\n response.status_code='404'\n else:\n response.status_code='200'\n response.headers['last-modified']=datetime_to_str(os.path.getmtime(file))\n response.headers['content-length']=os.path.getsize(file)\n return(response)", "metadata": "root.Explorer.head_on_file", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 306 }, { "content": " def allowed_entries(self,capability):\n \"\"\"Given a current capability document, return list of allowed entries\n\n Includes handling of capability = *index where the only acceptable \n entries are *.\n \"\"\"\n index = re.match(r'(.+)index$',capability)\n archive = re.match('r(.+)\\-archive$',capability)\n if (capability == 'capabilitylistindex'):\n return([]) #not allowed so no valid references\n elif (index):\n return(index.group(0)) #name without index ending\n elif (archive):\n return(archive.group(0)) #name without -archive ending\n elif (capability == 'description'):\n return(['capabilitylist'])\n elif (capability == 'capabilitylist'):\n return(['resourcelist', 'resourcedump',\n 'changelist', 'changedump',\n 'resourcelist-archive', 'resourcedump-archive',\n 'changelist-archive', 'changedump-archive'])\n return([])", "metadata": "root.Explorer.allowed_entries", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 318 }, { "content": " def expand_relative_uri(self,context,uri):\n \"\"\"If uri is relative then expand in context\n \n Prints warning if expansion happens\n \"\"\"\n full_uri = urljoin(context,uri)\n if (full_uri != uri):\n print(\" WARNING - expanded relative URI to %s\" % (full_uri))\n uri = full_uri\n return(uri)", "metadata": "root.Explorer.expand_relative_uri", "header": "['class', 'Explorer', '(', 'Client', ')', ':', '___EOS___']", "index": 341 } ]
[ { "span": "import sys", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 10 }, { "span": "import datetime", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 15 }, { "span": "import distutils.dir_util ", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 25 }, { "span": "import time", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 11 }, { "span": "import logging", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 14 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Reso", "urc", "e", "Sync", " ", "explorer", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "is", " ", "the", " ", "gut", "s", " ", "of", " ", "a", " ", "client", " ", "design", "ed", " ", "to", " ", "'", "explore", "'", " ", "the", " ", "Reso", "urc", "e", "Sync", "\\", "10", ";", "facilit", "ies", " ", "offered", " ", "by", " ", "a", " ", "source", ".", " ", "Wil", "l", " ", "use", " ", "standard", " ", "practic", "es", " ", "to", " ", "\\", "10", ";", "look", " ", "for", " ", "and", " ", "interpret", " ", "capab", "ilities", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "#", "python", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "._", "parse_", "import_", "urlparse_", ",_", "urlu", "npar", "se_", ",_", "urljoin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "#", "python", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urlparse_", "import_", "urlparse_", ",_", "urlu", "npar", "se_", ",_", "urljoin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "distutils_", "._", "dir\\u", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "mapper_", "import_", "Mapper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "sitemap", "_", "import_", "Site", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "client_", "import_", "Client_", ",_", "Client", "Fat", "al", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "client", "\\u", "state_", "import_", "Client", "State_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "resource_", "import_", "Resource_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "w3", "c\\u", "datetime_", "import_", "str", "\\u", "to", "\\u", "datetime_", ",_", "datetime", "\\u", "to", "\\u", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "XR", "esource", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Information", " ", "abo", "ut", " ", "a", " ", "resource", " ", "for", " ", "the", " ", "explorer", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Mus", "t", " ", "have", " ", "a", " ", "uri", " ", "but", " ", "may", " ", "als", "o", " ", "store", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "acceptabl", "e\\u", "capab", "ilities", " ", "-", " ", "Non", "e", " ", "for", " ", "any", " ", "acceptabl", "e", ",", " ", "'", "resource", "'", " ", "if", " ", "a", " ", "\\", "10", ";", " ", " ", " ", " ", "resource", " ", "rat", "her", " ", "than", " ", "a", " ", "capab", "ilit", "y", " ", "document", " ", "is", " ", "expected", ",", " ", "else", " ", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "list", " ", "of", " ", "capab", "ilit", "y", " ", "names", "\\", "10", ";", " ", " ", " ", " ", "checks", " ", "-", " ", "a", " ", "set", " ", "of", " ", "informati", "on", " ", "to", " ", "check", " ", "whe", "n", " ", "then", " ", "XR", "esource", " ", "is", " ", "inspect", "ed", "\\", "10", ";", " ", " ", " ", " ", "base", "\\u", "uri", " ", "-", " ", "on", " ", "creati", "on", " ", "interpret", " ", "any", " ", "relative", " ", "URI", " ", "specified", " ", "in", " ", "the", " ", "\\", "10", ";", " ", " ", " ", " ", "context", " ", "of", " ", "base", "\\u", "uri", ",", " ", "store", " ", "the", " ", "result", "ing", " ", "full", " ", "URI", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "XR", "esource", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "uri_", ",_", "acceptabl", "e\\u", "capabilities_", "=_", "None_", ",_", "checks_", "=_", "None_", ",_", "context_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "uri_", "=_", "urljoin_", "(_", "context_", ",_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "acceptabl", "e\\u", "capabilities_", "=_", "acceptabl", "e\\u", "capabilities_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "checks_", "=_", "checks_", "\\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_", "Head", "Response_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Object", " ", "to", " ", "mock", " ", "up", " ", "request", "s", ".", "head", "(...)", " ", "response", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Head", "Response_", "(_", "object_", ")_", ":_", "\\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 ", " _", "self_", "._", "status", "\\u", "code_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "headers_", "=_", "{_", "}_", "\\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_", "Explorer", "Quit_", "(_", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Except", "ion", " ", "raise", "d", " ", "whe", "n", " ", "user", " ", "quit", "s", " ", "normal", "ly", ",", " ", "no", " ", "error", "\"\"\"_", "\\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_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ext", "ensi", "on", " ", "of", " ", "the", " ", "client", " ", "code", " ", "to", " ", "explore", " ", "a", " ", "Reso", "urc", "e", "Sync", " ", "source", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Designe", "d", " ", "to", " ", "support", " ", "a", " ", "text", "-", "based", " ", "command", "-", "line", " ", "client", " ", "tha", "t", " ", "starts", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "give", "n", " ", "URI", ",", " ", "server", ",", " ", "or", " ", "local", " ", "file", ",", " ", "and", " ", "then", " ", "allow", "s", " ", "interactive", " ", "\\", "10", ";", " ", " ", " ", " ", "exploration", " ", "of", " ", "Reso", "urc", "e", "Sync", " ", "capab", "ilities", " ", "offered", " ", "by", " ", "the", " ", "source", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "explore", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "INTER", "ACTI", "VE", " ", "exploration", " ", "source", " ", "capab", "ilities", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Wil", "l", " ", "use", " ", "sitemap", " ", "URI", " ", "take", "n", " ", "eit", "her", " ", "from", " ", "explicit", " ", "self", ".", "sitemap", "\\u", "name", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "derive", "d", " ", "from", " ", "the", " ", "mapping", "s", " ", "supplie", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Whe", "re", " ", "do", " ", "we", " ", "start", "?", " ", "Build", " ", "options", " ", "in", " ", "starts", " ", "whi", "ch", " ", "has", " ", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "are", " ", "a", " ", "pair", " ", "compr", "ise", "d", " ", "of", " ", "the", " ", "uri", " ", "and", " ", "a", " ", "list", " ", "of", " ", "acceptabl", "e_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "capabilities_", "\\u\\u\\uNL\\u\\u\\u_", "starts_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "sitemap", "\\u", "name_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Start", "ing", " ", "from", " ", "explicit", " ", "--", "sitemap", " ", "%", "s", "\"_", "%_", "(_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "starts_", "._", "append_", "(_", "XR", "esource", "_", "(_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "len_", "(_", "self_", "._", "mapper_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uri_", "=_", "self_", "._", "mapper_", "._", "default", "\\u", "src", "\\u", "uri_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "scheme_", ",_", "netloc_", ",_", "path_", ",_", "params_", ",_", "query_", ",_", "fragment_", ")_", "=_", "urlparse_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "scheme_", "and_", "not_", "netloc_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "os_", "._", "path_", "._", "isdir_", "(_", "path_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "have", " ", "a", " ", "dir", ",", " ", "look", " ", "for", " ", "'", "like", "ly", "'", " ", "file", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "\"", "Look", "ing", " ", "for", " ", "capab", "ilit", "y", " ", "document", "s", " ", "in", " ", "local", " ", "director", "y", " ", "%", "s", "\"_", "%_", "(_", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "name_", "in_", "[_", "'", "resource", "sync", "'_", ",_", "'", "capab", "ilities", ".", "xml", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "resource", "list", ".", "xml", "'_", ",_", "'", "changeli", "st", ".", "xml", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "file_", "=_", "os_", "._", "path_", "._", "join_", "(_", "path_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "os_", "._", "path_", "._", "isfile_", "(_", "file_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "starts_", "._", "append_", "(_", "XR", "esource", "_", "(_", "file_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "len_", "(_", "starts_", ")_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "Client", "Fat", "al", "Error_", "(_", "\"", "No", " ", "like", "ly", " ", "capab", "ilit", "y", " ", "files", " ", "found", " ", "in", " ", "local", " ", "director", "y", " ", "%", "s", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "path_", ")_", ")_", "\\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_", "#", " ", "local", " ", "file", ",", " ", "mig", "ht", " ", "be", " ", "anyt", "hing", " ", "(", "or", " ", "not", " ", "exist", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "\"", "Start", "ing", " ", "from", " ", "local", " ", "file", " ", "%", "s", "\"_", "%_", "(_", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "starts_", "._", "append_", "(_", "XR", "esource", "_", "(_", "path_", ")_", ")_", "\\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_", "#", " ", "remote", ",", " ", "can", "'", "t", " ", "tell", " ", "whe", "ther", " ", "we", " ", "have", " ", "a", " ", "sitemap", " ", "or", " ", "a", " ", "server", " ", "name", " ", "or", " ", "somet", "hing", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "else", ",", " ", "build", " ", "list", " ", "of", " ", "options", " ", "depend", "ing", " ", "on", " ", "whe", "ther", " ", "there", " ", "is", " ", "a", " ", "path", " ", "and", " ", "whe", "ther_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "there", " ", "is", " ", "an", " ", "extensi", "on", "/", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "well", "\\u", "known_", "=_", "urlu", "npar", "se_", "(_", "[_", "scheme_", ",_", "netloc_", ",_", "'/.", "well", "-", "know", "n", "/", "resource", "sync", "'_", ",_", "''_", ",_", "''_", ",_", "''_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "root", ",", " ", "just", " ", "look", " ", "for", " ", ".", "well", "-", "known_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "starts_", "._", "append_", "(_", "XR", "esource", "_", "(_", "well", "\\u", "known_", ",_", "[_", "'", "capab", "ilit", "yli", "st", "'_", ",_", "'", "capab", "ilit", "yli", "stin", "dex", "'_", "]_", ")_", ")_", "\\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 ", " ", "_", "starts_", "._", "append_", "(_", "XR", "esource", "_", "(_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "starts_", "._", "append_", "(_", "XR", "esource", "_", "(_", "well", "\\u", "known_", ",_", "[_", "'", "capab", "ilit", "yli", "st", "'_", ",_", "'", "capab", "ilit", "yli", "stin", "dex", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Look", "ing", " ", "for", " ", "discove", "ry", " ", "informati", "on", " ", "based", " ", "on", " ", "mapping", "s", "\"_", ")_", "\\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_", "Client", "Fat", "al", "Error_", "(_", "\"", "No", " ", "source", " ", "informati", "on", " ", "(", "server", " ", "base", " ", "uri", " ", "or", " ", "capab", "ilit", "y", " ", "uri", ")", " ", "specified", ",", " ", "use", " ", "-", "h", " ", "for", " ", "help", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ha", "ve", " ", "list", " ", "of", " ", "one", " ", "or", " ", "more", " ", "possib", "le", " ", "startin", "g", " ", "point", ",", " ", "try", " ", "them", " ", "in", " ", "turn_", "\\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 ", " _", "for_", "start_", "in_", "starts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "For", " ", "each", " ", "startin", "g", " ", "point", " ", "we", " ", "create", " ", "a", " ", "fresh", " ", "history_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "history_", "=_", "[_", "start_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "(_", "len_", "(_", "history_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xr_", "=_", "history_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "xr_", "=_", "self_", "._", "explore", "\\u", "uri_", "(_", "xr_", ",_", "len_", "(_", "history_", ")_", ">_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "new", "\\u", "xr_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "current", " ", "and", " ", "new", " ", "to", " ", "history_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "history_", "._", "append_", "(_", "xr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "history_", "._", "append_", "(_", "new", "\\u", "xr_", ")_", "\\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_", "except_", "Explorer", "Quit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "#", " ", "expected", " ", "way", " ", "to", " ", "exit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"\\\\", "nre", "sync", "-", "explorer", " ", "don", "e", ",", " ", "bye", "...", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "explore", "\\u", "uri_", "(_", "self_", ",_", "explorer", "\\u", "resource_", ",_", "show", "\\u", "back_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "INTER", "ACTI", "VE", " ", "exploration", " ", "of", " ", "capab", "ilities", " ", "document", "(", "s", ")", " ", "startin", "g", " ", "at", " ", "a", " ", "give", "n", " ", "URI", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Wil", "l", " ", "flag", " ", "warn", "ings", " ", "if", " ", "the", " ", "document", " ", "is", " ", "not", " ", "of", " ", "type", " ", "liste", "d", " ", "in", " ", "caps", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "explorer", "\\u", "resource_", "._", "uri_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "caps_", "=_", "explorer", "\\u", "resource_", "._", "acceptabl", "e\\u", "capabilities_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checks_", "=_", "explorer", "\\u", "resource_", "._", "checks_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Reading", " ", "%", "s", "\"_", "%_", "(_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "capability_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "caps_", "==_", "'", "resource", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", " ", "expect", "ing", " ", "a", " ", "capab", "ilit", "y", " ", "document_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "explore", "\\u", "show", "\\u", "head_", "(_", "uri_", ",_", "check", "\\u", "headers_", "=_", "checks_", ")_", "\\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 ", " _", "s_", "=_", "Site", "map_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list_", "=_", "s_", "._", "parse", "\\u", "xml_", "(_", "urllib_", "._", "urlopen_", "(_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "options_", ",_", "capability_", ")_", "=_", "self_", "._", "explore", "\\u", "show", "\\u", "summary_", "(_", "list_", ",_", "s_", "._", "parsed", "\\u", "index_", ",_", "caps_", ",_", "context_", "=_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Cann", "ot", " ", "read", " ", "%", "s", " ", "(%", "s", ")\"_", "%_", "(_", "uri_", ",_", "str_", "(_", "e_", ")_", ")_", ")_", "\\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_", "(_", "\"", "Cann", "ot", " ", "parse", " ", "%", "s", " ", "(%", "s", ")\"_", "%_", "(_", "uri_", ",_", "str_", "(_", "e_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Loop", " ", "unti", "l", " ", "we", " ", "have", " ", "some", " ", "valid", "e", " ", "input_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "(_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "don", "'", "t", " ", "off", "er", " ", "number", " ", "option", " ", "for", " ", "no", " ", "resource", "s", "/", "capabilities_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "num", "\\u", "prompt_", "=_", "''_", "if_", "(_", "len_", "(_", "options_", ")_", "==_", "0_", ")_", "else_", "'", "number", ",", " ", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "up", "\\u", "prompt_", "=_", "'", "b", "(", "ack", "),", " ", "'_", "if_", "(_", "show", "\\u", "back_", ")_", "else_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input_", "=_", "raw", "\\u", "input_", "(_", "\"", "Follow", " ", "[", "%", "s", "%", "sq", "(", "uit", ")]", "?\"_", "%_", "(_", "num", "\\u", "prompt_", ",_", "up", "\\u", "prompt_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "input_", "in_", "options_", "._", "keys_", "(_", ")_", ")_", ":_", "\\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_", "if_", "(_", "input_", "==_", "'", "q", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Explorer", "Quit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "input_", "==_", "'", "b", "'_", ")_", ":_", "\\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_", "#", " ", "Got", " ", "input", " ", "tha", "t", " ", "is", " ", "one", " ", "of", " ", "the", " ", "options_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "checks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "options_", "[_", "input_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "r_", "._", "capability_", "is_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "capability_", "in_", "[_", "'", "resource", "list", "'_", ",_", "'", "changeli", "st", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "resource", "dump", "'_", ",_", "'", "change", "dump", "'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "caps_", "=_", "'", "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 ", " _", "caps_", "=_", "self_", "._", "allow", "ed", "\\u", "entries_", "(_", "capability_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "r_", "._", "capability_", "is_", "'", "resource", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "caps_", "=_", "r_", "._", "capability_", "\\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 ", " _", "caps_", "=_", "[_", "r_", "._", "capability_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Record", " ", "anyt", "hing", " ", "we", " ", "know", " ", "abo", "ut", " ", "the", " ", "resource", " ", "to", " ", "check_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "r_", "._", "length_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checks_", "[_", "'", "content", "-", "length", "'_", "]_", "=_", "r_", "._", "length_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "r_", "._", "lastm", "od_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checks_", "[_", "'", "last", "-", "modifi", "ed", "'_", "]_", "=_", "r_", "._", "lastm", "od_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "r_", "._", "mime", "\\u", "type_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checks_", "[_", "'", "content", "-", "type", "'_", "]_", "=_", "r_", "._", "mime", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", " ", "-", " ", "coul", "d", " ", "add", " ", "fix", "it", "y", " ", "checks", " ", "here", " ", "too", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "XR", "esource", "_", "(_", "options_", "[_", "input_", "]_", "._", "uri_", ",_", "caps_", ",_", "checks_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "explore", "\\u", "show", "\\u", "summary_", "(_", "self_", ",_", "list_", ",_", "index_", "=_", "False_", ",_", "expected_", "=_", "None_", ",_", "context_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Show", " ", "summar", "y", " ", "of", " ", "one", " ", "capab", "ilit", "y", " ", "document", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Give", "n", " ", "a", " ", "capab", "ilit", "y", " ", "document", " ", "or", " ", "index", " ", "(", "in", " ", "list", ",", " ", "index", " ", "Tru", "e", " ", "if", " ", "it", " ", "is", " ", "an", " ", "\\", "10", ";", " ", " ", " ", " ", "index", "),", " ", "write", " ", "out", " ", "a", " ", "simp", "ly", " ", "textu", "al", " ", "summar", "y", " ", "of", " ", "the", " ", "document", " ", "with", " ", "all", " ", "\\", "10", ";", " ", " ", " ", " ", "relate", "d", " ", "document", "s", " ", "shown", " ", "as", " ", "numbered", " ", "options", " ", "(", "of", " ", "the", " ", "form", " ", "\\", "10", ";", " ", " ", " ", " ", "[", "#]", " ", "...", "description", "...)", " ", "whi", "ch", " ", "will", " ", "then", " ", "form", " ", "a", " ", "menu", " ", "for", " ", "the", " ", "next", " ", "\\", "10", ";", " ", " ", " ", " ", "exploration", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "expected", " ", "is", " ", "not", " ", "Non", "e", " ", "then", " ", "it", " ", "shou", "ld", " ", "be", " ", "a", " ", "list", " ", "of", " ", "expected", " ", "document", "\\", "10", ";", " ", " ", " ", " ", "types", ".", " ", "If", " ", "this", " ", "is", " ", "set", " ", "then", " ", "a", " ", "warn", "ing", " ", "will", " ", "be", " ", "printed", " ", "if", " ", "list", " ", "is", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "one", " ", "of", " ", "these", " ", "document", " ", "types", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Look", " ", "for", " ", "cert", "ain", " ", "top", "-", "level", " ", "link", " ", "types", " ", "inclu", "ding", " ", "rel", "=\"", "up", "\".\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "entries_", "=_", "len_", "(_", "list_", "._", "resources_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "capability_", "=_", "'(", "unknown", " ", "capab", "ilit", "y", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "'", "capab", "ilit", "y", "'_", "in_", "list_", "._", "md_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "capability_", "=_", "list_", "._", "md_", "[_", "'", "capab", "ilit", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "capability_", "+=_", "'", "index", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Pars", "ed", " ", "%", "s", " ", "document", " ", "with", " ", "%", "d", " ", "entri", "es", ":\"_", "%_", "(_", "capability_", ",_", "num", "\\u", "entries_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "expected_", "is_", "not_", "None_", "and_", "capability_", "not_", "in_", "expected_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "WARN", "ING", " ", "-", " ", "expected", " ", "a", " ", "%", "s", " ", "document", "\"_", "%_", "(_", "','_", "._", "join_", "(_", "expected_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "capability_", "not_", "in_", "[_", "'", "description", "'_", ",_", "'", "description", "oin", "dex", "'_", ",_", "'", "capab", "ilit", "yli", "st", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "resource", "list", "'_", ",_", "'", "resource", "listi", "nde", "x", "'_", ",_", "'", "changeli", "st", "'_", ",_", "'", "changeli", "stin", "dex", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "resource", "dump", "'_", ",_", "'", "resource", "dump", "index", "'_", ",_", "'", "change", "dump", "'_", ",_", "'", "change", "dump", "index", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "resource", "list", "-", "archive", "'_", ",_", "'", "resource", "dump", "-", "archive", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "changeli", "st", "-", "archive", "'_", ",_", "'", "change", "dump", "-", "archive", "'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "WARN", "ING", " ", "-", " ", "unknown", " ", "%", "s", " ", "document", " ", "type", "\"_", "%_", "(_", "capability_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "to", "\\u", "show_", "=_", "num", "\\u", "entries_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "num", "\\u", "entries_", ">_", "21_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "to", "\\u", "show_", "=_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "What", " ", "capab", "ilit", "y", " ", "entri", "es", " ", "are", " ", "allow", "ed", "/", "expected", "?", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "entry", "\\u", "caps_", "=_", "self_", "._", "allow", "ed", "\\u", "entries_", "(_", "capability_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Look", " ", "for", " ", "<", "rs", ":", "ln", ">", " ", "element", "s", " ", "in", " ", "this", " ", "document_", "\\u\\u\\uNL\\u\\u\\u_", "ln", "\\u", "descri", "bed", "by_", "=_", "list_", "._", "link_", "(_", "'", "descri", "bed", "by", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "ln", "\\u", "descri", "bed", "by_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "'", "href", "'_", "in_", "ln", "\\u", "descri", "bed", "by_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uri_", "=_", "ln", "\\u", "descri", "bed", "by_", "[_", "'", "href", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "%", "s", "]", " ", "rel", "='", "descri", "bed", "by", "'", " ", "link", " ", "to", " ", "%", "s", "\"_", "%_", "(_", "'", "d", "'_", ",_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "self_", "._", "expand", "\\u", "relative", "\\u", "uri_", "(_", "context_", ",_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "[_", "'", "d", "'_", "]_", "=_", "Resource_", "(_", "uri_", ",_", "capability_", "=_", "'", "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 ", " _", "print_", "(_", "\"", "WARN", "ING", " ", "-", " ", "descri", "bed", "by", " ", "link", " ", "with", " ", "no", " ", "href", ",", " ", "ign", "orin", "g", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ln", "\\u", "up_", "=_", "list_", "._", "link_", "(_", "'", "up", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "ln", "\\u", "up_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "'", "href", "'_", "in_", "ln", "\\u", "up_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uri_", "=_", "ln", "\\u", "up_", "[_", "'", "href", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "%", "s", "]", " ", "rel", "='", "up", "'", " ", "link", " ", "to", " ", "%", "s", "\"_", "%_", "(_", "'", "u", "'_", ",_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "self_", "._", "expand", "\\u", "relative", "\\u", "uri_", "(_", "context_", ",_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "[_", "'", "u", "'_", "]_", "=_", "Resource_", "(_", "uri_", ")_", "\\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_", "(_", "\"", "WARN", "ING", " ", "-", " ", "up", " ", "link", " ", "with", " ", "no", " ", "href", ",", " ", "ign", "orin", "g", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ln", "\\u", "index_", "=_", "list_", "._", "link_", "(_", "'", "index", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "ln", "\\u", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "'", "href", "'_", "in_", "ln", "\\u", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uri_", "=_", "ln", "\\u", "index_", "[_", "'", "href", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "%", "s", "]", " ", "rel", "='", "index", "'", " ", "link", " ", "to", " ", "%", "s", "\"_", "%_", "(_", "'", "i", "'_", ",_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "self_", "._", "expand", "\\u", "relative", "\\u", "uri_", "(_", "context_", ",_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "[_", "'", "i", "'_", "]_", "=_", "Resource_", "(_", "uri_", ")_", "\\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_", "(_", "\"", "WARN", "ING", " ", "-", " ", "index", " ", "link", " ", "with", " ", "no", " ", "href", ",", " ", "ign", "orin", "g", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Show", " ", "liste", "d", " ", "resource", "s", " ", "as", " ", "numbered", " ", "options_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "list_", "._", "resources_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "n_", ">=_", "to", "\\u", "show_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"(", "not", " ", "showin", "g", " ", "rema", "inin", "g", " ", "%", "d", " ", "entri", "es", ")\"_", "%_", "(_", "num", "\\u", "entries_", "-_", "n_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "n_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "[_", "str_", "(_", "n_", ")_", "]_", "=_", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "%", "d", "]", " ", "%", "s", "\"_", "%_", "(_", "n_", ",_", "r_", "._", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "verbose_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", " ", "\"_", "+_", "str_", "(_", "r_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "._", "uri_", "=_", "self_", "._", "expand", "\\u", "relative", "\\u", "uri_", "(_", "context_", ",_", "r_", "._", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "r_", "._", "capability_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warning_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "r_", "._", "capability_", "not_", "in_", "entry", "\\u", "caps_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "warning_", "=_", "\"", " ", "(", "EXPECT", "ED", " ", "%", "s", ")\"_", "%_", "(_", "'", " ", "or", " ", "'_", "._", "join_", "(_", "entry", "\\u", "caps_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "%", "s", "%", "s", "\"_", "%_", "(_", "r_", "._", "capability_", ",_", "warning_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "len_", "(_", "entry", "\\u", "caps_", ")_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "._", "capability_", "=_", "entry", "\\u", "caps_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "capab", "ilit", "y", " ", "not", " ", "specified", ",", " ", "shou", "ld", " ", "be", " ", "%", "s", "\"_", "%_", "(_", "r_", "._", "capability_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "options_", ",_", "capability_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "explore", "\\u", "show", "\\u", "head_", "(_", "self_", ",_", "uri_", ",_", "check", "\\u", "headers_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Do", " ", "HEAD", " ", "on", " ", "uri", " ", "and", " ", "show", " ", "info", "mati", "on", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Wil", "l", " ", "als", "o", " ", "check", " ", "header", "s", " ", "against", " ", "any", " ", "values", " ", "specified", " ", "in", " ", "\\", "10", ";", " ", " ", " ", " ", "check", "\\u", "header", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "HEAD", " ", "%", "s", "\"_", "%_", "(_", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "re_", "._", "match_", "(_", "r", "'", "^", "\\\\", "w", "+:", "'_", ",_", "uri_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Look", "s", " ", "like", " ", "a", " ", "URI_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "requests_", "._", "head_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Moc", "k", " ", "up", " ", "response", " ", "if", " ", "we", " ", "have", " ", "a", " ", "local", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "head", "\\u", "on", "\\u", "file_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "status", ":", " ", "%", "s", "\"_", "%_", "(_", "response_", "._", "status", "\\u", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "response_", "._", "status", "\\u", "code_", "==_", "'", "200", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "generat", "e", " ", "normali", "zed", " ", "lastm", "od_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "if", " ", "('", "last", "-", "modifi", "ed", "'", " ", "in", " ", "response", ".", "header", "s", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "response", ".", "header", "s", ".", "add", "['", "lastm", "od", "']", " ", "=", " ", "datetime", "\\u", "to", "\\u", "str", "(", "str", "\\u", "to", "\\u", "datetime", "(", "response", ".", "header", "s", "['", "last", "-", "modifi", "ed", "'])", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "some", " ", "of", " ", "the", " ", "headers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "header_", "in_", "[_", "'", "content", "-", "length", "'_", ",_", "'", "last", "-", "modifi", "ed", "'_", ",_", "'", "lastm", "od", "'_", ",_", "'", "content", "-", "type", "'_", ",_", "'", "eta", "g", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "header_", "in_", "response_", "._", "headers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "check", "\\u", "str_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "check", "\\u", "headers_", "is_", "not_", "None_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "header_", "in_", "check", "\\u", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "(_", "response_", "._", "headers_", "[_", "header_", "]_", "==_", "check", "\\u", "headers_", "[_", "header_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "check", "\\u", "str_", "=_", "'", " ", "MATCH", "ES", " ", "EXPECT", "ED", " ", "VALU", "E", "'_", "\\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 ", " ", " _", "check", "\\u", "str_", "=_", "'", " ", "EXPECT", "ED", " ", "%", "s", "'_", "%_", "(_", "check", "\\u", "headers_", "[_", "header_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "%", "s", ":", " ", "%", "s", "%", "s", "\"_", "%_", "(_", "header_", ",_", "response_", "._", "headers_", "[_", "header_", "]_", ",_", "check", "\\u", "str_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\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_", "head", "\\u", "on", "\\u", "file_", "(_", "self_", ",_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Moc", "k", " ", "up", " ", "request", "s", ".", "head", "(.", ".)", " ", "response", " ", "on", " ", "local", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "Head", "Response_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "os_", "._", "path_", "._", "isfile_", "(_", "file_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "status", "\\u", "code_", "=_", "'", "404", "'_", "\\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 ", " _", "response_", "._", "status", "\\u", "code_", "=_", "'", "200", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "headers_", "[_", "'", "last", "-", "modifi", "ed", "'_", "]_", "=_", "datetime", "\\u", "to", "\\u", "str_", "(_", "os_", "._", "path_", "._", "getmtime_", "(_", "file_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "headers_", "[_", "'", "content", "-", "length", "'_", "]_", "=_", "os_", "._", "path_", "._", "getsize_", "(_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "allow", "ed", "\\u", "entries_", "(_", "self_", ",_", "capability_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Give", "n", " ", "a", " ", "current", " ", "capab", "ilit", "y", " ", "document", ",", " ", "return", " ", "list", " ", "of", " ", "allow", "ed", " ", "entri", "es", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Includes", " ", "handling", " ", "of", " ", "capab", "ilit", "y", " ", "=", " ", "*", "index", " ", "where", " ", "the", " ", "only", " ", "acceptabl", "e", " ", "\\", "10", ";", " ", " ", " ", " ", "entri", "es", " ", "are", " ", "*.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "=_", "re_", "._", "match_", "(_", "r", "'(", ".+)", "index", "$'_", ",_", "capability_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "archive_", "=_", "re_", "._", "match_", "(_", "'", "r", "(.+", ")\\\\", "-", "archive", "$'_", ",_", "capability_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "capability_", "==_", "'", "capab", "ilit", "yli", "stin", "dex", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "[_", "]_", ")_", "#", "not", " ", "allow", "ed", " ", "so", " ", "no", " ", "valid", " ", "references_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "index_", "._", "group_", "(_", "0_", ")_", ")_", "#", "name", " ", "with", "out", " ", "index", " ", "ending_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "archive_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "archive_", "._", "group_", "(_", "0_", ")_", ")_", "#", "name", " ", "with", "out", " ", "-", "archive", " ", "ending_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "capability_", "==_", "'", "description", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "[_", "'", "capab", "ilit", "yli", "st", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "capability_", "==_", "'", "capab", "ilit", "yli", "st", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "[_", "'", "resource", "list", "'_", ",_", "'", "resource", "dump", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "changeli", "st", "'_", ",_", "'", "change", "dump", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "resource", "list", "-", "archive", "'_", ",_", "'", "resource", "dump", "-", "archive", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "changeli", "st", "-", "archive", "'_", ",_", "'", "change", "dump", "-", "archive", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explorer", "_", "(_", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "expand", "\\u", "relative", "\\u", "uri_", "(_", "self_", ",_", "context_", ",_", "uri_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "uri", " ", "is", " ", "relative", " ", "then", " ", "expand", " ", "in", " ", "context", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Print", "s", " ", "warn", "ing", " ", "if", " ", "expansion", " ", "happ", "ens", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "full", "\\u", "uri_", "=_", "urljoin_", "(_", "context_", ",_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "full", "\\u", "uri_", "!=_", "uri_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", " ", "WARN", "ING", " ", "-", " ", "expand", "ed", " ", "relative", " ", "URI", " ", "to", " ", "%", "s", "\"_", "%_", "(_", "full", "\\u", "uri_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "full", "\\u", "uri_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "uri_", ")_" ]
[ 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, 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, 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and.py
[ { "content": "################################################################################\n#\n# MRC FGU Computational Genomics Group\n#\n# $Id: pipeline_rnaseq_geneset.py 2900 2012-03-38 14:38:00Z david $\n#\n# Copyright (C) 2012 David Sims\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n#################################################################################\n\"\"\"\n========================\nRNAseq Geneset Pipeline\n========================\n\n:Author: David Sims \n:Release: $Id: pipeline_rnaseq_genesst.py 2900 2012-03-28 14:38:00Z david $\n:Date: |today|\n:Tags: Python\n\nThe RNAseq geneset pipeline parses multiple GTF files derived from RNAseq experiments in different tissues and produces a consensus geneset\n\nUsage\n=====\n\nSee :ref:`PipelineSettingUp` and :ref:`PipelineRunning` on general information how to use CGAT pipelines.\n\nConfiguration\n-------------\n\nThe pipeline requires a configured :file:`pipeline.ini` file. \n\nConfiguration files follow the ini format (see the python\n`ConfigParser <http://docs.python.org/library/configparser.html>` documentation).\nThe configuration file is organized by section and the variables are documented within \nthe file. In order to get a local configuration file in the current directory, type::\n\n python <codedir>/pipeline_rnaseq_genest.py config\n\nThe sphinxreport report requires a :file:`conf.py` and :file:`sphinxreport.ini` file \n(see :ref:`PipelineDocumenation`). To start with, use the files supplied with the\n:ref:`Example` data.\n\n\nInput\n-----\n\nInput are GTF-formatted files. \n\nRequirements\n------------\n\nThe pipeline requires the information from the following pipelines:\n\n:doc:`pipeline_annotations`\n\nset the configuration variables:\n :py:data:`annotations_database` \n :py:data:`annotations_dir`\n\nOn top of the default CGAT setup, the pipeline requires the following software to be in the \npath:\n\n+--------------------+-------------------+------------------------------------------------+\n|*Program* |*Version* |*Purpose* |\n+--------------------+-------------------+------------------------------------------------+\n|BEDTools | |interval comparison |\n+--------------------+-------------------+------------------------------------------------+\n\n\nPipline Output\n==============\n\nThe results of the computation are all stored in an sqlite relational\ndatabase :file:`csvdb`.\n\n\nCode\n====\n\n\"\"\"\nimport sys\nimport tempfile\nimport optparse\nimport shutil\nimport itertools\nimport csv\nimport math\nimport random\nimport re\nimport glob\nimport os\nimport shutil\nimport collections\nimport gzip\nimport sqlite3\nimport pysam\nimport CGAT.IndexedFasta as IndexedFasta\nimport CGAT.IndexedGenome as IndexedGenome\nimport CGAT.FastaIterator as FastaIterator\nimport CGAT.Genomics as Genomics\nimport CGAT.IOTools as IOTools\nimport CGAT.MAST as MAST\nimport CGAT.GTF as GTF\nimport CGAT.GFF as GFF\nimport CGAT.Bed as Bed\nimport cStringIO\nimport numpy\nimport CGAT.Masker as Masker\nimport fileinput\nimport CGAT.Experiment as E\nimport logging as L\nfrom ruffus import *\n\nUSECLUSTER = True\n\n###################################################\n###################################################\n###################################################\n## Pipeline configuration\n###################################################\nimport CGAT.Pipeline as P\nP.getParameters( [\"pipeline.ini\", ] )\nPARAMS = P.PARAMS\n#PARAMS_ANNOTATIONS = P.peekParameters( PARAMS[\"geneset_dir\"],\"pipeline_annotations.py\" )\n\n###################################################\n################################################### \n###################################################\n## Parse transcripts from GTF file\n \n###################################################\n \n###################################################\n\n###################################################\n \n###################################################\n \n###################################################\n\n###################################################\n \n###################################################\n################################################### \n###################################################\n## Non-coding\n \n###################################################\n \n###################################################\n \n###################################################\n\n###################################################\n###################################################\n###################################################\n## Load transcript_info table to database\n\n###################################################\n\n###################################################\n \n###################################################\n \n###################################################\n###################################################\n###################################################\n## create input files for CAPseq interval annotation pipeline\n\n###################################################\n\n###################################################\n\n###################################################\n\n###################################################\n\n###################################################\n\n############################################################\n############################################################\n############################################################\n## TRANSCRIPTION START SITES\n\n###################################################\n \n###################################################\n \n###################################################\n \n###################################################\n \n###################################################\n\n############################################################\n############################################################\n############################################################\n## Copy relevant files from Ensembl build\n\n############################################################\n \n############################################################\n \n############################################################\n############################################################\n############################################################\n\n \n\n \n\n\n\n\n\nif __name__== \"__main__\":\n sys.exit( P.main(sys.argv) )\n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@transform( \"*.txt\", regex(r\"(\\S+).txt\"), r\"\\1.gtf\" )\ndef convertTxtToGtf( infile, outfile ):\n '''Convert txt to Gtf'''\n track = P.snip( os.path.basename(infile), \".txt\" )\n statement = '''cat %(infile)s \n | awk 'OFS=\"\\\\t\" {print \"chr\"$3,\"rnaseq\",\"exon\",$4,$5,0,substr($6,0,1),\".\",\"transcript_id \\\\\"\"$1\"\\\\\"; gene_id \\\\\"\"$1\"\\\\\"; exon_number \\\\\"\"substr($2,20,2)\"\\\\\"; \"}' \n | sed s/0\\\\\\\\t1\\\\\\\\t\\./0\\\\\\\\t+\\\\\\\\t\\./g | sed s/chrUltra/Ultra/ | sed s/chrContig/Contig/ > %(outfile)s'''\n P.run()", "metadata": "root.convertTxtToGtf", "header": "['module', '___EOS___']", "index": 142 }, { "content": "@transform( convertTxtToGtf, regex(r\"(\\S+).gtf\"), r\"\\1.transcripts.gtf\" )\ndef getGtfStrandedTranscripts( infile, outfile ):\n '''join exons to get transcripts from GTF file'''\n track = P.snip( os.path.basename(infile), \".gtf\" )\n statement = '''cat %(infile)s | python %(scriptsdir)s/gtf2gtf.py --join-exons | sort -k1,1 -k4,4n > %(outfile)s'''\n P.run()", "metadata": "root.getGtfStrandedTranscripts", "header": "['module', '___EOS___']", "index": 152 }, { "content": "@transform( getGtfStrandedTranscripts, suffix(\".gtf\"), \".coding.gtf\")\ndef getEnsemblCodingGeneset( infile, outfile ):\n '''identify transcrpts that overlap an ensembl coding gene '''\n ensembl_genes = PARAMS[\"ensembl_genes\"]\n ensembl_noncoding = PARAMS[\"ensembl_noncoding\"]\n # need to remove transcripts that overlap 100% with noncoding transcripts\n statement = '''cat %(infile)s | intersectBed -a stdin -b %(ensembl_genes)s -u -s \n | intersectBed -a stdin -b %(ensembl_noncoding)s -v -s -f 1 -r\n | sort -k1,1 -k4,4n > %(outfile)s;\n echo \"transcripts with ensembl coding overlap: \" > %(outfile)s.count; \n cat %(outfile)s | wc -l >> %(outfile)s.count;'''\n P.run()", "metadata": "root.getEnsemblCodingGeneset", "header": "['module', '___EOS___']", "index": 160 }, { "content": "@transform( getEnsemblCodingGeneset, suffix(\".gtf\"), \".rename.gtf\")\ndef renameTranscripts( infile, outfile ):\n '''systematically rename transcripts to remove duplicate cuffdiff names '''\n statement = '''cat %(infile)s | awk 'OFS=\"\\\\t\" {print $1,$2,$3,$4,$5,$6,$7,$8,\"transcript_id \\\\\"rnaseq_coding_transcript_\"NR\"\\\\\"; \"}' > %(outfile)s;'''\n P.run()", "metadata": "root.renameTranscripts", "header": "['module', '___EOS___']", "index": 174 }, { "content": "@transform(renameTranscripts, suffix(\".gtf\"), \".ensg.gtf\" )\ndef annotateTranscripts( infile, outfile ):\n ''' Add ensembl gene id to GTF file'''\n ensembl_genes = PARAMS[\"ensembl_genes\"]\n statement = '''cat %(infile)s \n | intersectBed -a stdin -b %(ensembl_genes)s -wa -wb -s \n | awk -F \"\\\\t\" 'OFS=\"\\\\t\" {print $1,$2,$3,$4,$5,$6,$7,$8,\"gene_id \\\\\"\"$13\"\\\\\"; \"$9}'\n | sort -k1,1 -k4,4n > %(outfile)s;'''\n P.run()", "metadata": "root.annotateTranscripts", "header": "['module', '___EOS___']", "index": 181 }, { "content": "@transform(annotateTranscripts, regex(r\"(\\S+).ensg.gtf\"), r\"all_transcripts.gtf\" )\ndef addMissingEnsemblTranscripts( infile, outfile ):\n ''' Add ensembl gene id to GTF file'''\n ensembl_transcripts = PARAMS[\"ensembl_transcripts_gtf\"]\n statement = '''cat %(infile)s \n | intersectBed -a %(ensembl_transcripts)s -b stdin -v -s -f 1 -r > missing_ensembl_transcripts.gtf;\n cat %(infile)s missing_ensembl_transcripts.gtf | sort -k1,1 -k4,4n\n > %(outfile)s;'''\n P.run()", "metadata": "root.addMissingEnsemblTranscripts", "header": "['module', '___EOS___']", "index": 192 }, { "content": "@follows( mkdir(\"geneset\") )\n@transform( addMissingEnsemblTranscripts, regex(r\"all_transcripts.gtf\"), \"geneset/transcripts.gtf.gz\" )\ndef renameTranscriptToExon( infile, outfile ):\n '''reformat transcript file for use in proj007 pipeline '''\n statement = \"\"\"cat %(infile)s | sed s/\\\\\\\\ttranscript\\\\\\\\t/\\\\\\\\texon\\\\\\\\t/g\n | gzip > %(outfile)s; \"\"\"\n P.run()", "metadata": "root.renameTranscriptToExon", "header": "['module', '___EOS___']", "index": 203 }, { "content": "@transform( getGtfStrandedTranscripts, suffix(\".gtf\"), \".noncoding.gtf\")\ndef getNoncodingGeneset( infile, outfile ):\n '''Assume that all transcripts the do not overlap with ensembl coding geneset are noncoding '''\n ensembl_transcripts = PARAMS[\"ensembl_transcripts\"]\n statement = '''cat %(infile)s | intersectBed -a stdin -b %(ensembl_transcripts)s -v -s > %(outfile)s;\n echo \"transcripts without ensembl coding overlap: \" > %(outfile)s.count; \n cat %(outfile)s | wc -l >> %(outfile)s.count;'''\n P.run()", "metadata": "root.getNoncodingGeneset", "header": "['module', '___EOS___']", "index": 215 }, { "content": "@transform( getNoncodingGeneset, suffix(\".gtf\"), \".rename.gtf\")\ndef renameNoncodingTranscripts( infile, outfile ):\n '''systematically rename transcripts to remove duplicate cuffdiff names '''\n statement = '''cat %(infile)s | awk 'OFS=\"\\\\t\" {print $1,$2,$3,$4,$5,$6,$7,$8,\"transcript_id \\\\\"rnaseq_noncoding_transcript_\"NR\"\\\\\"; \"}' > %(outfile)s;'''\n P.run()", "metadata": "root.renameNoncodingTranscripts", "header": "['module', '___EOS___']", "index": 225 }, { "content": "@transform(renameNoncodingTranscripts, suffix(\".gtf\"), \".ensg.gtf\" )\ndef annotateNoncodingTranscripts( infile, outfile ):\n ''' Add ensembl gene id to GTF file'''\n ensembl_noncoding = PARAMS[\"ensembl_noncoding_genes\"]\n statement = '''intersectBed -a %(infile)s -b %(ensembl_noncoding)s -wa -wb -s \n | awk -F \"\\\\t\" 'OFS=\"\\\\t\" {print $1,$2,$3,$4,$5,$6,$7,$8,\"gene_id \\\\\"\"$13\"\\\\\"; \"$9}' > known_noncoding_exons.gtf; \n intersectBed -a %(infile)s -b %(ensembl_noncoding)s -v -s\n | awk -F \"\\\\t\" 'OFS=\"\\\\t\" {print $1,$2,$3,$4,$5,$6,$7,$8,\"gene_id \\\\\"novel_gene_\"NR\"\\\\\"; \"$9}' > novel_noncoding_transcripts.gtf; \n cat known_noncoding_exons.gtf novel_noncoding_transcripts.gtf | sort -k1,1 -k4,4n\n > %(outfile)s;'''\n P.run()", "metadata": "root.annotateNoncodingTranscripts", "header": "['module', '___EOS___']", "index": 232 }, { "content": "@transform(annotateNoncodingTranscripts, regex(r\"(\\S+).ensg.gtf\"), r\"all_noncoding_transcripts.gtf\" )\ndef addMissingNoncodingTranscripts( infile, outfile ):\n ''' Add ensembl gene id to GTF file'''\n ensembl_noncoding = PARAMS[\"ensembl_noncoding_gtf\"]\n statement = '''intersectBed -a %(ensembl_noncoding)s -b %(infile)s -v -s -f 1 -r > missing_ensembl_noncoding_transcripts.gtf;\n cat %(infile)s missing_ensembl_noncoding_transcripts.gtf | sort -k1,1 -k4,4n\n > %(outfile)s;'''\n P.run()", "metadata": "root.addMissingNoncodingTranscripts", "header": "['module', '___EOS___']", "index": 245 }, { "content": "@transform( addMissingEnsemblTranscripts, suffix(\".gtf\"), \".tab\" )\ndef transcriptGtfToTab( infile, outfile ):\n '''Copy replicated Bed files generated by capseq pipline to geneset-specific output directory'''\n statement = '''cat %(infile)s | python %(scriptsdir)s/gtf2tsv.py -f --log=%(outfile)s.log | awk '{if (NR==1) {print $0\"\\\\tgene_biotype\\\\tgene_name\"} else {print $0\"\\\\tprotein_coding\\\\tunknown\"}}' > %(outfile)s'''\n P.run()", "metadata": "root.transcriptGtfToTab", "header": "['module', '___EOS___']", "index": 258 }, { "content": "@transform( addMissingNoncodingTranscripts, suffix(\".gtf\"), \".tab\" )\ndef noncodingGtfToTab( infile, outfile ):\n '''Copy replicated Bed files generated by capseq pipline to geneset-specific output directory'''\n statement = '''cat %(infile)s | python %(scriptsdir)s/gtf2tsv.py -f --log=%(outfile)s.log | awk '{if (NR==1) {print $0\"\\\\tgene_biotype\\\\tgene_name\"} else {print $0\"\\\\tnoncoding\\\\tunknown\"}}' > %(outfile)s'''\n P.run()", "metadata": "root.noncodingGtfToTab", "header": "['module', '___EOS___']", "index": 265 }, { "content": "@follows(transcriptGtfToTab, noncodingGtfToTab)\n@merge( \"*.tab\", \"transcript_info.tab\" )\ndef mergeTranscriptInfo( infiles, outfile ):\n '''Copy replicated Bed files generated by capseq pipline to geneset-specific output directory'''\n inlist = \" \".join(infiles)\n statement = '''cat %(inlist)s | awk '{if (NR==1 || $1 != \"contig\") {print $0}}' > %(outfile)s'''\n P.run()", "metadata": "root.mergeTranscriptInfo", "header": "['module', '___EOS___']", "index": 272 }, { "content": "@transform( mergeTranscriptInfo, suffix(\".tab\"), \".tab.load\" )\ndef loadTranscripts( infile, outfile ):\n '''load GTF file into database '''\n headers = \"contig,source,feature,start,end,score,strand,frame,gene_id,transcript_id,gene_biotype\"\n statement = \"\"\"cat %(infile)s | python ~/src/csv2db.py \n --database=%(database)s\n --table=transcript_info\n --index=gene_id\n --index=contig,start\n --index=transcript_id\n > %(outfile)s; \"\"\"\n P.run()", "metadata": "root.loadTranscripts", "header": "['module', '___EOS___']", "index": 281 }, { "content": "@follows( mkdir(\"geneset\") )\n@transform(getEnsemblCodingGeneset, regex(r\"(\\S+).coding.gtf\"), r\"geneset/\\1.genes.bed\" )\ndef buildGeneIntervals( infile, outfile ):\n ''' Merge all transcripts per gene (including utr) to get start and stop \n coordinates for every protein-coding gene and store in a GTF file'''\n ensembl_genes = PARAMS[\"ensembl_genes_gtf\"]\n statement = '''cat %(ensembl_genes)s %(infile)s | mergeBed -i stdin -s -n \n | awk 'OFS=\"\\\\t\" {print $1,$2,$3,\"gene\"NR,$4,$5 }'\n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log\n | sort -k1,1 -k2,2n > %(outfile)s;'''\n P.run()", "metadata": "root.buildGeneIntervals", "header": "['module', '___EOS___']", "index": 298 }, { "content": "@transform(buildGeneIntervals, regex(r\"geneset/(\\S+).genes.bed\"), r\"geneset/genes.bed\" )\ndef annotateGeneIntervals( infile, outfile ):\n ''' Add ensembl gene id to GTF file'''\n ensembl_genes = PARAMS[\"ensembl_genes\"]\n statement = '''cat %(infile)s \n | intersectBed -a stdin -b %(ensembl_genes)s -wa -wb -s \n | awk 'OFS=\"\\\\t\" {print $1,$2,$3,$10,$5,$6}' \n | sort -k1,1 -k2,2n > %(outfile)s;'''\n P.run()", "metadata": "root.annotateGeneIntervals", "header": "['module', '___EOS___']", "index": 311 }, { "content": "@transform(annotateGeneIntervals, regex(PARAMS['interface_genic_bed']), PARAMS['interface_upstream_flank_bed'] )\ndef buildUpstreamFlankBed( infile, outfile ):\n ''' build interval upstream of gene start for each entry in bed file'''\n window=PARAMS[\"geneset_flank\"]\n faidx=PARAMS[\"faidx\"]\n statement = '''flankBed -i %(infile)s -g %(faidx)s -l %(window)s -r 0 -s \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log > %(outfile)s'''\n P.run()", "metadata": "root.buildUpstreamFlankBed", "header": "['module', '___EOS___']", "index": 322 }, { "content": "@transform(annotateGeneIntervals, regex(PARAMS['interface_genic_bed']), PARAMS['interface_downstream_flank_bed'] )\ndef buildDownstreamFlankBed( infile, outfile ):\n ''' build interval downstream of gene start for each entry in bed file'''\n window=PARAMS[\"geneset_flank\"]\n faidx=PARAMS[\"faidx\"]\n statement = '''flankBed -i %(infile)s -g %(faidx)s -l 0 -r %(window)s -s \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log > %(outfile)s'''\n P.run()", "metadata": "root.buildDownstreamFlankBed", "header": "['module', '___EOS___']", "index": 332 }, { "content": "@merge((annotateGeneIntervals, buildUpstreamFlankBed, buildDownstreamFlankBed), os.path.join(\"geneset\",PARAMS['interface_intergenic_bed']) )\ndef buildIntergenicBed( infiles, outfile ):\n ''' Genomic regions not associated with any other features'''\n inlist = \" \".join(infiles)\n statement = '''cat %(inlist)s | complementBed -i stdin -g %(faidx)s \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log > %(outfile)s'''\n P.run()", "metadata": "root.buildIntergenicBed", "header": "['module', '___EOS___']", "index": 342 }, { "content": "@transform((annotateGeneIntervals,buildUpstreamFlankBed,buildDownstreamFlankBed,buildIntergenicBed), suffix(\".bed\"), \".gtf\" )\ndef convertBedToGtf( infile, outfile ):\n ''' convert bed files to GTF'''\n statement = '''cat %(infile)s | python %(scriptsdir)s/bed2gff.py --as-gtf | grep -v \"#\" > %(outfile)s'''\n P.run()", "metadata": "root.convertBedToGtf", "header": "['module', '___EOS___']", "index": 351 }, { "content": "@transform(addMissingEnsemblTranscripts, regex(r\"all_transcripts.gtf\"), os.path.join(\"geneset\",PARAMS[\"interface_tss_bed\"]) )\ndef buildTranscriptTSS( infile, outfile ):\n '''annotate transcription start sites from reference gene set.\n Similar to promotors, except that the witdth is set to 1. '''\n statement = \"\"\"\n cat < %(infile)s \n | python %(scriptsdir)s/gff2gff.py --sanitize=genome --skip-missing --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gtf2gff.py --method=promotors --promotor=1 --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gff2bed.py --is-gtf --name=transcript_id --log=%(outfile)s.log \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log\n | gzip\n > %(outfile)s \"\"\"\n P.run()", "metadata": "root.buildTranscriptTSS", "header": "['module', '___EOS___']", "index": 361 }, { "content": "@follows( convertBedToGtf )\n@files( \"geneset/genes.gtf\", os.path.join(\"geneset\", PARAMS[\"interface_tss_gene_bed\"]) )\ndef buildGeneTSS( infile, outfile ):\n '''create a single TSS for each gene'''\n statement = \"\"\"\n cat %(infile)s \n | python %(scriptsdir)s/gff2gff.py --sanitize=genome --skip-missing --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gtf2gff.py --method=promotors --promotor=1 --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gff2bed.py --is-gtf --name=gene_id --log=%(outfile)s.log \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log\n | gzip\n > %(outfile)s \"\"\"\n P.run()", "metadata": "root.buildGeneTSS", "header": "['module', '___EOS___']", "index": 376 }, { "content": "@transform( addMissingEnsemblTranscripts, regex(r\"all_transcripts.gtf\"), os.path.join(\"geneset\",PARAMS[\"interface_tss_gene_interval_bed\"]) )\ndef buildGeneTSSInterval( infile, outfile ):\n '''create a single interval that encompasses all annotated TSSs for a given gene'''\n statement = \"\"\"\n cat < %(infile)s \n | python %(scriptsdir)s/gff2gff.py --sanitize=genome --skip-missing --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gtf2gff.py --method=promotors --promotor=1 --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | sed s/\\\\\\\\ttranscript\\\\\\\\t/\\\\\\\\texon\\\\\\\\t/g \n | python %(scriptsdir)s/gtf2gtf.py --merge-transcripts --log=%(outfile)s.log \n | python %(scriptsdir)s/gff2bed.py --is-gtf --name=transcript_id --log=%(outfile)s.log \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log\n | gzip\n > %(outfile)s \"\"\"\n P.run()", "metadata": "root.buildGeneTSSInterval", "header": "['module', '___EOS___']", "index": 391 }, { "content": "@transform( addMissingNoncodingTranscripts, regex(r\"(\\S+).gtf\"), os.path.join(\"geneset\",PARAMS[\"interface_tss_gene_noncoding_bed\"]) )\ndef buildNoncodingGeneTSS( infile, outfile ):\n '''Assign a TSS for each non-coding gene'''\n statement = \"\"\"\n cat < %(infile)s \n | python %(scriptsdir)s/gff2gff.py --sanitize=genome --skip-missing --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gtf2gff.py --method=promotors --promotor=1 --genome-file=%(genome_dir)s/%(genome)s --log=%(outfile)s.log \n | python %(scriptsdir)s/gff2bed.py --is-gtf --name=gene_id --log=%(outfile)s.log \n | python %(scriptsdir)s/bed2bed.py --method=filter-genome --genome-file=%(genome_dir)s/%(genome)s --log %(outfile)s.log\n | gzip\n > %(outfile)s \"\"\"\n P.run()", "metadata": "root.buildNoncodingGeneTSS", "header": "['module', '___EOS___']", "index": 407 }, { "content": "@transform( (buildTranscriptTSS, buildGeneTSS, buildGeneTSSInterval, buildNoncodingGeneTSS), suffix(\".bed.gz\"), \".extended.bed.gz\" )\ndef ExtendRegion( infile, outfile ):\n '''convert bed to gtf'''\n statement = \"\"\"gunzip < %(infile)s \n | slopBed -i stdin -g %(faidx)s -b 1000 \n | gzip\n > %(outfile)s \"\"\"\n P.run()", "metadata": "root.ExtendRegion", "header": "['module', '___EOS___']", "index": 421 }, { "content": "@transform( (buildTranscriptTSS, buildGeneTSS, buildGeneTSSInterval, buildNoncodingGeneTSS, ExtendRegion), suffix(\".bed.gz\"), \".gtf\" )\ndef convertToGTF( infile, outfile ):\n '''convert bed to gtf'''\n statement = \"\"\"gunzip < %(infile)s \n | python %(scriptsdir)s/bed2gff.py --as-gtf --log=%(outfile)s.log \n > %(outfile)s \"\"\"\n P.run()", "metadata": "root.convertToGTF", "header": "['module', '___EOS___']", "index": 431 }, { "content": "@files( \"pipeline.ini\", \"ensembl.copy.log\" )\ndef copyEnsembl( infile, outfile ):\n '''convert bed to gtf'''\n ensembl_dir = PARAMS[\"ensembl_dir\"]\n statement = \"\"\"cp %(ensembl_dir)s/repeats.gtf geneset/ 2> %(outfile)s;\n cp %(ensembl_dir)s/go.tsv.gz geneset/ 2> %(outfile)s;\n cp %(ensembl_dir)s/goslim.tsv.gz geneset/ 2> %(outfile)s;\n cp %(ensembl_dir)s/go_ontology.obo geneset/ 2> %(outfile)s;\n cp %(ensembl_dir)s/goslim.obo geneset/ 2> %(outfile)s;\"\"\"\n P.run()", "metadata": "root.copyEnsembl", "header": "['module', '___EOS___']", "index": 443 }, { "content": "@files( \"pipeline.ini\", \"ensembldb.copy.log\" )\ndef copyEnsemblDb( infile, outfile ):\n '''copy tables from ensembl database to rnaseq database'''\n table_list = P.asList(PARAMS[\"ensembl_tables\"])\n dbhandle = sqlite3.connect( PARAMS[\"database\"] )\n cc = dbhandle.cursor()\n query = \"\"\"ATTACH \"%s\" as ensembl;\"\"\" % PARAMS[\"ensembl_db\"]\n cc.execute( query )\n for table in table_list:\n cc = dbhandle.cursor()\n query = \"\"\"CREATE TABLE %s AS SELECT * FROM ensembl.%s;\"\"\" % (table, table)\n print query\n cc.execute( query )\n cc.close()\n statement = \"\"\"touch %(outfile)s;\"\"\"\n P.run()", "metadata": "root.copyEnsemblDb", "header": "['module', '___EOS___']", "index": 455 }, { "content": "@transform( loadTranscripts, regex(r\"(\\S+).load\"), \"gene_name.update.log\" )\ndef updateGeneName( infile, outfile ):\n '''update gene name from ensembl database'''\n dbhandle = sqlite3.connect( PARAMS[\"database\"] )\n cc = dbhandle.cursor()\n query = \"\"\"ATTACH \"%s\" as ensembl;\"\"\" % PARAMS[\"ensembl_db\"]\n cc.execute( query )\n query = \"\"\"UPDATE transcript_info SET gene_name=\n (SELECT gene_name from ensembl.transcript_info \n WHERE transcript_info.gene_id=ensembl.transcript_info.gene_id);\"\"\"\n print query\n cc.execute( query )\n cc.close()\n statement = \"\"\"touch %(outfile)s;\"\"\"\n P.run()", "metadata": "root.updateGeneName", "header": "['module', '___EOS___']", "index": 473 }, { "content": "@follows( convertTxtToGtf, getGtfStrandedTranscripts,\n getEnsemblCodingGeneset, renameTranscripts, annotateTranscripts,\n addMissingEnsemblTranscripts, renameTranscriptToExon )\ndef transcripts():\n '''build all targets.'''\n pass", "metadata": "root.transcripts", "header": "['module', '___EOS___']", "index": 493 }, { "content": "@follows( getNoncodingGeneset, renameNoncodingTranscripts,\n annotateNoncodingTranscripts, addMissingNoncodingTranscripts )\ndef noncoding():\n '''build all targets.'''\n pass", "metadata": "root.noncoding", "header": "['module', '___EOS___']", "index": 500 }, { "content": "@follows( transcriptGtfToTab, noncodingGtfToTab, mergeTranscriptInfo, loadTranscripts )\ndef loadTranscriptInfo():\n '''build all targets.'''\n pass", "metadata": "root.loadTranscriptInfo", "header": "['module', '___EOS___']", "index": 506 }, { "content": "@follows( buildGeneIntervals, annotateGeneIntervals, buildUpstreamFlankBed,\n buildDownstreamFlankBed, buildIntergenicBed, convertBedToGtf )\ndef genes():\n '''build all targets.'''\n pass ", "metadata": "root.genes", "header": "['module', '___EOS___']", "index": 511 }, { "content": "@follows( buildTranscriptTSS, buildGeneTSS, buildNoncodingGeneTSS,\n ExtendRegion, convertToGTF )\ndef tss():\n '''build all targets.'''\n pass ", "metadata": "root.tss", "header": "['module', '___EOS___']", "index": 517 }, { "content": "@follows( copyEnsembl, copyEnsemblDb, updateGeneName )\ndef ensembl():\n '''build all targets.'''\n pass ", "metadata": "root.ensembl", "header": "['module', '___EOS___']", "index": 523 }, { "content": "@follows( transcripts, noncoding, loadTranscriptInfo, genes, tss, ensembl )\ndef full():\n '''build all targets.'''\n pass ", "metadata": "root.full", "header": "['module', '___EOS___']", "index": 528 } ]
[ { "span": "import tempfile", "start_line": 94, "start_column": 0, "end_line": 94, "end_column": 15 }, { "span": "import optparse", "start_line": 95, "start_column": 0, "end_line": 95, "end_column": 15 }, { "span": "import shutil", "start_line": 96, "start_column": 0, "end_line": 96, "end_column": 13 }, { "span": "import itertools", "start_line": 97, "start_column": 0, "end_line": 97, "end_column": 16 }, { "span": "import csv", "start_line": 98, "start_column": 0, "end_line": 98, "end_column": 10 }, { "span": "import math", "start_line": 99, "start_column": 0, "end_line": 99, "end_column": 11 }, { "span": "import random", "start_line": 100, "start_column": 0, "end_line": 100, "end_column": 13 }, { "span": "import re", "start_line": 101, "start_column": 0, "end_line": 101, "end_column": 9 }, { "span": "import glob", "start_line": 102, "start_column": 0, "end_line": 102, "end_column": 11 }, { "span": "import shutil", "start_line": 104, "start_column": 0, "end_line": 104, "end_column": 13 }, { "span": "import collections", "start_line": 105, "start_column": 0, "end_line": 105, "end_column": 18 }, { "span": "import gzip", "start_line": 106, "start_column": 0, "end_line": 106, "end_column": 11 }, { "span": "import pysam", "start_line": 108, "start_column": 0, "end_line": 108, "end_column": 12 }, { "span": "import CGAT.IndexedFasta as IndexedFasta", "start_line": 109, "start_column": 0, "end_line": 109, "end_column": 40 }, { "span": "import CGAT.IndexedGenome as IndexedGenome", "start_line": 110, "start_column": 0, "end_line": 110, "end_column": 42 }, { "span": "import CGAT.FastaIterator as FastaIterator", "start_line": 111, "start_column": 0, "end_line": 111, "end_column": 42 }, { "span": "import CGAT.Genomics as Genomics", "start_line": 112, "start_column": 0, "end_line": 112, "end_column": 32 }, { "span": "import CGAT.IOTools as IOTools", "start_line": 113, "start_column": 0, "end_line": 113, "end_column": 30 }, { "span": "import CGAT.MAST as MAST", "start_line": 114, "start_column": 0, "end_line": 114, "end_column": 24 }, { "span": "import CGAT.GTF as GTF", "start_line": 115, "start_column": 0, "end_line": 115, "end_column": 22 }, { "span": "import CGAT.GFF as GFF", "start_line": 116, "start_column": 0, "end_line": 116, "end_column": 22 }, { "span": "import CGAT.Bed as Bed", "start_line": 117, "start_column": 0, "end_line": 117, "end_column": 22 }, { "span": "import cStringIO", "start_line": 118, "start_column": 0, "end_line": 118, "end_column": 16 }, { "span": "import numpy", "start_line": 119, "start_column": 0, "end_line": 119, "end_column": 12 }, { "span": "import CGAT.Masker as Masker", "start_line": 120, "start_column": 0, "end_line": 120, "end_column": 28 }, { "span": "import fileinput", "start_line": 121, "start_column": 0, "end_line": 121, "end_column": 16 }, { "span": "import CGAT.Experiment as E", "start_line": 122, "start_column": 0, "end_line": 122, "end_column": 27 }, { "span": "import logging as L", "start_line": 123, "start_column": 0, "end_line": 123, "end_column": 19 } ]
[]
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_", "#", " ", " ", " ", "MR", "C", " ", "FG", "U", " ", "Computation", "al", " ", "Geno", "mic", "s", " ", "Group_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "$", "Id", ":", " ", "pipeline", "\\u", "rna", "seq", "\\u", "gene", "set", ".", "py", " ", "290", "0", " ", "2012", "-0", "3", "-", "3", "8", " ", "14", ":", "3", "8", ":", "00", "Z", " ", "davi", "d", " ", "$", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Copy", "right", " ", "(", "C", ")", " ", "2012", " ", "Dav", "id", " ", "Sim", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Thi", "s", " ", "program", " ", "is", " ", "free", " ", "software", ";", " ", "you", " ", "can", " ", "redis", "tribut", "e", " ", "it", " ", "and", "/", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "modif", "y", " ", "it", " ", "under", " ", "the", " ", "term", "s", " ", "of", " ", "the", " ", "GN", "U", " ", "General", " ", "Public", " ", "License", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "as", " ", "publi", "shed", " ", "by", " ", "the", " ", "Free", " ", "Sof", "twa", "re", " ", "Foun", "dati", "on", ";", " ", "eit", "her", " ", "version", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "of", " ", "the", " ", "License", ",", " ", "or", " ", "(", "at", " ", "your", " ", "option", ")", " ", "any", " ", "late", "r", " ", "version", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Thi", "s", " ", "program", " ", "is", " ", "distributed", " ", "in", " ", "the", " ", "hop", "e", " ", "tha", "t", " ", "it", " ", "will", " ", "be", " ", "usef", "ul", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "but", " ", "WITH", "OUT", " ", "ANY", " ", "WAR", "RAN", "TY", ";", " ", "with", "out", " ", "even", " ", "the", " ", "impli", "ed", " ", "warr", "ant", "y", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "MER", "CHAN", "TAB", "ILI", "TY", " ", "or", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", ".", " ", " ", "See", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "GN", "U", " ", "General", " ", "Public", " ", "License", " ", "for", " ", "more", " ", "deta", "il", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "You", " ", "shou", "ld", " ", "have", " ", "receive", "d", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "GN", "U", " ", "General", " ", "Public", " ", "License", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "along", " ", "with", " ", "this", " ", "program", ";", " ", "if", " ", "not", ",", " ", "write", " ", "to", " ", "the", " ", "Free", " ", "Sof", "twa", "re_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Foun", "dati", "on", ",", " ", "Inc", ".,", " ", "5", "9", " ", "Temp", "le", " ", "Place", " ", "-", " ", "Suit", "e", " ", "330", ",", " ", "Bo", "ston", ",", " ", "MA", " ", " ", "0211", "1", "-1", "307", ",", " ", "USA", "._", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "==============", "=========", "=", "\\", "10", ";", "RNA", "seq", " ", "Genes", "et", " ", "Pipe", "line", "\\", "10", ";", "==============", "=========", "=", "\\", "10", ";", "\\", "10", ";", ":", "Author", ":", " ", "Dav", "id", " ", "Sim", "s", " ", "\\", "10", ";", ":", "Release", ":", " ", "$", "Id", ":", " ", "pipeline", "\\u", "rna", "seq", "\\u", "gene", "sst", ".", "py", " ", "290", "0", " ", "2012", "-0", "3", "-", "2", "8", " ", "14", ":", "3", "8", ":", "00", "Z", " ", "davi", "d", " ", "$", "\\", "10", ";", ":", "Date", ":", " ", "|", "toda", "y", "|", "\\", "10", ";", ":", "Ta", "gs", ":", " ", "Pyth", "on", "\\", "10", ";", "\\", "10", ";", "The", " ", "RNA", "seq", " ", "gene", "set", " ", "pipeline", " ", "parse", "s", " ", "multiple", " ", "GT", "F", " ", "files", " ", "derive", "d", " ", "from", " ", "RNA", "seq", " ", "experiment", "s", " ", "in", " ", "different", " ", "tissue", "s", " ", "and", " ", "produce", "s", " ", "a", " ", "consensus", " ", "gene", "set", "\\", "10", ";", "\\", "10", ";", "Us", "age", "\\", "10", ";", "=====", "\\", "10", ";", "\\", "10", ";", "See", " ", ":", "ref", ":`", "Pipe", "line", "Sett", "ing", "Up", "`", " ", "and", " ", ":", "ref", ":`", "Pipe", "line", "Run", "ning", "`", " ", "on", " ", "genera", "l", " ", "informati", "on", " ", "how", " ", "to", " ", "use", " ", "CGA", "T", " ", "pipeline", "s", ".", "\\", "10", ";", "\\", "10", ";", "Configura", "tion", "\\", "10", ";", "-------------", "\\", "10", ";", "\\", "10", ";", "The", " ", "pipeline", " ", "require", "s", " ", "a", " ", "configur", "ed", " ", ":", "file", ":`", "pipeline", ".", "ini", "`", " ", "file", ".", " ", "\\", "10", ";", "\\", "10", ";", "Configura", "tion", " ", "files", " ", "follow", " ", "the", " ", "ini", " ", "format", " ", "(", "see", " ", "the", " ", "python", "\\", "10", ";", "`", "Config", "Parser", " ", "<", "http", "://", "docs", ".", "python", ".", "org", "/", "librar", "y", "/", "config", "parser", ".", "html", ">`", " ", "documentation", ").", "\\", "10", ";", "The", " ", "configura", "tion", " ", "file", " ", "is", " ", "organize", "d", " ", "by", " ", "section", " ", "and", " ", "the", " ", "variab", "les", " ", "are", " ", "documente", "d", " ", "within", " ", "\\", "10", ";", "the", " ", "file", ".", " ", "In", " ", "order", " ", "to", " ", "get", " ", "a", " ", "local", " ", "configura", "tion", " ", "file", " ", "in", " ", "the", " ", "current", " ", "director", "y", ",", " ", "type", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "python", " ", "<", "code", "dir", ">/", "pipeline", "\\u", "rna", "seq", "\\u", "gene", "st", ".", "py", " ", "config", "\\", "10", ";", "\\", "10", ";", "The", " ", "sphinx", "report", " ", "report", " ", "require", "s", " ", "a", " ", ":", "file", ":`", "conf", ".", "py", "`", " ", "and", " ", ":", "file", ":`", "sphinx", "report", ".", "ini", "`", " ", "file", " ", "\\", "10", ";", "(", "see", " ", ":", "ref", ":`", "Pipe", "line", "Doc", "ume", "nati", "on", "`)", ".", " ", "To", " ", "start", " ", "with", ",", " ", "use", " ", "the", " ", "files", " ", "supplie", "d", " ", "with", " ", "the", "\\", "10", ";", ":", "ref", ":`", "Exam", "ple", "`", " ", "data", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Inp", "ut", "\\", "10", ";", "-----", "\\", "10", ";", "\\", "10", ";", "Inp", "ut", " ", "are", " ", "GT", "F", "-", "format", "ted", " ", "files", ".", " ", "\\", "10", ";", "\\", "10", ";", "Requirements", "\\", "10", ";", "------------", "\\", "10", ";", "\\", "10", ";", "The", " ", "pipeline", " ", "require", "s", " ", "the", " ", "informati", "on", " ", "from", " ", "the", " ", "follow", "ing", " ", "pipeline", "s", ":", "\\", "10", ";", "\\", "10", ";", ":", "doc", ":`", "pipeline", "\\u", "annot", "ation", "s", "`", "\\", "10", ";", "\\", "10", ";", "set", " ", "the", " ", "configura", "tion", " ", "variab", "les", ":", "\\", "10", ";", " ", " ", " ", ":", "py", ":", "data", ":`", "annotations\\u", "databa", "se", "`", " ", "\\", "10", ";", " ", " ", " ", ":", "py", ":", "data", ":`", "annotations\\u", "dir", "`", "\\", "10", ";", "\\", "10", ";", "On", " ", "top", " ", "of", " ", "the", " ", "default", " ", "CGA", "T", " ", "setup", ",", " ", "the", " ", "pipeline", " ", "require", "s", " ", "the", " ", "follow", "ing", " ", "software", " ", "to", " ", "be", " ", "in", " ", "the", " ", "\\", "10", ";", "path", ":", "\\", "10", ";", "\\", "10", ";", "+----------", "----------", "+----------", "---------", "+----------", "--------------", "--------------", "----------", "+", "\\", "10", ";", "|", "*", "Program", "*", " ", " ", " ", "|", "*", "Version", "*", " ", " ", "|", "*", "Pur", "pose", "*", " ", " ", " ", "|", "\\", "10", ";", "+----------", "----------", "+----------", "---------", "+----------", "--------------", "--------------", "----------", "+", "\\", "10", ";", "|", "BED", "Tool", "s", " ", " ", " ", " ", "|", " ", "|", "interval", " ", "compa", "ris", "on", " ", " ", " ", "|", "\\", "10", ";", "+----------", "----------", "+----------", "---------", "+----------", "--------------", "--------------", "----------", "+", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Pi", "plin", "e", " ", "Output", "\\", "10", ";", "==============", "\\", "10", ";", "\\", "10", ";", "The", " ", "results", " ", "of", " ", "the", " ", "computation", " ", "are", " ", "all", " ", "store", "d", " ", "in", " ", "an", " ", "sql", "ite", " ", "relation", "al", "\\", "10", ";", "databa", "se", " ", ":", "file", ":`", "csv", "db", "`.", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Code", "\\", "10", ";", "====", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "optparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "itertools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "csv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "glob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "collections_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gzip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sqlite3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pysam", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Indexe", "d", "Fast", "a_", "as_", "Indexe", "d", "Fast", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Indexe", "d", "Genome", "_", "as_", "Indexe", "d", "Genome", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Fast", "a", "Iterator_", "as_", "Fast", "a", "Iterator_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Geno", "mic", "s_", "as_", "Geno", "mic", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "IO", "Tools_", "as_", "IO", "Tools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "MAS", "T_", "as_", "MAS", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "GT", "F_", "as_", "GT", "F_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "GF", "F_", "as_", "GF", "F_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Bed", "_", "as_", "Bed", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "c", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Mask", "er_", "as_", "Mask", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "fileinput_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "CGA", "T_", "._", "Experiment_", "as_", "E_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "as_", "L_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ru", "ff", "us_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "USE", "CLUSTER", "_", "=_", "True_", "\\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_", "##", " ", "Pipe", "line", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "CGA", "T_", "._", "Pipeline_", "as_", "P_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "get", "Parameters_", "(_", "[_", "\"", "pipeline", ".", "ini", "\"_", ",_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PARAMS_", "=_", "P_", "._", "PARAMS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "PARAM", "S", "\\u", "ANNOTAT", "IONS", " ", "=", " ", "P", ".", "peek", "Parameter", "s", "(", " ", "PARAM", "S", "[\"", "gene", "set\\u", "dir", "\"]", ",\"", "pipeline", "\\u", "annot", "ation", "s", ".", "py", "\"", " ", ")_", "\\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_", "##", " ", "Pars", "e", " ", "transcripts", " ", "from", " ", "GT", "F", " ", "file_", "\\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\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Non", "-", "coding_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Load", " ", "transcri", "pt", "\\u", "info", " ", "table", " ", "to", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "create", " ", "input", " ", "files", " ", "for", " ", "CAP", "seq", " ", "interval", " ", "annot", "ation", " ", "pipeline_", "\\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\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "TRANS", "CRI", "PTION", " ", "START", " ", "SITE", "S_", "\\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\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Copy", " ", "rele", "van", "t", " ", "files", " ", "from", " ", "Ens", "embl", " ", "build_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\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\\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_", "(_", "P_", "._", "main_", "(_", "sys_", "._", "argv_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "transform_", "(_", "\"*", ".", "txt", "\"_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "txt", "\"_", ")_", ",_", "r", "\"\\\\", "1", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "convert", "Txt", "To", "Gt", "f_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Convert", " ", " ", "txt", " ", "to", " ", "Gt", "f", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "track_", "=_", "P_", "._", "snip", "_", "(_", "os_", "._", "path_", "._", "basename_", "(_", "infile_", ")_", ",_", "\".", "txt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "aw", "k", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "\"", "chr", "\"$", "3", ",\"", "rna", "seq", "\",\"", "exon", "\",", "$", "4", ",", "$", "5", ",", "0", ",", "substr", "($", "6", ",", "0", ",", "1", "),", "\".", "\",\"", "transcri", "pt", "\\u", "id", " ", "\\\\\\\\\"", "\"$", "1", "\"\\\\\\\\", "\";", " ", "gene", "\\u", "id", " ", "\\\\\\\\\"", "\"$", "1", "\"\\\\\\\\", "\";", " ", "exon", "\\u", "number", " ", "\\\\\\\\\"", "\"", "substr", "($", "2", ",", "20", ",", "2", ")\"", "\\\\\\\\\"", ";", " ", "\"}", "'", " ", "\\", "10", ";", " ", "|", " ", "sed", " ", "s", "/", "0", "\\\\\\\\\\\\\\\\", "t1", "\\\\\\\\\\\\\\\\", "t", "\\\\.", "/", "0", "\\\\\\\\\\\\\\\\", "t", "+\\\\", "\\\\\\\\\\\\", "t", "\\\\.", "/", "g", " ", "|", " ", "sed", " ", "s", "/", "chr", "Ult", "ra", "/", "Ult", "ra", "/", " ", "|", " ", "sed", " ", "s", "/", "chr", "Conti", "g", "/", "Conti", "g", "/", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "convert", "Txt", "To", "Gt", "f_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "gtf", "\"_", ")_", ",_", "r", "\"\\\\", "1", ".", "transcripts", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "Gt", "f", "Strand", "ed", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "join", " ", "exon", "s", " ", "to", " ", "get", " ", "transcripts", " ", "from", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "track_", "=_", "P_", "._", "snip", "_", "(_", "os_", "._", "path_", "._", "basename_", "(_", "infile_", ")_", ",_", "\".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2g", "tf", ".", "py", " ", "--", "join", "-", "exon", "s", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k", "4", ",", "4", "n", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "get", "Gt", "f", "Strand", "ed", "Transcript", "s_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "codi", "ng", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "Ens", "embl", "Codi", "ng", "Genes", "et_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "identify", " ", "transc", "rpt", "s", " ", "tha", "t", " ", "overl", "ap", " ", "an", " ", "ensembl", " ", "codi", "ng", " ", "gene", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "genes_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "gene", "s", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "nonc", "odi", "ng_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "nonc", "odi", "ng", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "need", " ", "to", " ", "remove", " ", "transcripts", " ", "tha", "t", " ", "overl", "ap", " ", "100", "%", " ", "with", " ", "nonc", "odi", "ng", " ", "transcripts", "_", "\\u\\u\\uNL\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "intersect", "Bed", " ", "-", "a", " ", "std", "in", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "gene", "s", ")", "s", " ", "-", "u", " ", "-", "s", " ", "\\", "10", ";", " ", "|", " ", "intersect", "Bed", " ", "-", "a", " ", "std", "in", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "nonc", "odi", "ng", ")", "s", " ", "-", "v", " ", "-", "s", " ", "-", "f", " ", "1", " ", "-", "r", "\\", "10", ";", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k", "4", ",", "4", "n", " ", ">", " ", "%", "(", "outfile", ")", "s", ";", "\\", "10", ";", " ", "echo", " ", "\"", "transcripts", " ", "with", " ", "ensembl", " ", "codi", "ng", " ", "overl", "ap", ":", " ", "\"", " ", ">", " ", "%", "(", "outfile", ")", "s", ".", "count", ";", " ", "\\", "10", ";", " ", "cat", " ", "%", "(", "outfile", ")", "s", " ", "|", " ", "wc", " ", "-", "l", " ", ">>", " ", "%", "(", "outfile", ")", "s", ".", "count", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "get", "Ens", "embl", "Codi", "ng", "Genes", "et_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "rename", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "rename", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "system", "atic", "ally", " ", "rename", " ", "transcripts", " ", "to", " ", "remove", " ", "duplicat", "e", " ", "cu", "ffd", "iff", " ", "names", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "aw", "k", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",", "$", "4", ",", "$", "5", ",", "$", "6", ",", "$", "7", ",", "$", "8", ",\"", "transcri", "pt", "\\u", "id", " ", "\\\\\\\\\"", "rna", "seq", "\\u", "codi", "ng", "\\u", "transcri", "pt", "\\u\"", "NR", "\"\\\\\\\\", "\";", " ", "\"}", "'", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "rename", "Transcript", "s_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "ens", "g", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "annot", "ate", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Add", " ", "ensembl", " ", "gene", " ", "id", " ", "to", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "genes_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "gene", "s", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "intersect", "Bed", " ", "-", "a", " ", "std", "in", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "gene", "s", ")", "s", " ", "-", "wa", " ", "-", "wb", " ", "-", "s", " ", "\\", "10", ";", " ", "|", " ", "aw", "k", " ", "-", "F", " ", "\"\\\\\\\\", "t", "\"", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",", "$", "4", ",", "$", "5", ",", "$", "6", ",", "$", "7", ",", "$", "8", ",\"", "gene", "\\u", "id", " ", "\\\\\\\\\"", "\"$", "13", "\"\\\\\\\\", "\";", " ", "\"$", "9", "}'", "\\", "10", ";", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k", "4", ",", "4", "n", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "annot", "ate", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "ens", "g", ".", "gtf", "\"_", ")_", ",_", "r", "\"", "all", "\\u", "transcripts", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "Missing", "Ens", "embl", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Add", " ", "ensembl", " ", "gene", " ", "id", " ", "to", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "transcripts", "_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "transcripts", "\\u", "gtf", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "intersect", "Bed", " ", "-", "a", " ", "%", "(", "ensembl", "\\u", "transcripts", ")", "s", " ", "-", "b", " ", "std", "in", " ", "-", "v", " ", "-", "s", " ", "-", "f", " ", "1", " ", "-", "r", " ", ">", " ", "missi", "ng", "\\u", "ensembl", "\\u", "transcripts", ".", "gtf", ";", "\\", "10", ";", " ", "cat", " ", "%", "(", "infile", ")", "s", " ", "missi", "ng", "\\u", "ensembl", "\\u", "transcripts", ".", "gtf", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k", "4", ",", "4", "n", "\\", "10", ";", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "follow", "s_", "(_", "mkdir_", "(_", "\"", "gene", "set", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "transform_", "(_", "add", "Missing", "Ens", "embl", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"", "all", "\\u", "transcripts", ".", "gtf", "\"_", ")_", ",_", "\"", "gene", "set", "/", "transcripts", ".", "gtf", ".", "gz", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "rename", "Transcript", "To", "Exo", "n_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "reformat", " ", "transcri", "pt", " ", "file", " ", "for", " ", "use", " ", "in", " ", "proj", "007", " ", "pipeline", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "sed", " ", "s", "/\\\\\\\\", "\\\\\\\\", "ttr", "ans", "cript", "\\\\\\\\\\\\\\\\", "t", "/\\\\\\\\", "\\\\\\\\", "tex", "on", "\\\\\\\\\\\\\\\\", "t", "/", "g", "\\", "10", ";", " ", " ", " ", " ", " ", "|", " ", "gzip", " ", ">", " ", "%", "(", "outfile", ")", "s", ";", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "get", "Gt", "f", "Strand", "ed", "Transcript", "s_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "nonc", "odi", "ng", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "Non", "codi", "ng", "Genes", "et_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Assume", " ", "tha", "t", " ", "all", " ", "transcripts", " ", "the", " ", "do", " ", "not", " ", "overl", "ap", " ", "with", " ", "ensembl", " ", "codi", "ng", " ", "gene", "set", " ", "are", " ", "nonc", "odi", "ng", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "transcripts", "_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "transcripts", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "intersect", "Bed", " ", "-", "a", " ", "std", "in", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "transcripts", ")", "s", " ", "-", "v", " ", "-", "s", " ", ">", " ", "%", "(", "outfile", ")", "s", ";", "\\", "10", ";", " ", "echo", " ", "\"", "transcripts", " ", "with", "out", " ", "ensembl", " ", "codi", "ng", " ", "overl", "ap", ":", " ", "\"", " ", ">", " ", "%", "(", "outfile", ")", "s", ".", "count", ";", " ", "\\", "10", ";", " ", "cat", " ", "%", "(", "outfile", ")", "s", " ", "|", " ", "wc", " ", "-", "l", " ", ">>", " ", "%", "(", "outfile", ")", "s", ".", "count", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "get", "Non", "codi", "ng", "Genes", "et_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "rename", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "rename", "Non", "codi", "ng", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "system", "atic", "ally", " ", "rename", " ", "transcripts", " ", "to", " ", "remove", " ", "duplicat", "e", " ", "cu", "ffd", "iff", " ", "names", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "aw", "k", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",", "$", "4", ",", "$", "5", ",", "$", "6", ",", "$", "7", ",", "$", "8", ",\"", "transcri", "pt", "\\u", "id", " ", "\\\\\\\\\"", "rna", "seq", "\\u", "nonc", "odi", "ng", "\\u", "transcri", "pt", "\\u\"", "NR", "\"\\\\\\\\", "\";", " ", "\"}", "'", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "rename", "Non", "codi", "ng", "Transcript", "s_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "ens", "g", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "annot", "ate", "Non", "codi", "ng", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Add", " ", "ensembl", " ", "gene", " ", "id", " ", "to", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "nonc", "odi", "ng_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "nonc", "odi", "ng", "\\u", "gene", "s", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "intersect", "Bed", " ", "-", "a", " ", "%", "(", "infile", ")", "s", " ", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "nonc", "odi", "ng", ")", "s", " ", "-", "wa", " ", "-", "wb", " ", "-", "s", " ", "\\", "10", ";", " ", "|", " ", "aw", "k", " ", "-", "F", " ", "\"\\\\\\\\", "t", "\"", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",", "$", "4", ",", "$", "5", ",", "$", "6", ",", "$", "7", ",", "$", "8", ",\"", "gene", "\\u", "id", " ", "\\\\\\\\\"", "\"$", "13", "\"\\\\\\\\", "\";", " ", "\"$", "9", "}'", " ", ">", " ", "know", "n", "\\u", "nonc", "odi", "ng", "\\u", "exon", "s", ".", "gtf", ";", " ", " ", "\\", "10", ";", " ", "intersect", "Bed", " ", "-", "a", " ", "%", "(", "infile", ")", "s", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "nonc", "odi", "ng", ")", "s", " ", "-", "v", " ", "-", "s", "\\", "10", ";", " ", "|", " ", "aw", "k", " ", "-", "F", " ", "\"\\\\\\\\", "t", "\"", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",", "$", "4", ",", "$", "5", ",", "$", "6", ",", "$", "7", ",", "$", "8", ",\"", "gene", "\\u", "id", " ", "\\\\\\\\\"", "novel", "\\u", "gene", "\\u\"", "NR", "\"\\\\\\\\", "\";", " ", "\"$", "9", "}'", " ", ">", " ", "novel", "\\u", "nonc", "odi", "ng", "\\u", "transcripts", ".", "gtf", ";", " ", "\\", "10", ";", " ", "cat", " ", "know", "n", "\\u", "nonc", "odi", "ng", "\\u", "exon", "s", ".", "gtf", " ", "novel", "\\u", "nonc", "odi", "ng", "\\u", "transcripts", ".", "gtf", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k", "4", ",", "4", "n", "\\", "10", ";", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "annot", "ate", "Non", "codi", "ng", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "ens", "g", ".", "gtf", "\"_", ")_", ",_", "r", "\"", "all", "\\u", "nonc", "odi", "ng", "\\u", "transcripts", ".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "Missing", "Non", "codi", "ng", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Add", " ", "ensembl", " ", "gene", " ", "id", " ", "to", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "nonc", "odi", "ng_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "nonc", "odi", "ng", "\\u", "gtf", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "intersect", "Bed", " ", "-", "a", " ", "%", "(", "ensembl", "\\u", "nonc", "odi", "ng", ")", "s", " ", "-", "b", " ", "%", "(", "infile", ")", "s", " ", " ", "-", "v", " ", "-", "s", " ", "-", "f", " ", "1", " ", "-", "r", " ", ">", " ", "missi", "ng", "\\u", "ensembl", "\\u", "nonc", "odi", "ng", "\\u", "transcripts", ".", "gtf", ";", "\\", "10", ";", " ", "cat", " ", "%", "(", "infile", ")", "s", " ", "missi", "ng", "\\u", "ensembl", "\\u", "nonc", "odi", "ng", "\\u", "transcripts", ".", "gtf", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k", "4", ",", "4", "n", "\\", "10", ";", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "add", "Missing", "Ens", "embl", "Transcript", "s_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "tab", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "transcri", "pt", "Gt", "f", "To", "Tab_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Copy", " ", "replicate", "d", " ", "Bed", " ", "files", " ", "generat", "ed", " ", "by", " ", "caps", "eq", " ", "pip", "line", " ", "to", " ", "gene", "set", "-", "specific", " ", "output", " ", "director", "y", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2t", "sv", ".", "py", " ", "-", "f", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "|", " ", "aw", "k", " ", "'{", "if", " ", "(", "NR", "==", "1", ")", " ", "{", "print", " ", "$", "0", "\"\\\\\\\\", "tge", "ne", "\\u", "biot", "ype", "\\\\\\\\", "tge", "ne", "\\u", "name", "\"}", " ", "else", " ", "{", "print", " ", "$", "0", "\"\\\\\\\\", "tpr", "ote", "in", "\\u", "codi", "ng", "\\\\\\\\", "tun", "know", "n", "\"}}", "'", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "add", "Missing", "Non", "codi", "ng", "Transcript", "s_", ",_", "suffix_", "(_", "\".", "gtf", "\"_", ")_", ",_", "\".", "tab", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "nonc", "odi", "ng", "Gt", "f", "To", "Tab_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Copy", " ", "replicate", "d", " ", "Bed", " ", "files", " ", "generat", "ed", " ", "by", " ", "caps", "eq", " ", "pip", "line", " ", "to", " ", "gene", "set", "-", "specific", " ", "output", " ", "director", "y", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2t", "sv", ".", "py", " ", "-", "f", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "|", " ", "aw", "k", " ", "'{", "if", " ", "(", "NR", "==", "1", ")", " ", "{", "print", " ", "$", "0", "\"\\\\\\\\", "tge", "ne", "\\u", "biot", "ype", "\\\\\\\\", "tge", "ne", "\\u", "name", "\"}", " ", "else", " ", "{", "print", " ", "$", "0", "\"\\\\\\\\", "tno", "nco", "ding", "\\\\\\\\", "tun", "know", "n", "\"}}", "'", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "follow", "s_", "(_", "transcri", "pt", "Gt", "f", "To", "Tab_", ",_", "nonc", "odi", "ng", "Gt", "f", "To", "Tab_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "merge_", "(_", "\"*", ".", "tab", "\"_", ",_", "\"", "transcri", "pt", "\\u", "info", ".", "tab", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "merge", "Transcript", "Info_", "(_", "infiles", "_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Copy", " ", "replicate", "d", " ", "Bed", " ", "files", " ", "generat", "ed", " ", "by", " ", "caps", "eq", " ", "pip", "line", " ", "to", " ", "gene", "set", "-", "specific", " ", "output", " ", "director", "y", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inli", "st_", "=_", "\"", " ", "\"_", "._", "join_", "(_", "infiles", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "inli", "st", ")", "s", " ", "|", " ", "aw", "k", " ", "'{", "if", " ", "(", "NR", "==", "1", " ", "||", " ", "$", "1", " ", "!=", " ", "\"", "conti", "g", "\")", " ", "{", "print", " ", "$", "0", "}}", "'", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "merge", "Transcript", "Info_", ",_", "suffix_", "(_", "\".", "tab", "\"_", ")_", ",_", "\".", "tab", ".", "load", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "load", "Transcript", "s_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "load", " ", "GT", "F", " ", "file", " ", "int", "o", " ", "databa", "se", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "\"", "conti", "g", ",", "source", ",", "feature", ",", "start", ",", "end", ",", "score", ",", "strand", ",", "frame", ",", "gene", "\\u", "id", ",", "transcri", "pt", "\\u", "id", ",", "gene", "\\u", "biot", "ype", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "python", " ", "~", "/", "src", "/", "csv", "2d", "b", ".", "py", " ", "\\", "10", ";", " ", " ", " ", "--", "databa", "se", "=", "%", "(", "databa", "se", ")", "s", "\\", "10", ";", " ", " ", " ", "--", "table", "=", "transcri", "pt", "\\u", "info", "\\", "10", ";", " ", " ", " ", "--", "index", "=", "gene", "\\u", "id", "\\", "10", ";", " ", " ", " ", "--", "index", "=", "conti", "g", ",", "start", "\\", "10", ";", " ", " ", " ", "--", "index", "=", "transcri", "pt", "\\u", "id", "\\", "10", ";", " ", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", ";", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "follow", "s_", "(_", "mkdir_", "(_", "\"", "gene", "set", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "transform_", "(_", "get", "Ens", "embl", "Codi", "ng", "Genes", "et_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "codi", "ng", ".", "gtf", "\"_", ")_", ",_", "r", "\"", "gene", "set", "/\\\\", "1", ".", "gene", "s", ".", "bed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Gene", "Intervals", "_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Merge", " ", "all", " ", "transcripts", " ", "per", " ", "gene", " ", "(", "inclu", "ding", " ", "utr", ")", " ", "to", " ", "get", " ", "start", " ", "and", " ", "stop", " ", "\\", "10", ";", " ", " ", " ", " ", "coordinate", "s", " ", "for", " ", "every", " ", "prote", "in", "-", "codi", "ng", " ", "gene", " ", "and", " ", "store", " ", "in", " ", "a", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "genes_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "gene", "s", "\\u", "gtf", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "ensembl", "\\u", "gene", "s", ")", "s", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "merge", "Bed", " ", "-", "i", " ", "std", "in", " ", "-", "s", " ", "-", "n", " ", "\\", "10", ";", " ", "|", " ", "aw", "k", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",\"", "gene", "\"", "NR", ",", "$", "4", ",", "$", "5", " ", "}'", "\\", "10", ";", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k2", ",", "2n", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "build", "Gene", "Intervals", "_", ",_", "regex_", "(_", "r", "\"", "gene", "set", "/(", "\\\\", "S", "+)", ".", "gene", "s", ".", "bed", "\"_", ")_", ",_", "r", "\"", "gene", "set", "/", "gene", "s", ".", "bed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "annot", "ate", "Gene", "Intervals", "_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Add", " ", "ensembl", " ", "gene", " ", "id", " ", "to", " ", "GT", "F", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "genes_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "gene", "s", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "intersect", "Bed", " ", "-", "a", " ", "std", "in", " ", "-", "b", " ", "%", "(", "ensembl", "\\u", "gene", "s", ")", "s", " ", "-", "wa", " ", "-", "wb", " ", "-", "s", " ", "\\", "10", ";", " ", "|", " ", "aw", "k", " ", "'", "OF", "S", "=\"\\\\", "\\\\", "t", "\"", " ", "{", "print", " ", "$", "1", ",", "$", "2", ",", "$", "3", ",", "$", "10", ",", "$", "5", ",", "$", "6", "}'", " ", "\\", "10", ";", " ", "|", " ", "sort", " ", "-", "k", "1", ",", "1", " ", "-", "k2", ",", "2n", " ", ">", " ", "%", "(", "outfile", ")", "s", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "annot", "ate", "Gene", "Intervals", "_", ",_", "regex_", "(_", "PARAMS_", "[_", "'", "interface", "\\u", "geni", "c\\u", "bed", "'_", "]_", ")_", ",_", "PARAMS_", "[_", "'", "interface", "\\u", "ups", "tream", "\\u", "flan", "k", "\\u", "bed", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Ups", "tream", "Fla", "nk", "Bed", "_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "build", " ", "interval", " ", "ups", "tream", " ", "of", " ", "gene", " ", "start", " ", "for", " ", "each", " ", "entry", " ", "in", " ", "bed", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "window_", "=_", "PARAMS_", "[_", "\"", "gene", "set\\u", "flan", "k", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fai", "dx_", "=_", "PARAMS_", "[_", "\"", "fai", "dx", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "flan", "k", "Bed", " ", "-", "i", " ", "%", "(", "infile", ")", "s", " ", "-", "g", " ", "%", "(", "fai", "dx", ")", "s", " ", "-", "l", " ", "%", "(", "window", ")", "s", " ", "-", "r", " ", "0", " ", "-", "s", " ", "\\", "10", ";", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "annot", "ate", "Gene", "Intervals", "_", ",_", "regex_", "(_", "PARAMS_", "[_", "'", "interface", "\\u", "geni", "c\\u", "bed", "'_", "]_", ")_", ",_", "PARAMS_", "[_", "'", "interface", "\\u", "downstream", "\\u", "flan", "k", "\\u", "bed", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Down", "stream", "Fla", "nk", "Bed", "_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "build", " ", "interval", " ", "downstream", " ", "of", " ", "gene", " ", "start", " ", "for", " ", "each", " ", "entry", " ", "in", " ", "bed", " ", "file", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "window_", "=_", "PARAMS_", "[_", "\"", "gene", "set\\u", "flan", "k", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fai", "dx_", "=_", "PARAMS_", "[_", "\"", "fai", "dx", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "flan", "k", "Bed", " ", "-", "i", " ", "%", "(", "infile", ")", "s", " ", "-", "g", " ", "%", "(", "fai", "dx", ")", "s", " ", "-", "l", " ", "0", " ", "-", "r", " ", "%", "(", "window", ")", "s", " ", "-", "s", " ", "\\", "10", ";", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "merge_", "(_", "(_", "annot", "ate", "Gene", "Intervals", "_", ",_", "build", "Ups", "tream", "Fla", "nk", "Bed", "_", ",_", "build", "Down", "stream", "Fla", "nk", "Bed", "_", ")_", ",_", "os_", "._", "path_", "._", "join_", "(_", "\"", "gene", "set", "\"_", ",_", "PARAMS_", "[_", "'", "interface", "\\u", "inter", "geni", "c\\u", "bed", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Inter", "geni", "c", "Bed", "_", "(_", "infiles", "_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Geno", "mic", " ", "regions", " ", "not", " ", "associate", "d", " ", "with", " ", "any", " ", "other", " ", "features", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inli", "st_", "=_", "\"", " ", "\"_", "._", "join_", "(_", "infiles", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "inli", "st", ")", "s", " ", "|", " ", "complement", "Bed", " ", "-", "i", " ", "std", "in", " ", "-", "g", " ", "%", "(", "fai", "dx", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "(_", "annot", "ate", "Gene", "Intervals", "_", ",_", "build", "Ups", "tream", "Fla", "nk", "Bed", "_", ",_", "build", "Down", "stream", "Fla", "nk", "Bed", "_", ",_", "build", "Inter", "geni", "c", "Bed", "_", ")_", ",_", "suffix_", "(_", "\".", "bed", "\"_", ")_", ",_", "\".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "convert", "Bed", "To", "Gt", "f_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "convert", " ", "bed", " ", "files", " ", "to", " ", "GT", "F", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "cat", " ", "%", "(", "infile", ")", "s", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2g", "ff", ".", "py", " ", "--", "as", "-", "gtf", " ", "|", " ", "grep", " ", "-", "v", " ", "\"#", "\"", " ", ">", " ", "%", "(", "outfile", ")", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "add", "Missing", "Ens", "embl", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"", "all", "\\u", "transcripts", ".", "gtf", "\"_", ")_", ",_", "os_", "._", "path_", "._", "join_", "(_", "\"", "gene", "set", "\"_", ",_", "PARAMS_", "[_", "\"", "interface", "\\u", "tss", "\\u", "bed", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Transcript", "TS", "S_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "annot", "ate", " ", "transcription", " ", "start", " ", "sites", " ", "from", " ", "reference", " ", "gene", " ", "set", ".", "\\", "10", ";", " ", " ", " ", " ", "Simil", "ar", " ", "to", " ", "promo", "tors", ",", " ", "except", " ", "tha", "t", " ", "the", " ", "wit", "dth", " ", "is", " ", "set", " ", "to", " ", "1", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "<", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2g", "ff", ".", "py", " ", "--", "sanitize", "=", "geno", "me", " ", "--", "skip", "-", "missi", "ng", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2g", "ff", ".", "py", " ", "--", "method", "=", "promo", "tors", " ", "--", "promo", "tor", "=", "1", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2b", "ed", ".", "py", " ", "--", "is", "-", "gtf", " ", "--", "name", "=", "transcri", "pt", "\\u", "id", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "gzip", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "follow", "s_", "(_", "convert", "Bed", "To", "Gt", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "files_", "(_", "\"", "gene", "set", "/", "gene", "s", ".", "gtf", "\"_", ",_", "os_", "._", "path_", "._", "join_", "(_", "\"", "gene", "set", "\"_", ",_", "PARAMS_", "[_", "\"", "interface", "\\u", "tss", "\\u", "gene", "\\u", "bed", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Gene", "TS", "S_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "create", " ", "a", " ", "single", " ", "TS", "S", " ", "for", " ", "each", " ", "gene", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2g", "ff", ".", "py", " ", "--", "sanitize", "=", "geno", "me", " ", "--", "skip", "-", "missi", "ng", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2g", "ff", ".", "py", " ", "--", "method", "=", "promo", "tors", " ", "--", "promo", "tor", "=", "1", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2b", "ed", ".", "py", " ", "--", "is", "-", "gtf", " ", "--", "name", "=", "gene", "\\u", "id", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "gzip", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "add", "Missing", "Ens", "embl", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"", "all", "\\u", "transcripts", ".", "gtf", "\"_", ")_", ",_", "os_", "._", "path_", "._", "join_", "(_", "\"", "gene", "set", "\"_", ",_", "PARAMS_", "[_", "\"", "interface", "\\u", "tss", "\\u", "gene", "\\u", "interval", "\\u", "bed", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Gene", "TS", "SI", "nter", "val_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "create", " ", "a", " ", "single", " ", "interval", " ", "tha", "t", " ", "enco", "mpa", "sses", " ", "all", " ", "annotated", " ", "TS", "Ss", " ", "for", " ", "a", " ", "give", "n", " ", "gene", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "<", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2g", "ff", ".", "py", " ", "--", "sanitize", "=", "geno", "me", " ", "--", "skip", "-", "missi", "ng", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2g", "ff", ".", "py", " ", "--", "method", "=", "promo", "tors", " ", "--", "promo", "tor", "=", "1", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "sed", " ", "s", "/\\\\\\\\", "\\\\\\\\", "ttr", "ans", "cript", "\\\\\\\\\\\\\\\\", "t", "/\\\\\\\\", "\\\\\\\\", "tex", "on", "\\\\\\\\\\\\\\\\", "t", "/", "g", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2g", "tf", ".", "py", " ", "--", "merge", "-", "transcripts", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2b", "ed", ".", "py", " ", "--", "is", "-", "gtf", " ", "--", "name", "=", "transcri", "pt", "\\u", "id", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "gzip", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "add", "Missing", "Non", "codi", "ng", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "gtf", "\"_", ")_", ",_", "os_", "._", "path_", "._", "join_", "(_", "\"", "gene", "set", "\"_", ",_", "PARAMS_", "[_", "\"", "interface", "\\u", "tss", "\\u", "gene", "\\u", "nonc", "odi", "ng", "\\u", "bed", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Non", "codi", "ng", "Gene", "TS", "S_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Assign", " ", "a", " ", "TS", "S", " ", "for", " ", "each", " ", "non", "-", "codi", "ng", " ", "gene", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "<", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2g", "ff", ".", "py", " ", "--", "sanitize", "=", "geno", "me", " ", "--", "skip", "-", "missi", "ng", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gtf", "2g", "ff", ".", "py", " ", "--", "method", "=", "promo", "tors", " ", "--", "promo", "tor", "=", "1", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "gff", "2b", "ed", ".", "py", " ", "--", "is", "-", "gtf", " ", "--", "name", "=", "gene", "\\u", "id", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2b", "ed", ".", "py", " ", "--", "method", "=", "filter", "-", "geno", "me", " ", "--", "geno", "me", "-", "file", "=", "%", "(", "geno", "me", "\\u", "dir", ")", "s", "/", "%", "(", "geno", "me", ")", "s", " ", "--", "log", " ", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "gzip", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "(_", "build", "Transcript", "TS", "S_", ",_", "build", "Gene", "TS", "S_", ",_", "build", "Gene", "TS", "SI", "nter", "val_", ",_", "build", "Non", "codi", "ng", "Gene", "TS", "S_", ")_", ",_", "suffix_", "(_", "\".", "bed", ".", "gz", "\"_", ")_", ",_", "\".", "extend", "ed", ".", "bed", ".", "gz", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "Extend", "Region_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "convert", " ", "bed", " ", "to", " ", "gtf", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "gun", "zip", " ", "<", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "slo", "p", "Bed", " ", "-", "i", " ", "std", "in", " ", "-", "g", " ", "%", "(", "fai", "dx", ")", "s", " ", "-", "b", " ", "1000", " ", " ", "\\", "10", ";", " ", "|", " ", "gzip", "\\", "10", ";", " ", ">", " ", "%", "(", "outfile", ")", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "(_", "build", "Transcript", "TS", "S_", ",_", "build", "Gene", "TS", "S_", ",_", "build", "Gene", "TS", "SI", "nter", "val_", ",_", "build", "Non", "codi", "ng", "Gene", "TS", "S_", ",_", "Extend", "Region_", ")_", ",_", "suffix_", "(_", "\".", "bed", ".", "gz", "\"_", ")_", ",_", "\".", "gtf", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "convert", "To", "GT", "F_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "convert", " ", "bed", " ", "to", " ", "gtf", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "gun", "zip", " ", "<", " ", "%", "(", "infile", ")", "s", " ", "\\", "10", ";", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "bed", "2g", "ff", ".", "py", " ", "--", "as", "-", "gtf", " ", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "\\", "10", ";", " ", ">", " ", "%", "(", "outfile", ")", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "files_", "(_", "\"", "pipeline", ".", "ini", "\"_", ",_", "\"", "ensembl", ".", "copy", ".", "log", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "copy", "Ens", "embl", "_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "convert", " ", "bed", " ", "to", " ", "gtf", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ensembl", "\\u", "dir_", "=_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "dir", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "cp", " ", "%", "(", "ensembl", "\\u", "dir", ")", "s", "/", "repeat", "s", ".", "gtf", " ", "gene", "set", "/", " ", "2", ">", " ", "%", "(", "outfile", ")", "s", ";", "\\", "10", ";", " ", "cp", " ", "%", "(", "ensembl", "\\u", "dir", ")", "s", "/", "go", ".", "tsv", ".", "gz", " ", "gene", "set", "/", " ", "2", ">", " ", "%", "(", "outfile", ")", "s", ";", "\\", "10", ";", " ", "cp", " ", "%", "(", "ensembl", "\\u", "dir", ")", "s", "/", "gos", "lim", ".", "tsv", ".", "gz", " ", "gene", "set", "/", " ", "2", ">", " ", "%", "(", "outfile", ")", "s", ";", "\\", "10", ";", " ", "cp", " ", "%", "(", "ensembl", "\\u", "dir", ")", "s", "/", "go", "\\u", "ontology", ".", "obo", " ", "gene", "set", "/", " ", "2", ">", " ", "%", "(", "outfile", ")", "s", ";", "\\", "10", ";", " ", "cp", " ", "%", "(", "ensembl", "\\u", "dir", ")", "s", "/", "gos", "lim", ".", "obo", " ", "gene", "set", "/", " ", "2", ">", " ", "%", "(", "outfile", ")", "s", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "files_", "(_", "\"", "pipeline", ".", "ini", "\"_", ",_", "\"", "ensembl", "db", ".", "copy", ".", "log", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "copy", "Ens", "embl", "Db_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "copy", " ", "tables", " ", "from", " ", "ensembl", " ", "databa", "se", " ", "to", " ", "rna", "seq", " ", "databa", "se", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table", "\\u", "list_", "=_", "P_", "._", "as", "List_", "(_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "tables", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbh", "andle", "_", "=_", "sqlite3_", "._", "connect_", "(_", "PARAMS_", "[_", "\"", "databa", "se", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "=_", "dbh", "andle", "_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "\"\"\"", "ATTACH", " ", "\"%", "s", "\"", " ", "as", " ", "ensembl", ";\"\"\"_", "%_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "db", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "._", "execute_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "table_", "in_", "table", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cc_", "=_", "dbh", "andle", "_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "\"\"\"", "CREATE", " ", "TAB", "LE", " ", "%", "s", " ", "AS", " ", "SELECT", " ", "*", " ", "FROM", " ", "ensembl", ".", "%", "s", ";\"\"\"_", "%_", "(_", "table_", ",_", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "._", "execute_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cc_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "touch", " ", "%", "(", "outfile", ")", "s", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "transform_", "(_", "load", "Transcript", "s_", ",_", "regex_", "(_", "r", "\"(", "\\\\", "S", "+)", ".", "load", "\"_", ")_", ",_", "\"", "gene", "\\u", "name", ".", "update", ".", "log", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "update", "Gene", "Name_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "update", " ", "gene", " ", "name", " ", "from", " ", "ensembl", " ", "databa", "se", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbh", "andle", "_", "=_", "sqlite3_", "._", "connect_", "(_", "PARAMS_", "[_", "\"", "databa", "se", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "=_", "dbh", "andle", "_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "\"\"\"", "ATTACH", " ", "\"%", "s", "\"", " ", "as", " ", "ensembl", ";\"\"\"_", "%_", "PARAMS_", "[_", "\"", "ensembl", "\\u", "db", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "._", "execute_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "\"\"\"", "UPDATE", " ", "transcri", "pt", "\\u", "info", " ", "SET", " ", "gene", "\\u", "name", "=", "\\", "10", ";", " ", " ", " ", "(", "SELECT", " ", "gene", "\\u", "name", " ", "from", " ", "ensembl", ".", "transcri", "pt", "\\u", "info", " ", "\\", "10", ";", " ", " ", " ", "WHE", "RE", " ", "transcri", "pt", "\\u", "info", ".", "gene", "\\u", "id", "=", "ensembl", ".", "transcri", "pt", "\\u", "info", ".", "gene", "\\u", "id", ");", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "._", "execute_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cc_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "\"\"\"", "touch", " ", "%", "(", "outfile", ")", "s", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\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_", "@_", "follow", "s_", "(_", "convert", "Txt", "To", "Gt", "f_", ",_", "get", "Gt", "f", "Strand", "ed", "Transcript", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "get", "Ens", "embl", "Codi", "ng", "Genes", "et_", ",_", "rename", "Transcript", "s_", ",_", "annot", "ate", "Transcript", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Missing", "Ens", "embl", "Transcript", "s_", ",_", "rename", "Transcript", "To", "Exo", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "transcripts", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\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_", "@_", "follow", "s_", "(_", "get", "Non", "codi", "ng", "Genes", "et_", ",_", "rename", "Non", "codi", "ng", "Transcript", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "annot", "ate", "Non", "codi", "ng", "Transcript", "s_", ",_", "add", "Missing", "Non", "codi", "ng", "Transcript", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "nonc", "odi", "ng_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\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_", "@_", "follow", "s_", "(_", "transcri", "pt", "Gt", "f", "To", "Tab_", ",_", "nonc", "odi", "ng", "Gt", "f", "To", "Tab_", ",_", "merge", "Transcript", "Info_", ",_", "load", "Transcript", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "load", "Transcript", "Info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\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_", "@_", "follow", "s_", "(_", "build", "Gene", "Intervals", "_", ",_", "annot", "ate", "Gene", "Intervals", "_", ",_", "build", "Ups", "tream", "Fla", "nk", "Bed", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "build", "Down", "stream", "Fla", "nk", "Bed", "_", ",_", "build", "Inter", "geni", "c", "Bed", "_", ",_", "convert", "Bed", "To", "Gt", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "genes_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\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_", "@_", "follow", "s_", "(_", "build", "Transcript", "TS", "S_", ",_", "build", "Gene", "TS", "S_", ",_", "build", "Non", "codi", "ng", "Gene", "TS", "S_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extend", "Region_", ",_", "convert", "To", "GT", "F_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "tss", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\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_", "@_", "follow", "s_", "(_", "copy", "Ens", "embl", "_", ",_", "copy", "Ens", "embl", "Db_", ",_", "update", "Gene", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "ensembl", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\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_", "@_", "follow", "s_", "(_", "transcripts", "_", ",_", "nonc", "odi", "ng_", ",_", "load", "Transcript", "Info_", ",_", "genes_", ",_", "tss", "_", ",_", "ensembl", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "full_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "all", " ", "target", "s", ".'''_", "\\u\\u\\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 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, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
gdanezis/petlib/examples/tormedian.py
[ { "content": " def dec(self, x):\n \"\"\" Decrypt a ciphertext using a secret key \"\"\"\n try:\n hm = self.b - x * self.a\n return _table[hm]\n except Exception as e:\n o = self.pub.group.order()\n self.self_check()\n print(\"Failed to decrypt: %s\" % self.m )\n raise e", "metadata": "root.Ct.dec", "header": "['class', 'Ct', ':', '___EOS___']", "index": 62 }, { "content": " def __add__(self, other):\n \"\"\" Add two ciphertexts, to produce a ciphertext of their sums. Also handles addition with a constant. \"\"\"\n o = self.pub.group.order()\n g = self.pub.group.generator()\n\n if isinstance(other, int):\n # Case for int other\n new_b = self.b + _n_table[(o + other) % o] # other * g\n new_k, new_m = None, None\n if self.k is not None:\n new_m = self.m + other # self.m.mod_add( other, o)\n return Ct(self.pub, self.a, new_b, self.k, new_m)\n else:\n # Case for ciphertext other\n if __debug__:\n assert self.pub == other.pub\n new_a = self.a + other.a\n new_b = self.b + other.b\n new_k, new_m = None, None\n if self.k is not None and other.k is not None:\n new_k = self.k.mod_add( other.k, o)\n new_m = self.m + other.m # self.m.mod_add(other.m, o)\n return Ct(self.pub, new_a, new_b, new_k, new_m)", "metadata": "root.Ct.__add__", "header": "['class', 'Ct', ':', '___EOS___']", "index": 73 }, { "content": " def estimate(self, item):\n \"\"\" Estimate the frequency of one value \"\"\"\n\n item = str(item)\n h = hashes(item, self.d)\n h2 = []\n for hi in h:\n v = hi - 1 if hi % 2 == 0 else hi + 1\n h2 += [v]\n\n g = self.pub.group.generator()\n o = self.pub.group.order()\n\n elist = []\n for i, [hi, hpi] in enumerate(zip(h, h2)):\n v1 = self.store[i][hi % self.w] \n v2 = self.store[i][hpi % self.w]\n elist += [v1, -v2]\n \n estimates = Ct.sum(elist)\n return estimates, self.d", "metadata": "root.CountSketchCt.estimate", "header": "['class', 'CountSketchCt', '(', 'object', ')', ':', '___EOS___']", "index": 204 }, { "content": "def get_median(cs, min_b = 0, max_b = 1000, steps = 20):\n L, R = 0, 0\n bounds = [min_b, max_b]\n total = None\n\n for _ in range(steps):\n old_bounds = copy(bounds)\n # print(bounds)\n\n cand_median = int((bounds[1] + bounds[0]) / 2)\n\n if bounds[0] == cand_median:\n yield cand_median\n return\n\n EL = Ct.sum([ cs.estimate(i)[0] for i in range(bounds[0], cand_median) ])\n newl = yield EL # EL.dec(sec)\n \n if total is None:\n ER = Ct.sum([ cs.estimate(i)[0] for i in range(cand_median, bounds[1]) ]) \n newr = yield ER # ER.dec(sec)\n\n total = newl + newr\n # print(\"total: %s\" % total)\n\n else:\n newr = total - newl\n if __debug__:\n ER = Ct.sum( [ cs.estimate(i)[0] for i in range(cand_median, bounds[1]) ]) \n newrx = yield ER # ER.dec(sec)\n # assert newrx == newr\n\n if newl + L > newr + R:\n R = R + newr\n bounds[1] = cand_median\n total = newl\n else:\n L = L + newl\n bounds[0] = cand_median\n total = newr\n\n if bounds == old_bounds:\n yield cand_median\n return ", "metadata": "root.get_median", "header": "['module', '___EOS___']", "index": 248 }, { "content": "def size_vs_error():\n #d, w = 25, 7\n #print(\"Sketch: d=%s w=%s (Cmp. size: %s%%)\" % (d, w, (float(100*d*w)/1000)))\n\n # Setup the crypto\n G = EcGroup()\n sec = G.order().random()\n y = sec * G.generator()\n\n # Get some test data\n narrow_vals = 1000\n wide_vals = 200\n\n from numpy.random import laplace \n from collections import defaultdict\n\n \n datapoints = defaultdict(list)\n sizes = defaultdict(list)\n\n eps = [0.5, 0.35, 0.25, 0.15, 0.1, 0.05, 0.025, 0.01] #, 0.005, 0.001]\n for epsilon in eps:\n print epsilon\n\n for _ in range(40):\n vals = [gauss(300, 25) for _ in range (narrow_vals)]\n vals += [gauss(500, 200) for _ in range (wide_vals)]\n vals = sorted([int(v) for v in vals])\n\n median = vals[int(len(vals) / 2)]\n\n # Add each sample to the sketch\n # cs = CountSketchCt(d, w, y)\n cs = CountSketchCt.epsilondelta(epsilon, epsilon, y)\n sizes[epsilon] += [ float(100*cs.d*cs.w) / 1000 ]\n for x in vals:\n cs.insert(\"%s\" % x)\n\n # Now use test the median function\n proto = get_median(cs, min_b = 0, max_b = 1000, steps = 20)\n\n plain = None\n no_decryptions = 0\n while True:\n v = proto.send(plain)\n if isinstance(v, int):\n break\n no_decryptions += 1\n\n noise = 0\n plain = v.dec(sec) + noise\n\n print(\"Estimated median: %s\\t\\tAbs. Err: %s\" % (v, abs(v - median)))\n datapoints[epsilon] += [ 100 * float(abs(v - median)) / median ] \n\n lower_err, core_err, upper_err = analyze_series(eps, datapoints)\n lower_siz, core_siz, upper_siz = analyze_series(eps, sizes)\n\n import matplotlib.pyplot as plt\n\n eps_lab = range(len(eps))\n\n\n plt.plot(eps, core_err, label=\"Error (%)\")\n plt.xscale('log')\n # v = v_issue / (len(cnt_issue)**0.5)\n plt.fill_between(x=eps, y1=lower_err, y2=upper_err, alpha=0.2, color=\"b\")\n plt.xticks(eps, eps)\n\n\n plt.plot(eps, core_siz, label=r\"Size (%)\")\n # plt.yscale('log')\n # v = v_issue / (len(cnt_issue)**0.5)\n plt.fill_between(x=eps, y1=lower_siz, y2=upper_siz, alpha=0.2, color=\"b\")\n # plt.xticks(eps_lab, eps)\n\n plt.xlabel(r'(epsilon, delta) parameter of Count-Sketch')\n plt.ylabel(r'%')\n plt.title(r'Median Estimation - Error vs. Size')\n # plt.axis([1, 10, 0, 1700])\n #plt.grid(True)\n plt.legend(loc=\"upper center\")\n\n plt.savefig(\"Size.pdf\")\n\n # plt.show()\n plt.close()\n # print core_err", "metadata": "root.size_vs_error", "header": "['module', '___EOS___']", "index": 365 } ]
[ { "span": "o ", "start_line": 68, "start_column": 12, "end_line": 68, "end_column": 13 }, { "span": "g ", "start_line": 76, "start_column": 8, "end_line": 76, "end_column": 9 }, { "span": "g ", "start_line": 214, "start_column": 8, "end_line": 214, "end_column": 9 }, { "span": "o ", "start_line": 215, "start_column": 8, "end_line": 215, "end_column": 9 }, { "span": "newrx ", "start_line": 277, "start_column": 16, "end_line": 277, "end_column": 21 }, { "span": "eps_lab ", "start_line": 425, "start_column": 4, "end_line": 425, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Ct", "_", ":_", "\\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_", "dec_", "(_", "self_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Decrypt", " ", "a", " ", "cipher", "text", " ", "usi", "ng", " ", "a", " ", "secret", " ", "key", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hm_", "=_", "self_", "._", "b_", "-_", "x_", "*_", "self_", "._", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u", "table_", "[_", "hm_", "]_", "\\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 ", " _", "o_", "=_", "self_", "._", "pub_", "._", "group_", "._", "order_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "self", "\\u", "check_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Fail", "ed", " ", "to", " ", "decrypt", ":", " ", "%", "s", "\"_", "%_", "self_", "._", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ct", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "add\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Add", " ", "two", " ", "cipher", "texts", ",", " ", "to", " ", "produce", " ", "a", " ", "cipher", "text", " ", "of", " ", "thei", "r", " ", "sums", ".", " ", "Al", "so", " ", "handle", "s", " ", "addition", " ", "with", " ", "a", " ", "constant", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "o_", "=_", "self_", "._", "pub_", "._", "group_", "._", "order_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "self_", "._", "pub_", "._", "group_", "._", "generator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "other_", ",_", "int_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Case", " ", "for", " ", "int", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "b_", "=_", "self_", "._", "b_", "+_", "\\u", "n", "\\u", "table_", "[_", "(_", "o_", "+_", "other_", ")_", "%_", "o_", "]_", "#", " ", "other", " ", "*", " ", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "k_", ",_", "new", "\\u", "m_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "k_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "m_", "=_", "self_", "._", "m_", "+_", "other_", "#", " ", "self", ".", "m", ".", "mod", "\\u", "add", "(", " ", "other", ",", " ", "o", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Ct", "_", "(_", "self_", "._", "pub_", ",_", "self_", "._", "a_", ",_", "new", "\\u", "b_", ",_", "self_", "._", "k_", ",_", "new", "\\u", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Case", " ", "for", " ", "cipher", "text", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u\\u", "debug", "\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "pub_", "==_", "other_", "._", "pub_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "a_", "=_", "self_", "._", "a_", "+_", "other_", "._", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "b_", "=_", "self_", "._", "b_", "+_", "other_", "._", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "k_", ",_", "new", "\\u", "m_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "k_", "is_", "not_", "None_", "and_", "other_", "._", "k_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "k_", "=_", "self_", "._", "k_", "._", "mod", "\\u", "add_", "(_", "other_", "._", "k_", ",_", "o_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "m_", "=_", "self_", "._", "m_", "+_", "other_", "._", "m_", "#", " ", "self", ".", "m", ".", "mod", "\\u", "add", "(", "other", ".", "m", ",", " ", "o", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Ct", "_", "(_", "self_", "._", "pub_", ",_", "new", "\\u", "a_", ",_", "new", "\\u", "b_", ",_", "new", "\\u", "k_", ",_", "new", "\\u", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Count", "Sketch", "Ct", "_", "(_", "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_", "estimate_", "(_", "self_", ",_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Estimat", "e", " ", "the", " ", "freque", "nc", "y", " ", "of", " ", "one", " ", "value", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "item_", "=_", "str_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "=_", "hashes_", "(_", "item_", ",_", "self_", "._", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h2_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "hi_", "in_", "h_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "hi_", "-_", "1_", "if_", "hi_", "%_", "2_", "==_", "0_", "else_", "hi_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h2_", "+=_", "[_", "v_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "g_", "=_", "self_", "._", "pub_", "._", "group_", "._", "generator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "o_", "=_", "self_", "._", "pub_", "._", "group_", "._", "order_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "elist", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "[_", "hi_", ",_", "hp", "i_", "]_", "in_", "enumerate_", "(_", "zip_", "(_", "h_", ",_", "h2_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v1_", "=_", "self_", "._", "store_", "[_", "i_", "]_", "[_", "hi_", "%_", "self_", "._", "w_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v2_", "=_", "self_", "._", "store_", "[_", "i_", "]_", "[_", "hp", "i_", "%_", "self_", "._", "w_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elist", "_", "+=_", "[_", "v1_", ",_", "-_", "v2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "estimate", "s_", "=_", "Ct", "_", "._", "sum_", "(_", "elist", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "estimate", "s_", ",_", "self_", "._", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "median_", "(_", "cs_", ",_", "min", "\\u", "b_", "=_", "0_", ",_", "max", "\\u", "b_", "=_", "1000_", ",_", "steps_", "=_", "20_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "L_", ",_", "R_", "=_", "0_", ",_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bounds_", "=_", "[_", "min", "\\u", "b_", ",_", "max", "\\u", "b_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "\\u_", "in_", "range_", "(_", "steps_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "old", "\\u", "bounds_", "=_", "copy_", "(_", "bounds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(", "bound", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cand", "\\u", "median_", "=_", "int_", "(_", "(_", "bounds_", "[_", "1_", "]_", "+_", "bounds_", "[_", "0_", "]_", ")_", "/_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "bounds_", "[_", "0_", "]_", "==_", "cand", "\\u", "median_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "cand", "\\u", "median_", "\\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_", "EL_", "=_", "Ct", "_", "._", "sum_", "(_", "[_", "cs_", "._", "estimate_", "(_", "i_", ")_", "[_", "0_", "]_", "for_", "i_", "in_", "range_", "(_", "bounds_", "[_", "0_", "]_", ",_", "cand", "\\u", "median_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newl", "_", "=_", "yield_", "EL_", "#", " ", "EL", ".", "dec", "(", "sec", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "total_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ER_", "=_", "Ct", "_", "._", "sum_", "(_", "[_", "cs_", "._", "estimate_", "(_", "i_", ")_", "[_", "0_", "]_", "for_", "i_", "in_", "range_", "(_", "cand", "\\u", "median_", ",_", "bounds_", "[_", "1_", "]_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newr", "_", "=_", "yield_", "ER_", "#", " ", "ER", ".", "dec", "(", "sec", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "total_", "=_", "newl", "_", "+_", "newr", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(\"", "total", ":", " ", "%", "s", "\"", " ", "%", " ", "total", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "newr", "_", "=_", "total_", "-_", "newl", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u\\u", "debug", "\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ER_", "=_", "Ct", "_", "._", "sum_", "(_", "[_", "cs_", "._", "estimate_", "(_", "i_", ")_", "[_", "0_", "]_", "for_", "i_", "in_", "range_", "(_", "cand", "\\u", "median_", ",_", "bounds_", "[_", "1_", "]_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newr", "x_", "=_", "yield_", "ER_", "#", " ", "ER", ".", "dec", "(", "sec", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "assert", " ", "newr", "x", " ", "==", " ", "newr", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "newl", "_", "+_", "L_", ">_", "newr", "_", "+_", "R_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "=_", "R_", "+_", "newr", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bounds_", "[_", "1_", "]_", "=_", "cand", "\\u", "median_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "=_", "newl", "_", "\\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 ", " _", "L_", "=_", "L_", "+_", "newl", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bounds_", "[_", "0_", "]_", "=_", "cand", "\\u", "median_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "=_", "newr", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "bounds_", "==_", "old", "\\u", "bounds_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "cand", "\\u", "median_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\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_", "size", "\\u", "vs", "\\u", "error_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "d", ",", " ", "w", " ", "=", " ", "25", ",", " ", "7_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "Sketch", ":", " ", "d", "=", "%", "s", " ", "w", "=", "%", "s", " ", "(", "Cmp", ".", " ", "size", ":", " ", "%", "s", "%%", ")\"", " ", "%", " ", "(", "d", ",", " ", "w", ",", " ", "(", "float", "(", "100", "*", "d", "*", "w", ")/", "1000", ")))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", "up", " ", "the", " ", "crypto_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "G_", "=_", "Ec", "Group_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sec_", "=_", "G_", "._", "order_", "(_", ")_", "._", "random_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "sec_", "*_", "G_", "._", "generator_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "some", " ", "test", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "narrow", "\\u", "vals_", "=_", "1000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wide", "\\u", "vals_", "=_", "200_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "numpy_", "._", "random_", "import_", "laplac", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "defaultdict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "datapoints", "_", "=_", "defaultdict_", "(_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizes_", "=_", "defaultdict_", "(_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "eps_", "=_", "[_", "0.5_", ",_", "0.35_", ",_", "0.25_", ",_", "0.15_", ",_", "0.1_", ",_", "0.05_", ",_", "0.025", "_", ",_", "0.01_", "]_", "#", ",", " ", "0.005", ",", " ", "0.001", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "epsilon_", "in_", "eps_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "epsilon_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "\\u_", "in_", "range_", "(_", "40_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "[_", "gauss_", "(_", "300_", ",_", "25_", ")_", "for_", "\\u_", "in_", "range_", "(_", "narrow", "\\u", "vals_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "+=_", "[_", "gauss_", "(_", "500_", ",_", "200_", ")_", "for_", "\\u_", "in_", "range_", "(_", "wide", "\\u", "vals_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "sorted_", "(_", "[_", "int_", "(_", "v_", ")_", "for_", "v_", "in_", "vals_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "median_", "=_", "vals_", "[_", "int_", "(_", "len_", "(_", "vals_", ")_", "/_", "2_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "each", " ", "sample", " ", "to", " ", "the", " ", "sketch", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cs", " ", "=", " ", "Count", "Sketch", "Ct", "(", "d", ",", " ", "w", ",", " ", "y", ")_", "\\u\\u\\uNL\\u\\u\\u_", "cs_", "=_", "Count", "Sketch", "Ct", "_", "._", "eps", "ilon", "delta_", "(_", "epsilon_", ",_", "epsilon_", ",_", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizes_", "[_", "epsilon_", "]_", "+=_", "[_", "float_", "(_", "100_", "*_", "cs_", "._", "d_", "*_", "cs_", "._", "w_", ")_", "/_", "1000_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "vals_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cs_", "._", "insert_", "(_", "\"%", "s", "\"_", "%_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", "w", " ", "use", " ", "test", " ", "the", " ", "median", " ", "function_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "proto_", "=_", "get", "\\u", "median_", "(_", "cs_", ",_", "min", "\\u", "b_", "=_", "0_", ",_", "max", "\\u", "b_", "=_", "1000_", ",_", "steps_", "=_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plain_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "no", "\\u", "decrypt", "ions_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "proto_", "._", "send_", "(_", "plain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "v_", ",_", "int_", ")_", ":_", "\\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_", "no", "\\u", "decrypt", "ions_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "noise_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plain_", "=_", "v_", "._", "dec_", "(_", "sec_", ")_", "+_", "noise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Estimated", " ", "median", ":", " ", "%", "s", "\\\\", "t", "\\\\", "t", "Abs", ".", " ", "Err", ":", " ", "%", "s", "\"_", "%_", "(_", "v_", ",_", "abs_", "(_", "v_", "-_", "median_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "datapoints", "_", "[_", "epsilon_", "]_", "+=_", "[_", "100_", "*_", "float_", "(_", "abs_", "(_", "v_", "-_", "median_", ")_", ")_", "/_", "median_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lower", "\\u", "err_", ",_", "core", "\\u", "err_", ",_", "upper", "\\u", "err_", "=_", "analyze", "\\u", "series_", "(_", "eps_", ",_", "datapoints", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lower", "\\u", "siz", "_", ",_", "core", "\\u", "siz", "_", ",_", "upper", "\\u", "siz", "_", "=_", "analyze", "\\u", "series_", "(_", "eps_", ",_", "sizes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "matplotlib_", "._", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "eps", "\\u", "lab_", "=_", "range_", "(_", "len_", "(_", "eps_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "plot_", "(_", "eps_", ",_", "core", "\\u", "err_", ",_", "label_", "=_", "\"", "Error", " ", "(%", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xscale_", "(_", "'", "log", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "v", " ", "=", " ", "v", "\\u", "issue", " ", "/", " ", "(", "len", "(", "cnt", "\\u", "issue", ")**", "0.", "5", ")_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "fill", "\\u", "between_", "(_", "x_", "=_", "eps_", ",_", "y1_", "=_", "lower", "\\u", "err_", ",_", "y2_", "=_", "upper", "\\u", "err_", ",_", "alpha_", "=_", "0.2_", ",_", "color_", "=_", "\"", "b", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xticks_", "(_", "eps_", ",_", "eps_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "plot_", "(_", "eps_", ",_", "core", "\\u", "siz", "_", ",_", "label_", "=_", "r", "\"", "Size", " ", "(%", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "plt", ".", "ysc", "ale", "('", "log", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "v", " ", "=", " ", "v", "\\u", "issue", " ", "/", " ", "(", "len", "(", "cnt", "\\u", "issue", ")**", "0.", "5", ")_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "fill", "\\u", "between_", "(_", "x_", "=_", "eps_", ",_", "y1_", "=_", "lower", "\\u", "siz", "_", ",_", "y2_", "=_", "upper", "\\u", "siz", "_", ",_", "alpha_", "=_", "0.2_", ",_", "color_", "=_", "\"", "b", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "plt", ".", "xtick", "s", "(", "eps", "\\u", "lab", ",", " ", "eps", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "r", "'(", "eps", "ilon", ",", " ", "delta", ")", " ", "parameter", " ", "of", " ", "Count", "-", "Sketch", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "r", "'%'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "r", "'", "Media", "n", " ", "Estimat", "ion", " ", "-", " ", "Error", " ", "vs", ".", " ", "Size", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "plt", ".", "axis", "([", "1", ",", " ", "10", ",", " ", "0", ",", " ", "1700", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "plt", ".", "grid", "(", "Tru", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "legend_", "(_", "loc_", "=_", "\"", "upper", " ", "center", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "savefig_", "(_", "\"", "Size", ".", "pdf", "\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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 ]
Testing equality to None
sippy/b2bua/sippy/UacStateIdle.py
[ { "content": " def recvEvent(self, event):\n if isinstance(event, CCEventTry):\n if self.ua.setup_ts == None:\n self.ua.setup_ts = event.rtime\n self.ua.origin = 'callee'\n cId, cGUID, callingID, calledID, body, auth, callingName = event.getData()\n if body != None:\n if self.ua.on_local_sdp_change != None and body.needs_update:\n self.ua.on_local_sdp_change(body, lambda x: self.ua.recvEvent(event))\n return None\n else:\n self.ua.late_media = True\n if cId == None:\n self.ua.cId = SipCallId()\n else:\n self.ua.cId = cId.getCopy()\n self.ua.global_config['_sip_tm'].regConsumer(self.ua, str(self.ua.cId), compact = self.ua.compact_sip)\n self.ua.rTarget = SipURL(username = calledID, host = self.ua.rAddr0[0], port = self.ua.rAddr0[1])\n self.ua.rUri = SipTo(address = SipAddress(url = self.ua.rTarget.getCopy(), hadbrace = True))\n if self.ua.ruri_userparams != None:\n self.ua.rTarget.userparams = self.ua.ruri_userparams\n self.ua.rUri.getUrl().port = None\n if self.ua.to_username != None:\n self.ua.rUri.getUrl().username = self.ua.to_username\n self.ua.lUri = SipFrom(address = SipAddress(url = SipURL(username = callingID), hadbrace = True, name = callingName))\n self.ua.lUri.getUrl().port = None\n if self.ua.from_domain != None:\n self.ua.lUri.getUrl().host = self.ua.from_domain\n self.ua.lUri.setTag(self.ua.lTag)\n self.ua.lCSeq = 200\n if self.ua.lContact == None:\n self.ua.lContact = SipContact()\n self.ua.lContact.getUrl().username = callingID\n self.ua.routes = []\n self.ua.cGUID = cGUID\n self.ua.lSDP = body\n req = self.ua.genRequest('INVITE', body, reason = event.reason)\n self.ua.lCSeq += 1\n self.ua.tr = self.ua.global_config['_sip_tm'].newTransaction(req, self.ua.recvResponse, \\\n laddress = self.ua.source_address, cb_ifver = 2, compact = self.ua.compact_sip)\n self.ua.auth = None\n if self.ua.expire_time != None:\n self.ua.expire_time += event.rtime\n if self.ua.no_progress_time != None:\n self.ua.no_progress_time += event.rtime\n if self.ua.expire_time != None and self.ua.no_progress_time >= self.ua.expire_time:\n self.ua.no_progress_time = None\n if self.ua.no_reply_time != None:\n if self.ua.no_reply_time < 32:\n self.ua.no_reply_time += event.rtime\n if self.ua.expire_time != None and self.ua.no_reply_time >= self.ua.expire_time:\n self.ua.no_reply_time = None\n elif self.ua.no_progress_time != None and self.ua.no_reply_time >= self.ua.no_progress_time:\n self.ua.no_reply_time = None\n else:\n self.ua.no_reply_time = None\n if self.ua.no_reply_time != None:\n self.ua.no_reply_timer = TimeoutAbs(self.ua.no_reply_expires, self.ua.no_reply_time)\n elif self.ua.no_progress_time != None:\n self.ua.no_progress_timer = TimeoutAbs(self.ua.no_progress_expires, self.ua.no_progress_time)\n elif self.ua.expire_time != None:\n self.ua.expire_timer = TimeoutAbs(self.ua.expires, self.ua.expire_time)\n return (UacStateTrying,)\n if isinstance(event, CCEventFail) or isinstance(event, CCEventRedirect) or isinstance(event, CCEventDisconnect):\n return (UaStateDead, self.ua.disc_cbs, event.rtime, event.origin)\n return None", "metadata": "root.UacStateIdle.recvEvent", "header": "['class', 'UacStateIdle', '(', 'UaStateGeneric', ')', ':', '___EOS___']", "index": 39 } ]
[ { "span": "self.ua.setup_ts == None:", "start_line": 41, "start_column": 15, "end_line": 41, "end_column": 39 }, { "span": "cId == None:", "start_line": 51, "start_column": 15, "end_line": 51, "end_column": 26 }, { "span": "self.ua.lContact == None:", "start_line": 69, "start_column": 15, "end_line": 69, "end_column": 39 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Ua", "c", "State", "Id", "le_", "(_", "Ua", "State", "Generic_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "recv", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "event_", ",_", "CC", "Event", "Tr", "y_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "ua_", "._", "setup", "\\u", "ts_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "setup", "\\u", "ts_", "=_", "event_", "._", "rti", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "ua_", "._", "origin_", "=_", "'", "callee", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c", "Id_", ",_", "c", "GUID", "_", ",_", "calling", "ID_", ",_", "call", "ed", "ID_", ",_", "body_", ",_", "auth_", ",_", "calling", "Name_", "=_", "event_", "._", "get", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "body_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "ua_", "._", "on", "\\u", "local", "\\u", "sd", "p", "\\u", "change_", "!=_", "None_", "and_", "body_", "._", "need", "s", "\\u", "update_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "ua_", "._", "on", "\\u", "local", "\\u", "sd", "p", "\\u", "change_", "(_", "body_", ",_", "lambda_", "x_", ":_", "self_", "._", "ua_", "._", "recv", "Event_", "(_", "event_", ")_", ")_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "late", "\\u", "media_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "c", "Id_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "c", "Id_", "=_", "Si", "p", "Call", "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 ", " _", "self_", "._", "ua_", "._", "c", "Id_", "=_", "c", "Id_", "._", "get", "Copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "ua_", "._", "global", "\\u", "config_", "[_", "'\\u", "sip", "\\u", "tm", "'_", "]_", "._", "reg", "Consumer_", "(_", "self_", "._", "ua_", ",_", "str_", "(_", "self_", "._", "ua_", "._", "c", "Id_", ")_", ",_", "compact_", "=_", "self_", "._", "ua_", "._", "compact", "\\u", "sip_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "r", "Target_", "=_", "Si", "p", "URL_", "(_", "username_", "=_", "call", "ed", "ID_", ",_", "host_", "=_", "self_", "._", "ua_", "._", "r", "Add", "r0_", "[_", "0_", "]_", ",_", "port_", "=_", "self_", "._", "ua_", "._", "r", "Add", "r0_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "r", "Uri_", "=_", "Si", "p", "To_", "(_", "address_", "=_", "Si", "p", "Address_", "(_", "url_", "=_", "self_", "._", "ua_", "._", "r", "Target_", "._", "get", "Copy_", "(_", ")_", ",_", "had", "brace", "_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "ru", "ri", "\\u", "userp", "arams_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "r", "Target_", "._", "userp", "arams_", "=_", "self_", "._", "ua_", "._", "ru", "ri", "\\u", "userp", "arams_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "ua_", "._", "r", "Uri_", "._", "get", "Url_", "(_", ")_", "._", "port_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "to", "\\u", "username_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "r", "Uri_", "._", "get", "Url_", "(_", ")_", "._", "username_", "=_", "self_", "._", "ua_", "._", "to", "\\u", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "Uri_", "=_", "Si", "p", "From_", "(_", "address_", "=_", "Si", "p", "Address_", "(_", "url_", "=_", "Si", "p", "URL_", "(_", "username_", "=_", "calling", "ID_", ")_", ",_", "had", "brace", "_", "=_", "True_", ",_", "name_", "=_", "calling", "Name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "Uri_", "._", "get", "Url_", "(_", ")_", "._", "port_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "from", "\\u", "domain_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "l", "Uri_", "._", "get", "Url_", "(_", ")_", "._", "host_", "=_", "self_", "._", "ua_", "._", "from", "\\u", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "Uri_", "._", "set", "Tag_", "(_", "self_", "._", "ua_", "._", "l", "Tag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "CS", "eq_", "=_", "200_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "l", "Contact_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "l", "Contact_", "=_", "Si", "p", "Contact_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "Contact_", "._", "get", "Url_", "(_", ")_", "._", "username_", "=_", "calling", "ID_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "routes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "c", "GUID", "_", "=_", "c", "GUID", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "SD", "P_", "=_", "body_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "=_", "self_", "._", "ua_", "._", "gen", "Request_", "(_", "'", "INVI", "TE", "'_", ",_", "body_", ",_", "reason_", "=_", "event_", "._", "reason_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "l", "CS", "eq_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "tr_", "=_", "self_", "._", "ua_", "._", "global", "\\u", "config_", "[_", "'\\u", "sip", "\\u", "tm", "'_", "]_", "._", "new", "Transaction_", "(_", "req_", ",_", "self_", "._", "ua_", "._", "recv", "Response_", ",_", "lad", "dress", "_", "=_", "self_", "._", "ua_", "._", "source", "\\u", "address_", ",_", "cb", "\\u", "if", "ver_", "=_", "2_", ",_", "compact_", "=_", "self_", "._", "ua_", "._", "compact", "\\u", "sip_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ua_", "._", "auth_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", "+=_", "event_", "._", "rti", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", "+=_", "event_", "._", "rti", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", "!=_", "None_", "and_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", ">=_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "<_", "32_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "+=_", "event_", "._", "rti", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", "!=_", "None_", "and_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", ">=_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", "!=_", "None_", "and_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", ">=_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "timer_", "=_", "Time", "out", "Abs", "_", "(_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "expires_", ",_", "self_", "._", "ua_", "._", "no", "\\u", "repl", "y", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "timer_", "=_", "Time", "out", "Abs", "_", "(_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "expires_", ",_", "self_", "._", "ua_", "._", "no", "\\u", "progress", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ua_", "._", "expir", "e\\u", "timer_", "=_", "Time", "out", "Abs", "_", "(_", "self_", "._", "ua_", "._", "expires_", ",_", "self_", "._", "ua_", "._", "expir", "e\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "Ua", "c", "State", "Tr", "ying", "_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "event_", ",_", "CC", "Event", "Fail_", ")_", "or_", "isinstance_", "(_", "event_", ",_", "CC", "Event", "Redirect_", ")_", "or_", "isinstance_", "(_", "event_", ",_", "CC", "Event", "Disconnect", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "Ua", "State", "Dead", "_", ",_", "self_", "._", "ua_", "._", "disc", "\\u", "cbs", "_", ",_", "event_", "._", "rti", "me_", ",_", "event_", "._", "origin_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unreachable code
Esri/solutions-geoprocessing-toolbox/suitability/toolboxes/scripts/MultidimensionSupplementalTools/MultidimensionSupplementalTools/Scripts/mds/tools/multidimensional_zonal_statistics_as_table.py
[ { "content": " def isLicensed(self):\n \"\"\"Execute only if the ArcGIS Spatial Analyst extension is available.\"\"\"\n try:\n if arcpy.CheckExtension(\"Spatial\") == \"Available\":\n #arcpy.CheckOutExtension(\"Spatial\")\n return True\n else:\n return False\n except:\n return False # tool cannot be executed\n return True # tool can be executed", "metadata": "root.MultidimensionalZonalStatisticsAsTable.isLicensed", "header": "['class', 'MultidimensionalZonalStatisticsAsTable', '(', 'object', ')', ':', '___EOS___']", "index": 239 }, { "content": " def zonal_statistics_as_table_for_grid(self, parameters, messages, dataset):\n \"\"\"Performs zonal statistics as table assuming dataset contains\n regularly gridded variables.\"\"\"\n\n zone_parameter = parameters[0]\n input_parameter = parameters[1]\n variable_parameter = parameters[2]\n output_parameter = parameters[3]\n type_parameter = parameters[4]\n ignore_parameter = parameters[5]\n zonefield_parameter = parameters[6]\n\n # Grab the parameter values\n dataset_name = input_parameter.valueAsText # input netCDF filename\n output_filename = output_parameter.valueAsText # output filename\n var_name = variable_parameter.valueAsText # netCDF variable name\n\n # Extract variable from netCDF dataset\n arr_var = dataset.variable(var_name)\n\n # Check that spatial dimensions of input netCDF variable are regularly\n # gridded and obtain cell size\n cell_size_x = None\n cell_size_y = None\n spat_list = list(dataset.space_dimension_names(var_name))\n assert len(spat_list) >= 2\n spat_var = dataset.variable(spat_list[0])\n blfirst = True\n if spat_var.size > 1:\n for i in range(spat_var.size - 1):\n cell_size_x = spat_var[i+1] - spat_var[i]\n if (not blfirst) and (cell_size_x != last_cell_size):\n messages.addErrorMessage(\n mds.messages.VARIABLE_NOT_REGULARLY_GRIDDED.format(\n var_name, spat_list[0]))\n raise arcpy.ExecuteError\n break\n last_cell_size = cell_size_x\n blfirst = False\n cell_size_x = float(cell_size_x)\n spat_var = dataset.variable(spat_list[1])\n blfirst = True\n if spat_var.size > 1:\n for i in range(spat_var.size - 1):\n cell_size_y = spat_var[i+1] - spat_var[i]\n if (not blfirst) and (cell_size_y != last_cell_size):\n messages.addErrorMessage(\n mds.messages.VARIABLE_NOT_REGULARLY_GRIDDED.format(\n var_name, spat_list[1]))\n raise arcpy.ExecuteError\n break\n last_cell_size = cell_size_y\n blfirst = False\n cell_size_y = float(cell_size_y)\n # If both x and y cell sizes are None, the dataset is a scalar.\n if (cell_size_x is None) and (cell_size_y is None):\n messages.addErrorMessage(\n mds.messages.VARIABLE_CONTAINS_INSUFFICIENT_VALUES.format(\n var_name))\n raise arcpy.ExecuteError\n # If one of x and y is None, the dataset is a line, so we will assume\n # the singleton dimension shares the other's cell size.\n if cell_size_x is None:\n cell_size_x = cell_size_y\n messages.addWarningMessage(\n (\"Assuming variable dimension {} shares a cell size of {} \" + \\\n \"with {}\").format(spat_list[0], cell_size_y, spat_list[1]))\n if cell_size_y is None:\n cell_size_y = cell_size_x\n messages.addWarningMessage(\n (\"Assuming variable dimension {} shares a cell size of {} \" + \\\n \"with {}\").format(spat_list[1], cell_size_x, spat_list[0]))\n\n # Figure out which spatial variable is x and which is y\n # and then get corresponding number of columns and rows\n if dataset.convention.is_x_dimension_variable(dataset.variable(spat_list[0])):\n ncol = len(dataset.variable(spat_list[0]))\n nrow = len(dataset.variable(spat_list[1]))\n bltranspose = True\n else:\n ncol = len(dataset.variable(spat_list[1]))\n nrow = len(dataset.variable(spat_list[0]))\n cell_size_x, cell_size_y = cell_size_y, cell_size_x\n bltranspose = False\n\n # Grab extent from netCDF dataset\n # i.e. [x_min, y_min, x_max, y_max]\n var_extent = dataset.extent(var_name)\n # Lower left hand corner of netCDF variable spatial slice\n xl = float(var_extent[0])\n yl = float(var_extent[1])\n\n # Determine whether to flip the zone data over a given axis and\n # transpose it to align with the netCDF data\n blflipx = False\n blflipy = False\n if cell_size_y > 0:\n blflipx = True\n if cell_size_x < 0:\n blflipy = True\n\n # Use absolute cell sizes\n cell_size_x = abs(cell_size_x)\n cell_size_y = abs(cell_size_y)\n\n # Convert extent to extent object for use later\n var_extent = arcpy.Extent(var_extent[0], var_extent[1], \\\n var_extent[2], var_extent[3])\n\n # Was a temporary raster created?\n bltempRaster = False\n\n # Describe zone data\n desc = arcpy.Describe(zone_parameter.value)\n\n # Environments\n arcpy.env.outputCoordinateSystem = desc.spatialReference\n temp_snap = arcpy.NumPyArrayToRaster(numpy.zeros((1,1)), \\\n arcpy.Point(xl,yl), cell_size_x, cell_size_y)\n arcpy.env.snapRaster = temp_snap\n\n # Process input zone data\n valid_raster_types = [\"RasterLayer\", \"RasterDataset\"]\n valid_feature_types = [\"ShapeFile\",\"FeatureLayer\", \"FeatureDataset\"]\n if desc.dataType in valid_feature_types:\n # Limitation of Feature to Raster\n if cell_size_x != cell_size_y:\n messages.addErrorMessage(\n \"The variable %s must use the same gridding \" + \\\n \"for both its spatial dimensions when feature zone \" + \\\n \"data is used.\" % var_name)\n raise arcpy.ExecuteError\n # Convert features\n temp_raster = 'in_memory\\\\temp'\n arcpy.FeatureToRaster_conversion(zone_parameter.value, \\\n zonefield_parameter.value, temp_raster, cell_size_x)\n bltempRaster = True\n # NoData value\n noDataValue = arcpy.Describe(temp_raster).noDataValue\n elif desc.dataType in valid_raster_types:\n # Map non-Value field to Value if necessary and grab NoData value\n if zonefield_parameter.value != 'Value':\n in_raster = arcpy.sa.Lookup(zone_parameter.value, \\\n zonefield_parameter.value)\n # Raster created with Lookup will have default noDataValue\n # used for given .pixelType, but not assigned to .noDataValue\n if '8' in in_raster.pixelType:\n noDataValue = -128 # S8\n else:\n noDataValue = -2147483647 # S32\n else:\n in_raster = zone_parameter.valueAsText\n noDataValue = desc.noDataValue\n # Resample if necessary\n if (desc.meanCellHeight != cell_size_y) or \\\n (desc.meanCellWidth != cell_size_x):\n temp_raster = 'in_memory\\\\temp'\n arcpy.Resample_management(in_raster, temp_raster, \\\n \"%f %f\" % (cell_size_x, cell_size_y))\n bltempRaster = True\n else:\n temp_raster = in_raster\n else:\n messages.addErrorMessage(\"Not a valid zone dataset.\")\n raise arcpy.ExecuteError\n\n # Make raster object from zone data if not already\n if not isinstance(temp_raster, arcpy.Raster):\n temp_raster = arcpy.Raster(temp_raster)\n\n # Limit to lon [-180, 180] and lat [-90, 90]\n def convert_coord(num, islon = True):\n lim = 180 if islon else 90\n if num > lim:\n out = num % -lim\n elif num < -lim:\n out = num % lim\n else:\n out = num\n if not islon:\n mult = -1.0 if num < 0 else 1.0\n out = mult * abs(out)\n return out\n\n # Determine whether input zone data has a PCS or GCS\n if (temp_raster.spatialReference.exporttostring() == \\\n temp_raster.spatialReference.GCS.exporttostring()):\n # Test for overlap between zone and netCDF data\n if temp_raster.extent.disjoint(var_extent):\n # Try with coordinates in lon[-180,180] and lat[-90,90] ranges\n var_extent_temp = arcpy.Extent(\n convert_coord(var_extent.XMin, True),\n convert_coord(var_extent.YMin, True),\n convert_coord(var_extent.XMax, False),\n convert_coord(var_extent.YMax, False))\n xl = var_extent_temp.XMin\n yl = var_extent_temp.YMin\n # Check again and throw warning on failure\n if temp_raster.extent.disjoint(var_extent_temp):\n messages.addWarningMessage(\"Data extents don't overlap.\")\n else:\n if (not temp_raster.extent.overlaps(var_extent)) and (\n not temp_raster.extent.equals(var_extent)):\n messages.addWarningMessage(\"Data extents don't overlap.\")\n\n # Extract zone data from raster\n arr_zone = arcpy.RasterToNumPyArray(temp_raster, arcpy.Point(xl,yl), \\\n ncol, nrow)\n # Flip zone raster to accord with how data is stored\n if blflipx:\n arr_zone = numpy.flipud(arr_zone)\n if blflipy:\n arr_zone = numpy.fliplr(arr_zone)\n if bltranspose:\n arr_zone = numpy.transpose(arr_zone)\n # Delete temporary raster if it exists\n if bltempRaster:\n arcpy.Delete_management(temp_raster)\n\n # Check if variable is packed\n ispacked = hasattr(arr_var,'scale_factor') or hasattr(arr_var, 'add_offset')\n # Determine whether given statistic is categorical or not\n new_var_dtype = False\n for stat in self.statistics:\n if type_parameter.valueAsText in stat[1].keys():\n new_var_dtype = stat[2]\n break\n type_changed = False\n if ('int' in str(arr_var.dtype)) and (not new_var_dtype) and (\n not ispacked):\n type_changed = True\n\n # Slice generator\n # Adapted from: http://code.activestate.com/recipes/\n # 502194-a-generator-for-an-arbitrary-number-of-for-loops/\n # Originally written by Steven Bethard\n def multi_for(iterables):\n if not iterables:\n yield ()\n else:\n if isinstance(iterables[0], collections.Iterable):\n for item in iterables[0]:\n for rest_tuple in multi_for(iterables[1:]):\n yield (item,) + rest_tuple\n else:\n for rest_tuple in multi_for(iterables[1:]):\n yield (iterables[0],) + rest_tuple\n\n # Generate slice list\n dim_shape = arr_var.shape\n dim_name = arr_var.dimensions\n dim_slices = []\n dim_dims = []\n dim_prod = 1\n for dim_index, dim_item in enumerate(dim_name):\n if not dim_item in spat_list:\n dim_prod *= dim_shape[dim_index]\n dim_slices.append(xrange(dim_shape[dim_index]))\n dim_dims.append((str(dim_item), numpy.int))\n else:\n dim_slices.append(Ellipsis)\n\n blstructcreated = False\n\n def hstack_struct(arr1, arr2):\n # Will only work correctly if arr1 and arr2 only have one record\n dt = numpy.lib.recfunctions.zip_descr((arr1, arr2), flatten=True)\n return numpy.array(arr1.tolist() + arr2.tolist(), dtype = dt)\n\n # Get zone values\n if noDataValue is not None:\n zones = numpy.setdiff1d(numpy.unique(arr_zone), [noDataValue])\n else:\n zones = numpy.unique(arr_zone)\n\n # Progress bar\n dim_prod *= zones.size\n arcpy.ResetProgressor()\n arcpy.SetProgressor('step', 'Calculating...', 0, dim_prod, 1)\n\n # Loop through slices\n index = 0\n valid_indices = []\n for varslice in multi_for(dim_slices):\n\n # Take slice from data\n if type_changed:\n arr_slice = arr_var[varslice].astype('f8')\n else:\n arr_slice = arr_var[varslice]\n\n # Create masked array\n if hasattr(arr_slice, 'mask'):\n arr_mask = arr_slice.mask.copy()\n else:\n arr_mask = numpy.ma.make_mask_none(arr_slice.shape)\n arr_slice = numpy.ma.asarray(arr_slice)\n\n # Loop over zones\n for z in zones:\n # Perform for zone when NoData is ignored\n # or when there is no NoData within zone\n if ignore_parameter.value or \\\n (not numpy.any((arr_zone==z) & arr_mask)):\n # Set mask to netCDF NoData mask\n arr_slice.mask = arr_mask\n # Apply zone mask\n arr_slice[arr_zone!=z] = numpy.ma.masked\n # Apply operator to zone masked slice\n result = self.calculate_statistic(arr_slice[:], \\\n type_parameter.valueAsText)\n\n # Structure results into row\n struct_data = [dataset.variable(dim_name[it_ind])[it] for \\\n it_ind, it in enumerate(list(varslice)) if \\\n it != Ellipsis]\n struct_data.append(z)\n struct_data.append(numpy.ma.count(arr_slice))\n if numpy.isscalar(result):\n # Single-valued result\n struct_data.append(result)\n else:\n # Multivalued result\n struct_data += [it2 for it in result.tolist() for \\\n it2 in it]\n\n # Create table when necessary\n if not blstructcreated:\n struct_dtype = dim_dims[:]\n struct_dtype.append((str(zonefield_parameter.value), \\\n numpy.int))\n struct_dtype.append(('COUNT', numpy.int))\n if type_parameter.valueAsText in \\\n self.statistics_multiple_values:\n struct_dtype += [(it, numpy.float) for it in list(\n result.dtype.names)]\n else:\n struct_dtype.append((str(\n type_parameter.valueAsText), numpy.float))\n struct = numpy.zeros((dim_prod,), numpy.dtype(struct_dtype))\n blstructcreated = True\n\n # Insert row\n struct[index] = numpy.array(tuple(struct_data), \\\n numpy.dtype(struct_dtype))\n\n valid_indices.append(index)\n #else:\n # # Passing drops zones with NoData in them from table\n # pass\n index += 1\n arcpy.SetProgressorPosition()\n\n arcpy.ResetProgressor()\n\n if 'time' in dim_name:\n # Output zonal statistics to temporary table\n temp_table = os.path.join(tempfile.gettempdir(), 'temp_table.dbf')\n if arcpy.Exists(temp_table):\n arcpy.Delete_management(temp_table)\n arcpy.da.NumPyArrayToTable(struct[valid_indices], temp_table)\n # Create table view of the time dimension from netCDF file\n temp_mdtable = r\"md_table\"\n arcpy.MakeNetCDFTableView_md(dataset_name, 'time', temp_mdtable, 'time')\n # Get time field from table view\n desc_fields = arcpy.ListFields(temp_mdtable)\n time_field = desc_fields[[field.name for field in \\\n desc_fields].index('time')]\n # Create a table in the output location\n arcpy.CreateTable_management(*os.path.split(output_filename))\n # Add fields from temporary table except for time field, which\n # we add from the MakeNetCDFTableView\n desc_fields = arcpy.ListFields(temp_table)\n for index, field in enumerate(desc_fields):\n if field.type != 'OID':\n if field.name == 'time':\n arcpy.AddField_management(output_filename, time_field.name, \\\n time_field.type, time_field.precision, time_field.scale, \\\n time_field.length, time_field.aliasName, \\\n time_field.isNullable, time_field.required, \\\n time_field.domain)\n else:\n arcpy.AddField_management(output_filename, field.name, \\\n field.type, field.precision, field.scale, field.length, \\\n field.aliasName, field.isNullable, field.required,\n field.domain)\n arcpy.DeleteField_management(output_filename,\"Field1\")\n # Create list of datetime objects from table view\n time_arc = []\n with arcpy.da.SearchCursor(temp_mdtable, 'time') as cursor:\n for row in cursor:\n time_arc.append(row[0])\n del cursor\n # Get time variable from netCDF dataset\n time_var = dataset.variable('time')[:].tolist()\n # Loop through entries from temporary table\n with arcpy.da.InsertCursor(output_filename, '*') as ins_cursor:\n new_time_ind = ins_cursor.fields.index('time')\n with arcpy.da.SearchCursor(temp_table, '*') as cursor:\n time_ind = cursor.fields.index('time')\n for row in cursor:\n new_row = list(row)\n new_row[new_time_ind] = \\\n time_arc[time_var.index(row[time_ind])]\n ins_cursor.insertRow(tuple(new_row))\n del ins_cursor\n del cursor\n else:\n # Write table\n if arcpy.env.overwriteOutput:\n arcpy.Delete_management(output_filename)\n arcpy.da.NumPyArrayToTable(struct[valid_indices], output_filename)\n\n return", "metadata": "root.MultidimensionalZonalStatisticsAsTable.zonal_statistics_as_table_for_grid", "header": "['class', 'MultidimensionalZonalStatisticsAsTable', '(', 'object', ')', ':', '___EOS___']", "index": 447 } ]
[ { "span": "return True ", "start_line": 249, "start_column": 8, "end_line": 249, "end_column": 19 }, { "span": "break", "start_line": 483, "start_column": 20, "end_line": 483, "end_column": 25 }, { "span": "break", "start_line": 497, "start_column": 20, "end_line": 497, "end_column": 25 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Multi", "dimension", "al", "Zon", "al", "Statistic", "s", "As", "Table_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "License", "d_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Execut", "e", " ", "only", " ", "if", " ", "the", " ", "Arc", "GI", "S", " ", "Spa", "tial", " ", "Analy", "st", " ", "extensi", "on", " ", "is", " ", "avail", "able", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "arcpy_", "._", "Check", "Extension_", "(_", "\"", "Spa", "tial", "\"_", ")_", "==_", "\"", "Avail", "able", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "arc", "py", ".", "Check", "Out", "Ext", "ensi", "on", "(\"", "Spa", "tial", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\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_", "\\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 ", " _", "return_", "False_", "#", " ", "tool", " ", "cann", "ot", " ", "be", " ", "executed", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "#", " ", "tool", " ", "can", " ", "be", " ", "executed", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Multi", "dimension", "al", "Zon", "al", "Statistic", "s", "As", "Table_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "zona", "l\\u", "statistic", "s", "\\u", "as", "\\u", "table", "\\u", "for", "\\u", "grid_", "(_", "self_", ",_", "parameters_", ",_", "messages_", ",_", "dataset_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Perform", "s", " ", "zona", "l", " ", "statistic", "s", " ", "as", " ", "table", " ", "ass", "umi", "ng", " ", "dataset", " ", "contain", "s", "\\", "10", ";", " ", " ", " ", " ", "regular", "ly", " ", "gridd", "ed", " ", "variab", "les", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "zone", "\\u", "parameter_", "=_", "parameters_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input", "\\u", "parameter_", "=_", "parameters_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "variab", "le", "\\u", "parameter_", "=_", "parameters_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output", "\\u", "parameter_", "=_", "parameters_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type", "\\u", "parameter_", "=_", "parameters_", "[_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ignore", "\\u", "parameter_", "=_", "parameters_", "[_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zone", "field", "\\u", "parameter_", "=_", "parameters_", "[_", "6_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "the", " ", "parameter", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "dataset", "\\u", "name_", "=_", "input", "\\u", "parameter_", "._", "value", "As", "Text_", "#", " ", "input", " ", "net", "CD", "F", " ", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output", "\\u", "filename_", "=_", "output", "\\u", "parameter_", "._", "value", "As", "Text_", "#", " ", "output", " ", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "var", "\\u", "name_", "=_", "variab", "le", "\\u", "parameter_", "._", "value", "As", "Text_", "#", " ", "net", "CD", "F", " ", "variab", "le", " ", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Extract", " ", "variab", "le", " ", "from", " ", "net", "CD", "F", " ", "dataset_", "\\u\\u\\uNL\\u\\u\\u_", "arr", "\\u", "var_", "=_", "dataset_", "._", "variable_", "(_", "var", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "spat", "ial", " ", "dimension", "s", " ", "of", " ", "input", " ", "net", "CD", "F", " ", "variab", "le", " ", "are", " ", "regular", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "gridd", "ed", " ", "and", " ", "obtain", " ", "cell", " ", "size_", "\\u\\u\\uNL\\u\\u\\u_", "cell", "\\u", "size", "\\u", "x_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cell", "\\u", "size", "\\u", "y_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "spat", "\\u", "list_", "=_", "list_", "(_", "dataset_", "._", "space", "\\u", "dimension", "\\u", "names_", "(_", "var", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "spat", "\\u", "list_", ")_", ">=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "spat", "\\u", "var_", "=_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "first_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "spat", "\\u", "var_", "._", "size_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "range_", "(_", "spat", "\\u", "var_", "._", "size_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cell", "\\u", "size", "\\u", "x_", "=_", "spat", "\\u", "var_", "[_", "i_", "+_", "1_", "]_", "-_", "spat", "\\u", "var_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "bl", "first_", ")_", "and_", "(_", "cell", "\\u", "size", "\\u", "x_", "!=_", "last", "\\u", "cell", "\\u", "size_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "messages_", "._", "add", "Error", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "mds", "_", "._", "messages_", "._", "VARIABLE", "\\u", "NOT", "\\u", "REGULA", "RL", "Y", "\\u", "GRID", "DED", "_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "var", "\\u", "name_", ",_", "spat", "\\u", "list_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "arcpy_", "._", "Execut", "e", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "last", "\\u", "cell", "\\u", "size_", "=_", "cell", "\\u", "size", "\\u", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "first_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cell", "\\u", "size", "\\u", "x_", "=_", "float_", "(_", "cell", "\\u", "size", "\\u", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spat", "\\u", "var_", "=_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "first_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "spat", "\\u", "var_", "._", "size_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "range_", "(_", "spat", "\\u", "var_", "._", "size_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cell", "\\u", "size", "\\u", "y_", "=_", "spat", "\\u", "var_", "[_", "i_", "+_", "1_", "]_", "-_", "spat", "\\u", "var_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "bl", "first_", ")_", "and_", "(_", "cell", "\\u", "size", "\\u", "y_", "!=_", "last", "\\u", "cell", "\\u", "size_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "messages_", "._", "add", "Error", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "mds", "_", "._", "messages_", "._", "VARIABLE", "\\u", "NOT", "\\u", "REGULA", "RL", "Y", "\\u", "GRID", "DED", "_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "var", "\\u", "name_", ",_", "spat", "\\u", "list_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "arcpy_", "._", "Execut", "e", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "last", "\\u", "cell", "\\u", "size_", "=_", "cell", "\\u", "size", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "first_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cell", "\\u", "size", "\\u", "y_", "=_", "float_", "(_", "cell", "\\u", "size", "\\u", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "bot", "h", " ", "x", " ", "and", " ", "y", " ", "cell", " ", "size", "s", " ", "are", " ", "Non", "e", ",", " ", "the", " ", "dataset", " ", "is", " ", "a", " ", "scala", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "cell", "\\u", "size", "\\u", "x_", "is_", "None_", ")_", "and_", "(_", "cell", "\\u", "size", "\\u", "y_", "is_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "add", "Error", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "mds", "_", "._", "messages_", "._", "VARIABLE", "\\u", "CONT", "AINS", "\\u", "INS", "UFF", "ICI", "ENT", "\\u", "VALUES_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "var", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "arcpy_", "._", "Execut", "e", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "one", " ", "of", " ", "x", " ", "and", " ", "y", " ", "is", " ", "Non", "e", ",", " ", "the", " ", "dataset", " ", "is", " ", "a", " ", "line", ",", " ", "so", " ", "we", " ", "will", " ", "assume", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "the", " ", "singleton", " ", "dimension", " ", "share", "s", " ", "the", " ", "other", "'", "s", " ", "cell", " ", "size", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cell", "\\u", "size", "\\u", "x_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cell", "\\u", "size", "\\u", "x_", "=_", "cell", "\\u", "size", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "add", "Warn", "ing", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Assu", "ming", " ", "variab", "le", " ", "dimension", " ", "{}", " ", "share", "s", " ", "a", " ", "cell", " ", "size", " ", "of", " ", "{}", " ", "\"_", "+_", "\"", "with", " ", "{}\"_", ")_", "._", "format_", "(_", "spat", "\\u", "list_", "[_", "0_", "]_", ",_", "cell", "\\u", "size", "\\u", "y_", ",_", "spat", "\\u", "list_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cell", "\\u", "size", "\\u", "y_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cell", "\\u", "size", "\\u", "y_", "=_", "cell", "\\u", "size", "\\u", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "add", "Warn", "ing", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Assu", "ming", " ", "variab", "le", " ", "dimension", " ", "{}", " ", "share", "s", " ", "a", " ", "cell", " ", "size", " ", "of", " ", "{}", " ", "\"_", "+_", "\"", "with", " ", "{}\"_", ")_", "._", "format_", "(_", "spat", "\\u", "list_", "[_", "1_", "]_", ",_", "cell", "\\u", "size", "\\u", "x_", ",_", "spat", "\\u", "list_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fig", "ure", " ", "out", " ", "whi", "ch", " ", "spat", "ial", " ", "variab", "le", " ", "is", " ", "x", " ", "and", " ", "whi", "ch", " ", "is", " ", "y_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "and", " ", "then", " ", "get", " ", "correspond", "ing", " ", "number", " ", "of", " ", "column", "s", " ", "and", " ", "rows_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "dataset_", "._", "convention", "_", "._", "is", "\\u", "x", "\\u", "dimension", "\\u", "variable_", "(_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "0_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ncol_", "=_", "len_", "(_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nrow_", "=_", "len_", "(_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "transpose_", "=_", "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 ", " _", "ncol_", "=_", "len_", "(_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nrow_", "=_", "len_", "(_", "dataset_", "._", "variable_", "(_", "spat", "\\u", "list_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cell", "\\u", "size", "\\u", "x_", ",_", "cell", "\\u", "size", "\\u", "y_", "=_", "cell", "\\u", "size", "\\u", "y_", ",_", "cell", "\\u", "size", "\\u", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "transpose_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "extent", " ", "from", " ", "net", "CD", "F", " ", "dataset_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "i", ".", "e", ".", " ", "[", "x", "\\u", "min", ",", " ", "y", "\\u", "min", ",", " ", "x", "\\u", "max", ",", " ", "y", "\\u", "max", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "var", "\\u", "extent_", "=_", "dataset_", "._", "extent_", "(_", "var", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Lower", " ", "left", " ", "hand", " ", "corn", "er", " ", "of", " ", "net", "CD", "F", " ", "variab", "le", " ", "spat", "ial", " ", "slice_", "\\u\\u\\uNL\\u\\u\\u_", "xl_", "=_", "float_", "(_", "var", "\\u", "extent_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yl", "_", "=_", "float_", "(_", "var", "\\u", "extent_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Det", "erm", "ine", " ", "whe", "ther", " ", "to", " ", "flip", " ", "the", " ", "zone", " ", "data", " ", "over", " ", "a", " ", "give", "n", " ", "axis", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "transpose", " ", "it", " ", "to", " ", "align", " ", "with", " ", "the", " ", "net", "CD", "F", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "bl", "flip", "x_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "flip", "y_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cell", "\\u", "size", "\\u", "y_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bl", "flip", "x_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cell", "\\u", "size", "\\u", "x_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bl", "flip", "y_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Us", "e", " ", "abs", "olute", " ", "cell", " ", "sizes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cell", "\\u", "size", "\\u", "x_", "=_", "abs_", "(_", "cell", "\\u", "size", "\\u", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cell", "\\u", "size", "\\u", "y_", "=_", "abs_", "(_", "cell", "\\u", "size", "\\u", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "extent", " ", "to", " ", "extent", " ", "object", " ", "for", " ", "use", " ", "later_", "\\u\\u\\uNL\\u\\u\\u_", "var", "\\u", "extent_", "=_", "arcpy_", "._", "Extent_", "(_", "var", "\\u", "extent_", "[_", "0_", "]_", ",_", "var", "\\u", "extent_", "[_", "1_", "]_", ",_", "var", "\\u", "extent_", "[_", "2_", "]_", ",_", "var", "\\u", "extent_", "[_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wa", "s", " ", "a", " ", "temporar", "y", " ", "rast", "er", " ", "created", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "bl", "temp", "Raster_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Describe", " ", "zone", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "desc_", "=_", "arcpy_", "._", "Describe", "_", "(_", "zone", "\\u", "parameter_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Environ", "ments_", "\\u\\u\\uNL\\u\\u\\u_", "arcpy_", "._", "env_", "._", "output", "Coordinat", "e", "System_", "=_", "desc_", "._", "spat", "ial", "Reference_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "snap_", "=_", "arcpy_", "._", "Num", "Py", "Array", "To", "Raster_", "(_", "numpy_", "._", "zeros_", "(_", "(_", "1_", ",_", "1_", ")_", ")_", ",_", "arcpy_", "._", "Point_", "(_", "xl_", ",_", "yl", "_", ")_", ",_", "cell", "\\u", "size", "\\u", "x_", ",_", "cell", "\\u", "size", "\\u", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "env_", "._", "snap", "Raster_", "=_", "temp", "\\u", "snap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "input", " ", "zone", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "valid", "\\u", "rast", "er", "\\u", "types_", "=_", "[_", "\"", "Ras", "ter", "Layer", "\"_", ",_", "\"", "Ras", "ter", "Datas", "et", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "valid", "\\u", "feature", "\\u", "types_", "=_", "[_", "\"", "Shape", "File", "\"_", ",_", "\"", "Feature", "Layer", "\"_", ",_", "\"", "Feature", "Datas", "et", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "desc_", "._", "data", "Type_", "in_", "valid", "\\u", "feature", "\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Limit", "ation", " ", "of", " ", "Feature", " ", "to", " ", "Raster_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cell", "\\u", "size", "\\u", "x_", "!=_", "cell", "\\u", "size", "\\u", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "add", "Error", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", " ", "variab", "le", " ", "%", "s", " ", "must", " ", "use", " ", "the", " ", "same", " ", "gridd", "ing", " ", "\"_", "+_", "\"", "for", " ", "bot", "h", " ", "its", " ", "spat", "ial", " ", "dimension", "s", " ", "whe", "n", " ", "feature", " ", "zone", " ", "\"_", "+_", "\"", "data", " ", "is", " ", "used", ".\"_", "%_", "var", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "arcpy_", "._", "Execut", "e", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Convert", " ", "features_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "temp", "\\u", "raster_", "=_", "'", "in", "\\u", "memory", "\\\\\\\\", "temp", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Feature", "To", "Ras", "ter", "\\u", "conversion_", "(_", "zone", "\\u", "parameter_", "._", "value_", ",_", "zone", "field", "\\u", "parameter_", "._", "value_", ",_", "temp", "\\u", "raster_", ",_", "cell", "\\u", "size", "\\u", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "temp", "Raster_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", "Data", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "no", "Data", "Value_", "=_", "arcpy_", "._", "Describe", "_", "(_", "temp", "\\u", "raster_", ")_", "._", "no", "Data", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "desc_", "._", "data", "Type_", "in_", "valid", "\\u", "rast", "er", "\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Map", " ", "non", "-", "Value", " ", "field", " ", "to", " ", "Value", " ", "if", " ", "necessar", "y", " ", "and", " ", "gra", "b", " ", "No", "Data", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "zone", "field", "\\u", "parameter_", "._", "value_", "!=_", "'", "Value", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "in", "\\u", "raster_", "=_", "arcpy_", "._", "sa_", "._", "Lookup_", "(_", "zone", "\\u", "parameter_", "._", "value_", ",_", "zone", "field", "\\u", "parameter_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ras", "ter", " ", "created", " ", "with", " ", "Look", "up", " ", "will", " ", "have", " ", "default", " ", "no", "Data", "Value_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "used", " ", "for", " ", "give", "n", " ", ".", "pixel", "Type", ",", " ", "but", " ", "not", " ", "assign", "ed", " ", "to", " ", ".", "no", "Data", "Value_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "8", "'_", "in_", "in", "\\u", "raster_", "._", "pixel", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "no", "Data", "Value_", "=_", "-_", "128_", "#", " ", "S", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "no", "Data", "Value_", "=_", "-_", "2147483647", "_", "#", " ", "S", "32_", "\\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 ", " _", "in", "\\u", "raster_", "=_", "zone", "\\u", "parameter_", "._", "value", "As", "Text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "no", "Data", "Value_", "=_", "desc_", "._", "no", "Data", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Res", "ample", " ", "if", " ", "necessar", "y_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "desc_", "._", "mean", "Cel", "l", "Height_", "!=_", "cell", "\\u", "size", "\\u", "y_", ")_", "or_", "(_", "desc_", "._", "mean", "Cel", "l", "Width_", "!=_", "cell", "\\u", "size", "\\u", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "temp", "\\u", "raster_", "=_", "'", "in", "\\u", "memory", "\\\\\\\\", "temp", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Res", "ample", "\\u", "management_", "(_", "in", "\\u", "raster_", ",_", "temp", "\\u", "raster_", ",_", "\"%", "f", " ", "%", "f", "\"_", "%_", "(_", "cell", "\\u", "size", "\\u", "x_", ",_", "cell", "\\u", "size", "\\u", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "temp", "Raster_", "=_", "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 ", " _", "temp", "\\u", "raster_", "=_", "in", "\\u", "raster_", "\\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 ", " _", "messages_", "._", "add", "Error", "Message_", "(_", "\"", "Not", " ", "a", " ", "valid", " ", "zone", " ", "dataset", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "arcpy_", "._", "Execut", "e", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "rast", "er", " ", "object", " ", "from", " ", "zone", " ", "data", " ", "if", " ", "not", " ", "alr", "ead", "y_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "temp", "\\u", "raster_", ",_", "arcpy_", "._", "Raster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "temp", "\\u", "raster_", "=_", "arcpy_", "._", "Raster_", "(_", "temp", "\\u", "raster_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Limit", " ", "to", " ", "lon", " ", "[-", "180", ",", " ", "180", "]", " ", "and", " ", "lat", " ", "[-", "90", ",", " ", "90", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "convert", "\\u", "coord_", "(_", "num_", ",_", "isl", "on_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lim_", "=_", "180_", "if_", "isl", "on_", "else_", "90_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "num_", ">_", "lim_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out_", "=_", "num_", "%_", "-_", "lim_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "num_", "<_", "-_", "lim_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out_", "=_", "num_", "%_", "lim_", "\\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 ", " _", "out_", "=_", "num_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isl", "on_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mult_", "=_", "-_", "1.0_", "if_", "num_", "<_", "0_", "else_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "=_", "mult_", "*_", "abs_", "(_", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "out_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Det", "erm", "ine", " ", "whe", "ther", " ", "input", " ", "zone", " ", "data", " ", "has", " ", "a", " ", "PC", "S", " ", "or", " ", "GC", "S_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "temp", "\\u", "raster_", "._", "spat", "ial", "Reference_", "._", "export", "tostring_", "(_", ")_", "==_", "temp", "\\u", "raster_", "._", "spat", "ial", "Reference_", "._", "GC", "S_", "._", "export", "tostring_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "for", " ", "overl", "ap", " ", "bet", "ween", " ", "zone", " ", "and", " ", "net", "CD", "F", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "temp", "\\u", "raster_", "._", "extent_", "._", "disj", "oint_", "(_", "var", "\\u", "extent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "with", " ", "coordinate", "s", " ", "in", " ", "lon", "[-", "180", ",", "180", "]", " ", "and", " ", "lat", "[-", "90", ",", "90", "]", " ", "ranges_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "var", "\\u", "extent", "\\u", "temp_", "=_", "arcpy_", "._", "Extent_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "convert", "\\u", "coord_", "(_", "var", "\\u", "extent_", "._", "XM", "in_", ",_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "convert", "\\u", "coord_", "(_", "var", "\\u", "extent_", "._", "YM", "in_", ",_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "convert", "\\u", "coord_", "(_", "var", "\\u", "extent_", "._", "XM", "ax_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "convert", "\\u", "coord_", "(_", "var", "\\u", "extent_", "._", "YM", "ax_", ",_", "False_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xl_", "=_", "var", "\\u", "extent", "\\u", "temp_", "._", "XM", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yl", "_", "=_", "var", "\\u", "extent", "\\u", "temp_", "._", "YM", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "again", " ", "and", " ", "throw", " ", "warn", "ing", " ", "on", " ", "failure_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "temp", "\\u", "raster_", "._", "extent_", "._", "disj", "oint_", "(_", "var", "\\u", "extent", "\\u", "temp_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "messages_", "._", "add", "Warn", "ing", "Message_", "(_", "\"", "Data", " ", "extent", "s", " ", "don", "'", "t", " ", "overl", "ap", ".\"_", ")_", "\\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 ", " _", "if_", "(_", "not_", "temp", "\\u", "raster_", "._", "extent_", "._", "overlaps_", "(_", "var", "\\u", "extent_", ")_", ")_", "and_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "temp", "\\u", "raster_", "._", "extent_", "._", "equals_", "(_", "var", "\\u", "extent_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "add", "Warn", "ing", "Message_", "(_", "\"", "Data", " ", "extent", "s", " ", "don", "'", "t", " ", "overl", "ap", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Extract", " ", "zone", " ", "data", " ", "from", " ", "raster_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arr", "\\u", "zone_", "=_", "arcpy_", "._", "Ras", "ter", "To", "Num", "Py", "Array_", "(_", "temp", "\\u", "raster_", ",_", "arcpy_", "._", "Point_", "(_", "xl_", ",_", "yl", "_", ")_", ",_", "ncol_", ",_", "nrow_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Flip", " ", "zone", " ", "rast", "er", " ", "to", " ", "acco", "rd", " ", "with", " ", "how", " ", "data", " ", "is", " ", "stored_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "bl", "flip", "x_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arr", "\\u", "zone_", "=_", "numpy_", "._", "flip", "ud_", "(_", "arr", "\\u", "zone_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "bl", "flip", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arr", "\\u", "zone_", "=_", "numpy_", "._", "flip", "lr_", "(_", "arr", "\\u", "zone_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "bl", "transpose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arr", "\\u", "zone_", "=_", "numpy_", "._", "transpose_", "(_", "arr", "\\u", "zone_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Delete", " ", "temporar", "y", " ", "rast", "er", " ", "if", " ", "it", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "bl", "temp", "Raster_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arcpy_", "._", "Delete", "\\u", "management_", "(_", "temp", "\\u", "raster_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "variab", "le", " ", "is", " ", "packed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "isp", "acke", "d_", "=_", "hasattr_", "(_", "arr", "\\u", "var_", ",_", "'", "scale", "\\u", "factor", "'_", ")_", "or_", "hasattr_", "(_", "arr", "\\u", "var_", ",_", "'", "add", "\\u", "offset", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Det", "erm", "ine", " ", "whe", "ther", " ", "give", "n", " ", "statistic", " ", "is", " ", "categor", "ical", " ", "or", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "var", "\\u", "dtype_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "stat_", "in_", "self_", "._", "statistics_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type", "\\u", "parameter_", "._", "value", "As", "Text_", "in_", "stat_", "[_", "1_", "]_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "var", "\\u", "dtype_", "=_", "stat_", "[_", "2_", "]_", "\\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_", "type", "\\u", "changed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "'", "int", "'_", "in_", "str_", "(_", "arr", "\\u", "var_", "._", "dtype_", ")_", ")_", "and_", "(_", "not_", "new", "\\u", "var", "\\u", "dtype_", ")_", "and_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "isp", "acke", "d_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type", "\\u", "changed_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Slice", " ", "generator_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Adapt", "ed", " ", "from", ":", " ", "http", "://", "code", ".", "active", "state", ".", "com", "/", "recip", "es", "/_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "502", "194", "-", "a", "-", "generat", "or", "-", "for", "-", "an", "-", "arbitra", "ry", "-", "number", "-", "of", "-", "for", "-", "loop", "s", "/_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Origina", "ll", "y", " ", "writt", "en", " ", "by", " ", "Ste", "ven", " ", "Bet", "hard", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "multi", "\\u", "for_", "(_", "iterable", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "iterable", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "(_", ")_", "\\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_", "isinstance_", "(_", "iterable", "s_", "[_", "0_", "]_", ",_", "collections_", "._", "Iterable_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "item_", "in_", "iterable", "s_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "rest", "\\u", "tuple_", "in_", "multi", "\\u", "for_", "(_", "iterable", "s_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "yield_", "(_", "item_", ",_", ")_", "+_", "rest", "\\u", "tuple_", "\\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_", "rest", "\\u", "tuple_", "in_", "multi", "\\u", "for_", "(_", "iterable", "s_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "yield_", "(_", "iterable", "s_", "[_", "0_", "]_", ",_", ")_", "+_", "rest", "\\u", "tuple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "slice", " ", "list_", "\\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_", "dim", "\\u", "shape_", "=_", "arr", "\\u", "var_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "\\u", "name_", "=_", "arr", "\\u", "var_", "._", "dimensions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "\\u", "slices_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "\\u", "dims_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "\\u", "prod_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dim", "\\u", "index_", ",_", "dim", "\\u", "item_", "in_", "enumerate_", "(_", "dim", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "dim", "\\u", "item_", "in_", "spat", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dim", "\\u", "prod_", "*=_", "dim", "\\u", "shape_", "[_", "dim", "\\u", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "\\u", "slices_", "._", "append_", "(_", "xrange_", "(_", "dim", "\\u", "shape_", "[_", "dim", "\\u", "index_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "\\u", "dims_", "._", "append_", "(_", "(_", "str_", "(_", "dim", "\\u", "item_", ")_", ",_", "numpy_", "._", "int_", ")_", ")_", "\\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 ", " _", "dim", "\\u", "slices_", "._", "append_", "(_", "Ellips", "is_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bl", "struct", "created_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "hst", "ack", "\\u", "struct_", "(_", "arr", "1_", ",_", "arr", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Wil", "l", " ", "only", " ", "work", " ", "correct", "ly", " ", "if", " ", "arr", "1", " ", "and", " ", "arr", "2", " ", "only", " ", "have", " ", "one", " ", "record_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dt_", "=_", "numpy_", "._", "lib_", "._", "rec", "functions_", "._", "zip", "\\u", "descr_", "(_", "(_", "arr", "1_", ",_", "arr", "2_", ")_", ",_", "flatten_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "numpy_", "._", "array_", "(_", "arr", "1_", "._", "tolist_", "(_", ")_", "+_", "arr", "2_", "._", "tolist_", "(_", ")_", ",_", "dtype_", "=_", "dt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "zone", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "no", "Data", "Value_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zones_", "=_", "numpy_", "._", "setd", "iff", "1d_", "(_", "numpy_", "._", "unique_", "(_", "arr", "\\u", "zone_", ")_", ",_", "[_", "no", "Data", "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 ", " _", "zones_", "=_", "numpy_", "._", "unique_", "(_", "arr", "\\u", "zone_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Progres", "s", " ", "bar_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dim", "\\u", "prod_", "*=_", "zones_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Reset", "Progres", "sor", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Set", "Progres", "sor", "_", "(_", "'", "step", "'_", ",_", "'", "Calculating", "...'_", ",_", "0_", ",_", "dim", "\\u", "prod_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Loop", " ", "through", " ", "slices_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "valid", "\\u", "indices_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "vars", "lice", "_", "in_", "multi", "\\u", "for_", "(_", "dim", "\\u", "slices_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tak", "e", " ", "slice", " ", "from", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type", "\\u", "changed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arr", "\\u", "slice_", "=_", "arr", "\\u", "var_", "[_", "vars", "lice", "_", "]_", "._", "astype_", "(_", "'", "f8", "'_", ")_", "\\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 ", " _", "arr", "\\u", "slice_", "=_", "arr", "\\u", "var_", "[_", "vars", "lice", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "mask", "ed", " ", "array_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "arr", "\\u", "slice_", ",_", "'", "mask", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arr", "\\u", "mask_", "=_", "arr", "\\u", "slice_", "._", "mask_", "._", "copy_", "(_", ")_", "\\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 ", " _", "arr", "\\u", "mask_", "=_", "numpy_", "._", "ma_", "._", "make", "\\u", "mask", "\\u", "none_", "(_", "arr", "\\u", "slice_", "._", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arr", "\\u", "slice_", "=_", "numpy_", "._", "ma_", "._", "asarray_", "(_", "arr", "\\u", "slice_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Loop", " ", "over", " ", "zones_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "z_", "in_", "zones_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Perform", " ", "for", " ", "zone", " ", "whe", "n", " ", "No", "Data", " ", "is", " ", "ignored_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "or", " ", "whe", "n", " ", "there", " ", "is", " ", "no", " ", "No", "Data", " ", "within", " ", "zone_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ignore", "\\u", "parameter_", "._", "value_", "or_", "(_", "not_", "numpy_", "._", "any_", "(_", "(_", "arr", "\\u", "zone_", "==_", "z_", ")_", "&_", "arr", "\\u", "mask_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Set", " ", "mask", " ", "to", " ", "net", "CD", "F", " ", "No", "Data", " ", "mask_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "arr", "\\u", "slice_", "._", "mask_", "=_", "arr", "\\u", "mask_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Apply", " ", "zone", " ", "mask_", "\\u\\u\\uNL\\u\\u\\u_", "arr", "\\u", "slice_", "[_", "arr", "\\u", "zone_", "!=_", "z_", "]_", "=_", "numpy_", "._", "ma_", "._", "masked_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Apply", " ", "opera", "tor", " ", "to", " ", "zone", " ", "mask", "ed", " ", "slice_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "self_", "._", "calcul", "ate", "\\u", "statistic_", "(_", "arr", "\\u", "slice_", "[_", ":_", "]_", ",_", "type", "\\u", "parameter_", "._", "value", "As", "Text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Structur", "e", " ", "results", " ", "int", "o", " ", "row_", "\\u\\u\\uNL\\u\\u\\u_", "struct", "\\u", "data_", "=_", "[_", "dataset_", "._", "variable_", "(_", "dim", "\\u", "name_", "[_", "it", "\\u", "ind_", "]_", ")_", "[_", "it_", "]_", "for_", "it", "\\u", "ind_", ",_", "it_", "in_", "enumerate_", "(_", "list_", "(_", "vars", "lice", "_", ")_", ")_", "if_", "it_", "!=_", "Ellips", "is_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "struct", "\\u", "data_", "._", "append_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "struct", "\\u", "data_", "._", "append_", "(_", "numpy_", "._", "ma_", "._", "count_", "(_", "arr", "\\u", "slice_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "numpy_", "._", "iss", "cala", "r_", "(_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sing", "le", "-", "valued", " ", "result_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "struct", "\\u", "data_", "._", "append_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Multi", "valued", " ", "result_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "struct", "\\u", "data_", "+=_", "[_", "it", "2_", "for_", "it_", "in_", "result_", "._", "tolist_", "(_", ")_", "for_", "it", "2_", "in_", "it_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "table", " ", "whe", "n", " ", "necessar", "y_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "bl", "struct", "created_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "struct", "\\u", "dtype_", "=_", "dim", "\\u", "dims_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "struct", "\\u", "dtype_", "._", "append_", "(_", "(_", "str_", "(_", "zone", "field", "\\u", "parameter_", "._", "value_", ")_", ",_", "numpy_", "._", "int_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "struct", "\\u", "dtype_", "._", "append_", "(_", "(_", "'", "COUNT", "'_", ",_", "numpy_", "._", "int_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type", "\\u", "parameter_", "._", "value", "As", "Text_", "in_", "self_", "._", "statistic", "s", "\\u", "multiple", "\\u", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "struct", "\\u", "dtype_", "+=_", "[_", "(_", "it_", ",_", "numpy_", "._", "float_", ")_", "for_", "it_", "in_", "list_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "dtype_", "._", "names_", ")_", "]_", "\\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 ", " ", " _", "struct", "\\u", "dtype_", "._", "append_", "(_", "(_", "str_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "type", "\\u", "parameter_", "._", "value", "As", "Text_", ")_", ",_", "numpy_", "._", "float_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "struct_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "dim", "\\u", "prod_", ",_", ")_", ",_", "numpy_", "._", "dtype_", "(_", "struct", "\\u", "dtype_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bl", "struct", "created_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Insert", " ", "row_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "struct_", "[_", "index_", "]_", "=_", "numpy_", "._", "array_", "(_", "tuple_", "(_", "struct", "\\u", "data_", ")_", ",_", "numpy_", "._", "dtype_", "(_", "struct", "\\u", "dtype_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "valid", "\\u", "indices_", "._", "append_", "(_", "index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "else", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "#", " ", "Passi", "ng", " ", "drops", " ", "zone", "s", " ", "with", " ", "No", "Data", " ", "in", " ", "them", " ", "from", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "pass_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "index_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Set", "Progres", "sor", "Position_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arcpy_", "._", "Reset", "Progres", "sor", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "time", "'_", "in_", "dim", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Output", " ", "zona", "l", " ", "statistic", "s", " ", "to", " ", "temporar", "y", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "temp", "\\u", "table_", "=_", "os_", "._", "path_", "._", "join_", "(_", "tempfile_", "._", "gettempdir_", "(_", ")_", ",_", "'", "temp", "\\u", "table", ".", "dbf", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "arcpy_", "._", "Exists_", "(_", "temp", "\\u", "table_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arcpy_", "._", "Delete", "\\u", "management_", "(_", "temp", "\\u", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arcpy_", "._", "da_", "._", "Num", "Py", "Array", "To", "Table_", "(_", "struct_", "[_", "valid", "\\u", "indices_", "]_", ",_", "temp", "\\u", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "table", " ", "view", " ", "of", " ", "the", " ", "time", " ", "dimension", " ", "from", " ", "net", "CD", "F", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "temp", "\\u", "mdt", "able_", "=_", "r", "\"", "md", "\\u", "table", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Make", "Net", "CD", "FT", "able", "View", "\\u", "md_", "(_", "dataset", "\\u", "name_", ",_", "'", "time", "'_", ",_", "temp", "\\u", "mdt", "able_", ",_", "'", "time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "time", " ", "field", " ", "from", " ", "table", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "desc", "\\u", "fields_", "=_", "arcpy_", "._", "List", "Fields_", "(_", "temp", "\\u", "mdt", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time", "\\u", "field_", "=_", "desc", "\\u", "fields_", "[_", "[_", "field_", "._", "name_", "for_", "field_", "in_", "desc", "\\u", "fields_", "]_", "._", "index_", "(_", "'", "time", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "table", " ", "in", " ", "the", " ", "output", " ", "location_", "\\u\\u\\uNL\\u\\u\\u_", "arcpy_", "._", "Creat", "e", "Table", "\\u", "management_", "(_", "*_", "os_", "._", "path_", "._", "split_", "(_", "output", "\\u", "filename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "fields", " ", "from", " ", "temporar", "y", " ", "table", " ", "except", " ", "for", " ", "time", " ", "field", ",", " ", "which_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "we", " ", "add", " ", "from", " ", "the", " ", "Make", "Net", "CD", "FT", "able", "View_", "\\u\\u\\uNL\\u\\u\\u_", "desc", "\\u", "fields_", "=_", "arcpy_", "._", "List", "Fields_", "(_", "temp", "\\u", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "index_", ",_", "field_", "in_", "enumerate_", "(_", "desc", "\\u", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "field_", "._", "type_", "!=_", "'", "OID", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "field_", "._", "name_", "==_", "'", "time", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "arcpy_", "._", "Add", "Field", "\\u", "management_", "(_", "output", "\\u", "filename_", ",_", "time", "\\u", "field_", "._", "name_", ",_", "time", "\\u", "field_", "._", "type_", ",_", "time", "\\u", "field_", "._", "precision_", ",_", "time", "\\u", "field_", "._", "scale_", ",_", "time", "\\u", "field_", "._", "length_", ",_", "time", "\\u", "field_", "._", "alias", "Name_", ",_", "time", "\\u", "field_", "._", "is", "Null", "able_", ",_", "time", "\\u", "field_", "._", "required_", ",_", "time", "\\u", "field_", "._", "domain_", ")_", "\\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 ", " ", " _", "arcpy_", "._", "Add", "Field", "\\u", "management_", "(_", "output", "\\u", "filename_", ",_", "field_", "._", "name_", ",_", "field_", "._", "type_", ",_", "field_", "._", "precision_", ",_", "field_", "._", "scale_", ",_", "field_", "._", "length_", ",_", "field_", "._", "alias", "Name_", ",_", "field_", "._", "is", "Null", "able_", ",_", "field_", "._", "required_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "field_", "._", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arcpy_", "._", "Delete", "Field", "\\u", "management_", "(_", "output", "\\u", "filename_", ",_", "\"", "Field", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "list", " ", "of", " ", "datetime", " ", "object", "s", " ", "from", " ", "table", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "time", "\\u", "arc_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "arcpy_", "._", "da_", "._", "Sear", "ch", "Cursor_", "(_", "temp", "\\u", "mdt", "able_", ",_", "'", "time", "'_", ")_", "as_", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "row_", "in_", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "time", "\\u", "arc_", "._", "append_", "(_", "row_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "cursor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "time", " ", "variab", "le", " ", "from", " ", "net", "CD", "F", " ", "dataset_", "\\u\\u\\uNL\\u\\u\\u_", "time", "\\u", "var_", "=_", "dataset_", "._", "variable_", "(_", "'", "time", "'_", ")_", "[_", ":_", "]_", "._", "tolist_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Loop", " ", "through", " ", "entri", "es", " ", "from", " ", "temporar", "y", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "arcpy_", "._", "da_", "._", "Insert", "Cursor_", "(_", "output", "\\u", "filename_", ",_", "'*'_", ")_", "as_", "ins", "\\u", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "time", "\\u", "ind_", "=_", "ins", "\\u", "cursor_", "._", "fields_", "._", "index_", "(_", "'", "time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "arcpy_", "._", "da_", "._", "Sear", "ch", "Cursor_", "(_", "temp", "\\u", "table_", ",_", "'*'_", ")_", "as_", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "time", "\\u", "ind_", "=_", "cursor_", "._", "fields_", "._", "index_", "(_", "'", "time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "new", "\\u", "row_", "=_", "list_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "row_", "[_", "new", "\\u", "time", "\\u", "ind_", "]_", "=_", "time", "\\u", "arc_", "[_", "time", "\\u", "var_", "._", "index_", "(_", "row_", "[_", "time", "\\u", "ind_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ins", "\\u", "cursor_", "._", "insert", "Row_", "(_", "tuple_", "(_", "new", "\\u", "row_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "ins", "\\u", "cursor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "cursor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Write", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "arcpy_", "._", "env_", "._", "overwrit", "e", "Output_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arcpy_", "._", "Delete", "\\u", "management_", "(_", "output", "\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arcpy_", "._", "da_", "._", "Num", "Py", "Array", "To", "Table_", "(_", "struct_", "[_", "valid", "\\u", "indices_", "]_", ",_", "output", "\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\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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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 ]
Unused import
caseywstark/colab/colab/apps/issues/templatetags/issues_tags.py
[ { "content": "from django import template\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.core.urlresolvers import reverse\n\nregister = template.Library()\n\nfrom voting.models import Vote\nfrom issues.models import Issue, IssueContributor\n\n\n\n\n\n\n\n# can't believe this isn't in django core...\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@register.inclusion_tag(\"issues/issue_item.html\", takes_context=True)\ndef show_issue(context, issue):\n extras = False\n if issue.private or issue.sandbox or issue.model_project:\n extras = True\n return {'issue': issue, 'extras': extras, 'request': context['request']}", "metadata": "root.show_issue", "header": "['module', '___EOS___']", "index": 9 }, { "content": "@register.simple_tag\ndef clear_search_url(request):\n getvars = request.GET.copy()\n if 'search' in getvars:\n del getvars['search']\n if len(getvars.keys()) > 0:\n return \"%s?%s\" % (request.path, getvars.urlencode())\n else:\n return request.path", "metadata": "root.clear_search_url", "header": "['module', '___EOS___']", "index": 16 }, { "content": "@register.simple_tag\ndef persist_getvars(request):\n getvars = request.GET.copy()\n if len(getvars.keys()) > 0:\n return \"?%s\" % getvars.urlencode()\n return ''", "metadata": "root.persist_getvars", "header": "['module', '___EOS___']", "index": 26 }, { "content": "@register.simple_tag\ndef filter_url(request, the_filter, the_value):\n getvars = request.GET.copy()\n getvars[the_filter] = the_value\n return \"%s?%s\" % (request.path, getvars.urlencode())", "metadata": "root.filter_url", "header": "['module', '___EOS___']", "index": 33 }, { "content": "@register.simple_tag\ndef remove_filter_url(request, the_filter):\n getvars = request.GET.copy()\n del getvars[the_filter]\n return \"%s?%s\" % (request.path, getvars.urlencode())", "metadata": "root.remove_filter_url", "header": "['module', '___EOS___']", "index": 39 }, { "content": "@register.simple_tag\ndef filter_link(request, the_filter, the_value, the_text):\n return '<a href=\"%s\">%s</a>' % (filter_url(request, the_filter, the_value), the_text)", "metadata": "root.filter_link", "header": "['module', '___EOS___']", "index": 45 }, { "content": "@register.filter\n# truncate after a certain number of characters\ndef truncatechar(text, length):\n if len(text) <= length:\n return text\n else:\n return text[:length] + '...'", "metadata": "root.truncatechar", "header": "['module', '___EOS___']", "index": 50 } ]
[ { "span": "from django.contrib.contenttypes.models import ContentType", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 58 }, { "span": "from django.core.urlresolvers import reverse", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 44 }, { "span": "from voting.models import Vote", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 30 }, { "span": "from issues.models import Issue, IssueContributor", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 49 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "import_", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "._", "models_", "import_", "Conten", "t", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "register_", "=_", "template_", "._", "Library_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "voting", "_", "._", "models_", "import_", "Vote", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "issues_", "._", "models_", "import_", "Issue_", ",_", "Issue", "Contributor", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "can", "'", "t", " ", "beli", "eve", " ", "this", " ", "isn", "'", "t", " ", "in", " ", "django", " ", "core", "..._", "\\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_", "@_", "register_", "._", "inclusion", "\\u", "tag_", "(_", "\"", "issue", "s", "/", "issue", "\\u", "item", ".", "html", "\"_", ",_", "take", "s", "\\u", "context_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "show", "\\u", "issue_", "(_", "context_", ",_", "issue_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extras_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "issue_", "._", "private_", "or_", "issue_", "._", "sandbox_", "or_", "issue_", "._", "model", "\\u", "project_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extras_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "{_", "'", "issue", "'_", ":_", "issue_", ",_", "'", "extra", "s", "'_", ":_", "extras_", ",_", "'", "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_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "clear", "\\u", "search", "\\u", "url_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "getv", "ars_", "=_", "request_", "._", "GET_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "search", "'_", "in_", "getv", "ars_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "getv", "ars_", "[_", "'", "search", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "getv", "ars_", "._", "keys_", "(_", ")_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"%", "s", "?", "%", "s", "\"_", "%_", "(_", "request_", "._", "path_", ",_", "getv", "ars_", "._", "urlencode_", "(_", ")_", ")_", "\\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_", "request_", "._", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "persist", "\\u", "getv", "ars_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "getv", "ars_", "=_", "request_", "._", "GET_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "getv", "ars_", "._", "keys_", "(_", ")_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"?", "%", "s", "\"_", "%_", "getv", "ars_", "._", "urlencode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "''_", "\\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_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "filter", "\\u", "url_", "(_", "request_", ",_", "the", "\\u", "filter_", ",_", "the", "\\u", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "getv", "ars_", "=_", "request_", "._", "GET_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "getv", "ars_", "[_", "the", "\\u", "filter_", "]_", "=_", "the", "\\u", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"%", "s", "?", "%", "s", "\"_", "%_", "(_", "request_", "._", "path_", ",_", "getv", "ars_", "._", "urlencode_", "(_", ")_", ")_", "\\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_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "remove", "\\u", "filter", "\\u", "url_", "(_", "request_", ",_", "the", "\\u", "filter_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "getv", "ars_", "=_", "request_", "._", "GET_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "getv", "ars_", "[_", "the", "\\u", "filter_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"%", "s", "?", "%", "s", "\"_", "%_", "(_", "request_", "._", "path_", ",_", "getv", "ars_", "._", "urlencode_", "(_", ")_", ")_", "\\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_", "@_", "register_", "._", "simple", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "filter", "\\u", "link_", "(_", "request_", ",_", "the", "\\u", "filter_", ",_", "the", "\\u", "value_", ",_", "the", "\\u", "text_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "a", " ", "href", "=\"", "%", "s", "\">", "%", "s", "</", "a", ">'_", "%_", "(_", "filter", "\\u", "url_", "(_", "request_", ",_", "the", "\\u", "filter_", ",_", "the", "\\u", "value_", ")_", ",_", "the", "\\u", "text_", ")_", "\\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_", "@_", "register_", "._", "filter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "truncat", "e", " ", "after", " ", "a", " ", "cert", "ain", " ", "number", " ", "of", " ", "characters_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "truncat", "ech", "ar_", "(_", "text_", ",_", "length_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "text_", ")_", "<=_", "length_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "text_", "\\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_", "text_", "[_", ":_", "length_", "]_", "+_", "'...'_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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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 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 ]
Except block handles 'BaseException'
whoenig/SublimeCodeSearch/Index.py
[ { "content": "\tdef runIndexing(self):\n\t\tcsearchdir = os.path.abspath(os.path.dirname(self.csearchindex))\n\t\tif not os.path.isdir(csearchdir):\n\t\t\tos.makedirs(csearchdir)\n\t\tself.indexing = True\n\t\tproject_file_name = self.window.project_file_name()\n\t\tworking_dir = os.path.dirname(project_file_name)\n\n\t\tself.total_files = 0\n\t\tself.num_files = 0\n\t\tfor folder in self.folders:\n\t\t\tdir = os.path.join(working_dir, folder)\n\t\t\tself.total_files += self.getNumberOfFiles(dir)\n\n\t\tself.updateStatus()\n\n\t\tmy_env = os.environ.copy()\n\t\tmy_env[\"CSEARCHINDEX\"] = self.csearchindex\n\t\tcommandLine = [self.path_cindex, \"-verbose\"]\n\t\ttry:\n\t\t\tstartupinfo = subprocess.STARTUPINFO()\n\t\t\tstartupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW\n\t\texcept:\n\t\t\tstartupinfo = None\n\t\tself.popen = subprocess.Popen(commandLine + self.folders, cwd=working_dir, env=my_env, startupinfo=startupinfo, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\t\tstdoutQueue = Queue()\n\t\treadStdOutThread = threading.Thread(target=self.readStdout, args=(self.popen.stdout, stdoutQueue))\n\t\treadStdOutThread.daemon = True\n\t\treadStdOutThread.start()\n\t\tstderrQueue = Queue()\n\t\treadStdErrThread = threading.Thread(target=self.readStderr, args=(self.popen.stderr, stderrQueue))\n\t\treadStdErrThread.daemon = True\n\t\treadStdErrThread.start()\n\t\tself.popen.wait()\n\t\tself.popen = None\n\t\tself.indexing = False\n\t\tself.window.active_view().erase_status(\"CodeSearch\")", "metadata": "root.CodeSearchIndexCommand.runIndexing", "header": "['class', 'CodeSearchIndexCommand', '(', 'sublime_plugin', '.', 'WindowCommand', ')', ':', '___EOS___']", "index": 28 } ]
[ { "span": "except:", "start_line": 50, "start_column": 2, "end_line": 50, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Code", "Sear", "ch", "Index", "Command_", "(_", "sublim", "e\\u", "plugin_", "._", "Window", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "Index", "ing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "cse", "arch", "dir_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "self_", "._", "cse", "archi", "ndex_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "isdir_", "(_", "cse", "arch", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "os_", "._", "makedirs_", "(_", "cse", "arch", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "indexing", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project", "\\u", "file", "\\u", "name_", "=_", "self_", "._", "window_", "._", "project", "\\u", "file", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "working", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "project", "\\u", "file", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "total", "\\u", "files_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "num", "\\u", "files_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "folder_", "in_", "self_", "._", "folders_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "working", "\\u", "dir_", ",_", "folder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "total", "\\u", "files_", "+=_", "self_", "._", "get", "Number", "Of", "Files_", "(_", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update", "Status_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "my", "\\u", "env_", "=_", "os_", "._", "environ_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "my", "\\u", "env_", "[_", "\"", "CS", "EAR", "CHI", "NDE", "X", "\"_", "]_", "=_", "self_", "._", "cse", "archi", "ndex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "Line_", "=_", "[_", "self_", "._", "path", "\\u", "cinde", "x_", ",_", "\"-", "verbo", "se", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "start", "upi", "nfo_", "=_", "subprocess_", "._", "START", "UP", "INFO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "upi", "nfo_", "._", "dw", "Flags_", "|=_", "subprocess_", "._", "START", "F", "\\u", "USE", "SHOW", "WINDOW_", "\\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_", "start", "upi", "nfo_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "popen_", "=_", "subprocess_", "._", "Popen_", "(_", "command", "Line_", "+_", "self_", "._", "folders_", ",_", "cwd_", "=_", "working", "\\u", "dir_", ",_", "env_", "=_", "my", "\\u", "env_", ",_", "start", "upi", "nfo_", "=_", "start", "upi", "nfo_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ",_", "stderr_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stdout", "Queue_", "=_", "Queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "Std", "Out", "Thread_", "=_", "threading_", "._", "Thread_", "(_", "target_", "=_", "self_", "._", "read", "Stdout", "_", ",_", "args_", "=_", "(_", "self_", "._", "popen_", "._", "stdout_", ",_", "stdout", "Queue_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "Std", "Out", "Thread_", "._", "daemon_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "Std", "Out", "Thread_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "std", "err", "Queue_", "=_", "Queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "Std", "Err", "Thread_", "=_", "threading_", "._", "Thread_", "(_", "target_", "=_", "self_", "._", "read", "Std", "err_", ",_", "args_", "=_", "(_", "self_", "._", "popen_", "._", "stderr_", ",_", "std", "err", "Queue_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "Std", "Err", "Thread_", "._", "daemon_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "Std", "Err", "Thread_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "popen_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "popen_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "indexing", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "window_", "._", "active", "\\u", "view_", "(_", ")_", "._", "erase", "\\u", "status_", "(_", "\"", "Code", "Sear", "ch", "\"_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
mtth/hdfs/test/test_ext_kerberos.py
[ { "content": "#!/usr/bin/env python\n# encoding: utf-8\n\n\"\"\"Test Kerberos extension.\"\"\"\n\nfrom mock import Mock\nfrom nose.tools import eq_, nottest, ok_, raises\nfrom threading import Lock, Thread\nfrom time import sleep, time\nimport sys\n\ntry:\n import requests_kerberos\nexcept ImportError:\n sys.modules['requests_kerberos'] = Mock()\n\nfrom hdfs.ext.kerberos import KerberosClient\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestKerberosClient(object):\n\n", "metadata": "root.TestKerberosClient", "header": "['module', '___EOS___']", "index": 19 }, { "content": " def test_concurrency(self):\n lock = Lock()\n calls = set()\n items = []\n\n def add_item(method, url, **kwargs):\n with lock:\n ok_(not items)\n items.append(kwargs['thread'])\n sleep(0.25)\n with lock:\n thread = items.pop()\n eq_(thread, kwargs['thread'])\n calls.add(thread)\n return Mock()\n\n session = Mock()\n session.request = add_item\n client = KerberosClient('http://nn', max_concurrency=1, session=session)\n args = ('POST', 'http://foo')\n t1 = Thread(\n target=client._request,\n args=args,\n kwargs={'thread': 1, 'auth': True}\n )\n t1.start()\n t2 = Thread(\n target=client._request,\n args=args,\n kwargs={'thread': 2, 'auth': True}\n )\n t2.start()\n t1.join()\n t2.join()\n eq_(calls, set([1, 2]))", "metadata": "root.TestKerberosClient.test_concurrency", "header": "['class', 'TestKerberosClient', '(', 'object', ')', ':', '___EOS___']", "index": 21 }, { "content": " def test_concurrency_no_auth(self):\n lock = Lock()\n calls = set()\n items = []\n\n def add_item(method, url, **kwargs):\n thread = kwargs['thread']\n with lock:\n if items:\n other = items.pop()\n ok_(other != thread)\n else:\n items.append(thread)\n sleep(0.25)\n with lock:\n ok_(not items)\n calls.add(thread)\n return Mock()\n\n session = Mock()\n session.request = add_item\n client = KerberosClient('http://nn', max_concurrency=1, session=session)\n args = ('POST', 'http://foo')\n t1 = Thread(\n target=client._request,\n args=args,\n kwargs={'thread': 1, 'auth': True}\n )\n t1.start()\n t2 = Thread(target=client._request, args=args, kwargs={'thread': 2})\n t2.start()\n t1.join()\n t2.join()\n eq_(calls, set([1, 2]))", "metadata": "root.TestKerberosClient.test_concurrency_no_auth", "header": "['class', 'TestKerberosClient', '(', 'object', ')', ':', '___EOS___']", "index": 57 } ]
[ { "span": "from nose.tools import eq_, nottest, ok_, raises", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 48 }, { "span": "from time import sleep, time", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 28 }, { "span": "import requests_kerberos", "start_line": 12, "start_column": 2, "end_line": 12, "end_column": 26 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encoding", ":", " ", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Test", " ", "Ker", "ber", "os", " ", "extensi", "on", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "mock_", "import_", "Mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nose_", "._", "tools_", "import_", "eq\\u_", ",_", "not", "test_", ",_", "ok\\u_", ",_", "raises_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "threading_", "import_", "Lock_", ",_", "Thread_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "time_", "import_", "sleep_", ",_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "request", "s", "\\u", "kerberos", "_", "\\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 ", " _", "sys_", "._", "modules_", "[_", "'", "request", "s", "\\u", "kerberos", "'_", "]_", "=_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "hdfs", "_", "._", "ext_", "._", "kerberos", "_", "import_", "Ker", "ber", "os", "Client_", "\\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", "Ker", "ber", "os", "Client_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ker", "ber", "os", "Client_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "concurrency", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lock_", "=_", "Lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calls_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "add", "\\u", "item_", "(_", "method_", ",_", "url_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ok\\u_", "(_", "not_", "items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "._", "append_", "(_", "kwargs_", "[_", "'", "thread", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sleep_", "(_", "0.25_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "thread_", "=_", "items_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eq\\u_", "(_", "thread_", ",_", "kwargs_", "[_", "'", "thread", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calls_", "._", "add_", "(_", "thread_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "=_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session_", "._", "request_", "=_", "add", "\\u", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "Ker", "ber", "os", "Client_", "(_", "'", "http", "://", "nn", "'_", ",_", "max", "\\u", "concurrency", "_", "=_", "1_", ",_", "session_", "=_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "(_", "'", "POST", "'_", ",_", "'", "http", "://", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "=_", "Thread_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "client_", "._", "\\u", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "args_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "thread", "'_", ":_", "1_", ",_", "'", "auth", "'_", ":_", "True_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "=_", "Thread_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "client_", "._", "\\u", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "args_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "thread", "'_", ":_", "2_", ",_", "'", "auth", "'_", ":_", "True_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eq\\u_", "(_", "calls_", ",_", "set_", "(_", "[_", "1_", ",_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ker", "ber", "os", "Client_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "concurrency", "\\u", "no", "\\u", "auth_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lock_", "=_", "Lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calls_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "add", "\\u", "item_", "(_", "method_", ",_", "url_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "thread_", "=_", "kwargs_", "[_", "'", "thread", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "items_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "other_", "=_", "items_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ok\\u_", "(_", "other_", "!=_", "thread_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "items_", "._", "append_", "(_", "thread_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sleep_", "(_", "0.25_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ok\\u_", "(_", "not_", "items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calls_", "._", "add_", "(_", "thread_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "=_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session_", "._", "request_", "=_", "add", "\\u", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "Ker", "ber", "os", "Client_", "(_", "'", "http", "://", "nn", "'_", ",_", "max", "\\u", "concurrency", "_", "=_", "1_", ",_", "session_", "=_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "(_", "'", "POST", "'_", ",_", "'", "http", "://", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "=_", "Thread_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "client_", "._", "\\u", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "args_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "thread", "'_", ":_", "1_", ",_", "'", "auth", "'_", ":_", "True_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "=_", "Thread_", "(_", "target_", "=_", "client_", "._", "\\u", "request_", ",_", "args_", "=_", "args_", ",_", "kwargs_", "=_", "{_", "'", "thread", "'_", ":_", "2_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eq\\u_", "(_", "calls_", ",_", "set_", "(_", "[_", "1_", ",_", "2_", "]_", ")_", ")_" ]
[ 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1,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ication.sfa.AggregateManager import AggregateManager\nfrom vt_manager.communication.sfa.tests.example_vm_rspec import rspec as RSPEC\nfrom vt_manager.communication.utils.XmlHelper import *\nfrom vt_manager.controller.dispatchers.xmlrpc.ProvisioningResponseDispatcher import ProvisioningResponseDispatcher as prd\nfrom vt_manager.utils.ServiceThread import *\nfrom vt_manager.communication.sfa.tests.hardcoded_vars import users as USERS\n'''\nThis module run tests over the AM locally without xmlrpc or sfa instances\n'''\n\n\n\nxrn = 'urn:publicid:IDN+topdomain:nitos+slice+SFATest'\nusers = USERS\noptions = Options(123456)\nagg = AggregateManager(None)\nprint 'Aggregate instance:',agg\nxml = agg.ListResources(None,None,options)\n#print '------------------ListResources:',xml\n#options.geni_slice_urn = 'slice-name'\n#print 'Second List Resources'\n#xml = agg.ListResources(None,None,options)\n#print '-----------------ListResources with slice parametre:', xml\n\n#XXX: Last ListResources() test was 02/13/2013 with OK results, the first temptative of OCF rspecs are done(based in PGv2). OCF Rspecs need to be improved and clearify the XRN, HRN and URN concepts in order to offer the correct notation for aggregates, component managers, slices etc. \n#\n#xml = agg.CreateSliver(None, xrn, None, RSPEC, users, None)\n#print xml\n#XXX: Last CreateSliver() test was 02/25/2013 with OK results. The test does not get any parametre from VTShell yet, but the RSpec parsing(v1) is OK. The CreateSliver and GetSlice VTShell functions should be implemented working with slice_leaf parametre in order to check the manifest response RSpec.\n\n#xml = agg.stop_slice(None,xrn,None)\n#xml = agg.reset_slice(None,xrn)\n#xml = agg.SliverStatus(None,xrn,None,None)\n#xml = agg.DeleteSliver(None,xrn,None,None)\nprint xml\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Options:\n\n", "metadata": "root.Options", "header": "['module', '___EOS___']", "index": 11 }, { "content": "\tdef __init__(self,callId='fancy-UUID',sliceId=None):\n\t\tself.call_id = callId\n\t\tself.geni_slice_urn = None\n\t\tself.geni_rspec_version = 'OcfVt'", "metadata": "root.Options.__init__", "header": "['class', 'Options', ':', '___EOS___']", "index": 13 }, { "content": "\tdef get(self,attr,extra=None):\n\t\treturn getattr(options,attr)", "metadata": "root.Options.get", "header": "['class', 'Options', ':', '___EOS___']", "index": 18 } ]
[ { "span": "from vt_manager.communication.sfa.tests.example_vm_rspec import rspec as RSPEC", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 78 }, { "span": "from vt_manager.controller.dispatchers.xmlrpc.ProvisioningResponseDispatcher import ProvisioningResponseDispatcher as prd", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 121 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "communication", "_", "._", "sfa", "_", "._", "Aggregate", "Manager_", "import_", "Aggregate", "Manager_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "communication", "_", "._", "sfa", "_", "._", "tests_", "._", "example", "\\u", "vm", "\\u", "rsp", "ec_", "import_", "rsp", "ec_", "as_", "RS", "PEC", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "communication", "_", "._", "utils_", "._", "Xm", "l", "Helper_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "controller_", "._", "dispatcher", "s_", "._", "xmlrpc", "_", "._", "Provision", "ing", "Respons", "e", "Dispatcher_", "import_", "Provision", "ing", "Respons", "e", "Dispatcher_", "as_", "prd", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "utils_", "._", "Service", "Thread_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "communication", "_", "._", "sfa", "_", "._", "tests_", "._", "hard", "code", "d\\u", "vars_", "import_", "users_", "as_", "USERS", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "'''", "\\", "10", ";", "Thi", "s", " ", "module", " ", "run", " ", "tests", " ", "over", " ", "the", " ", "AM", " ", "local", "ly", " ", "with", "out", " ", "xmlrpc", " ", "or", " ", "sfa", " ", "instance", "s", "\\", "10", ";'", "''_", "\\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_", "xr", "n_", "=_", "'", "urn", ":", "public", "id", ":", "ID", "N", "+", "top", "domain", ":", "nit", "os", "+", "slice", "+", "SF", "AT", "est", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "=_", "USERS", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "Options_", "(_", "12345", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "agg_", "=_", "Aggregate", "Manager_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Aggregate", " ", "instance", ":'_", ",_", "agg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xml_", "=_", "agg_", "._", "List", "Resources_", "(_", "None_", ",_", "None_", ",_", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "'-------", "-----------", "List", "Reso", "urc", "es", ":'", ",", "xml_", "\\u\\u\\uNL\\u\\u\\u_", "#", "options", ".", "geni", "\\u", "slice", "\\u", "urn", " ", "=", " ", "'", "slice", "-", "name", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'", "Second", " ", "List", " ", "Reso", "urc", "es", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "xml", " ", "=", " ", "agg", ".", "List", "Reso", "urc", "es", "(", "Non", "e", ",", "Non", "e", ",", "options", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'-------", "----------", "List", "Reso", "urc", "es", " ", "with", " ", "slice", " ", "parametr", "e", ":'", ",", " ", "xml_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "XX", "X", ":", " ", "Las", "t", " ", "List", "Reso", "urc", "es", "()", " ", "test", " ", "was", " ", "02", "/", "13", "/", "2013", " ", "with", " ", "OK", " ", "results", ",", " ", "the", " ", "first", " ", "temp", "tative", " ", "of", " ", "OC", "F", " ", "rsp", "ecs", " ", "are", " ", "don", "e", "(", "based", " ", "in", " ", "PG", "v2", ").", " ", "OC", "F", " ", "Rs", "pec", "s", " ", "need", " ", "to", " ", "be", " ", "improve", "d", " ", "and", " ", "clear", "if", "y", " ", "the", " ", "XR", "N", ",", " ", "HR", "N", " ", "and", " ", "URN", " ", "concepts", " ", "in", " ", "order", " ", "to", " ", "off", "er", " ", "the", " ", "correct", " ", "notation", " ", "for", " ", "aggregates", ",", " ", "component", " ", "manage", "rs", ",", " ", "slice", "s", " ", "etc", ".", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "xml", " ", "=", " ", "agg", ".", "Creat", "e", "Sli", "ver", "(", "Non", "e", ",", " ", "xr", "n", ",", " ", "Non", "e", ",", " ", "RS", "PEC", ",", " ", "users", ",", " ", "Non", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "xml_", "\\u\\u\\uNL\\u\\u\\u_", "#", "XX", "X", ":", " ", "Las", "t", " ", "Creat", "e", "Sli", "ver", "()", " ", "test", " ", "was", " ", "02", "/", "25", "/", "2013", " ", "with", " ", "OK", " ", "results", ".", " ", "The", " ", "test", " ", "doe", "s", " ", "not", " ", "get", " ", "any", " ", "parametr", "e", " ", "from", " ", "VT", "Shel", "l", " ", "ye", "t", ",", " ", "but", " ", "the", " ", "RS", "pec", " ", "pars", "ing", "(", "v1", ")", " ", "is", " ", "OK", ".", " ", "The", " ", "Creat", "e", "Sli", "ver", " ", "and", " ", "Get", "Slice", " ", "VT", "Shel", "l", " ", "function", "s", " ", "shou", "ld", " ", "be", " ", "implemented", " ", "working", " ", "with", " ", "slice", "\\u", "leaf", " ", "parametr", "e", " ", "in", " ", "order", " ", "to", " ", "check", " ", "the", " ", "manifest", " ", "response", " ", "RS", "pec", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "xml", " ", "=", " ", "agg", ".", "stop", "\\u", "slice", "(", "Non", "e", ",", "xr", "n", ",", "Non", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "xml", " ", "=", " ", "agg", ".", "reset", "\\u", "slice", "(", "Non", "e", ",", "xr", "n", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "xml", " ", "=", " ", "agg", ".", "Sli", "ver", "Status", "(", "Non", "e", ",", "xr", "n", ",", "Non", "e", ",", "Non", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "xml", " ", "=", " ", "agg", ".", "Delete", "Sli", "ver", "(", "Non", "e", ",", "xr", "n", ",", "Non", "e", ",", "Non", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "xml_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Options_", ":_", "\\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_", "Options_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "call", "Id_", "=_", "'", "fancy", "-", "UU", "ID", "'_", ",_", "slice", "Id_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "call", "\\u", "id_", "=_", "call", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "geni", "\\u", "slice", "\\u", "urn_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "geni", "\\u", "rsp", "ec", "\\u", "version_", "=_", "'", "Oc", "f", "Vt", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Options_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "attr_", ",_", "extra_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "getattr_", "(_", "options_", ",_", "attr_", ")_", "\\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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
dimagi/commcare-hq/corehq/apps/sms/views.py
[ { "content": "#!/usr/bin/env python\n# vim: ai ts=4 sts=4 et sw=4 encoding=utf-8\nfrom StringIO import StringIO\nimport base64\nimport logging\nfrom datetime import datetime, timedelta, time\nimport re\nimport json\nfrom couchdbkit import ResourceNotFound\nimport pytz\nfrom django.contrib.auth import authenticate\nfrom django.core.urlresolvers import reverse\nfrom django.db import transaction\nfrom django.http import HttpResponse, HttpResponseRedirect, HttpResponseBadRequest, Http404\nfrom django.shortcuts import render\nfrom django.utils.decorators import method_decorator\nfrom casexml.apps.case.models import CommCareCase\nfrom corehq import privileges, toggles\nfrom corehq.apps.hqadmin.views import BaseAdminSectionView\nfrom corehq.apps.hqwebapp.doc_info import get_doc_info_by_id\nfrom corehq.apps.hqwebapp.utils import get_bulk_upload_form, sign\nfrom corehq.apps.reminders.util import can_use_survey_reminders\nfrom corehq.apps.accounting.decorators import requires_privilege_with_fallback, requires_privilege_plaintext_response\nfrom corehq.apps.api.models import require_api_user_permission, PERMISSION_POST_SMS, ApiUser\nfrom corehq.apps.commtrack.models import AlertConfig\nfrom corehq.apps.sms.api import (\n send_sms,\n incoming,\n send_sms_with_backend_name,\n send_sms_to_verified_number,\n DomainScopeValidationError,\n MessageMetadata,\n)\nfrom corehq.apps.domain.views import BaseDomainView, DomainViewMixin\nfrom corehq.apps.hqwebapp.views import CRUDPaginatedViewMixin\nfrom corehq.apps.sms.dbaccessors import get_forwarding_rules_for_domain\nfrom corehq.apps.style.decorators import (\n use_bootstrap3,\n use_timepicker,\n use_typeahead,\n use_select2,\n use_jquery_ui,\n upgrade_knockout_js,\n use_datatables,\n)\nfrom corehq.apps.users.decorators import require_permission\nfrom corehq.apps.users.models import CouchUser, Permissions, CommCareUser\nfrom corehq.apps.users import models as user_models\nfrom corehq.apps.users.views.mobile.users import EditCommCareUserView\nfrom corehq.apps.sms.models import (\n SMS, INCOMING, OUTGOING, ForwardingRule,\n MessagingEvent, SelfRegistrationInvitation,\n SQLMobileBackend, SQLMobileBackendMapping, PhoneLoadBalancingMixin,\n SQLLastReadMessage\n)\nfrom corehq.apps.sms.mixin import VerifiedNumber, BadSMSConfigException\nfrom corehq.apps.sms.forms import (ForwardingRuleForm, BackendMapForm,\n InitiateAddSMSBackendForm, SubscribeSMSForm,\n SettingsForm, SHOW_ALL, SHOW_INVALID, HIDE_ALL, ENABLED, DISABLED,\n DEFAULT, CUSTOM, SendRegistrationInviationsForm,\n WELCOME_RECIPIENT_NONE, WELCOME_RECIPIENT_CASE,\n WELCOME_RECIPIENT_MOBILE_WORKER, WELCOME_RECIPIENT_ALL, ComposeMessageForm)\nfrom corehq.apps.sms.util import get_contact, get_sms_backend_classes\nfrom corehq.apps.sms.messages import _MESSAGES\nfrom corehq.apps.smsbillables.utils import country_name_from_isd_code_or_empty as country_name_from_code\nfrom corehq.apps.groups.models import Group\nfrom corehq.apps.domain.decorators import (\n login_and_domain_required,\n login_or_digest_ex,\n domain_admin_required,\n require_superuser,\n)\nfrom corehq.messaging.smsbackends.telerivet.models import SQLTelerivetBackend\nfrom corehq.apps.translations.models import StandaloneTranslationDoc\nfrom corehq.util.dates import iso_string_to_datetime\nfrom corehq.util.spreadsheets.excel import WorkbookJSONReader\nfrom corehq.util.timezones.conversions import ServerTime, UserTime\nfrom corehq.util.quickcache import quickcache\nfrom django.contrib import messages\nfrom django.db.models import Q\nfrom corehq.util.soft_assert import soft_assert\nfrom corehq.util.timezones.utils import get_timezone_for_user\nfrom django.views.decorators.csrf import csrf_exempt\nfrom django.views.generic import View\nfrom corehq.apps.domain.models import Domain\nfrom corehq.const import SERVER_DATETIME_FORMAT, SERVER_DATE_FORMAT\nfrom django.utils.translation import ugettext as _, ugettext_noop, ugettext_lazy\nfrom dimagi.utils.parsing import json_format_datetime, string_to_boolean\nfrom dimagi.utils.decorators.memoized import memoized\nfrom dimagi.utils.decorators.view import get_file\nfrom dimagi.utils.logging import notify_exception\nfrom dimagi.utils.web import json_response\nfrom dimagi.utils.couch import CriticalSection\nfrom dimagi.utils.couch.database import iter_docs\nfrom dimagi.utils.couch.cache import cache_core\nfrom django.conf import settings\nfrom couchdbkit.resource import ResourceNotFound\nfrom couchexport.models import Format\nfrom couchexport.export import export_raw\nfrom couchexport.shortcuts import export_response\n\n\n# Tuple of (description, days in the past)\nSMS_CHAT_HISTORY_CHOICES = (\n (ugettext_noop(\"Yesterday\"), 1),\n (ugettext_noop(\"1 Week\"), 7),\n (ugettext_noop(\"30 Days\"), 30),\n)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@login_and_domain_required\ndef default(request, domain):\n return HttpResponseRedirect(reverse(ComposeMessageView.urlname, args=[domain]))", "metadata": "root.default", "header": "['module', '___EOS___']", "index": 109 }, { "content": "class BaseMessagingSectionView(BaseDomainView):\n section_name = ugettext_noop(\"Messaging\")\n\n", "metadata": "root.BaseMessagingSectionView", "header": "['module', '___EOS___']", "index": 114 }, { "content": " @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n def dispatch(self, *args, **kwargs):\n return super(BaseMessagingSectionView, self).dispatch(*args, **kwargs)", "metadata": "root.BaseMessagingSectionView.dispatch", "header": "['class', 'BaseMessagingSectionView', '(', 'BaseDomainView', ')', ':', '___EOS___']", "index": 117 }, { "content": " @property\n def section_url(self):\n return reverse(\"sms_default\", args=[self.domain])", "metadata": "root.BaseMessagingSectionView.section_url", "header": "['class', 'BaseMessagingSectionView', '(', 'BaseDomainView', ')', ':', '___EOS___']", "index": 121 }, { "content": "class BaseAdvancedMessagingSectionView(BaseMessagingSectionView):\n \"\"\"\n Just like BaseMessagingSectionView, only requires access to inbound SMS\n as well.\n \"\"\"", "metadata": "root.BaseAdvancedMessagingSectionView", "header": "['module', '___EOS___']", "index": 126 }, { "content": " @method_decorator(requires_privilege_with_fallback(privileges.INBOUND_SMS))\n def dispatch(self, *args, **kwargs):\n return super(BaseAdvancedMessagingSectionView, self).dispatch(*args, **kwargs)", "metadata": "root.BaseAdvancedMessagingSectionView.dispatch", "header": "['class', 'BaseAdvancedMessagingSectionView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 131 }, { "content": "class ComposeMessageView(BaseMessagingSectionView):\n template_name = 'sms/compose.html'\n urlname = 'sms_compose_message'\n page_title = _('Compose SMS Message')\n\n", "metadata": "root.ComposeMessageView", "header": "['module', '___EOS___']", "index": 136 }, { "content": " @property\n def page_context(self):\n page_context = super(ComposeMessageView, self).page_context\n tz = get_timezone_for_user(self.request.couch_user, self.domain)\n page_context.update({\n 'now': datetime.utcnow(),\n 'timezone': tz,\n 'timezone_now': datetime.now(tz=tz),\n 'form': ComposeMessageForm(domain=self.domain)\n })\n page_context.update(get_sms_autocomplete_context(self.request, self.domain))\n return page_context", "metadata": "root.ComposeMessageView.page_context", "header": "['class', 'ComposeMessageView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 141 }, { "content": " @method_decorator(require_permission(Permissions.edit_data))\n @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n @use_bootstrap3\n @use_typeahead\n def dispatch(self, *args, **kwargs):\n return super(BaseMessagingSectionView, self).dispatch(*args, **kwargs)", "metadata": "root.ComposeMessageView.dispatch", "header": "['class', 'ComposeMessageView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 154 }, { "content": "@csrf_exempt\ndef post(request, domain):\n \"\"\"\n I don't know of anywhere this is being invoked from. If the soft asserts\n don't produce any results then I'll remove it.\n \"\"\"\n _assert = soft_assert('@'.join(['gcapalbo', 'dimagi.com']), exponential_backoff=False)\n _assert(False, \"sms post invoked\")\n return HttpResponse('OK')", "metadata": "root.post", "header": "['module', '___EOS___']", "index": 162 }, { "content": "@require_api_user_permission(PERMISSION_POST_SMS)\ndef sms_in(request):\n \"\"\"\n CommCareHQ's generic inbound sms post api, requiring an ApiUser with permission to post sms.\n The request must be a post, and must have the following post parameters:\n username - ApiUser username\n password - ApiUser password\n phone_number - phone number message was sent from\n message - text of message\n \"\"\"\n backend_api = \"HQ_HTTP_INBOUND\"\n phone_number = request.POST.get(\"phone_number\", None)\n message = request.POST.get(\"message\", None)\n if phone_number is None or message is None:\n return HttpResponse(\"Please specify 'phone_number' and 'message' parameters.\", status=400)\n else:\n incoming(phone_number, message, backend_api)\n return HttpResponse(\"OK\")", "metadata": "root.sms_in", "header": "['module', '___EOS___']", "index": 173 }, { "content": "def get_sms_autocomplete_context(request, domain):\n \"\"\"A helper view for sms autocomplete\"\"\"\n phone_users = CouchUser.view(\"users/phone_users_by_domain\",\n startkey=[domain], endkey=[domain, {}], include_docs=True\n )\n groups = Group.by_domain(domain)\n\n contacts = [\"[send to all]\"]\n contacts.extend(['%s [group]' % group.name for group in groups])\n user_id = None\n for user in phone_users:\n if user._id == user_id:\n continue\n contacts.append(user.username)\n user_id = user._id\n return {\"sms_contacts\": contacts}", "metadata": "root.get_sms_autocomplete_context", "header": "['module', '___EOS___']", "index": 193 }, { "content": "@login_and_domain_required\n@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)\ndef send_to_recipients(request, domain):\n recipients = request.POST.get('recipients')\n message = request.POST.get('message')\n if not recipients:\n messages.error(request, _(\"You didn't specify any recipients\"))\n elif not message:\n messages.error(request, _(\"You can't send an empty message\"))\n else:\n recipients = [x.strip() for x in recipients.split(',') if x.strip()]\n phone_numbers = []\n # formats: GroupName (group), \"Username\", +15555555555\n group_names = []\n usernames = []\n phone_numbers = []\n\n unknown_usernames = []\n GROUP = \"[group]\"\n send_to_all_checked = False\n\n for recipient in recipients:\n if recipient == \"[send to all]\":\n send_to_all_checked = True\n phone_users = CouchUser.view(\"users/phone_users_by_domain\",\n startkey=[domain], endkey=[domain, {}], include_docs=True\n )\n for user in phone_users:\n usernames.append(user.username)\n group_names = []\n break\n elif (not send_to_all_checked) and recipient.endswith(GROUP):\n name = recipient[:-len(GROUP)].strip()\n group_names.append(name)\n elif re.match(r'^\\+\\d+$', recipient): # here we expect it to have a plus sign\n def wrap_user_by_type(u):\n return getattr(user_models, u['doc']['doc_type']).wrap(u['doc'])\n\n phone_users = CouchUser.view(\"users/by_default_phone\", # search both with and w/o the plus\n keys=[recipient, recipient[1:]], include_docs=True,\n wrapper=wrap_user_by_type).all()\n\n phone_users = filter(lambda u: u.is_member_of(domain), phone_users)\n if len(phone_users) > 0:\n phone_numbers.append((phone_users[0], recipient))\n else:\n phone_numbers.append((None, recipient))\n elif (not send_to_all_checked) and re.match(r'[\\w\\.]+', recipient):\n usernames.append(recipient)\n else:\n unknown_usernames.append(recipient)\n\n login_ids = {\n r['key']: r['id'] for r in CommCareUser.get_db().view(\n \"users/by_username\", keys=usernames, reduce=False).all()}\n for username in usernames:\n if username not in login_ids:\n unknown_usernames.append(username)\n login_ids = login_ids.values()\n\n users = []\n empty_groups = []\n if len(group_names) > 0:\n users.extend(CouchUser.view('users/by_group', keys=[[domain, gn] for gn in group_names],\n include_docs=True).all())\n if len(users) == 0:\n empty_groups = group_names\n\n users.extend(CouchUser.view('_all_docs', keys=login_ids, include_docs=True).all())\n users = [user for user in users if user.is_active and not user.is_deleted()]\n\n phone_numbers.extend([(user, user.phone_number) for user in users])\n\n failed_numbers = []\n no_numbers = []\n sent = []\n\n if len(phone_numbers) == 1:\n recipient = phone_numbers[0][0]\n else:\n recipient = None\n\n logged_event = MessagingEvent.create_event_for_adhoc_sms(domain, recipient=recipient)\n\n for user, number in phone_numbers:\n if not number:\n no_numbers.append(user.raw_username)\n else:\n args = [user.doc_type, user.get_id] if user else []\n logged_subevent = logged_event.create_subevent_for_single_sms(*args)\n if send_sms(\n domain, user, number, message,\n metadata=MessageMetadata(messaging_subevent_id=logged_subevent.pk)\n ):\n sent.append(\"%s\" % (user.raw_username if user else number))\n logged_subevent.completed()\n else:\n failed_numbers.append(\"%s (%s)\" % (\n number,\n user.raw_username if user else \"<no username>\"\n ))\n logged_subevent.error(MessagingEvent.ERROR_INTERNAL_SERVER_ERROR)\n\n logged_event.completed()\n\n def comma_reminder():\n messages.error(request, _(\"Please remember to separate recipients\"\n \" with a comma.\"))\n\n if empty_groups or failed_numbers or unknown_usernames or no_numbers:\n if empty_groups:\n messages.error(request, _(\"The following groups don't exist: \") + (', '.join(empty_groups)))\n comma_reminder()\n if no_numbers:\n messages.error(request, _(\"The following users don't have phone numbers: \") + (', '.join(no_numbers)))\n if failed_numbers:\n messages.error(request, _(\"Couldn't send to the following number(s): \") + (', '.join(failed_numbers)))\n if unknown_usernames:\n messages.error(request, _(\"Couldn't find the following user(s): \") + (', '.join(unknown_usernames)))\n comma_reminder()\n if sent:\n messages.success(request, _(\"Successfully sent: \") + (', '.join(sent)))\n else:\n messages.info(request, _(\"No messages were sent.\"))\n else:\n messages.success(request, _(\"Message sent\"))\n\n return HttpResponseRedirect(\n request.META.get('HTTP_REFERER') or\n reverse(ComposeMessageView.urlname, args=[domain])\n )", "metadata": "root.send_to_recipients", "header": "['module', '___EOS___']", "index": 211 }, { "content": "@domain_admin_required\n@requires_privilege_with_fallback(privileges.INBOUND_SMS)\ndef message_test(request, domain, phone_number):\n if request.method == \"POST\":\n message = request.POST.get(\"message\", \"\")\n domain_scope = None if request.couch_user.is_superuser else domain\n try:\n incoming(phone_number, message, \"TEST\", domain_scope=domain_scope)\n except DomainScopeValidationError:\n messages.error(\n request,\n _(\"Invalid phone number being simulated. You may only \" \\\n \"simulate SMS from verified numbers belonging to contacts \" \\\n \"in this domain.\")\n )\n except Exception:\n notify_exception(request)\n messages.error(\n request,\n _(\"An error has occurred. Please try again in a few minutes \" \\\n \"and if the issue persists, please contact CommCareHQ \" \\\n \"Support.\")\n )\n\n context = get_sms_autocomplete_context(request, domain)\n context['domain'] = domain\n context['layout_flush_content'] = True\n context['phone_number'] = phone_number\n return render(request, \"sms/message_tester.html\", context)", "metadata": "root.message_test", "header": "['module', '___EOS___']", "index": 344 }, { "content": "@csrf_exempt\n@login_or_digest_ex(allow_cc_users=True)\n@requires_privilege_plaintext_response(privileges.OUTBOUND_SMS)\ndef api_send_sms(request, domain):\n \"\"\"\n An API to send SMS.\n Expected post parameters:\n phone_number - the phone number to send to\n contact_id - the _id of a contact to send to (overrides phone_number)\n vn_id - the _id of a VerifiedNumber to send to (overrides contact_id)\n text - the text of the message\n backend_id - the name of the MobileBackend to use while sending\n \"\"\"\n if request.method == \"POST\":\n phone_number = request.POST.get(\"phone_number\", None)\n contact_id = request.POST.get(\"contact_id\", None)\n vn_id = request.POST.get(\"vn_id\", None)\n text = request.POST.get(\"text\", None)\n backend_id = request.POST.get(\"backend_id\", None)\n chat = request.POST.get(\"chat\", None)\n contact = None\n\n if (phone_number is None and contact_id is None and not vn_id) or (text is None):\n return HttpResponseBadRequest(\"Not enough arguments.\")\n\n vn = None\n if vn_id:\n try:\n vn = VerifiedNumber.get(vn_id)\n except ResourceNotFound:\n return HttpResponseBadRequest(\"VerifiedNumber not found.\")\n\n if vn.domain != domain:\n return HttpResponseBadRequest(\"VerifiedNumber not found.\")\n\n phone_number = vn.phone_number\n contact = vn.owner\n elif contact_id is not None:\n try:\n contact = get_contact(contact_id)\n assert contact is not None\n assert contact.domain == domain\n except Exception:\n return HttpResponseBadRequest(\"Contact not found.\")\n try:\n vn = contact.get_verified_number()\n assert vn is not None\n phone_number = vn.phone_number\n except Exception:\n return HttpResponseBadRequest(\"Contact has no phone number.\")\n\n try:\n chat_workflow = string_to_boolean(chat)\n except Exception:\n chat_workflow = False\n\n if chat_workflow:\n chat_user_id = request.couch_user._id\n else:\n chat_user_id = None\n\n logged_event = MessagingEvent.create_event_for_adhoc_sms(\n domain, recipient=contact,\n content_type=(MessagingEvent.CONTENT_CHAT_SMS if chat_workflow\n else MessagingEvent.CONTENT_API_SMS))\n\n args = [contact.doc_type, contact.get_id] if contact else []\n logged_subevent = logged_event.create_subevent_for_single_sms(*args)\n\n metadata = MessageMetadata(\n chat_user_id=chat_user_id,\n messaging_subevent_id=logged_subevent.pk,\n )\n if backend_id is not None:\n success = send_sms_with_backend_name(domain, phone_number, text, backend_id, metadata)\n elif vn is not None:\n success = send_sms_to_verified_number(vn, text, metadata)\n else:\n success = send_sms(domain, None, phone_number, text, metadata)\n\n if success:\n logged_subevent.completed()\n logged_event.completed()\n return HttpResponse(\"OK\")\n else:\n logged_subevent.error(MessagingEvent.ERROR_INTERNAL_SERVER_ERROR)\n return HttpResponse(\"ERROR\")\n else:\n return HttpResponseBadRequest(\"POST Expected.\")", "metadata": "root.api_send_sms", "header": "['module', '___EOS___']", "index": 375 }, { "content": "@login_and_domain_required\n@require_superuser\ndef list_forwarding_rules(request, domain):\n forwarding_rules = get_forwarding_rules_for_domain(domain)\n\n context = {\n \"domain\" : domain,\n \"forwarding_rules\" : forwarding_rules,\n }\n return render(request, \"sms/list_forwarding_rules.html\", context)", "metadata": "root.list_forwarding_rules", "header": "['module', '___EOS___']", "index": 466 }, { "content": "@login_and_domain_required\n@require_superuser\ndef add_forwarding_rule(request, domain, forwarding_rule_id=None):\n forwarding_rule = None\n if forwarding_rule_id is not None:\n forwarding_rule = ForwardingRule.get(forwarding_rule_id)\n if forwarding_rule.domain != domain:\n raise Http404\n\n if request.method == \"POST\":\n form = ForwardingRuleForm(request.POST)\n if form.is_valid():\n if forwarding_rule is None:\n forwarding_rule = ForwardingRule(domain=domain)\n forwarding_rule.forward_type = form.cleaned_data.get(\"forward_type\")\n forwarding_rule.keyword = form.cleaned_data.get(\"keyword\")\n forwarding_rule.backend_id = form.cleaned_data.get(\"backend_id\")\n forwarding_rule.save()\n return HttpResponseRedirect(reverse('list_forwarding_rules', args=[domain]))\n else:\n initial = {}\n if forwarding_rule is not None:\n initial[\"forward_type\"] = forwarding_rule.forward_type\n initial[\"keyword\"] = forwarding_rule.keyword\n initial[\"backend_id\"] = forwarding_rule.backend_id\n form = ForwardingRuleForm(initial=initial)\n\n context = {\n \"domain\" : domain,\n \"form\" : form,\n \"forwarding_rule_id\" : forwarding_rule_id,\n }\n return render(request, \"sms/add_forwarding_rule.html\", context)", "metadata": "root.add_forwarding_rule", "header": "['module', '___EOS___']", "index": 477 }, { "content": "@login_and_domain_required\n@require_superuser\ndef delete_forwarding_rule(request, domain, forwarding_rule_id):\n forwarding_rule = ForwardingRule.get(forwarding_rule_id)\n if forwarding_rule.domain != domain or forwarding_rule.doc_type != \"ForwardingRule\":\n raise Http404\n forwarding_rule.retire()\n return HttpResponseRedirect(reverse(\"list_forwarding_rules\", args=[domain]))", "metadata": "root.delete_forwarding_rule", "header": "['module', '___EOS___']", "index": 511 }, { "content": "class GlobalBackendMap(BaseAdminSectionView):\n urlname = 'global_backend_map'\n template_name = 'sms/backend_map.html'\n page_title = ugettext_lazy(\"Default Gateways\")\n\n\n\n\n\n", "metadata": "root.GlobalBackendMap", "header": "['module', '___EOS___']", "index": 521 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname)", "metadata": "root.GlobalBackendMap.page_url", "header": "['class', 'GlobalBackendMap', '(', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 526 }, { "content": " @property\n @memoized\n def backends(self):\n return SQLMobileBackend.get_global_backends(SQLMobileBackend.SMS)", "metadata": "root.GlobalBackendMap.backends", "header": "['class', 'GlobalBackendMap', '(', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 530 }, { "content": " @property\n @memoized\n def backend_map_form(self):\n if self.request.method == 'POST':\n return BackendMapForm(self.request.POST, backends=self.backends)\n\n backend_map = SQLMobileBackendMapping.get_prefix_to_backend_map(SQLMobileBackend.SMS)\n initial = {\n 'catchall_backend_id': backend_map.catchall_backend_id,\n 'backend_map': json.dumps([\n {'prefix': prefix, 'backend_id': backend_id}\n for prefix, backend_id in backend_map.backend_map_tuples\n ]),\n }\n return BackendMapForm(initial=initial, backends=self.backends)", "metadata": "root.GlobalBackendMap.backend_map_form", "header": "['class', 'GlobalBackendMap', '(', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 535 }, { "content": " @use_bootstrap3\n @method_decorator(require_superuser)\n def dispatch(self, request, *args, **kwargs):\n return super(GlobalBackendMap, self).dispatch(request, *args, **kwargs)", "metadata": "root.GlobalBackendMap.dispatch", "header": "['class', 'GlobalBackendMap', '(', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 551 }, { "content": " @property\n def page_context(self):\n return {\n 'form': self.backend_map_form,\n 'backends': self.backends,\n }", "metadata": "root.GlobalBackendMap.page_context", "header": "['class', 'GlobalBackendMap', '(', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 556 }, { "content": " def post(self, request, *args, **kwargs):\n form = self.backend_map_form\n if form.is_valid():\n new_backend_map = form.cleaned_data.get('backend_map')\n new_catchall_backend_id = form.cleaned_data.get('catchall_backend_id')\n\n with transaction.atomic():\n SQLMobileBackendMapping.get_prefix_to_backend_map.clear(\n SQLMobileBackendMapping, SQLMobileBackend.SMS\n )\n SQLMobileBackendMapping.objects.filter(\n is_global=True,\n backend_type=SQLMobileBackend.SMS,\n ).delete()\n\n for prefix, backend_id in new_backend_map.items():\n SQLMobileBackendMapping.objects.create(\n is_global=True,\n backend_type=SQLMobileBackend.SMS,\n prefix=prefix,\n backend_id=backend_id\n )\n\n if new_catchall_backend_id:\n SQLMobileBackendMapping.objects.create(\n is_global=True,\n backend_type=SQLMobileBackend.SMS,\n prefix='*',\n backend_id=new_catchall_backend_id\n )\n\n messages.success(request, _(\"Changes Saved.\"))\n return HttpResponseRedirect(reverse(self.urlname))\n return self.get(request, *args, **kwargs)", "metadata": "root.GlobalBackendMap.post", "header": "['class', 'GlobalBackendMap', '(', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 563 }, { "content": "class ChatOverSMSView(BaseMessagingSectionView):\n urlname = 'chat_contacts'\n template_name = 'sms/chat_contacts.html'\n page_title = _(\"Chat over SMS\")\n", "metadata": "root.ChatOverSMSView", "header": "['module', '___EOS___']", "index": 599 }, { "content": " @method_decorator(require_permission(Permissions.edit_data))\n @use_bootstrap3\n @use_datatables\n def dispatch(self, *args, **kwargs):\n return super(ChatOverSMSView, self).dispatch(*args, **kwargs)", "metadata": "root.ChatOverSMSView.dispatch", "header": "['class', 'ChatOverSMSView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 604 }, { "content": "def get_case_contact_info(domain_obj, case_ids):\n data = {}\n for doc in iter_docs(CommCareCase.get_db(), case_ids):\n if domain_obj.custom_case_username:\n name = doc.get(domain_obj.custom_case_username)\n else:\n name = doc.get('name')\n data[doc['_id']] = [name or _('(unknown)')]\n return data", "metadata": "root.get_case_contact_info", "header": "['module', '___EOS___']", "index": 611 }, { "content": "def get_mobile_worker_contact_info(domain_obj, user_ids):\n data = {}\n for doc in iter_docs(CommCareUser.get_db(), user_ids):\n user = CommCareUser.wrap(doc)\n data[user.get_id] = [user.raw_username]\n return data", "metadata": "root.get_mobile_worker_contact_info", "header": "['module', '___EOS___']", "index": 622 }, { "content": "def get_contact_info(domain):\n # If the data has been cached, just retrieve it from there\n cache_key = 'sms-chat-contact-list-%s' % domain\n cache_expiration = 30 * 60\n try:\n client = cache_core.get_redis_client()\n cached_data = client.get(cache_key)\n if cached_data:\n return json.loads(cached_data)\n except:\n pass\n\n verified_number_ids = VerifiedNumber.by_domain(domain, ids_only=True)\n domain_obj = Domain.get_by_name(domain, strict=True)\n case_ids = []\n mobile_worker_ids = []\n data = []\n for doc in iter_docs(VerifiedNumber.get_db(), verified_number_ids):\n owner_id = doc['owner_id']\n if doc['owner_doc_type'] == 'CommCareCase':\n case_ids.append(owner_id)\n data.append([\n None,\n 'case',\n doc['phone_number'],\n owner_id,\n doc['_id'],\n ])\n elif doc['owner_doc_type'] == 'CommCareUser':\n mobile_worker_ids.append(owner_id)\n data.append([\n None,\n 'mobile_worker',\n doc['phone_number'],\n owner_id,\n doc['_id'],\n ])\n contact_data = get_case_contact_info(domain_obj, case_ids)\n contact_data.update(get_mobile_worker_contact_info(domain_obj, mobile_worker_ids))\n for row in data:\n contact_info = contact_data.get(row[3])\n row[0] = contact_info[0] if contact_info else _('(unknown)')\n\n # Save the data to the cache for faster lookup next time\n try:\n client.set(cache_key, json.dumps(data))\n client.expire(cache_key, cache_expiration)\n except:\n pass\n\n return data", "metadata": "root.get_contact_info", "header": "['module', '___EOS___']", "index": 630 }, { "content": "def format_contact_data(domain, data):\n for row in data:\n contact_id = row[3]\n vn_id = row[4]\n if row[1] == 'case':\n row[1] = _('Case')\n row[4] = reverse('case_details', args=[domain, contact_id])\n elif row[1] == 'mobile_worker':\n row[1] = _('Mobile Worker')\n row[4] = reverse(EditCommCareUserView.urlname, args=[domain, contact_id])\n else:\n row[4] = '#'\n row.append(reverse('sms_chat', args=[domain, contact_id, vn_id]))", "metadata": "root.format_contact_data", "header": "['module', '___EOS___']", "index": 683 }, { "content": "@require_permission(Permissions.edit_data)\n@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)\ndef chat_contact_list(request, domain):\n sEcho = request.GET.get('sEcho')\n iDisplayStart = int(request.GET.get('iDisplayStart'))\n iDisplayLength = int(request.GET.get('iDisplayLength'))\n sSearch = request.GET.get('sSearch', '').strip()\n\n data = get_contact_info(domain)\n total_records = len(data)\n\n if sSearch:\n regex = re.compile('^.*%s.*$' % sSearch)\n data = filter(lambda row: regex.match(row[0]) or regex.match(row[2]), data)\n filtered_records = len(data)\n\n data.sort(key=lambda row: row[0])\n data = data[iDisplayStart:iDisplayStart + iDisplayLength]\n format_contact_data(domain, data)\n result = {\n 'sEcho': sEcho,\n 'aaData': data,\n 'iTotalRecords': total_records,\n 'iTotalDisplayRecords': filtered_records,\n }\n\n return HttpResponse(json.dumps(result))", "metadata": "root.chat_contact_list", "header": "['module', '___EOS___']", "index": 698 }, { "content": "@require_permission(Permissions.edit_data)\n@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)\ndef chat(request, domain, contact_id, vn_id=None):\n domain_obj = Domain.get_by_name(domain, strict=True)\n timezone = get_timezone_for_user(None, domain)\n\n # floored_utc_timestamp is the datetime in UTC representing\n # midnight today in local time. This is used to calculate\n # all message history choices' timestamps, so that choosing\n # \"Yesterday\", for example, gives you data from yesterday at\n # midnight local time.\n local_date = datetime.now(timezone).date()\n floored_utc_timestamp = UserTime(\n datetime.combine(local_date, time(0, 0)),\n timezone\n ).server_time().done()\n\n def _fmt(d):\n return json_format_datetime(floored_utc_timestamp - timedelta(days=d))\n history_choices = [(_(x), _fmt(y)) for (x, y) in SMS_CHAT_HISTORY_CHOICES]\n history_choices.append(\n (_(\"All Time\"), json_format_datetime(datetime(1970, 1, 1)))\n )\n\n context = {\n \"domain\": domain,\n \"contact_id\": contact_id,\n \"contact\": get_contact(contact_id),\n \"use_message_counter\": domain_obj.chat_message_count_threshold is not None,\n \"message_count_threshold\": domain_obj.chat_message_count_threshold or 0,\n \"custom_case_username\": domain_obj.custom_case_username,\n \"history_choices\": history_choices,\n \"vn_id\": vn_id,\n }\n template = settings.CUSTOM_CHAT_TEMPLATES.get(domain_obj.custom_chat_template) or \"sms/chat.html\"\n return render(request, template, context)", "metadata": "root.chat", "header": "['module', '___EOS___']", "index": 727 }, { "content": "class ChatMessageHistory(View, DomainViewMixin):\n urlname = 'api_history'\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.ChatMessageHistory", "header": "['module', '___EOS___']", "index": 765 }, { "content": " @method_decorator(require_permission(Permissions.edit_data))\n @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n def dispatch(self, request, *args, **kwargs):\n return super(ChatMessageHistory, self).dispatch(request, *args, **kwargs)", "metadata": "root.ChatMessageHistory.dispatch", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 768 }, { "content": " @property\n @memoized\n def contact_id(self):\n return self.request.GET.get('contact_id')", "metadata": "root.ChatMessageHistory.contact_id", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 773 }, { "content": " @property\n @memoized\n def contact(self):\n if not self.contact_id:\n return None\n\n contact = get_contact(self.contact_id)\n if not contact or contact.domain != self.domain:\n return None\n\n return contact", "metadata": "root.ChatMessageHistory.contact", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 778 }, { "content": " @property\n @memoized\n def contact_name(self):\n if self.contact.doc_type == 'CommCareCase':\n if self.domain_object.custom_case_username:\n return self.contact.get_case_property(self.domain_object.custom_case_username)\n else:\n return self.contact.name\n else:\n return self.contact.first_name or self.contact.raw_username", "metadata": "root.ChatMessageHistory.contact_name", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 790 }, { "content": " @quickcache(['user_id'], timeout=60 * 60, memoize_timeout=5 * 60)\n def get_chat_user_name(self, user_id):\n if not user_id:\n return _(\"System\")\n\n try:\n user = CouchUser.get_by_user_id(user_id)\n return user.first_name or user.raw_username\n except:\n return _(\"Unknown\")", "metadata": "root.ChatMessageHistory.get_chat_user_name", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 801 }, { "content": " @property\n @memoized\n def start_date_str(self):\n return self.request.GET.get('start_date')", "metadata": "root.ChatMessageHistory.start_date_str", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 812 }, { "content": " @property\n @memoized\n def start_date(self):\n if not self.start_date_str:\n return None\n\n try:\n return iso_string_to_datetime(self.start_date_str)\n except (TypeError, ValueError):\n return None", "metadata": "root.ChatMessageHistory.start_date", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 817 }, { "content": " def get_raw_data(self):\n result = SMS.objects.filter(\n domain=self.domain,\n couch_recipient_doc_type=self.contact.doc_type,\n couch_recipient=self.contact_id\n ).exclude(\n direction=OUTGOING,\n processed=False\n )\n if self.start_date:\n result = result.filter(date__gt=self.start_date)\n result = self.filter_survey_data(result)\n return result.order_by('date')", "metadata": "root.ChatMessageHistory.get_raw_data", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 828 }, { "content": " def filter_survey_data(self, queryset):\n if not self.domain_object.filter_surveys_from_chat:\n return queryset\n\n if self.domain_object.show_invalid_survey_responses_in_chat:\n return queryset.exclude(\n Q(xforms_session_couch_id__isnull=False) &\n ~Q(direction=INCOMING, invalid_survey_response=True)\n )\n else:\n return queryset.exclude(\n xforms_session_couch_id__isnull=False\n )", "metadata": "root.ChatMessageHistory.filter_survey_data", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 842 }, { "content": " def get_response_data(self, requesting_user_id):\n timezone = get_timezone_for_user(None, self.domain)\n result = []\n last_sms = None\n for sms in self.get_raw_data():\n last_sms = sms\n if sms.direction == INCOMING:\n sender = self.contact_name\n else:\n sender = self.get_chat_user_name(sms.chat_user_id)\n result.append({\n 'sender': sender,\n 'text': sms.text,\n 'timestamp': (\n ServerTime(sms.date).user_time(timezone)\n .ui_string(\"%I:%M%p %m/%d/%y\").lower()\n ),\n 'utc_timestamp': json_format_datetime(sms.date),\n 'sent_by_requester': (sms.chat_user_id == requesting_user_id),\n })\n return result, last_sms", "metadata": "root.ChatMessageHistory.get_response_data", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 856 }, { "content": " def update_last_read_message(self, requesting_user_id, sms):\n domain = self.domain\n contact_id = self.contact_id\n\n key = 'update-last-read-message-%s-%s-%s' % (domain, requesting_user_id, contact_id)\n with CriticalSection([key]):\n try:\n entry = SQLLastReadMessage.objects.get(\n domain=domain,\n read_by=requesting_user_id,\n contact_id=contact_id\n )\n except SQLLastReadMessage.DoesNotExist:\n entry = SQLLastReadMessage(\n domain=domain,\n read_by=requesting_user_id,\n contact_id=contact_id\n )\n if not entry.message_timestamp or entry.message_timestamp < sms.date:\n entry.message_id = sms.couch_id\n entry.message_timestamp = sms.date\n entry.save()", "metadata": "root.ChatMessageHistory.update_last_read_message", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 878 }, { "content": " def get(self, request, *args, **kwargs):\n if not self.contact:\n return HttpResponse('[]')\n\n data, last_sms = self.get_response_data(request.couch_user.get_id)\n if last_sms:\n try:\n self.update_last_read_message(request.couch_user.get_id, last_sms)\n except:\n notify_exception(request, \"Error updating last read message for %s\" % last_sms.pk)\n\n return HttpResponse(json.dumps(data))", "metadata": "root.ChatMessageHistory.get", "header": "['class', 'ChatMessageHistory', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 901 }, { "content": "class ChatLastReadMessage(View, DomainViewMixin):\n urlname = 'api_last_read_message'\n\n\n", "metadata": "root.ChatLastReadMessage", "header": "['module', '___EOS___']", "index": 915 }, { "content": " @method_decorator(require_permission(Permissions.edit_data))\n @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n def dispatch(self, request, *args, **kwargs):\n return super(ChatLastReadMessage, self).dispatch(request, *args, **kwargs)", "metadata": "root.ChatLastReadMessage.dispatch", "header": "['class', 'ChatLastReadMessage', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 918 }, { "content": " @property\n @memoized\n def contact_id(self):\n return self.request.GET.get('contact_id')", "metadata": "root.ChatLastReadMessage.contact_id", "header": "['class', 'ChatLastReadMessage', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 923 }, { "content": " def get(self, request, *args, **kwargs):\n lrm_timestamp = None\n if self.contact_id:\n if self.domain_object.count_messages_as_read_by_anyone:\n lrm = SQLLastReadMessage.by_anyone(self.domain, self.contact_id)\n else:\n lrm = SQLLastReadMessage.by_user(self.domain, request.couch_user.get_id, self.contact_id)\n\n if lrm:\n lrm_timestamp = json_format_datetime(lrm.message_timestamp)\n return HttpResponse(json.dumps({\n 'message_timestamp': lrm_timestamp,\n }))", "metadata": "root.ChatLastReadMessage.get", "header": "['class', 'ChatLastReadMessage', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 928 }, { "content": "class DomainSmsGatewayListView(CRUDPaginatedViewMixin, BaseMessagingSectionView):\n template_name = \"sms/gateway_list.html\"\n urlname = 'list_domain_backends'\n page_title = ugettext_noop(\"SMS Connectivity\")\n strict_domain_fetching = True\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.DomainSmsGatewayListView", "header": "['module', '___EOS___']", "index": 943 }, { "content": " @use_bootstrap3\n @method_decorator(domain_admin_required)\n def dispatch(self, request, *args, **kwargs):\n return super(DomainSmsGatewayListView, self).dispatch(request, *args, **kwargs)", "metadata": "root.DomainSmsGatewayListView.dispatch", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 949 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname, args=[self.domain])", "metadata": "root.DomainSmsGatewayListView.page_url", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 954 }, { "content": " @property\n def parameters(self):\n return self.request.POST if self.request.method == 'POST' else self.request.GET", "metadata": "root.DomainSmsGatewayListView.parameters", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 958 }, { "content": " @property\n @memoized\n def total(self):\n return SQLMobileBackend.get_domain_backends(SQLMobileBackend.SMS, self.domain, count_only=True)", "metadata": "root.DomainSmsGatewayListView.total", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 962 }, { "content": " @property\n def column_names(self):\n return [\n _(\"Gateway\"),\n _(\"Description\"),\n _(\"Supported Countries\"),\n _(\"Status\"),\n _(\"Actions\"),\n ]", "metadata": "root.DomainSmsGatewayListView.column_names", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 967 }, { "content": " @property\n def page_context(self):\n context = self.pagination_context\n context.update({\n 'initiate_new_form': InitiateAddSMSBackendForm(is_superuser=self.request.couch_user.is_superuser),\n })\n return context", "metadata": "root.DomainSmsGatewayListView.page_context", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 977 }, { "content": " @property\n def paginated_list(self):\n backends = SQLMobileBackend.get_domain_backends(\n SQLMobileBackend.SMS,\n self.domain,\n offset=self.skip,\n limit=self.limit\n )\n default_backend = SQLMobileBackend.get_domain_default_backend(\n SQLMobileBackend.SMS,\n self.domain\n )\n\n if len(backends) > 0 and not default_backend:\n yield {\n 'itemData': {\n 'id': 'nodefault',\n 'name': \"Automatic Choose\",\n 'status': 'DEFAULT',\n },\n 'template': 'gateway-automatic-template',\n }\n elif default_backend:\n yield {\n 'itemData': self._fmt_backend_data(default_backend),\n 'template': 'gateway-default-template',\n }\n\n default_backend_id = default_backend.pk if default_backend else None\n for backend in backends:\n if backend.pk != default_backend_id:\n yield {\n 'itemData': self._fmt_backend_data(backend),\n 'template': 'gateway-template',\n }", "metadata": "root.DomainSmsGatewayListView.paginated_list", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 985 }, { "content": " def _fmt_backend_data(self, backend):\n is_editable = not backend.is_global and backend.domain == self.domain\n if len(backend.supported_countries) > 0:\n if backend.supported_countries[0] == '*':\n supported_country_names = _('Multiple%s') % '*'\n else:\n supported_country_names = ', '.join(\n [_(country_name_from_code(int(c))) for c in backend.supported_countries])\n else:\n supported_country_names = ''\n return {\n 'id': backend.pk,\n 'name': backend.name,\n 'description': backend.description,\n 'supported_countries': supported_country_names,\n 'editUrl': reverse(\n EditDomainGatewayView.urlname,\n args=[self.domain, backend.hq_api_id, backend.pk]\n ) if is_editable else \"\",\n 'canDelete': is_editable,\n 'isGlobal': backend.is_global,\n 'isShared': not backend.is_global and backend.domain != self.domain,\n 'deleteModalId': 'delete_%s' % backend.pk,\n }", "metadata": "root.DomainSmsGatewayListView._fmt_backend_data", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1021 }, { "content": " def _get_backend_from_item_id(self, item_id):\n try:\n item_id = int(item_id)\n backend = SQLMobileBackend.load(item_id)\n return item_id, backend\n except (BadSMSConfigException, SQLMobileBackend.DoesNotExist, TypeError, ValueError):\n raise Http404()", "metadata": "root.DomainSmsGatewayListView._get_backend_from_item_id", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1046 }, { "content": " def get_deleted_item_data(self, item_id):\n item_id, backend = self._get_backend_from_item_id(item_id)\n\n if backend.is_global or backend.domain != self.domain:\n raise Http404()\n\n # Do not actually delete so that linkage always exists between SMS and\n # MobileBackend for billable history\n backend.soft_delete()\n\n return {\n 'itemData': self._fmt_backend_data(backend),\n 'template': 'gateway-deleted-template',\n }", "metadata": "root.DomainSmsGatewayListView.get_deleted_item_data", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1054 }, { "content": " def refresh_item(self, item_id):\n item_id, backend = self._get_backend_from_item_id(item_id)\n\n if not backend.domain_is_authorized(self.domain):\n raise Http404()\n\n domain_default_backend_id = SQLMobileBackend.get_domain_default_backend(\n SQLMobileBackend.SMS,\n self.domain,\n id_only=True\n )\n\n if domain_default_backend_id == item_id:\n SQLMobileBackendMapping.unset_default_domain_backend(self.domain)\n else:\n SQLMobileBackendMapping.set_default_domain_backend(self.domain, backend)", "metadata": "root.DomainSmsGatewayListView.refresh_item", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1069 }, { "content": " @property\n def allowed_actions(self):\n actions = super(DomainSmsGatewayListView, self).allowed_actions\n return actions + ['new_backend']", "metadata": "root.DomainSmsGatewayListView.allowed_actions", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1086 }, { "content": " def post(self, request, *args, **kwargs):\n if self.action == 'new_backend':\n hq_api_id = request.POST['hq_api_id']\n if (\n toggles.TELERIVET_SETUP_WALKTHROUGH.enabled(self.domain) and\n hq_api_id == SQLTelerivetBackend.get_api_id()\n ):\n from corehq.messaging.smsbackends.telerivet.views import TelerivetSetupView\n return HttpResponseRedirect(reverse(TelerivetSetupView.urlname, args=[self.domain]))\n return HttpResponseRedirect(reverse(AddDomainGatewayView.urlname, args=[self.domain, hq_api_id]))\n return self.paginate_crud_response", "metadata": "root.DomainSmsGatewayListView.post", "header": "['class', 'DomainSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1091 }, { "content": "class AddGatewayViewMixin(object):\n \"\"\"\n A mixin to help extract the common functionality between adding/editing\n domain-level backends and adding/editing global backends.\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.AddGatewayViewMixin", "header": "['module', '___EOS___']", "index": 1104 }, { "content": " @property\n def is_superuser(self):\n return self.request.couch_user.is_superuser", "metadata": "root.AddGatewayViewMixin.is_superuser", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1110 }, { "content": " @property\n @memoized\n def hq_api_id(self):\n return self.kwargs.get('hq_api_id')", "metadata": "root.AddGatewayViewMixin.hq_api_id", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1114 }, { "content": " @property\n @memoized\n def backend_class(self):\n # Superusers can create/edit any backend\n # Regular users can only create/edit Telerivet backends for now\n if not self.is_superuser and self.hq_api_id != SQLTelerivetBackend.get_api_id():\n raise Http404()\n backend_classes = get_sms_backend_classes()\n try:\n return backend_classes[self.hq_api_id]\n except KeyError:\n raise Http404()", "metadata": "root.AddGatewayViewMixin.backend_class", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1119 }, { "content": " @property\n def use_load_balancing(self):\n return issubclass(self.backend_class, PhoneLoadBalancingMixin)", "metadata": "root.AddGatewayViewMixin.use_load_balancing", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1132 }, { "content": " @property\n def page_name(self):\n return _(\"Add %s Gateway\") % self.backend_class.get_generic_name()", "metadata": "root.AddGatewayViewMixin.page_name", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1136 }, { "content": " @property\n def button_text(self):\n return _(\"Create %s Gateway\") % self.backend_class.get_generic_name()", "metadata": "root.AddGatewayViewMixin.button_text", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1140 }, { "content": " @property\n def page_context(self):\n return {\n 'form': self.backend_form,\n 'button_text': self.button_text,\n 'use_load_balancing': self.use_load_balancing,\n }", "metadata": "root.AddGatewayViewMixin.page_context", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1144 }, { "content": " def post(self, request, *args, **kwargs):\n if self.backend_form.is_valid():\n self.backend.name = self.backend_form.cleaned_data.get('name')\n self.backend.description = self.backend_form.cleaned_data.get('description')\n self.backend.reply_to_phone_number = self.backend_form.cleaned_data.get('reply_to_phone_number')\n\n extra_fields = {}\n for key, value in self.backend_form.cleaned_data.items():\n if key in self.backend.get_available_extra_fields():\n extra_fields[key] = value\n self.backend.set_extra_fields(**extra_fields)\n\n if self.use_load_balancing:\n self.backend.load_balancing_numbers = self.backend_form.cleaned_data['phone_numbers']\n\n self.backend.save()\n if not self.backend.is_global:\n self.backend.set_shared_domains(self.backend_form.cleaned_data.get('authorized_domains'))\n return self.redirect_to_gateway_list()\n return self.get(request, *args, **kwargs)", "metadata": "root.AddGatewayViewMixin.post", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1152 }, { "content": " @property\n def backend(self):\n raise NotImplementedError()", "metadata": "root.AddGatewayViewMixin.backend", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1173 }, { "content": " @property\n def page_url(self):\n raise NotImplementedError()", "metadata": "root.AddGatewayViewMixin.page_url", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1177 }, { "content": " @property\n def backend_form(self):\n raise NotImplementedError()", "metadata": "root.AddGatewayViewMixin.backend_form", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1181 }, { "content": " @property\n def parent_pages(self):\n raise NotImplementedError()", "metadata": "root.AddGatewayViewMixin.parent_pages", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1185 }, { "content": " def redirect_to_gateway_list(self):\n raise NotImplementedError()", "metadata": "root.AddGatewayViewMixin.redirect_to_gateway_list", "header": "['class', 'AddGatewayViewMixin', '(', 'object', ')', ':', '___EOS___']", "index": 1189 }, { "content": "class AddDomainGatewayView(AddGatewayViewMixin, BaseMessagingSectionView):\n urlname = 'add_domain_gateway'\n template_name = 'sms/add_gateway.html'\n page_title = ugettext_lazy(\"Add SMS Gateway\")\n\n\n\n\n\n", "metadata": "root.AddDomainGatewayView", "header": "['module', '___EOS___']", "index": 1193 }, { "content": " @property\n @memoized\n def backend(self):\n return self.backend_class(\n domain=self.domain,\n is_global=False,\n backend_type=SQLMobileBackend.SMS,\n hq_api_id=self.backend_class.get_api_id()\n )", "metadata": "root.AddDomainGatewayView.backend", "header": "['class', 'AddDomainGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1198 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname, args=[self.domain, self.hq_api_id])", "metadata": "root.AddDomainGatewayView.page_url", "header": "['class', 'AddDomainGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1208 }, { "content": " @property\n @memoized\n def backend_form(self):\n form_class = self.backend_class.get_form_class()\n if self.request.method == 'POST':\n return form_class(\n self.request.POST,\n button_text=self.button_text,\n domain=self.domain,\n backend_id=None\n )\n return form_class(\n button_text=self.button_text,\n domain=self.domain,\n backend_id=None\n )", "metadata": "root.AddDomainGatewayView.backend_form", "header": "['class', 'AddDomainGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1212 }, { "content": " @property\n def parent_pages(self):\n return [{\n 'title': DomainSmsGatewayListView.page_title,\n 'url': reverse(DomainSmsGatewayListView.urlname, args=[self.domain]),\n }]", "metadata": "root.AddDomainGatewayView.parent_pages", "header": "['class', 'AddDomainGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1229 }, { "content": " def redirect_to_gateway_list(self):\n return HttpResponseRedirect(reverse(DomainSmsGatewayListView.urlname, args=[self.domain]))", "metadata": "root.AddDomainGatewayView.redirect_to_gateway_list", "header": "['class', 'AddDomainGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1236 }, { "content": " @use_bootstrap3\n @use_select2\n @method_decorator(domain_admin_required)\n @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n def dispatch(self, request, *args, **kwargs):\n return super(AddDomainGatewayView, self).dispatch(request, *args, **kwargs)", "metadata": "root.AddDomainGatewayView.dispatch", "header": "['class', 'AddDomainGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1239 }, { "content": "class EditDomainGatewayView(AddDomainGatewayView):\n urlname = 'edit_domain_gateway'\n page_title = ugettext_lazy(\"Edit SMS Gateway\")\n\n\n\n\n\n", "metadata": "root.EditDomainGatewayView", "header": "['module', '___EOS___']", "index": 1247 }, { "content": " @property\n def backend_id(self):\n return self.kwargs['backend_id']", "metadata": "root.EditDomainGatewayView.backend_id", "header": "['class', 'EditDomainGatewayView', '(', 'AddDomainGatewayView', ')', ':', '___EOS___']", "index": 1251 }, { "content": " @property\n @memoized\n def backend(self):\n try:\n backend = self.backend_class.objects.get(pk=self.backend_id)\n except ResourceNotFound:\n raise Http404()\n if (\n backend.is_global or\n backend.domain != self.domain or\n backend.hq_api_id != self.backend_class.get_api_id() or\n backend.deleted\n ):\n raise Http404()\n return backend", "metadata": "root.EditDomainGatewayView.backend", "header": "['class', 'EditDomainGatewayView', '(', 'AddDomainGatewayView', ')', ':', '___EOS___']", "index": 1255 }, { "content": " @property\n @memoized\n def backend_form(self):\n form_class = self.backend_class.get_form_class()\n authorized_domains = self.backend.get_authorized_domain_list()\n initial = {\n 'name': self.backend.name,\n 'description': self.backend.description,\n 'give_other_domains_access': len(authorized_domains) > 0,\n 'authorized_domains': ','.join(authorized_domains),\n 'reply_to_phone_number': self.backend.reply_to_phone_number,\n }\n initial.update(self.backend.get_extra_fields())\n\n if self.use_load_balancing:\n initial['phone_numbers'] = json.dumps(\n [{'phone_number': p} for p in self.backend.load_balancing_numbers]\n )\n\n if self.request.method == 'POST':\n return form_class(\n self.request.POST,\n initial=initial,\n button_text=self.button_text,\n domain=self.domain,\n backend_id=self.backend.pk\n )\n return form_class(\n initial=initial,\n button_text=self.button_text,\n domain=self.domain,\n backend_id=self.backend.pk\n )", "metadata": "root.EditDomainGatewayView.backend_form", "header": "['class', 'EditDomainGatewayView', '(', 'AddDomainGatewayView', ')', ':', '___EOS___']", "index": 1271 }, { "content": " @property\n def page_name(self):\n return _(\"Edit %s Gateway\") % self.backend_class.get_generic_name()", "metadata": "root.EditDomainGatewayView.page_name", "header": "['class', 'EditDomainGatewayView', '(', 'AddDomainGatewayView', ')', ':', '___EOS___']", "index": 1305 }, { "content": " @property\n def button_text(self):\n return _(\"Update %s Gateway\") % self.backend_class.get_generic_name()", "metadata": "root.EditDomainGatewayView.button_text", "header": "['class', 'EditDomainGatewayView', '(', 'AddDomainGatewayView', ')', ':', '___EOS___']", "index": 1309 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname, kwargs=self.kwargs)", "metadata": "root.EditDomainGatewayView.page_url", "header": "['class', 'EditDomainGatewayView', '(', 'AddDomainGatewayView', ')', ':', '___EOS___']", "index": 1313 }, { "content": "class GlobalSmsGatewayListView(CRUDPaginatedViewMixin, BaseAdminSectionView):\n template_name = \"sms/global_gateway_list.html\"\n urlname = 'list_global_backends'\n page_title = ugettext_noop(\"SMS Connectivity\")\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.GlobalSmsGatewayListView", "header": "['module', '___EOS___']", "index": 1318 }, { "content": " @use_bootstrap3\n @method_decorator(require_superuser)\n def dispatch(self, request, *args, **kwargs):\n return super(GlobalSmsGatewayListView, self).dispatch(request, *args, **kwargs)", "metadata": "root.GlobalSmsGatewayListView.dispatch", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1323 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname)", "metadata": "root.GlobalSmsGatewayListView.page_url", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1328 }, { "content": " @property\n def parameters(self):\n return self.request.POST if self.request.method == 'POST' else self.request.GET", "metadata": "root.GlobalSmsGatewayListView.parameters", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1332 }, { "content": " @property\n @memoized\n def total(self):\n return SQLMobileBackend.get_global_backends(SQLMobileBackend.SMS, count_only=True)", "metadata": "root.GlobalSmsGatewayListView.total", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1336 }, { "content": " @property\n def column_names(self):\n return [\n _(\"Gateway\"),\n _(\"Description\"),\n _(\"Supported Countries\"),\n _(\"Actions\"),\n ]", "metadata": "root.GlobalSmsGatewayListView.column_names", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1341 }, { "content": " @property\n def page_context(self):\n context = self.pagination_context\n context.update({\n 'initiate_new_form': InitiateAddSMSBackendForm(is_superuser=self.request.couch_user.is_superuser),\n })\n return context", "metadata": "root.GlobalSmsGatewayListView.page_context", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1350 }, { "content": " @property\n def paginated_list(self):\n backends = SQLMobileBackend.get_global_backends(\n SQLMobileBackend.SMS,\n offset=self.skip,\n limit=self.limit\n )\n\n for backend in backends:\n yield {\n 'itemData': self._fmt_backend_data(backend),\n 'template': 'gateway-template',\n }", "metadata": "root.GlobalSmsGatewayListView.paginated_list", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1358 }, { "content": " def _fmt_backend_data(self, backend):\n if len(backend.supported_countries) > 0:\n if backend.supported_countries[0] == '*':\n supported_country_names = _('Multiple%s') % '*'\n else:\n supported_country_names = ', '.join(\n [_(country_name_from_code(int(c))) for c in backend.supported_countries])\n else:\n supported_country_names = ''\n return {\n 'id': backend.pk,\n 'name': backend.name,\n 'description': backend.description,\n 'supported_countries': supported_country_names,\n 'editUrl': reverse(\n EditGlobalGatewayView.urlname,\n args=[backend.hq_api_id, backend.pk]\n ),\n 'deleteModalId': 'delete_%s' % backend.pk,\n }", "metadata": "root.GlobalSmsGatewayListView._fmt_backend_data", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1372 }, { "content": " def _get_backend_from_item_id(self, item_id):\n try:\n item_id = int(item_id)\n backend = SQLMobileBackend.load(item_id)\n return item_id, backend\n except (BadSMSConfigException, SQLMobileBackend.DoesNotExist, TypeError, ValueError):\n raise Http404()", "metadata": "root.GlobalSmsGatewayListView._get_backend_from_item_id", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1393 }, { "content": " def get_deleted_item_data(self, item_id):\n item_id, backend = self._get_backend_from_item_id(item_id)\n\n if not backend.is_global:\n raise Http404()\n\n # Do not actually delete so that linkage always exists between SMS and\n # MobileBackend for billable history\n backend.soft_delete()\n\n return {\n 'itemData': self._fmt_backend_data(backend),\n 'template': 'gateway-deleted-template',\n }", "metadata": "root.GlobalSmsGatewayListView.get_deleted_item_data", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1401 }, { "content": " @property\n def allowed_actions(self):\n actions = super(GlobalSmsGatewayListView, self).allowed_actions\n return actions + ['new_backend']", "metadata": "root.GlobalSmsGatewayListView.allowed_actions", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1416 }, { "content": " def post(self, request, *args, **kwargs):\n if self.action == 'new_backend':\n hq_api_id = request.POST['hq_api_id']\n return HttpResponseRedirect(reverse(AddGlobalGatewayView.urlname, args=[hq_api_id]))\n return self.paginate_crud_response", "metadata": "root.GlobalSmsGatewayListView.post", "header": "['class', 'GlobalSmsGatewayListView', '(', 'CRUDPaginatedViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1421 }, { "content": "class AddGlobalGatewayView(AddGatewayViewMixin, BaseAdminSectionView):\n urlname = 'add_global_gateway'\n template_name = 'sms/add_gateway.html'\n page_title = ugettext_lazy(\"Add SMS Gateway\")\n\n\n\n\n\n", "metadata": "root.AddGlobalGatewayView", "header": "['module', '___EOS___']", "index": 1428 }, { "content": " @property\n @memoized\n def backend(self):\n return self.backend_class(\n is_global=True,\n backend_type=SQLMobileBackend.SMS,\n hq_api_id=self.backend_class.get_api_id()\n )", "metadata": "root.AddGlobalGatewayView.backend", "header": "['class', 'AddGlobalGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1433 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname, args=[self.hq_api_id])", "metadata": "root.AddGlobalGatewayView.page_url", "header": "['class', 'AddGlobalGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1442 }, { "content": " @property\n @memoized\n def backend_form(self):\n form_class = self.backend_class.get_form_class()\n if self.request.method == 'POST':\n return form_class(\n self.request.POST,\n button_text=self.button_text,\n domain=None,\n backend_id=None\n )\n return form_class(\n button_text=self.button_text,\n domain=None,\n backend_id=None\n )", "metadata": "root.AddGlobalGatewayView.backend_form", "header": "['class', 'AddGlobalGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1446 }, { "content": " @property\n def parent_pages(self):\n return [{\n 'title': GlobalSmsGatewayListView.page_title,\n 'url': reverse(GlobalSmsGatewayListView.urlname),\n }]", "metadata": "root.AddGlobalGatewayView.parent_pages", "header": "['class', 'AddGlobalGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1463 }, { "content": " def redirect_to_gateway_list(self):\n return HttpResponseRedirect(reverse(GlobalSmsGatewayListView.urlname))", "metadata": "root.AddGlobalGatewayView.redirect_to_gateway_list", "header": "['class', 'AddGlobalGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1470 }, { "content": " @use_bootstrap3\n @use_select2\n @method_decorator(require_superuser)\n def dispatch(self, request, *args, **kwargs):\n return super(AddGlobalGatewayView, self).dispatch(request, *args, **kwargs)", "metadata": "root.AddGlobalGatewayView.dispatch", "header": "['class', 'AddGlobalGatewayView', '(', 'AddGatewayViewMixin', ',', 'BaseAdminSectionView', ')', ':', '___EOS___']", "index": 1473 }, { "content": "class EditGlobalGatewayView(AddGlobalGatewayView):\n urlname = 'edit_global_gateway'\n page_title = ugettext_lazy(\"Edit SMS Gateway\")\n\n\n\n\n\n", "metadata": "root.EditGlobalGatewayView", "header": "['module', '___EOS___']", "index": 1480 }, { "content": " @property\n def backend_id(self):\n return self.kwargs['backend_id']", "metadata": "root.EditGlobalGatewayView.backend_id", "header": "['class', 'EditGlobalGatewayView', '(', 'AddGlobalGatewayView', ')', ':', '___EOS___']", "index": 1484 }, { "content": " @property\n @memoized\n def backend(self):\n try:\n backend = self.backend_class.objects.get(pk=self.backend_id)\n except ResourceNotFound:\n raise Http404()\n if (\n not backend.is_global or\n backend.deleted or\n backend.hq_api_id != self.backend_class.get_api_id()\n ):\n raise Http404()\n return backend", "metadata": "root.EditGlobalGatewayView.backend", "header": "['class', 'EditGlobalGatewayView', '(', 'AddGlobalGatewayView', ')', ':', '___EOS___']", "index": 1488 }, { "content": " @property\n @memoized\n def backend_form(self):\n form_class = self.backend_class.get_form_class()\n initial = {\n 'name': self.backend.name,\n 'description': self.backend.description,\n 'reply_to_phone_number': self.backend.reply_to_phone_number,\n }\n initial.update(self.backend.get_extra_fields())\n\n if self.use_load_balancing:\n initial['phone_numbers'] = json.dumps(\n [{'phone_number': p} for p in self.backend.load_balancing_numbers]\n )\n\n if self.request.method == 'POST':\n return form_class(\n self.request.POST,\n initial=initial,\n button_text=self.button_text,\n domain=None,\n backend_id=self.backend.pk\n )\n return form_class(\n initial=initial,\n button_text=self.button_text,\n domain=None,\n backend_id=self.backend.pk\n )", "metadata": "root.EditGlobalGatewayView.backend_form", "header": "['class', 'EditGlobalGatewayView', '(', 'AddGlobalGatewayView', ')', ':', '___EOS___']", "index": 1503 }, { "content": " @property\n def page_name(self):\n return _(\"Edit %s Gateway\") % self.backend_class.get_generic_name()", "metadata": "root.EditGlobalGatewayView.page_name", "header": "['class', 'EditGlobalGatewayView', '(', 'AddGlobalGatewayView', ')', ':', '___EOS___']", "index": 1534 }, { "content": " @property\n def button_text(self):\n return _(\"Update %s Gateway\") % self.backend_class.get_generic_name()", "metadata": "root.EditGlobalGatewayView.button_text", "header": "['class', 'EditGlobalGatewayView', '(', 'AddGlobalGatewayView', ')', ':', '___EOS___']", "index": 1538 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname, kwargs=self.kwargs)", "metadata": "root.EditGlobalGatewayView.page_url", "header": "['class', 'EditGlobalGatewayView', '(', 'AddGlobalGatewayView', ')', ':', '___EOS___']", "index": 1542 }, { "content": "class SubscribeSMSView(BaseMessagingSectionView):\n template_name = \"sms/subscribe_sms.html\"\n urlname = 'subscribe_sms'\n page_title = ugettext_noop(\"Subscribe SMS\")\n\n\n\n\n", "metadata": "root.SubscribeSMSView", "header": "['module', '___EOS___']", "index": 1547 }, { "content": " @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n @use_bootstrap3\n def dispatch(self, *args, **kwargs):\n return super(SubscribeSMSView, self).dispatch(*args, **kwargs)", "metadata": "root.SubscribeSMSView.dispatch", "header": "['class', 'SubscribeSMSView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1552 }, { "content": " @property\n def commtrack_settings(self):\n return Domain.get_by_name(self.domain).commtrack_settings", "metadata": "root.SubscribeSMSView.commtrack_settings", "header": "['class', 'SubscribeSMSView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1557 }, { "content": " @property\n @memoized\n def form(self):\n if self.request.method == 'POST':\n return SubscribeSMSForm(self.request.POST)\n\n if self.commtrack_settings and self.commtrack_settings.alert_config:\n alert_config = self.commtrack_settings.alert_config\n else:\n alert_config = AlertConfig()\n initial = {\n 'stock_out_facilities': alert_config.stock_out_facilities,\n 'stock_out_commodities': alert_config.stock_out_commodities,\n 'stock_out_rates': alert_config.stock_out_rates,\n 'non_report': alert_config.non_report,\n }\n\n return SubscribeSMSForm(initial=initial)", "metadata": "root.SubscribeSMSView.form", "header": "['class', 'SubscribeSMSView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1561 }, { "content": " @property\n def page_context(self):\n context = {\n \"form\": self.form,\n \"domain\": self.domain,\n }\n return context", "metadata": "root.SubscribeSMSView.page_context", "header": "['class', 'SubscribeSMSView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1580 }, { "content": " def post(self, request, *args, **kwargs):\n if self.form.is_valid():\n self.form.save(self.commtrack_settings)\n messages.success(request, _(\"Updated CommCare Supply settings.\"))\n return HttpResponseRedirect(reverse(SubscribeSMSView.urlname, args=[self.domain]))\n return self.get(request, *args, **kwargs)", "metadata": "root.SubscribeSMSView.post", "header": "['class', 'SubscribeSMSView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1588 }, { "content": "class SMSLanguagesView(BaseMessagingSectionView):\n urlname = 'sms_languages'\n template_name = \"sms/languages.html\"\n page_title = ugettext_noop(\"Languages\")\n\n", "metadata": "root.SMSLanguagesView", "header": "['module', '___EOS___']", "index": 1596 }, { "content": " @use_bootstrap3\n @use_jquery_ui\n @method_decorator(domain_admin_required)\n def dispatch(self, *args, **kwargs):\n return super(SMSLanguagesView, self).dispatch(*args, **kwargs)", "metadata": "root.SMSLanguagesView.dispatch", "header": "['class', 'SMSLanguagesView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1601 }, { "content": " @property\n def page_context(self):\n with StandaloneTranslationDoc.get_locked_obj(self.domain, \"sms\", create=True) as tdoc:\n if len(tdoc.langs) == 0:\n tdoc.langs = [\"en\"]\n tdoc.translations[\"en\"] = {}\n tdoc.save()\n context = {\n \"domain\": self.domain,\n \"sms_langs\": tdoc.langs,\n \"bulk_upload\": {\n \"action\": reverse(\"upload_sms_translations\", args=(self.domain,)),\n \"download_url\": reverse(\"download_sms_translations\", args=(self.domain,)),\n \"adjective\": _(\"messaging translation\"),\n \"plural_noun\": _(\"messaging translations\"),\n },\n }\n context.update({\n \"bulk_upload_form\": get_bulk_upload_form(context),\n })\n\n return context", "metadata": "root.SMSLanguagesView.page_context", "header": "['class', 'SMSLanguagesView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1607 }, { "content": "@domain_admin_required\n@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)\ndef edit_sms_languages(request, domain):\n \"\"\"\n Accepts same post body as corehq.apps.app_manager.views.edit_app_langs\n \"\"\"\n with StandaloneTranslationDoc.get_locked_obj(domain, \"sms\",\n create=True) as tdoc:\n try:\n from corehq.apps.app_manager.views.utils import validate_langs\n langs, rename, build = validate_langs(request, tdoc.langs,\n validate_build=False)\n except AssertionError:\n return HttpResponse(status=400)\n\n for old, new in rename.items():\n if old != new:\n tdoc.translations[new] = tdoc.translations[old]\n del tdoc.translations[old]\n\n for lang in langs:\n if lang not in tdoc.translations:\n tdoc.translations[lang] = {}\n\n for lang in tdoc.translations.keys():\n if lang not in langs:\n del tdoc.translations[lang]\n\n tdoc.langs = langs\n tdoc.save()\n return json_response(langs)", "metadata": "root.edit_sms_languages", "header": "['module', '___EOS___']", "index": 1631 }, { "content": "@domain_admin_required\n@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)\ndef download_sms_translations(request, domain):\n tdoc = StandaloneTranslationDoc.get_obj(domain, \"sms\")\n columns = [\"property\"] + tdoc.langs + [\"default\"]\n\n msg_ids = sorted(_MESSAGES.keys())\n rows = []\n for msg_id in msg_ids:\n rows.append([msg_id])\n\n for lang in tdoc.langs:\n for row in rows:\n row.append(tdoc.translations[lang].get(row[0], \"\"))\n\n for row in rows:\n row.append(_MESSAGES.get(row[0]))\n\n temp = StringIO()\n headers = ((\"translations\", tuple(columns)),)\n data = ((\"translations\", tuple(rows)),)\n export_raw(headers, data, temp)\n return export_response(temp, Format.XLS_2007, \"translations\")", "metadata": "root.download_sms_translations", "header": "['module', '___EOS___']", "index": 1664 }, { "content": "@domain_admin_required\n@requires_privilege_with_fallback(privileges.OUTBOUND_SMS)\n@get_file(\"bulk_upload_file\")\ndef upload_sms_translations(request, domain):\n try:\n workbook = WorkbookJSONReader(request.file)\n translations = workbook.get_worksheet(title='translations')\n\n with StandaloneTranslationDoc.get_locked_obj(domain, \"sms\") as tdoc:\n msg_ids = sorted(_MESSAGES.keys())\n result = {}\n for lang in tdoc.langs:\n result[lang] = {}\n\n for row in translations:\n for lang in tdoc.langs:\n if row.get(lang):\n msg_id = row[\"property\"]\n if msg_id in msg_ids:\n val = row[lang]\n if not isinstance(val, basestring):\n val = str(val)\n val = val.strip()\n result[lang][msg_id] = val\n\n tdoc.translations = result\n tdoc.save()\n messages.success(request, _(\"SMS Translations Updated.\"))\n except Exception:\n notify_exception(request, 'SMS Upload Translations Error')\n messages.error(request, _(\"Update failed. We're looking into it.\"))\n\n return HttpResponseRedirect(reverse('sms_languages', args=[domain]))", "metadata": "root.upload_sms_translations", "header": "['module', '___EOS___']", "index": 1689 }, { "content": "class SMSSettingsView(BaseMessagingSectionView):\n urlname = \"sms_settings\"\n template_name = \"sms/settings.html\"\n page_title = ugettext_noop(\"SMS Settings\")\n\n\n\n\n\n\n\n", "metadata": "root.SMSSettingsView", "header": "['module', '___EOS___']", "index": 1724 }, { "content": " @property\n def page_name(self):\n return _(\"SMS Settings\")", "metadata": "root.SMSSettingsView.page_name", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1729 }, { "content": " @property\n def page_url(self):\n return reverse(self.urlname, args=[self.domain])", "metadata": "root.SMSSettingsView.page_url", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1733 }, { "content": " @property\n @memoized\n def previewer(self):\n return self.request.couch_user.is_previewer()", "metadata": "root.SMSSettingsView.previewer", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1737 }, { "content": " def get_welcome_message_recipient(self, domain_obj):\n if (\n domain_obj.enable_registration_welcome_sms_for_case and\n domain_obj.enable_registration_welcome_sms_for_mobile_worker\n ):\n return WELCOME_RECIPIENT_ALL\n elif domain_obj.enable_registration_welcome_sms_for_case:\n return WELCOME_RECIPIENT_CASE\n elif domain_obj.enable_registration_welcome_sms_for_mobile_worker:\n return WELCOME_RECIPIENT_MOBILE_WORKER\n else:\n return WELCOME_RECIPIENT_NONE", "metadata": "root.SMSSettingsView.get_welcome_message_recipient", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1742 }, { "content": " @property\n @memoized\n def form(self):\n if self.request.method == \"POST\":\n form = SettingsForm(self.request.POST, cchq_domain=self.domain,\n cchq_is_previewer=self.previewer)\n else:\n domain_obj = Domain.get_by_name(self.domain, strict=True)\n enabled_disabled = lambda b: (ENABLED if b else DISABLED)\n default_custom = lambda b: (CUSTOM if b else DEFAULT)\n initial = {\n \"use_default_sms_response\":\n enabled_disabled(domain_obj.use_default_sms_response),\n \"default_sms_response\":\n domain_obj.default_sms_response,\n \"use_restricted_sms_times\":\n enabled_disabled(len(domain_obj.restricted_sms_times) > 0),\n \"restricted_sms_times_json\":\n [w.to_json() for w in domain_obj.restricted_sms_times],\n \"send_to_duplicated_case_numbers\":\n enabled_disabled(domain_obj.send_to_duplicated_case_numbers),\n \"use_custom_case_username\":\n default_custom(domain_obj.custom_case_username),\n \"custom_case_username\":\n domain_obj.custom_case_username,\n \"use_custom_message_count_threshold\":\n default_custom(\n domain_obj.chat_message_count_threshold is not None),\n \"custom_message_count_threshold\":\n domain_obj.chat_message_count_threshold,\n \"use_sms_conversation_times\":\n enabled_disabled(len(domain_obj.sms_conversation_times) > 0),\n \"sms_conversation_times_json\":\n [w.to_json() for w in domain_obj.sms_conversation_times],\n \"sms_conversation_length\":\n domain_obj.sms_conversation_length,\n \"survey_traffic_option\":\n (SHOW_ALL\n if not domain_obj.filter_surveys_from_chat else\n SHOW_INVALID\n if domain_obj.show_invalid_survey_responses_in_chat else\n HIDE_ALL),\n \"count_messages_as_read_by_anyone\":\n enabled_disabled(domain_obj.count_messages_as_read_by_anyone),\n \"use_custom_chat_template\":\n default_custom(domain_obj.custom_chat_template),\n \"custom_chat_template\":\n domain_obj.custom_chat_template,\n \"sms_case_registration_enabled\":\n enabled_disabled(domain_obj.sms_case_registration_enabled),\n \"sms_case_registration_type\":\n domain_obj.sms_case_registration_type,\n \"sms_case_registration_owner_id\":\n domain_obj.sms_case_registration_owner_id,\n \"sms_case_registration_user_id\":\n domain_obj.sms_case_registration_user_id,\n \"sms_mobile_worker_registration_enabled\":\n enabled_disabled(domain_obj.sms_mobile_worker_registration_enabled),\n \"registration_welcome_message\":\n self.get_welcome_message_recipient(domain_obj),\n }\n form = SettingsForm(initial=initial, cchq_domain=self.domain,\n cchq_is_previewer=self.previewer)\n return form", "metadata": "root.SMSSettingsView.form", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1755 }, { "content": " @property\n def page_context(self):\n return {\n \"form\": self.form,\n }", "metadata": "root.SMSSettingsView.page_context", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1820 }, { "content": " def post(self, request, *args, **kwargs):\n form = self.form\n if form.is_valid():\n domain_obj = Domain.get_by_name(self.domain, strict=True)\n field_map = [\n (\"use_default_sms_response\",\n \"use_default_sms_response\"),\n (\"default_sms_response\",\n \"default_sms_response\"),\n (\"custom_case_username\",\n \"custom_case_username\"),\n (\"send_to_duplicated_case_numbers\",\n \"send_to_duplicated_case_numbers\"),\n (\"sms_conversation_length\",\n \"sms_conversation_length\"),\n (\"count_messages_as_read_by_anyone\",\n \"count_messages_as_read_by_anyone\"),\n (\"chat_message_count_threshold\",\n \"custom_message_count_threshold\"),\n (\"restricted_sms_times\",\n \"restricted_sms_times_json\"),\n (\"sms_conversation_times\",\n \"sms_conversation_times_json\"),\n (\"sms_mobile_worker_registration_enabled\",\n \"sms_mobile_worker_registration_enabled\"),\n ]\n if self.previewer:\n field_map.append(\n (\"custom_chat_template\",\n \"custom_chat_template\")\n )\n for (model_field_name, form_field_name) in field_map:\n setattr(domain_obj, model_field_name,\n form.cleaned_data[form_field_name])\n\n survey_traffic_option = form.cleaned_data[\"survey_traffic_option\"]\n if survey_traffic_option == HIDE_ALL:\n domain_obj.filter_surveys_from_chat = True\n domain_obj.show_invalid_survey_responses_in_chat = False\n elif survey_traffic_option == SHOW_INVALID:\n domain_obj.filter_surveys_from_chat = True\n domain_obj.show_invalid_survey_responses_in_chat = True\n else:\n domain_obj.filter_surveys_from_chat = False\n domain_obj.show_invalid_survey_responses_in_chat = False\n\n if form.cleaned_data[\"sms_case_registration_enabled\"]:\n domain_obj.sms_case_registration_enabled = True\n domain_obj.sms_case_registration_type = form.cleaned_data[\n \"sms_case_registration_type\"]\n domain_obj.sms_case_registration_owner_id = form.cleaned_data[\n \"sms_case_registration_owner_id\"]\n domain_obj.sms_case_registration_user_id = form.cleaned_data[\n \"sms_case_registration_user_id\"]\n else:\n domain_obj.sms_case_registration_enabled = False\n\n domain_obj.enable_registration_welcome_sms_for_case = \\\n form.enable_registration_welcome_sms_for_case\n\n domain_obj.enable_registration_welcome_sms_for_mobile_worker = \\\n form.enable_registration_welcome_sms_for_mobile_worker\n\n domain_obj.save()\n messages.success(request, _(\"Changes Saved.\"))\n return self.get(request, *args, **kwargs)", "metadata": "root.SMSSettingsView.post", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1826 }, { "content": " @method_decorator(domain_admin_required)\n @method_decorator(requires_privilege_with_fallback(privileges.OUTBOUND_SMS))\n @use_bootstrap3\n @use_timepicker\n def dispatch(self, request, *args, **kwargs):\n return super(SMSSettingsView, self).dispatch(request, *args, **kwargs)", "metadata": "root.SMSSettingsView.dispatch", "header": "['class', 'SMSSettingsView', '(', 'BaseMessagingSectionView', ')', ':', '___EOS___']", "index": 1893 }, { "content": "class ManageRegistrationInvitationsView(BaseAdvancedMessagingSectionView, CRUDPaginatedViewMixin):\n template_name = 'sms/manage_registration_invitations.html'\n urlname = 'sms_manage_registration_invitations'\n page_title = ugettext_lazy('Manage Registration Invitations')\n\n limit_text = ugettext_noop(\"invitations per page\")\n empty_notification = ugettext_noop(\"No registration invitations sent yet.\")\n loading_message = ugettext_noop(\"Loading invitations...\")\n strict_domain_fetching = True\n\n\n\n\n\n\n\n\n", "metadata": "root.ManageRegistrationInvitationsView", "header": "['module', '___EOS___']", "index": 1901 }, { "content": " @property\n @memoized\n def invitations_form(self):\n if self.request.method == 'POST':\n return SendRegistrationInviationsForm(self.request.POST, domain=self.domain)\n else:\n return SendRegistrationInviationsForm(domain=self.domain)", "metadata": "root.ManageRegistrationInvitationsView.invitations_form", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1911 }, { "content": " @property\n @memoized\n def project_timezone(self):\n return get_timezone_for_user(None, self.domain)", "metadata": "root.ManageRegistrationInvitationsView.project_timezone", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1919 }, { "content": " @property\n def parameters(self):\n return self.request.POST if self.request.method == 'POST' else self.request.GET", "metadata": "root.ManageRegistrationInvitationsView.parameters", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1924 }, { "content": " @property\n def page_context(self):\n context = self.pagination_context\n context.update({\n 'form': self.invitations_form,\n 'sms_mobile_worker_registration_enabled':\n self.domain_object.sms_mobile_worker_registration_enabled,\n })\n return context", "metadata": "root.ManageRegistrationInvitationsView.page_context", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1928 }, { "content": " @property\n def total(self):\n return SelfRegistrationInvitation.objects.filter(domain=self.domain).count()", "metadata": "root.ManageRegistrationInvitationsView.total", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1938 }, { "content": " @property\n def column_names(self):\n return [\n _('Created On'),\n _('Phone Number'),\n _('Status'),\n _('Expiration Date'),\n _('Application'),\n _('Phone Type'),\n ]", "metadata": "root.ManageRegistrationInvitationsView.column_names", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1942 }, { "content": " def format_status(self, invitation):\n if invitation.status == SelfRegistrationInvitation.STATUS_REGISTERED:\n registered_date = (ServerTime(invitation.registered_date)\n .user_time(self.project_timezone)\n .done()\n .strftime(SERVER_DATETIME_FORMAT))\n return _(\"Registered on %(date)s\") % {'date': registered_date}\n else:\n return {\n SelfRegistrationInvitation.STATUS_PENDING: _(\"Pending\"),\n SelfRegistrationInvitation.STATUS_EXPIRED: _(\"Expired\"),\n }.get(invitation.status)", "metadata": "root.ManageRegistrationInvitationsView.format_status", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1953 }, { "content": " @property\n def paginated_list(self):\n invitations = SelfRegistrationInvitation.objects.filter(\n domain=self.domain\n ).order_by('-created_date')\n doc_info_cache = {}\n for invitation in invitations[self.skip:self.skip + self.limit]:\n if invitation.app_id in doc_info_cache:\n doc_info = doc_info_cache[invitation.app_id]\n else:\n doc_info = get_doc_info_by_id(self.domain, invitation.app_id)\n doc_info_cache[invitation.app_id] = doc_info\n yield {\n 'itemData': {\n 'id': invitation.pk,\n 'created_date': (ServerTime(invitation.created_date)\n .user_time(self.project_timezone)\n .done()\n .strftime(SERVER_DATETIME_FORMAT)),\n 'phone_number': '+%s' % invitation.phone_number,\n 'status': self.format_status(invitation),\n 'expiration_date': invitation.expiration_date.strftime(SERVER_DATE_FORMAT),\n 'app_name': doc_info.display,\n 'app_link': doc_info.link,\n 'phone_type': dict(SelfRegistrationInvitation.PHONE_TYPE_CHOICES).get(invitation.phone_type),\n },\n 'template': 'invitations-template',\n }", "metadata": "root.ManageRegistrationInvitationsView.paginated_list", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1966 }, { "content": " def post(self, *args, **kwargs):\n if self.request.POST.get('action') == 'invite':\n if not self.domain_object.sms_mobile_worker_registration_enabled:\n return self.get(*args, **kwargs)\n if self.invitations_form.is_valid():\n phone_numbers = self.invitations_form.cleaned_data.get('phone_numbers')\n app_id = self.invitations_form.cleaned_data.get('app_id')\n result = SelfRegistrationInvitation.initiate_workflow(\n self.domain,\n phone_numbers,\n app_id=app_id\n )\n success_numbers, invalid_format_numbers, numbers_in_use = result\n if success_numbers:\n messages.success(\n self.request,\n _(\"Invitations sent to: %(phone_numbers)s\") % {\n 'phone_numbers': ','.join(success_numbers),\n }\n )\n if invalid_format_numbers:\n messages.error(\n self.request,\n _(\"Invitations could not be sent to: %(phone_numbers)s. \"\n \"These number(s) are in an invalid format.\") % {\n 'phone_numbers': ','.join(invalid_format_numbers)\n }\n )\n if numbers_in_use:\n messages.error(\n self.request,\n _(\"Invitations could not be sent to: %(phone_numbers)s. \"\n \"These number(s) are already in use.\") % {\n 'phone_numbers': ','.join(numbers_in_use)\n }\n )\n return self.get(*args, **kwargs)\n else:\n if not self.domain_object.sms_mobile_worker_registration_enabled:\n raise Http404()\n return self.paginate_crud_response", "metadata": "root.ManageRegistrationInvitationsView.post", "header": "['class', 'ManageRegistrationInvitationsView', '(', 'BaseAdvancedMessagingSectionView', ',', 'CRUDPaginatedViewMixin', ')', ':', '___EOS___']", "index": 1995 }, { "content": "class InvitationAppInfoView(View, DomainViewMixin):\n urlname = 'sms_registration_invitation_app_info'\n\n\n\n", "metadata": "root.InvitationAppInfoView", "header": "['module', '___EOS___']", "index": 2038 }, { "content": " @property\n @memoized\n def token(self):\n token = self.kwargs.get('token')\n if not token:\n raise Http404()\n return token", "metadata": "root.InvitationAppInfoView.token", "header": "['class', 'InvitationAppInfoView', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 2041 }, { "content": " @property\n @memoized\n def invitation(self):\n invitation = SelfRegistrationInvitation.by_token(self.token)\n if not invitation:\n raise Http404()\n return invitation", "metadata": "root.InvitationAppInfoView.invitation", "header": "['class', 'InvitationAppInfoView', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 2049 }, { "content": " def get(self, *args, **kwargs):\n if not self.invitation.odk_url:\n raise Http404()\n url = str(self.invitation.odk_url).strip()\n response = 'ccapp: %s signature: %s' % (url, sign(url))\n response = base64.b64encode(response)\n return HttpResponse(response)", "metadata": "root.InvitationAppInfoView.get", "header": "['class', 'InvitationAppInfoView', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 2057 }, { "content": " def post(self, *args, **kwargs):\n return self.get(*args, **kwargs)", "metadata": "root.InvitationAppInfoView.post", "header": "['class', 'InvitationAppInfoView', '(', 'View', ',', 'DomainViewMixin', ')', ':', '___EOS___']", "index": 2065 }, { "content": "class IncomingBackendView(View):", "metadata": "root.IncomingBackendView", "header": "['module', '___EOS___']", "index": 2069 }, { "content": " def dispatch(self, request, api_key, *args, **kwargs):\n try:\n api_user = ApiUser.get('ApiUser-%s' % api_key)\n except ResourceNotFound:\n return HttpResponse(status=401)\n\n if api_user.doc_type != 'ApiUser' or not api_user.has_permission(PERMISSION_POST_SMS):\n return HttpResponse(status=401)\n\n return super(IncomingBackendView, self).dispatch(request, api_key, *args, **kwargs)", "metadata": "root.IncomingBackendView.dispatch", "header": "['class', 'IncomingBackendView', '(', 'View', ')', ':', '___EOS___']", "index": 2070 }, { "content": "class NewIncomingBackendView(View):\n domain = None\n backend_couch_id = None\n\n", "metadata": "root.NewIncomingBackendView", "header": "['module', '___EOS___']", "index": 2082 }, { "content": " @property\n def backend_class(self):\n \"\"\"\n Should return the model class of the backend (a subclass of SQLMobileBackend).\n \"\"\"\n raise NotImplementedError(\"Please implement this method\")", "metadata": "root.NewIncomingBackendView.backend_class", "header": "['class', 'NewIncomingBackendView', '(', 'View', ')', ':', '___EOS___']", "index": 2086 }, { "content": " @method_decorator(csrf_exempt)\n def dispatch(self, request, api_key, *args, **kwargs):\n try:\n self.domain, self.backend_couch_id = SQLMobileBackend.get_backend_info_by_api_key(\n self.backend_class.get_api_id(),\n api_key\n )\n except SQLMobileBackend.DoesNotExist:\n return HttpResponse(status=401)\n\n return super(NewIncomingBackendView, self).dispatch(request, api_key, *args, **kwargs)", "metadata": "root.NewIncomingBackendView.dispatch", "header": "['class', 'NewIncomingBackendView', '(', 'View', ')', ':', '___EOS___']", "index": 2093 } ]
[ { "span": "import logging", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 14 }, { "span": "import pytz", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 11 }, { "span": "from django.contrib.auth import authenticate", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 44 }, { "span": "from corehq.apps.reminders.util import can_use_survey_reminders", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 63 }, { "span": "from corehq.apps.style.decorators import (\n use_bootstrap3,\n use_timepicker,\n use_typeahead,\n use_select2,\n use_jquery_ui,\n upgrade_knockout_js,\n use_datatables,\n)", "start_line": 36, "start_column": 0, "end_line": 44, "end_column": 1 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "vim", ":", " ", "ai", " ", "ts", "=", "4", " ", "sts", "=", "4", " ", "et", " ", "sw", "=", "4", " ", "encoding", "=", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "datetime_", ",_", "timedelta_", ",_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couchdb", "kit_", "import_", "Reso", "urc", "e", "Not", "Found_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pytz_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "import_", "authenticate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "transaction_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http", "Response_", ",_", "Http", "Respons", "e", "Redirect_", ",_", "Http", "Respons", "e", "Ba", "d", "Request_", ",_", "Http404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "shortcuts_", "import_", "render_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "decorators_", "import_", "method", "\\u", "decorator_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "case", "xml_", "._", "apps_", "._", "case_", "._", "models_", "import_", "Comm", "Care", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "import_", "privilege", "s_", ",_", "toggle", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "hq", "admin_", "._", "views_", "import_", "Base", "Admi", "n", "Sect", "ion", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "hq", "webapp_", "._", "doc", "\\u", "info_", "import_", "get", "\\u", "doc", "\\u", "info", "\\u", "by", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "hq", "webapp_", "._", "utils_", "import_", "get", "\\u", "bul", "k", "\\u", "upload", "\\u", "form_", ",_", "sign_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "reminder", "s_", "._", "util_", "import_", "can", "\\u", "use", "\\u", "survey", "\\u", "reminder", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "accounti", "ng_", "._", "decorators_", "import_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", ",_", "require", "s", "\\u", "privilege", "\\u", "plain", "text", "\\u", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "api_", "._", "models_", "import_", "require", "\\u", "api", "\\u", "user", "\\u", "permission_", ",_", "PERMISSION", "\\u", "POST", "\\u", "SMS", "_", ",_", "Ap", "i", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "comm", "track_", "._", "models_", "import_", "Alert", "Config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "api_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "send", "\\u", "sms_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "incoming_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "send", "\\u", "sms", "\\u", "with", "\\u", "back", "end", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "send", "\\u", "sms", "\\u", "to", "\\u", "verifie", "d\\u", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Doma", "in", "Sco", "pe", "Validat", "ion", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Messag", "e", "Metadata_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "domain_", "._", "views_", "import_", "Base", "Doma", "in", "View_", ",_", "Doma", "in", "View", "Mixin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "hq", "webapp_", "._", "views_", "import_", "CRUD", "Pagina", "ted", "View", "Mixin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "dba", "ccess", "ors_", "import_", "get", "\\u", "forward", "ing", "\\u", "rule", "s", "\\u", "for", "\\u", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "style_", "._", "decorators_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "boots", "trap", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "timep", "ick", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "type", "ahe", "ad_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "select", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "jq", "uer", "y", "\\u", "ui_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "upgrade", "\\u", "kno", "cko", "ut", "\\u", "js_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "datata", "bles_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "users_", "._", "decorators_", "import_", "require", "\\u", "permission_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "users_", "._", "models_", "import_", "Cou", "ch", "User_", ",_", "Permissions_", ",_", "Comm", "Care", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "users_", "import_", "models_", "as_", "user", "\\u", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "users_", "._", "views_", "._", "mobile_", "._", "users_", "import_", "Edit", "Comm", "Care", "User", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "models_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SMS", "_", ",_", "INCOM", "ING_", ",_", "OUT", "GO", "ING_", ",_", "Forward", "ing", "Rule_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Messag", "ing", "Event_", ",_", "Self", "Registration", "Invitation", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Mob", "ile", "Backend_", ",_", "SQL", "Mob", "ile", "Back", "end", "Mapping_", ",_", "Phone", "Load", "Bal", "anci", "ng", "Mixin_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Las", "t", "Read", "Message_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "mixin_", "import_", "Verifie", "d", "Number_", ",_", "Ba", "d", "SMS", "Config", "Exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "forms_", "import_", "(_", "Forward", "ing", "Rule", "Form_", ",_", "Back", "end", "Map", "Form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Initiat", "e", "Add", "SMS", "Back", "end", "Form_", ",_", "Subscrib", "e", "SMS", "Form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Sett", "ings", "Form_", ",_", "SHOW", "\\u", "ALL_", ",_", "SHOW", "\\u", "INVALID", "_", ",_", "HID", "E", "\\u", "ALL_", ",_", "ENABLED_", ",_", "DISABLED_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DEFAULT_", ",_", "CUSTOM", "_", ",_", "Sen", "d", "Registration", "Inv", "iation", "s", "Form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "NONE_", ",_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "CASE", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "MOB", "ILE", "\\u", "WORKER", "_", ",_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "ALL_", ",_", "Compose", "Messag", "e", "Form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "util_", "import_", "get", "\\u", "contact_", ",_", "get", "\\u", "sms", "\\u", "back", "end", "\\u", "classes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms_", "._", "messages_", "import_", "\\u", "MESSAGES_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "sms", "bill", "ables_", "._", "utils_", "import_", "countr", "y", "\\u", "name", "\\u", "from", "\\u", "isd", "\\u", "code", "\\u", "or", "\\u", "empty_", "as_", "countr", "y", "\\u", "name", "\\u", "from", "\\u", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "groups_", "._", "models_", "import_", "Group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "domain_", "._", "decorators_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "login", "\\u", "and", "\\u", "domain", "\\u", "required_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "login", "\\u", "or", "\\u", "digest", "\\u", "ex_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "admin", "\\u", "required_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "require", "\\u", "superuser_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "messaging_", "._", "sms", "backends_", "._", "tele", "rive", "t_", "._", "models_", "import_", "SQL", "Tele", "rive", "t", "Backend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "translations_", "._", "models_", "import_", "Stand", "alo", "ne", "Translat", "ion", "Doc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "util_", "._", "dates_", "import_", "iso", "\\u", "string", "\\u", "to", "\\u", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "util_", "._", "spreadsheet", "s_", "._", "excel_", "import_", "Workbook", "JSONR", "eader", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "util_", "._", "timezones", "_", "._", "conversions", "_", "import_", "Server", "Time_", ",_", "User", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "util_", "._", "quick", "cache_", "import_", "quick", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "import_", "messages_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "util_", "._", "soft", "\\u", "assert_", "import_", "soft", "\\u", "assert_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "util_", "._", "timezones", "_", "._", "utils_", "import_", "get", "\\u", "timezon", "e\\u", "for", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "views_", "._", "decorators_", "._", "csrf_", "import_", "csr", "f", "\\u", "exempt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "views_", "._", "generic_", "import_", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "domain_", "._", "models_", "import_", "Domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "const_", "import_", "SERVER", "\\u", "DATETIME", "\\u", "FORMAT_", ",_", "SERVER", "\\u", "DAT", "E", "\\u", "FORMAT_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "translation_", "import_", "ugettext_", "as_", "\\u_", ",_", "uge", "ttext", "\\u", "noop_", ",_", "uge", "ttext", "\\u", "lazy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "parsing_", "import_", "json", "\\u", "format\\u", "datetime_", ",_", "string", "\\u", "to", "\\u", "boolean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "decorators_", "._", "memoized", "_", "import_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "decorators_", "._", "view_", "import_", "get", "\\u", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "logging_", "import_", "notif", "y", "\\u", "exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "web_", "import_", "json", "\\u", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "couch", "_", "import_", "Crit", "ical", "Section_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "couch", "_", "._", "database_", "import_", "iter", "\\u", "docs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dim", "agi", "_", "._", "utils_", "._", "couch", "_", "._", "cache_", "import_", "cache", "\\u", "core_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couchdb", "kit_", "._", "resource_", "import_", "Reso", "urc", "e", "Not", "Found_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couch", "export_", "._", "models_", "import_", "Format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couch", "export_", "._", "export_", "import_", "export", "\\u", "raw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couch", "export_", "._", "shortcuts_", "import_", "export", "\\u", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tup", "le", " ", "of", " ", "(", "description", ",", " ", "day", "s", " ", "in", " ", "the", " ", "past", ")_", "\\u\\u\\uNL\\u\\u\\u_", "SMS", "\\u", "CHAT", "\\u", "HISTORY", "\\u", "CHOICES_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "Ye", "ster", "day", "\"_", ")_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "1", " ", "Week", "\"_", ")_", ",_", "7_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "30", " ", "Day", "s", "\"_", ")_", ",_", "30_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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\\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L\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "login", "\\u", "and", "\\u", "domain", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "default_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Compose", "Messag", "e", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "domain_", "]_", ")_", ")_", "\\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_", "Base", "Messag", "ing", "Sect", "ion", "View_", "(_", "Base", "Doma", "in", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "section", "\\u", "name_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "Messag", "ing", "\"_", ")_", "\\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", "Messag", "ing", "Sect", "ion", "View_", "(_", "Base", "Doma", "in", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Messag", "ing", "Sect", "ion", "View_", "(_", "Base", "Doma", "in", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "section", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "\"", "sms", "\\u", "default", "\"_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", "\\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", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Ju", "st", " ", "like", " ", "Base", "Messag", "ing", "Sect", "ion", "View", ",", " ", "only", " ", "require", "s", " ", "access", " ", "to", " ", "inbound", " ", "SMS", "\\", "10", ";", " ", " ", " ", " ", "as", " ", "well", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "IN", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Compose", "Messag", "e", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "name_", "=_", "'", "sms", "/", "compose", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "name_", "=_", "'", "sms", "\\u", "compose", "\\u", "message", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "\\u_", "(_", "'", "Compose", " ", "SMS", " ", "Messag", "e", "'_", ")_", "\\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_", "Compose", "Messag", "e", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "page", "\\u", "context_", "=_", "super_", "(_", "Compose", "Messag", "e", "View_", ",_", "self_", ")_", "._", "page", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tz_", "=_", "get", "\\u", "timezon", "e\\u", "for", "\\u", "user_", "(_", "self_", "._", "request_", "._", "couch", "\\u", "user_", ",_", "self_", "._", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "context_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "now", "'_", ":_", "datetime_", "._", "utcnow_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timezon", "e", "'_", ":_", "tz_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timezon", "e\\u", "now", "'_", ":_", "datetime_", "._", "now_", "(_", "tz_", "=_", "tz_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "Compose", "Messag", "e", "Form_", "(_", "domain_", "=_", "self_", "._", "domain_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "context_", "._", "update_", "(_", "get", "\\u", "sms", "\\u", "autocomplete", "\\u", "context_", "(_", "self_", "._", "request_", ",_", "self_", "._", "domain_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "page", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compose", "Messag", "e", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "permission_", "(_", "Permissions_", "._", "edit", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "type", "ahe", "ad_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "csr", "f", "\\u", "exempt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "post_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "I", " ", "don", "'", "t", " ", "know", " ", "of", " ", "any", "where", " ", "this", " ", "is", " ", "bei", "ng", " ", "invoke", "d", " ", "from", ".", " ", "If", " ", "the", " ", "soft", " ", "asserts", "\\", "10", ";", " ", " ", " ", " ", "don", "'", "t", " ", "produce", " ", "any", " ", "results", " ", "then", " ", "I", "'", "ll", " ", "remove", " ", "it", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "assert_", "=_", "soft", "\\u", "assert_", "(_", "'@'_", "._", "join_", "(_", "[_", "'", "gca", "pal", "bo", "'_", ",_", "'", "dim", "agi", ".", "com", "'_", "]_", ")_", ",_", "exponential", "\\u", "backoff_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "assert_", "(_", "False_", ",_", "\"", "sms", " ", "post", " ", "invoke", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "'", "OK", "'_", ")_", "\\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_", "@_", "require", "\\u", "api", "\\u", "user", "\\u", "permission_", "(_", "PERMISSION", "\\u", "POST", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "sms", "\\u", "in_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Comm", "Care", "HQ", "'", "s", " ", "gener", "ic", " ", "inbound", " ", "sms", " ", "post", " ", "api", ",", " ", "requi", "ring", " ", "an", " ", "Ap", "i", "User", " ", "with", " ", "permissi", "on", " ", "to", " ", "post", " ", "sms", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "request", " ", "must", " ", "be", " ", "a", " ", "post", ",", " ", "and", " ", "must", " ", "have", " ", "the", " ", "follow", "ing", " ", "post", " ", "parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "user", "name", " ", "-", " ", "Ap", "i", "User", " ", "user", "name", "\\", "10", ";", " ", " ", " ", " ", "password", " ", "-", " ", "Ap", "i", "User", " ", "password", "\\", "10", ";", " ", " ", " ", " ", "phone", "\\u", "number", " ", "-", " ", "phone", " ", "number", " ", "message", " ", "was", " ", "sent", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "message", " ", "-", " ", "text", " ", "of", " ", "message", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "back", "end", "\\u", "api_", "=_", "\"", "HQ", "\\u", "HTTP", "\\u", "IN", "BOUND", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone", "\\u", "number_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "phone", "\\u", "number", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "message", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "phone", "\\u", "number_", "is_", "None_", "or_", "message_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "\"", "Ple", "ase", " ", "speci", "fy", " ", "'", "phone", "\\u", "number", "'", " ", "and", " ", "'", "message", "'", " ", "parameter", "s", ".\"_", ",_", "status_", "=_", "400_", ")_", "\\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 ", " _", "incoming_", "(_", "phone", "\\u", "number_", ",_", "message_", ",_", "back", "end", "\\u", "api_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "\"", "OK", "\"_", ")_", "\\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", "sms", "\\u", "autocomplete", "\\u", "context_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "help", "er", " ", "view", " ", "for", " ", "sms", " ", "autocomplete", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone", "\\u", "users_", "=_", "Cou", "ch", "User_", "._", "view_", "(_", "\"", "users", "/", "phone", "\\u", "users", "\\u", "by", "\\u", "domain", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "key_", "=_", "[_", "domain_", "]_", ",_", "end", "key_", "=_", "[_", "domain_", ",_", "{_", "}_", "]_", ",_", "include", "\\u", "docs_", "=_", "True_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "groups_", "=_", "Group_", "._", "by", "\\u", "domain_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "contacts_", "=_", "[_", "\"[", "send", " ", "to", " ", "all", "]\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contacts_", "._", "extend_", "(_", "[_", "'%", "s", " ", "[", "group", "]'_", "%_", "group_", "._", "name_", "for_", "group_", "in_", "groups_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "phone", "\\u", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "user_", "._", "\\u", "id_", "==_", "user", "\\u", "id_", ":_", "\\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_", "contacts_", "._", "append_", "(_", "user_", "._", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "id_", "=_", "user_", "._", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "{_", "\"", "sms", "\\u", "contact", "s", "\"_", ":_", "contacts_", "}_", "\\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_", "@_", "login", "\\u", "and", "\\u", "domain", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "send", "\\u", "to", "\\u", "recipients_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "recipients_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "recip", "ients", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "message", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "recipients_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "You", " ", "did", "n", "'", "t", " ", "speci", "fy", " ", "any", " ", "recip", "ients", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "message_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "You", " ", "can", "'", "t", " ", "send", " ", "an", " ", "empty", " ", "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 ", " _", "recipients_", "=_", "[_", "x_", "._", "strip_", "(_", ")_", "for_", "x_", "in_", "recipients_", "._", "split_", "(_", "','_", ")_", "if_", "x_", "._", "strip_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone", "\\u", "numbers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "formats", ":", " ", "Group", "Name", " ", "(", "group", "),", " ", "\"", "User", "name", "\",", " ", "+", "155", "555555", "55_", "\\u\\u\\uNL\\u\\u\\u_", "group", "\\u", "names_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "usernames", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone", "\\u", "numbers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "unknown", "\\u", "usernames", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "GROUP_", "=_", "\"[", "group", "]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "to", "\\u", "all", "\\u", "checked_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "recipient_", "in_", "recipients_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "recipient_", "==_", "\"[", "send", " ", "to", " ", "all", "]\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "send", "\\u", "to", "\\u", "all", "\\u", "checked_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone", "\\u", "users_", "=_", "Cou", "ch", "User_", "._", "view_", "(_", "\"", "users", "/", "phone", "\\u", "users", "\\u", "by", "\\u", "domain", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "key_", "=_", "[_", "domain_", "]_", ",_", "end", "key_", "=_", "[_", "domain_", ",_", "{_", "}_", "]_", ",_", "include", "\\u", "docs_", "=_", "True_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "phone", "\\u", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "usernames", "_", "._", "append_", "(_", "user_", "._", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "group", "\\u", "names_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "not_", "send", "\\u", "to", "\\u", "all", "\\u", "checked_", ")_", "and_", "recipient_", "._", "endswith_", "(_", "GROUP_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "recipient_", "[_", ":_", "-_", "len_", "(_", "GROUP_", ")_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "group", "\\u", "names_", "._", "append_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "re_", "._", "match_", "(_", "r", "'", "^", "\\\\+", "\\\\", "d", "+$", "'_", ",_", "recipient_", ")_", ":_", "#", " ", "here", " ", "we", " ", "expect", " ", "it", " ", "to", " ", "have", " ", "a", " ", "plus", " ", "sign_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "wrap", "\\u", "user", "\\u", "by", "\\u", "type_", "(_", "u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "getattr_", "(_", "user", "\\u", "models_", ",_", "u_", "[_", "'", "doc", "'_", "]_", "[_", "'", "doc", "\\u", "type", "'_", "]_", ")_", "._", "wrap_", "(_", "u_", "[_", "'", "doc", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "phone", "\\u", "users_", "=_", "Cou", "ch", "User_", "._", "view_", "(_", "\"", "users", "/", "by", "\\u", "default", "\\u", "phone", "\"_", ",_", "#", " ", "search", " ", "bot", "h", " ", "with", " ", "and", " ", "w", "/", "o", " ", "the", " ", "plus_", "\\u\\u\\uNL\\u\\u\\u_", "keys_", "=_", "[_", "recipient_", ",_", "recipient_", "[_", "1_", ":_", "]_", "]_", ",_", "include", "\\u", "docs_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "wrapper_", "=_", "wrap", "\\u", "user", "\\u", "by", "\\u", "type_", ")_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "phone", "\\u", "users_", "=_", "filter_", "(_", "lambda_", "u_", ":_", "u_", "._", "is", "\\u", "member", "\\u", "of_", "(_", "domain_", ")_", ",_", "phone", "\\u", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "phone", "\\u", "users_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "phone", "\\u", "numbers_", "._", "append_", "(_", "(_", "phone", "\\u", "users_", "[_", "0_", "]_", ",_", "recipient_", ")_", ")_", "\\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 ", " ", "_", "phone", "\\u", "numbers_", "._", "append_", "(_", "(_", "None_", ",_", "recipient_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "not_", "send", "\\u", "to", "\\u", "all", "\\u", "checked_", ")_", "and_", "re_", "._", "match_", "(_", "r", "'[", "\\\\", "w", "\\\\.]", "+'_", ",_", "recipient_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "usernames", "_", "._", "append_", "(_", "recipient_", ")_", "\\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 ", " _", "unknown", "\\u", "usernames", "_", "._", "append_", "(_", "recipient_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "login", "\\u", "ids_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "r_", "[_", "'", "key", "'_", "]_", ":_", "r_", "[_", "'", "id", "'_", "]_", "for_", "r_", "in_", "Comm", "Care", "User_", "._", "get", "\\u", "db_", "(_", ")_", "._", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "users", "/", "by", "\\u", "user", "name", "\"_", ",_", "keys_", "=_", "usernames", "_", ",_", "reduce_", "=_", "False_", ")_", "._", "all_", "(_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "username_", "in_", "usernames", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "username_", "not_", "in_", "login", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unknown", "\\u", "usernames", "_", "._", "append_", "(_", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "login", "\\u", "ids_", "=_", "login", "\\u", "ids_", "._", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "empty", "\\u", "groups_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "group", "\\u", "names_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users_", "._", "extend_", "(_", "Cou", "ch", "User_", "._", "view_", "(_", "'", "users", "/", "by", "\\u", "group", "'_", ",_", "keys_", "=_", "[_", "[_", "domain_", ",_", "gn_", "]_", "for_", "gn_", "in_", "group", "\\u", "names_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "include", "\\u", "docs_", "=_", "True_", ")_", "._", "all_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "users_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "empty", "\\u", "groups_", "=_", "group", "\\u", "names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "users_", "._", "extend_", "(_", "Cou", "ch", "User_", "._", "view_", "(_", "'\\u", "all", "\\u", "docs", "'_", ",_", "keys_", "=_", "login", "\\u", "ids_", ",_", "include", "\\u", "docs_", "=_", "True_", ")_", "._", "all_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "=_", "[_", "user_", "for_", "user_", "in_", "users_", "if_", "user_", "._", "is", "\\u", "active_", "and_", "not_", "user_", "._", "is", "\\u", "deleted_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "phone", "\\u", "numbers_", "._", "extend_", "(_", "[_", "(_", "user_", ",_", "user_", "._", "phone", "\\u", "number_", ")_", "for_", "user_", "in_", "users_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fail", "ed", "\\u", "numbers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "no", "\\u", "numbers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sent_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "phone", "\\u", "numbers_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "recipient_", "=_", "phone", "\\u", "numbers_", "[_", "0_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "recipient_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logged", "\\u", "event_", "=_", "Messag", "ing", "Event_", "._", "create", "\\u", "event", "\\u", "for", "\\u", "adh", "oc", "\\u", "sms_", "(_", "domain_", ",_", "recipient_", "=_", "recipient_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "user_", ",_", "number_", "in_", "phone", "\\u", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "number_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "no", "\\u", "numbers_", "._", "append_", "(_", "user_", "._", "raw", "\\u", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "[_", "user_", "._", "doc", "\\u", "type_", ",_", "user_", "._", "get", "\\u", "id_", "]_", "if_", "user_", "else_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "sube", "vent_", "=_", "logged", "\\u", "event_", "._", "create", "\\u", "sube", "vent", "\\u", "for", "\\u", "single", "\\u", "sms_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "send", "\\u", "sms_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", ",_", "user_", ",_", "number_", ",_", "message_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metadata_", "=_", "Messag", "e", "Metadata_", "(_", "mess", "agin", "g", "\\u", "sube", "vent", "\\u", "id_", "=_", "logged", "\\u", "sube", "vent_", "._", "pk_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sent_", "._", "append_", "(_", "\"%", "s", "\"_", "%_", "(_", "user_", "._", "raw", "\\u", "username_", "if_", "user_", "else_", "number_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "sube", "vent_", "._", "completed_", "(_", ")_", "\\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 ", " ", "_", "fail", "ed", "\\u", "numbers_", "._", "append_", "(_", "\"%", "s", " ", "(%", "s", ")\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "._", "raw", "\\u", "username_", "if_", "user_", "else_", "\"<", "no", " ", "user", "name", ">\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "sube", "vent_", "._", "error_", "(_", "Messag", "ing", "Event_", "._", "ERROR", "\\u", "INTERN", "AL", "\\u", "SERVER", "\\u", "ERROR_", ")_", "\\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_", "logged", "\\u", "event_", "._", "completed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "comma", "\\u", "reminder", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Ple", "ase", " ", "remember", " ", "to", " ", "separate", " ", "recip", "ients", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", " ", "with", " ", "a", " ", "comma", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "empty", "\\u", "groups_", "or_", "fail", "ed", "\\u", "numbers_", "or_", "unknown", "\\u", "usernames", "_", "or_", "no", "\\u", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "empty", "\\u", "groups_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "The", " ", "follow", "ing", " ", "group", "s", " ", "don", "'", "t", " ", "exist", ":", " ", "\"_", ")_", "+_", "(_", "',", " ", "'_", "._", "join_", "(_", "empty", "\\u", "groups_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comma", "\\u", "reminder", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "no", "\\u", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "The", " ", "follow", "ing", " ", "users", " ", "don", "'", "t", " ", "have", " ", "phone", " ", "numbers", ":", " ", "\"_", ")_", "+_", "(_", "',", " ", "'_", "._", "join_", "(_", "no", "\\u", "numbers_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fail", "ed", "\\u", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "send", " ", "to", " ", "the", " ", "follow", "ing", " ", "number", "(", "s", "):", " ", "\"_", ")_", "+_", "(_", "',", " ", "'_", "._", "join_", "(_", "fail", "ed", "\\u", "numbers_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "unknown", "\\u", "usernames", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "find", " ", "the", " ", "follow", "ing", " ", "user", "(", "s", "):", " ", "\"_", ")_", "+_", "(_", "',", " ", "'_", "._", "join_", "(_", "unknown", "\\u", "usernames", "_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comma", "\\u", "reminder", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "success_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Success", "full", "y", " ", "sent", ":", " ", "\"_", ")_", "+_", "(_", "',", " ", "'_", "._", "join_", "(_", "sent_", ")_", ")_", ")_", "\\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 ", " _", "messages_", "._", "info_", "(_", "request_", ",_", "\\u_", "(_", "\"", "No", " ", "message", "s", " ", "wer", "e", " ", "sent", ".\"_", ")_", ")_", "\\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 ", " _", "messages_", "._", "success_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Messag", "e", " ", "sent", "\"_", ")_", ")_", "\\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_", "Http", "Respons", "e", "Redirect_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "META_", "._", "get_", "(_", "'", "HTTP", "\\u", "REFE", "RER", "'_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "reverse_", "(_", "Compose", "Messag", "e", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "domain_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "domain", "\\u", "admin", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "IN", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "message", "\\u", "test_", "(_", "request_", ",_", "domain_", ",_", "phone", "\\u", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "message", "\"_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "scope_", "=_", "None_", "if_", "request_", "._", "couch", "\\u", "user_", "._", "is", "\\u", "superuser_", "else_", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "incoming_", "(_", "phone", "\\u", "number_", ",_", "message_", ",_", "\"", "TEST", "\"_", ",_", "domain", "\\u", "scope_", "=_", "domain", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Doma", "in", "Sco", "pe", "Validat", "ion", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Inva", "lid", " ", "phone", " ", "number", " ", "bei", "ng", " ", "simulat", "ed", ".", " ", "You", " ", "may", " ", "only", " ", "\"_", "\"", "simulat", "e", " ", "SMS", " ", "from", " ", "verifie", "d", " ", "numbers", " ", "belonging", " ", "to", " ", "contact", "s", " ", "\"_", "\"", "in", " ", "this", " ", "domain", ".\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\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 ", " _", "notif", "y", "\\u", "exception_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "An", " ", "error", " ", "has", " ", "occur", "red", ".", " ", "Ple", "ase", " ", "try", " ", "again", " ", "in", " ", "a", " ", "few", " ", "minute", "s", " ", "\"_", "\"", "and", " ", "if", " ", "the", " ", "issue", " ", "persist", "s", ",", " ", "plea", "se", " ", "contact", " ", "Comm", "Care", "HQ", " ", "\"_", "\"", "Supp", "ort", ".\"_", ")_", "\\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_", "context_", "=_", "get", "\\u", "sms", "\\u", "autocomplete", "\\u", "context_", "(_", "request_", ",_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "[_", "'", "domain", "'_", "]_", "=_", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "[_", "'", "layout", "\\u", "flush", "\\u", "content", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "[_", "'", "phone", "\\u", "number", "'_", "]_", "=_", "phone", "\\u", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render_", "(_", "request_", ",_", "\"", "sms", "/", "message", "\\u", "teste", "r", ".", "html", "\"_", ",_", "context_", ")_", "\\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_", "@_", "csr", "f", "\\u", "exempt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "login", "\\u", "or", "\\u", "digest", "\\u", "ex_", "(_", "allow", "\\u", "cc", "\\u", "users_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "plain", "text", "\\u", "response_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "api", "\\u", "send", "\\u", "sms_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "API", " ", "to", " ", "send", " ", "SMS", ".", "\\", "10", ";", " ", " ", " ", " ", "Expect", "ed", " ", "post", " ", "parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "phone", "\\u", "number", " ", "-", " ", "the", " ", "phone", " ", "number", " ", "to", " ", "send", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "contact", "\\u", "id", " ", "-", " ", "the", " ", "\\u", "id", " ", "of", " ", "a", " ", "contact", " ", "to", " ", "send", " ", "to", " ", "(", "override", "s", " ", "phone", "\\u", "number", ")", "\\", "10", ";", " ", " ", " ", " ", "vn", "\\u", "id", " ", "-", " ", "the", " ", "\\u", "id", " ", "of", " ", "a", " ", "Verifie", "d", "Number", " ", "to", " ", "send", " ", "to", " ", "(", "override", "s", " ", "contact", "\\u", "id", ")", "\\", "10", ";", " ", " ", " ", " ", "text", " ", "-", " ", "the", " ", "text", " ", "of", " ", "the", " ", "message", "\\", "10", ";", " ", " ", " ", " ", "back", "end", "\\u", "id", " ", "-", " ", "the", " ", "name", " ", "of", " ", "the", " ", "Mob", "ile", "Back", "end", " ", "to", " ", "use", " ", "whi", "le", " ", "sendin", "g", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "phone", "\\u", "number_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "phone", "\\u", "number", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contact", "\\u", "id_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "contact", "\\u", "id", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vn", "\\u", "id_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "vn", "\\u", "id", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "text", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "back", "end", "\\u", "id", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chat_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "chat", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contact_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "phone", "\\u", "number_", "is_", "None_", "and_", "contact", "\\u", "id_", "is_", "None_", "and_", "not_", "vn", "\\u", "id_", ")_", "or_", "(_", "text_", "is_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Ba", "d", "Request_", "(_", "\"", "Not", " ", "eno", "ugh", " ", "argu", "ment", "s", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vn_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "vn", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vn_", "=_", "Verifie", "d", "Number_", "._", "get_", "(_", "vn", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Reso", "urc", "e", "Not", "Found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Ba", "d", "Request_", "(_", "\"", "Verifie", "d", "Number", " ", "not", " ", "found", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "vn_", "._", "domain_", "!=_", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Ba", "d", "Request_", "(_", "\"", "Verifie", "d", "Number", " ", "not", " ", "found", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "phone", "\\u", "number_", "=_", "vn_", "._", "phone", "\\u", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contact_", "=_", "vn_", "._", "owner_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "contact", "\\u", "id_", "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 ", " _", "contact_", "=_", "get", "\\u", "contact_", "(_", "contact", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "contact_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "contact_", "._", "domain_", "==_", "domain_", "\\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 ", " _", "return_", "Http", "Respons", "e", "Ba", "d", "Request_", "(_", "\"", "Conta", "ct", " ", "not", " ", "found", ".\"_", ")_", "\\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 ", " _", "vn_", "=_", "contact_", "._", "get", "\\u", "verifie", "d\\u", "number_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "vn_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone", "\\u", "number_", "=_", "vn_", "._", "phone", "\\u", "number_", "\\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 ", " _", "return_", "Http", "Respons", "e", "Ba", "d", "Request_", "(_", "\"", "Conta", "ct", " ", "has", " ", "no", " ", "phone", " ", "number", ".\"_", ")_", "\\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 ", " _", "chat", "\\u", "workflow_", "=_", "string", "\\u", "to", "\\u", "boolean_", "(_", "chat_", ")_", "\\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 ", " _", "chat", "\\u", "workflow_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "chat", "\\u", "workflow_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chat", "\\u", "user", "\\u", "id_", "=_", "request_", "._", "couch", "\\u", "user_", "._", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chat", "\\u", "user", "\\u", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logged", "\\u", "event_", "=_", "Messag", "ing", "Event_", "._", "create", "\\u", "event", "\\u", "for", "\\u", "adh", "oc", "\\u", "sms_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", ",_", "recipient_", "=_", "contact_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "(_", "Messag", "ing", "Event_", "._", "CONTE", "NT", "\\u", "CHAT", "\\u", "SMS", "_", "if_", "chat", "\\u", "workflow_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "Messag", "ing", "Event_", "._", "CONTE", "NT", "\\u", "API", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "contact_", "._", "doc", "\\u", "type_", ",_", "contact_", "._", "get", "\\u", "id_", "]_", "if_", "contact_", "else_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "sube", "vent_", "=_", "logged", "\\u", "event_", "._", "create", "\\u", "sube", "vent", "\\u", "for", "\\u", "single", "\\u", "sms_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "metadata_", "=_", "Messag", "e", "Metadata_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "chat", "\\u", "user", "\\u", "id_", "=_", "chat", "\\u", "user", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mess", "agin", "g", "\\u", "sube", "vent", "\\u", "id_", "=_", "logged", "\\u", "sube", "vent_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "back", "end", "\\u", "id_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "success_", "=_", "send", "\\u", "sms", "\\u", "with", "\\u", "back", "end", "\\u", "name_", "(_", "domain_", ",_", "phone", "\\u", "number_", ",_", "text_", ",_", "back", "end", "\\u", "id_", ",_", "metadata_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "vn_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "success_", "=_", "send", "\\u", "sms", "\\u", "to", "\\u", "verifie", "d\\u", "number_", "(_", "vn_", ",_", "text_", ",_", "metadata_", ")_", "\\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 ", " _", "success_", "=_", "send", "\\u", "sms_", "(_", "domain_", ",_", "None_", ",_", "phone", "\\u", "number_", ",_", "text_", ",_", "metadata_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logged", "\\u", "sube", "vent_", "._", "completed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "event_", "._", "completed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "\"", "OK", "\"_", ")_", "\\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 ", " _", "logged", "\\u", "sube", "vent_", "._", "error_", "(_", "Messag", "ing", "Event_", "._", "ERROR", "\\u", "INTERN", "AL", "\\u", "SERVER", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "\"", "ERROR", "\"_", ")_", "\\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_", "Http", "Respons", "e", "Ba", "d", "Request_", "(_", "\"", "POST", " ", "Expect", "ed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "login", "\\u", "and", "\\u", "domain", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "\\u", "superuser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "list", "\\u", "forward", "ing", "\\u", "rules_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "forward", "ing", "\\u", "rules_", "=_", "get", "\\u", "forward", "ing", "\\u", "rule", "s", "\\u", "for", "\\u", "domain_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "domain", "\"_", ":_", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "forward", "ing", "\\u", "rule", "s", "\"_", ":_", "forward", "ing", "\\u", "rules_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render_", "(_", "request_", ",_", "\"", "sms", "/", "list", "\\u", "forward", "ing", "\\u", "rule", "s", ".", "html", "\"_", ",_", "context_", ")_", "\\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_", "@_", "login", "\\u", "and", "\\u", "domain", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "\\u", "superuser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "forward", "ing", "\\u", "rule_", "(_", "request_", ",_", "domain_", ",_", "forward", "ing", "\\u", "rule", "\\u", "id_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "forward", "ing", "\\u", "rule_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "forward", "ing", "\\u", "rule", "\\u", "id_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "forward", "ing", "\\u", "rule_", "=_", "Forward", "ing", "Rule_", "._", "get_", "(_", "forward", "ing", "\\u", "rule", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "forward", "ing", "\\u", "rule_", "._", "domain_", "!=_", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "\\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_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Forward", "ing", "Rule", "Form_", "(_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "forward", "ing", "\\u", "rule_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "forward", "ing", "\\u", "rule_", "=_", "Forward", "ing", "Rule_", "(_", "domain_", "=_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "forward", "ing", "\\u", "rule_", "._", "forward", "\\u", "type_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "\"", "forward", "\\u", "type", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "forward", "ing", "\\u", "rule_", "._", "keyword_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "\"", "keyw", "ord", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "forward", "ing", "\\u", "rule_", "._", "back", "end", "\\u", "id_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "\"", "back", "end", "\\u", "id", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "forward", "ing", "\\u", "rule_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "list", "\\u", "forward", "ing", "\\u", "rule", "s", "'_", ",_", "args_", "=_", "[_", "domain_", "]_", ")_", ")_", "\\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 ", " _", "initial_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "forward", "ing", "\\u", "rule_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "\"", "forward", "\\u", "type", "\"_", "]_", "=_", "forward", "ing", "\\u", "rule_", "._", "forward", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "\"", "keyw", "ord", "\"_", "]_", "=_", "forward", "ing", "\\u", "rule_", "._", "keyword_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "\"", "back", "end", "\\u", "id", "\"_", "]_", "=_", "forward", "ing", "\\u", "rule_", "._", "back", "end", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Forward", "ing", "Rule", "Form_", "(_", "initial_", "=_", "initial_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "domain", "\"_", ":_", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "forward", "ing", "\\u", "rule", "\\u", "id", "\"_", ":_", "forward", "ing", "\\u", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render_", "(_", "request_", ",_", "\"", "sms", "/", "add", "\\u", "forward", "ing", "\\u", "rule", ".", "html", "\"_", ",_", "context_", ")_", "\\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_", "@_", "login", "\\u", "and", "\\u", "domain", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "\\u", "superuser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "delete", "\\u", "forward", "ing", "\\u", "rule_", "(_", "request_", ",_", "domain_", ",_", "forward", "ing", "\\u", "rule", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "forward", "ing", "\\u", "rule_", "=_", "Forward", "ing", "Rule_", "._", "get_", "(_", "forward", "ing", "\\u", "rule", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "forward", "ing", "\\u", "rule_", "._", "domain_", "!=_", "domain_", "or_", "forward", "ing", "\\u", "rule_", "._", "doc", "\\u", "type_", "!=_", "\"", "Forward", "ing", "Rule", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "forward", "ing", "\\u", "rule_", "._", "retire", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "list", "\\u", "forward", "ing", "\\u", "rule", "s", "\"_", ",_", "args_", "=_", "[_", "domain_", "]_", ")_", ")_", "\\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_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "global", "\\u", "back", "end", "\\u", "map", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "name_", "=_", "'", "sms", "/", "back", "end", "\\u", "map", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "lazy_", "(_", "\"", "Default", " ", "Gat", "ewa", "ys", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "backends_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "global", "\\u", "backends_", "(_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "map", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Back", "end", "Map", "Form_", "(_", "self_", "._", "request_", "._", "POST_", ",_", "backends_", "=_", "self_", "._", "backends_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "back", "end", "\\u", "map_", "=_", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "get", "\\u", "prefix", "\\u", "to", "\\u", "back", "end", "\\u", "map_", "(_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "catch", "all", "\\u", "back", "end", "\\u", "id", "'_", ":_", "back", "end", "\\u", "map_", "._", "catch", "all", "\\u", "back", "end", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "back", "end", "\\u", "map", "'_", ":_", "json_", "._", "dumps_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "prefix", "'_", ":_", "prefix_", ",_", "'", "back", "end", "\\u", "id", "'_", ":_", "back", "end", "\\u", "id_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "prefix_", ",_", "back", "end", "\\u", "id_", "in_", "back", "end", "\\u", "map_", "._", "back", "end", "\\u", "map", "\\u", "tuples_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Back", "end", "Map", "Form_", "(_", "initial_", "=_", "initial_", ",_", "backends_", "=_", "self_", "._", "backends_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "superuser_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Global", "Back", "end", "Map_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "self_", "._", "back", "end", "\\u", "map", "\\u", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "back", "ends", "'_", ":_", "self_", "._", "backends_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Back", "end", "Map_", "(_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "self_", "._", "back", "end", "\\u", "map", "\\u", "form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "back", "end", "\\u", "map_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "back", "end", "\\u", "map", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "catch", "all", "\\u", "back", "end", "\\u", "id_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "catch", "all", "\\u", "back", "end", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "transaction_", "._", "atomic_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "get", "\\u", "prefix", "\\u", "to", "\\u", "back", "end", "\\u", "map_", "._", "clear_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Mob", "ile", "Back", "end", "Mapping_", ",_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "global_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "type_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "prefix_", ",_", "back", "end", "\\u", "id_", "in_", "new", "\\u", "back", "end", "\\u", "map_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "global_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "type_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prefix_", "=_", "prefix_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "back", "end", "\\u", "id_", "\\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_", "new", "\\u", "catch", "all", "\\u", "back", "end", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "global_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "type_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prefix_", "=_", "'*'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "new", "\\u", "catch", "all", "\\u", "back", "end", "\\u", "id_", "\\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_", "messages_", "._", "success_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Change", "s", " ", "Save", "d", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "self_", "._", "url", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "get_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Cha", "t", "Over", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "chat", "\\u", "contact", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "name_", "=_", "'", "sms", "/", "chat", "\\u", "contact", "s", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "\\u_", "(_", "\"", "Cha", "t", " ", "over", " ", "SMS", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Over", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "permission_", "(_", "Permissions_", "._", "edit", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "datata", "bles_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Cha", "t", "Over", "SMS", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "case", "\\u", "contact", "\\u", "info_", "(_", "domain", "\\u", "obj_", ",_", "case", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "doc_", "in_", "iter", "\\u", "docs_", "(_", "Comm", "Care", "Case_", "._", "get", "\\u", "db_", "(_", ")_", ",_", "case", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "domain", "\\u", "obj_", "._", "custom", "\\u", "case", "\\u", "username_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "doc_", "._", "get_", "(_", "domain", "\\u", "obj_", "._", "custom", "\\u", "case", "\\u", "username_", ")_", "\\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 ", " _", "name_", "=_", "doc_", "._", "get_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "[_", "doc_", "[_", "'\\u", "id", "'_", "]_", "]_", "=_", "[_", "name_", "or_", "\\u_", "(_", "'(", "unknown", ")'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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_", "get", "\\u", "mobile", "\\u", "worker", "\\u", "contact", "\\u", "info_", "(_", "domain", "\\u", "obj_", ",_", "user", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "doc_", "in_", "iter", "\\u", "docs_", "(_", "Comm", "Care", "User_", "._", "get", "\\u", "db_", "(_", ")_", ",_", "user", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "Comm", "Care", "User_", "._", "wrap_", "(_", "doc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "user_", "._", "get", "\\u", "id_", "]_", "=_", "[_", "user_", "._", "raw", "\\u", "username_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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_", "get", "\\u", "contact", "\\u", "info_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "data", " ", "has", " ", "bee", "n", " ", "cache", "d", ",", " ", "just", " ", "retrieve", " ", "it", " ", "from", " ", "there", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache", "\\u", "key_", "=_", "'", "sms", "-", "chat", "-", "contact", "-", "list", "-%", "s", "'_", "%_", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cache", "\\u", "expiration_", "=_", "30_", "*_", "60_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "cache", "\\u", "core_", "._", "get", "\\u", "redis", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cache", "d\\u", "data_", "=_", "client_", "._", "get_", "(_", "cache", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cache", "d\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json_", "._", "loads_", "(_", "cache", "d\\u", "data_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "verifie", "d\\u", "number", "\\u", "ids_", "=_", "Verifie", "d", "Number_", "._", "by", "\\u", "domain_", "(_", "domain_", ",_", "ids", "\\u", "only_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "=_", "Domain_", "._", "get", "\\u", "by", "\\u", "name_", "(_", "domain_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case", "\\u", "ids_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mobile", "\\u", "worker", "\\u", "ids_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "doc_", "in_", "iter", "\\u", "docs_", "(_", "Verifie", "d", "Number_", "._", "get", "\\u", "db_", "(_", ")_", ",_", "verifie", "d\\u", "number", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "owner", "\\u", "id_", "=_", "doc_", "[_", "'", "owner", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "doc_", "[_", "'", "owner", "\\u", "doc", "\\u", "type", "'_", "]_", "==_", "'", "Comm", "Care", "Case", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "case", "\\u", "ids_", "._", "append_", "(_", "owner", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "._", "append_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "case", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "[_", "'", "phone", "\\u", "number", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "[_", "'\\u", "id", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "doc_", "[_", "'", "owner", "\\u", "doc", "\\u", "type", "'_", "]_", "==_", "'", "Comm", "Care", "User", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mobile", "\\u", "worker", "\\u", "ids_", "._", "append_", "(_", "owner", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "._", "append_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mobile", "\\u", "worker", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "[_", "'", "phone", "\\u", "number", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "[_", "'\\u", "id", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "contact", "\\u", "data_", "=_", "get", "\\u", "case", "\\u", "contact", "\\u", "info_", "(_", "domain", "\\u", "obj_", ",_", "case", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contact", "\\u", "data_", "._", "update_", "(_", "get", "\\u", "mobile", "\\u", "worker", "\\u", "contact", "\\u", "info_", "(_", "domain", "\\u", "obj_", ",_", "mobile", "\\u", "worker", "\\u", "ids_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "contact", "\\u", "info_", "=_", "contact", "\\u", "data_", "._", "get_", "(_", "row_", "[_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "0_", "]_", "=_", "contact", "\\u", "info_", "[_", "0_", "]_", "if_", "contact", "\\u", "info_", "else_", "\\u_", "(_", "'(", "unknown", ")'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Save", " ", "the", " ", "data", " ", "to", " ", "the", " ", "cache", " ", "for", " ", "faste", "r", " ", "look", "up", " ", "next", " ", "time_", "\\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 ", " _", "client_", "._", "set_", "(_", "cache", "\\u", "key_", ",_", "json_", "._", "dumps_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "expire_", "(_", "cache", "\\u", "key_", ",_", "cache", "\\u", "expiration_", ")_", "\\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_", "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_", "format\\u", "contact", "\\u", "data_", "(_", "domain_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "row_", "in_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "contact", "\\u", "id_", "=_", "row_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vn", "\\u", "id_", "=_", "row_", "[_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "row_", "[_", "1_", "]_", "==_", "'", "case", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "[_", "1_", "]_", "=_", "\\u_", "(_", "'", "Case", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "4_", "]_", "=_", "reverse_", "(_", "'", "case", "\\u", "deta", "il", "s", "'_", ",_", "args_", "=_", "[_", "domain_", ",_", "contact", "\\u", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "row_", "[_", "1_", "]_", "==_", "'", "mobile", "\\u", "worker", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "[_", "1_", "]_", "=_", "\\u_", "(_", "'", "Mob", "ile", " ", "Worke", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "4_", "]_", "=_", "reverse_", "(_", "Edit", "Comm", "Care", "User", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "domain_", ",_", "contact", "\\u", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "[_", "4_", "]_", "=_", "'#'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "row_", "._", "append_", "(_", "reverse_", "(_", "'", "sms", "\\u", "chat", "'_", ",_", "args_", "=_", "[_", "domain_", ",_", "contact", "\\u", "id_", ",_", "vn", "\\u", "id_", "]_", ")_", ")_", "\\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_", "@_", "require", "\\u", "permission_", "(_", "Permissions_", "._", "edit", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "chat", "\\u", "contact", "\\u", "list_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s", "Ech", "o_", "=_", "request_", "._", "GET_", "._", "get_", "(_", "'", "s", "Ech", "o", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "Display", "Start_", "=_", "int_", "(_", "request_", "._", "GET_", "._", "get_", "(_", "'", "i", "Display", "Start", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "Display", "Length_", "=_", "int_", "(_", "request_", "._", "GET_", "._", "get_", "(_", "'", "i", "Display", "Length", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s", "Search_", "=_", "request_", "._", "GET_", "._", "get_", "(_", "'", "s", "Sear", "ch", "'_", ",_", "''_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "get", "\\u", "contact", "\\u", "info_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "\\u", "records_", "=_", "len_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "s", "Search_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "regex_", "=_", "re_", "._", "compile_", "(_", "'", "^", ".*", "%", "s", ".*", "$'_", "%_", "s", "Search_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "filter_", "(_", "lambda_", "row_", ":_", "regex_", "._", "match_", "(_", "row_", "[_", "0_", "]_", ")_", "or_", "regex_", "._", "match_", "(_", "row_", "[_", "2_", "]_", ")_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "filter", "ed", "\\u", "records_", "=_", "len_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "._", "sort_", "(_", "key_", "=_", "lambda_", "row_", ":_", "row_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "data_", "[_", "i", "Display", "Start_", ":_", "i", "Display", "Start_", "+_", "i", "Display", "Length_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "format\\u", "contact", "\\u", "data_", "(_", "domain_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "s", "Ech", "o", "'_", ":_", "s", "Ech", "o_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "aa", "Data", "'_", ":_", "data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "i", "Total", "Record", "s", "'_", ":_", "total", "\\u", "records_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "i", "Total", "Display", "Record", "s", "'_", ":_", "filter", "ed", "\\u", "records_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "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_", "@_", "require", "\\u", "permission_", "(_", "Permissions_", "._", "edit", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "chat_", "(_", "request_", ",_", "domain_", ",_", "contact", "\\u", "id_", ",_", "vn", "\\u", "id_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain", "\\u", "obj_", "=_", "Domain_", "._", "get", "\\u", "by", "\\u", "name_", "(_", "domain_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timezone_", "=_", "get", "\\u", "timezon", "e\\u", "for", "\\u", "user_", "(_", "None_", ",_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "floor", "ed", "\\u", "utc", "\\u", "timestamp", " ", "is", " ", "the", " ", "datetime", " ", "in", " ", "UT", "C", " ", "represent", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mid", "night", " ", "toda", "y", " ", "in", " ", "local", " ", "time", ".", " ", "Thi", "s", " ", "is", " ", "used", " ", "to", " ", "calculate_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "message", " ", "histo", "ry", " ", "choice", "s", "'", " ", "timestamp", "s", ",", " ", "so", " ", "tha", "t", " ", "choo", "sing", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Ye", "ster", "day", "\",", " ", "for", " ", "example", ",", " ", "give", "s", " ", "you", " ", "data", " ", "from", " ", "yesterday", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mid", "night", " ", "local", " ", "time", "._", "\\u\\u\\uNL\\u\\u\\u_", "local", "\\u", "date_", "=_", "datetime_", "._", "now_", "(_", "timezone_", ")_", "._", "date_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "floor", "ed", "\\u", "utc", "\\u", "timestamp_", "=_", "User", "Time_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "combine_", "(_", "local", "\\u", "date_", ",_", "time_", "(_", "0_", ",_", "0_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "timezone_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "server", "\\u", "time_", "(_", ")_", "._", "done_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "fmt_", "(_", "d_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json", "\\u", "format\\u", "datetime_", "(_", "floor", "ed", "\\u", "utc", "\\u", "timestamp_", "-_", "timedelta_", "(_", "days_", "=_", "d_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "histo", "ry", "\\u", "choices_", "=_", "[_", "(_", "\\u_", "(_", "x_", ")_", ",_", "\\u", "fmt_", "(_", "y_", ")_", ")_", "for_", "(_", "x_", ",_", "y_", ")_", "in_", "SMS", "\\u", "CHAT", "\\u", "HISTORY", "\\u", "CHOICES_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "histo", "ry", "\\u", "choices_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\\u_", "(_", "\"", "All", " ", "Time", "\"_", ")_", ",_", "json", "\\u", "format\\u", "datetime_", "(_", "datetime_", "(_", "1970_", ",_", "1_", ",_", "1_", ")_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "domain", "\"_", ":_", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "contact", "\\u", "id", "\"_", ":_", "contact", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "contact", "\"_", ":_", "get", "\\u", "contact_", "(_", "contact", "\\u", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "message", "\\u", "counter", "\"_", ":_", "domain", "\\u", "obj_", "._", "chat", "\\u", "message", "\\u", "count", "\\u", "threshold_", "is_", "not_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "message", "\\u", "count", "\\u", "threshol", "d", "\"_", ":_", "domain", "\\u", "obj_", "._", "chat", "\\u", "message", "\\u", "count", "\\u", "threshold_", "or_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "case", "\\u", "user", "name", "\"_", ":_", "domain", "\\u", "obj_", "._", "custom", "\\u", "case", "\\u", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "histo", "ry", "\\u", "choice", "s", "\"_", ":_", "histo", "ry", "\\u", "choices_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "vn", "\\u", "id", "\"_", ":_", "vn", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "settings_", "._", "CUSTOM", "\\u", "CHAT", "\\u", "TEMPLATES_", "._", "get_", "(_", "domain", "\\u", "obj_", "._", "custom", "\\u", "chat", "\\u", "template_", ")_", "or_", "\"", "sms", "/", "chat", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render_", "(_", "request_", ",_", "template_", ",_", "context_", ")_", "\\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_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "api", "\\u", "histo", "ry", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "permission_", "(_", "Permissions_", "._", "edit", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Cha", "t", "Messag", "e", "History_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "contact", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "GET_", "._", "get_", "(_", "'", "contact", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "contact_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "contact", "\\u", "id_", ":_", "\\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_", "contact_", "=_", "get", "\\u", "contact_", "(_", "self_", "._", "contact", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "contact_", "or_", "contact_", "._", "domain_", "!=_", "self_", "._", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "contact_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "contact", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "contact_", "._", "doc", "\\u", "type_", "==_", "'", "Comm", "Care", "Case", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "domain", "\\u", "object_", "._", "custom", "\\u", "case", "\\u", "username_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "contact_", "._", "get", "\\u", "case", "\\u", "property_", "(_", "self_", "._", "domain", "\\u", "object_", "._", "custom", "\\u", "case", "\\u", "username_", ")_", "\\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_", "self_", "._", "contact_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "contact_", "._", "first", "\\u", "name_", "or_", "self_", "._", "contact_", "._", "raw", "\\u", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "quick", "cache_", "(_", "[_", "'", "user", "\\u", "id", "'_", "]_", ",_", "timeout_", "=_", "60_", "*_", "60_", ",_", "memo", "ize", "\\u", "timeout_", "=_", "5_", "*_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "chat", "\\u", "user", "\\u", "name_", "(_", "self_", ",_", "user", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "user", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "System", "\"_", ")_", "\\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_", "=_", "Cou", "ch", "User_", "._", "get", "\\u", "by", "\\u", "user", "\\u", "id_", "(_", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "user_", "._", "first", "\\u", "name_", "or_", "user_", "._", "raw", "\\u", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Un", "know", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "start", "\\u", "date", "\\u", "str_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "GET_", "._", "get_", "(_", "'", "start", "\\u", "date", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "start", "\\u", "date_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "start", "\\u", "date", "\\u", "str_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "iso", "\\u", "string", "\\u", "to", "\\u", "datetime_", "(_", "self_", "._", "start", "\\u", "date", "\\u", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Value", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\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", "raw", "\\u", "data_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "SMS", "_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "couch", "\\u", "recip", "ient", "\\u", "doc", "\\u", "type_", "=_", "self_", "._", "contact_", "._", "doc", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "couch", "\\u", "recipient_", "=_", "self_", "._", "contact", "\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "direction_", "=_", "OUT", "GO", "ING_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "processed_", "=_", "False_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "start", "\\u", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "result_", "._", "filter_", "(_", "date", "\\u\\u", "gt_", "=_", "self_", "._", "start", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "self_", "._", "filter", "\\u", "survey", "\\u", "data_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "._", "order", "\\u", "by_", "(_", "'", "date", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "filter", "\\u", "survey", "\\u", "data_", "(_", "self_", ",_", "queryset_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "domain", "\\u", "object_", "._", "filter", "\\u", "survey", "s", "\\u", "from", "\\u", "chat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "queryset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "domain", "\\u", "object_", "._", "show", "\\u", "invalid", "\\u", "survey", "\\u", "response", "s", "\\u", "in", "\\u", "chat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "queryset_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "xform", "s", "\\u", "session", "\\u", "couch", "\\u", "id", "\\u\\u", "isnull_", "=_", "False_", ")_", "&_", "\\u\\u\\uNL\\u\\u\\u_", "~_", "Q_", "(_", "direction_", "=_", "INCOM", "ING_", ",_", "invalid", "\\u", "survey", "\\u", "response_", "=_", "True_", ")_", "\\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 ", " _", "return_", "queryset_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "xform", "s", "\\u", "session", "\\u", "couch", "\\u", "id", "\\u\\u", "isnull_", "=_", "False_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\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", "response", "\\u", "data_", "(_", "self_", ",_", "request", "ing", "\\u", "user", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timezone_", "=_", "get", "\\u", "timezon", "e\\u", "for", "\\u", "user_", "(_", "None_", ",_", "self_", "._", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "sms_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "sms_", "in_", "self_", "._", "get", "\\u", "raw", "\\u", "data_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "\\u", "sms_", "=_", "sms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sms_", "._", "direction_", "==_", "INCOM", "ING_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sender_", "=_", "self_", "._", "contact", "\\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 ", " _", "sender_", "=_", "self_", "._", "get", "\\u", "chat", "\\u", "user", "\\u", "name_", "(_", "sms_", "._", "chat", "\\u", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sender", "'_", ":_", "sender_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "sms_", "._", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Server", "Time_", "(_", "sms_", "._", "date_", ")_", "._", "user", "\\u", "time_", "(_", "timezone_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "ui", "\\u", "string_", "(_", "\"%", "I", ":", "%", "M", "%", "p", " ", "%", "m", "/", "%", "d", "/", "%", "y", "\"_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "utc", "\\u", "timestamp", "'_", ":_", "json", "\\u", "format\\u", "datetime_", "(_", "sms_", "._", "date_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sent", "\\u", "by", "\\u", "requester", "'_", ":_", "(_", "sms_", "._", "chat", "\\u", "user", "\\u", "id_", "==_", "request", "ing", "\\u", "user", "\\u", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", ",_", "last", "\\u", "sms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "last", "\\u", "read", "\\u", "message_", "(_", "self_", ",_", "request", "ing", "\\u", "user", "\\u", "id_", ",_", "sms_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain_", "=_", "self_", "._", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contact", "\\u", "id_", "=_", "self_", "._", "contact", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "key_", "=_", "'", "update", "-", "last", "-", "read", "-", "message", "-%", "s", "-%", "s", "-%", "s", "'_", "%_", "(_", "domain_", ",_", "request", "ing", "\\u", "user", "\\u", "id_", ",_", "contact", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "Crit", "ical", "Section_", "(_", "[_", "key_", "]_", ")_", ":_", "\\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 ", " _", "entry_", "=_", "SQL", "Las", "t", "Read", "Message_", "._", "objects_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "read", "\\u", "by_", "=_", "request", "ing", "\\u", "user", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "contact", "\\u", "id_", "=_", "contact", "\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "SQL", "Las", "t", "Read", "Message_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "entry_", "=_", "SQL", "Las", "t", "Read", "Message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "read", "\\u", "by_", "=_", "request", "ing", "\\u", "user", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "contact", "\\u", "id_", "=_", "contact", "\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "entry_", "._", "message", "\\u", "timestamp_", "or_", "entry_", "._", "message", "\\u", "timestamp_", "<_", "sms_", "._", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "entry_", "._", "message", "\\u", "id_", "=_", "sms_", "._", "couch", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entry_", "._", "message", "\\u", "timestamp_", "=_", "sms_", "._", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entry_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Messag", "e", "History_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\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_", "get_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "contact_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "'[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", ",_", "last", "\\u", "sms_", "=_", "self_", "._", "get", "\\u", "response", "\\u", "data_", "(_", "request_", "._", "couch", "\\u", "user_", "._", "get", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "last", "\\u", "sms_", ":_", "\\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_", "._", "update", "\\u", "last", "\\u", "read", "\\u", "message_", "(_", "request_", "._", "couch", "\\u", "user_", "._", "get", "\\u", "id_", ",_", "last", "\\u", "sms_", ")_", "\\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 ", " _", "notif", "y", "\\u", "exception_", "(_", "request_", ",_", "\"", "Error", " ", "updat", "ing", " ", "last", " ", "read", " ", "message", " ", "for", " ", "%", "s", "\"_", "%_", "last", "\\u", "sms_", "._", "pk_", ")_", "\\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_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Cha", "t", "Las", "t", "Read", "Message_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "api", "\\u", "last", "\\u", "read", "\\u", "message", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Cha", "t", "Las", "t", "Read", "Message_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "permission_", "(_", "Permissions_", "._", "edit", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Cha", "t", "Las", "t", "Read", "Message_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Las", "t", "Read", "Message_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "contact", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "GET_", "._", "get_", "(_", "'", "contact", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cha", "t", "Las", "t", "Read", "Message_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lr", "m", "\\u", "timestamp_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "contact", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "domain", "\\u", "object_", "._", "count", "\\u", "message", "s", "\\u", "as", "\\u", "read", "\\u", "by", "\\u", "any", "one_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lr", "m_", "=_", "SQL", "Las", "t", "Read", "Message_", "._", "by", "\\u", "any", "one_", "(_", "self_", "._", "domain_", ",_", "self_", "._", "contact", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lr", "m_", "=_", "SQL", "Las", "t", "Read", "Message_", "._", "by", "\\u", "user_", "(_", "self_", "._", "domain_", ",_", "request_", "._", "couch", "\\u", "user_", "._", "get", "\\u", "id_", ",_", "self_", "._", "contact", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "lr", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lr", "m", "\\u", "timestamp_", "=_", "json", "\\u", "format\\u", "datetime_", "(_", "lr", "m_", "._", "message", "\\u", "timestamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "\\u", "timestamp", "'_", ":_", "lr", "m", "\\u", "timestamp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "name_", "=_", "\"", "sms", "/", "gateway", "\\u", "list", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "name_", "=_", "'", "list", "\\u", "domain", "\\u", "back", "ends", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "SMS", " ", "Connectivity", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "strict", "\\u", "domain", "\\u", "fetch", "ing_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "domain", "\\u", "admin", "\\u", "required_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "parameters_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "POST_", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", "else_", "self_", "._", "request_", "._", "GET_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "total_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "domain", "\\u", "backends_", "(_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "self_", "._", "domain_", ",_", "count", "\\u", "only_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "column", "\\u", "names_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Gat", "ewa", "y", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Descripti", "on", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Supp", "orte", "d", " ", "Count", "rie", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Status", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Action", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "=_", "self_", "._", "pagina", "tion", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "initiate", "\\u", "new", "\\u", "form", "'_", ":_", "Initiat", "e", "Add", "SMS", "Back", "end", "Form_", "(_", "is", "\\u", "superuser_", "=_", "self_", "._", "request_", "._", "couch", "\\u", "user_", "._", "is", "\\u", "superuser_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "paginated", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "backends_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "domain", "\\u", "backends_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "offset_", "=_", "self_", "._", "skip_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "limit_", "=_", "self_", "._", "limit_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "backend_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "domain", "\\u", "default", "\\u", "backend_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "domain_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "backends_", ")_", ">_", "0_", "and_", "not_", "default", "\\u", "backend_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "'", "node", "fault", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "\"", "Automat", "ic", " ", "Choose", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ":_", "'", "DEF", "AUL", "T", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "gateway", "-", "automati", "c", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "default", "\\u", "backend_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "self_", "._", "\\u", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "default", "\\u", "backend_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "gateway", "-", "default", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "default", "\\u", "back", "end", "\\u", "id_", "=_", "default", "\\u", "backend_", "._", "pk_", "if_", "default", "\\u", "backend_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "backend_", "in_", "backends_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "backend_", "._", "pk_", "!=_", "default", "\\u", "back", "end", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "self_", "._", "\\u", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "backend_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "gateway", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\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", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "self_", ",_", "backend_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "\\u", "editable_", "=_", "not_", "backend_", "._", "is", "\\u", "global_", "and_", "backend_", "._", "domain_", "==_", "self_", "._", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "backend_", "._", "support", "ed", "\\u", "countries_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "backend_", "._", "support", "ed", "\\u", "countries_", "[_", "0_", "]_", "==_", "'*'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "support", "ed", "\\u", "countr", "y", "\\u", "names_", "=_", "\\u_", "(_", "'", "Multipl", "e", "%", "s", "'_", ")_", "%_", "'*'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "support", "ed", "\\u", "countr", "y", "\\u", "names_", "=_", "',", " ", "'_", "._", "join_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u_", "(_", "countr", "y", "\\u", "name", "\\u", "from", "\\u", "code_", "(_", "int_", "(_", "c_", ")_", ")_", ")_", "for_", "c_", "in_", "backend_", "._", "support", "ed", "\\u", "countries_", "]_", ")_", "\\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 ", " _", "support", "ed", "\\u", "countr", "y", "\\u", "names_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "backend_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "backend_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "backend_", "._", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "support", "ed", "\\u", "countr", "ies", "'_", ":_", "support", "ed", "\\u", "countr", "y", "\\u", "names_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "edit", "Ur", "l", "'_", ":_", "reverse_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "._", "url", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "self_", "._", "domain_", ",_", "backend_", "._", "hq", "\\u", "api", "\\u", "id_", ",_", "backend_", "._", "pk_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "if_", "is", "\\u", "editable_", "else_", "\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "can", "Delete", "'_", ":_", "is", "\\u", "editable_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "Global", "'_", ":_", "backend_", "._", "is", "\\u", "global_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "Share", "d", "'_", ":_", "not_", "backend_", "._", "is", "\\u", "global_", "and_", "backend_", "._", "domain_", "!=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "Modal", "Id", "'_", ":_", "'", "delete", "\\u", "%", "s", "'_", "%_", "backend_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "back", "end", "\\u", "from", "\\u", "item", "\\u", "id_", "(_", "self_", ",_", "item", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "\\u", "id_", "=_", "int_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "backend_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "load_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "item", "\\u", "id_", ",_", "backend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Ba", "d", "SMS", "Config", "Exception_", ",_", "SQL", "Mob", "ile", "Backend_", "._", "Do", "es", "Not", "Exist_", ",_", "Type", "Error_", ",_", "Value", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\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", "delete", "d\\u", "item", "\\u", "data_", "(_", "self_", ",_", "item", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "\\u", "id_", ",_", "backend_", "=_", "self_", "._", "\\u", "get", "\\u", "back", "end", "\\u", "from", "\\u", "item", "\\u", "id_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "backend_", "._", "is", "\\u", "global_", "or_", "backend_", "._", "domain_", "!=_", "self_", "._", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Do", " ", "not", " ", "actual", "ly", " ", "delete", " ", "so", " ", "tha", "t", " ", "linkage", " ", "alw", "ay", "s", " ", "exist", "s", " ", "bet", "ween", " ", "SMS", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mob", "ile", "Back", "end", " ", "for", " ", "bill", "able", " ", "history_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "backend_", "._", "soft", "\\u", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "self_", "._", "\\u", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "backend_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "gateway", "-", "delete", "d", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "refre", "sh", "\\u", "item_", "(_", "self_", ",_", "item", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "\\u", "id_", ",_", "backend_", "=_", "self_", "._", "\\u", "get", "\\u", "back", "end", "\\u", "from", "\\u", "item", "\\u", "id_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "backend_", "._", "domain", "\\u", "is", "\\u", "authorized_", "(_", "self_", "._", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "domain", "\\u", "default", "\\u", "back", "end", "\\u", "id_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "domain", "\\u", "default", "\\u", "backend_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id", "\\u", "only_", "=_", "True_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "domain", "\\u", "default", "\\u", "back", "end", "\\u", "id_", "==_", "item", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "unse", "t", "\\u", "default", "\\u", "domain", "\\u", "backend_", "(_", "self_", "._", "domain_", ")_", "\\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 ", " _", "SQL", "Mob", "ile", "Back", "end", "Mapping_", "._", "set\\u", "default", "\\u", "domain", "\\u", "backend_", "(_", "self_", "._", "domain_", ",_", "backend_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "allow", "ed", "\\u", "actions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actions_", "=_", "super_", "(_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", ",_", "self_", ")_", "._", "allow", "ed", "\\u", "actions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "actions_", "+_", "[_", "'", "new", "\\u", "back", "end", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "action_", "==_", "'", "new", "\\u", "back", "end", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hq", "\\u", "api", "\\u", "id_", "=_", "request_", "._", "POST_", "[_", "'", "hq", "\\u", "api", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "toggle", "s_", "._", "TELE", "RI", "VE", "T", "\\u", "SETUP", "\\u", "WAL", "KT", "HR", "OU", "GH", "_", "._", "enabled_", "(_", "self_", "._", "domain_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "hq", "\\u", "api", "\\u", "id_", "==_", "SQL", "Tele", "rive", "t", "Backend_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "core", "hq", "_", "._", "messaging_", "._", "sms", "backends_", "._", "tele", "rive", "t_", "._", "views_", "import_", "Tele", "rive", "t", "Set", "up", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Tele", "rive", "t", "Set", "up", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", ",_", "hq", "\\u", "api", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "paginate", "\\u", "crud", "\\u", "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_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "mix", "in", " ", "to", " ", "help", " ", "extract", " ", "the", " ", "common", " ", "functional", "it", "y", " ", "bet", "ween", " ", "addin", "g", "/", "editin", "g", "\\", "10", ";", " ", " ", " ", " ", "domain", "-", "level", " ", "back", "ends", " ", "and", " ", "addin", "g", "/", "editin", "g", " ", "global", " ", "back", "ends", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "is", "\\u", "superuser_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "couch", "\\u", "user_", "._", "is", "\\u", "superuser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "hq", "\\u", "api", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "kwargs_", "._", "get_", "(_", "'", "hq", "\\u", "api", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "class_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Super", "users", " ", "can", " ", "create", "/", "edit", " ", "any", " ", "backend_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regula", "r", " ", "users", " ", "can", " ", "only", " ", "create", "/", "edit", " ", "Tele", "rive", "t", " ", "back", "ends", " ", "for", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "is", "\\u", "superuser_", "and_", "self_", "._", "hq", "\\u", "api", "\\u", "id_", "!=_", "SQL", "Tele", "rive", "t", "Backend_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "back", "end", "\\u", "classes_", "=_", "get", "\\u", "sms", "\\u", "back", "end", "\\u", "classes_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "back", "end", "\\u", "classes_", "[_", "self_", "._", "hq", "\\u", "api", "\\u", "id_", "]_", "\\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_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "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_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "use", "\\u", "load", "\\u", "balancing", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "issubclass_", "(_", "self_", "._", "back", "end", "\\u", "class_", ",_", "Phone", "Load", "Bal", "anci", "ng", "Mixin_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Add", " ", "%", "s", " ", "Gat", "ewa", "y", "\"_", ")_", "%_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "gener", "ic", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "button", "\\u", "text_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Creat", "e", " ", "%", "s", " ", "Gat", "ewa", "y", "\"_", ")_", "%_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "gener", "ic", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "self_", "._", "back", "end", "\\u", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "button", "\\u", "text", "'_", ":_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "use", "\\u", "load", "\\u", "balancing", "'_", ":_", "self_", "._", "use", "\\u", "load", "\\u", "balancing", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "back", "end", "\\u", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "backend_", "._", "name_", "=_", "self_", "._", "back", "end", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "backend_", "._", "description_", "=_", "self_", "._", "back", "end", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "description", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "backend_", "._", "repl", "y", "\\u", "to", "\\u", "phone", "\\u", "number_", "=_", "self_", "._", "back", "end", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "repl", "y", "\\u", "to", "\\u", "phone", "\\u", "number", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "fields_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "back", "end", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "in_", "self_", "._", "backend_", "._", "get", "\\u", "avail", "able", "\\u", "extra", "\\u", "fields_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "fields_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "backend_", "._", "set\\u", "extra", "\\u", "fields_", "(_", "**_", "extra", "\\u", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "use", "\\u", "load", "\\u", "balancing", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "backend_", "._", "load", "\\u", "balancing", "\\u", "numbers_", "=_", "self_", "._", "back", "end", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "phone", "\\u", "numbers", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "backend_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "backend_", "._", "is", "\\u", "global_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "backend_", "._", "set\\u", "shared", "\\u", "domains_", "(_", "self_", "._", "back", "end", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "authoriz", "ed", "\\u", "domains", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "redirec", "t", "\\u", "to", "\\u", "gateway", "\\u", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "get_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "backend_", "(_", "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_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "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_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "form_", "(_", "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_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "parent", "\\u", "pages_", "(_", "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_", "Add", "Gat", "ewa", "y", "View", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "redirec", "t", "\\u", "to", "\\u", "gateway", "\\u", "list_", "(_", "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]_", "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_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "add", "\\u", "domain", "\\u", "gateway", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "name_", "=_", "'", "sms", "/", "add", "\\u", "gateway", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "lazy_", "(_", "\"", "Add", " ", "SMS", " ", "Gat", "ewa", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "backend_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "back", "end", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "global_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "type_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "hq", "\\u", "api", "\\u", "id_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", ",_", "self_", "._", "hq", "\\u", "api", "\\u", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form", "\\u", "class_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "form", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", "._", "POST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "None_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "None_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "parent", "\\u", "pages_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "._", "page", "\\u", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "reverse_", "(_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "redirec", "t", "\\u", "to", "\\u", "gateway", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Doma", "in", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "select", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "domain", "\\u", "admin", "\\u", "required_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "edit", "\\u", "domain", "\\u", "gateway", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "lazy_", "(_", "\"", "Edit", " ", "SMS", " ", "Gat", "ewa", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "kwargs_", "[_", "'", "back", "end", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "backend_", "(_", "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 ", " _", "backend_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "self_", "._", "back", "end", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Reso", "urc", "e", "Not", "Found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "backend_", "._", "is", "\\u", "global_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "backend_", "._", "domain_", "!=_", "self_", "._", "domain_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "backend_", "._", "hq", "\\u", "api", "\\u", "id_", "!=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "backend_", "._", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "backend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form", "\\u", "class_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "form", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "authoriz", "ed", "\\u", "domains_", "=_", "self_", "._", "backend_", "._", "get", "\\u", "authoriz", "ed", "\\u", "domain", "\\u", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "self_", "._", "backend_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "self_", "._", "backend_", "._", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "give", "\\u", "other", "\\u", "domains", "\\u", "access", "'_", ":_", "len_", "(_", "authoriz", "ed", "\\u", "domains_", ")_", ">_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "authoriz", "ed", "\\u", "domains", "'_", ":_", "','_", "._", "join_", "(_", "authoriz", "ed", "\\u", "domains_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "repl", "y", "\\u", "to", "\\u", "phone", "\\u", "number", "'_", ":_", "self_", "._", "backend_", "._", "repl", "y", "\\u", "to", "\\u", "phone", "\\u", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "._", "update_", "(_", "self_", "._", "backend_", "._", "get", "\\u", "extra", "\\u", "fields_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "use", "\\u", "load", "\\u", "balancing", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "phone", "\\u", "numbers", "'_", "]_", "=_", "json_", "._", "dumps_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "{_", "'", "phone", "\\u", "number", "'_", ":_", "p_", "}_", "for_", "p_", "in_", "self_", "._", "backend_", "._", "load", "\\u", "balancing", "\\u", "numbers_", "]_", "\\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_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", "._", "POST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "initial_", "=_", "initial_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "self_", "._", "backend_", "._", "pk_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "initial_", "=_", "initial_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "self_", "._", "backend_", "._", "pk_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Edit", " ", "%", "s", " ", "Gat", "ewa", "y", "\"_", ")_", "%_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "gener", "ic", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "button", "\\u", "text_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Update", " ", "%", "s", " ", "Gat", "ewa", "y", "\"_", ")_", "%_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "gener", "ic", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Doma", "in", "Gat", "ewa", "y", "View_", "(_", "Add", "Doma", "in", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ",_", "kwargs_", "=_", "self_", "._", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "name_", "=_", "\"", "sms", "/", "global", "\\u", "gateway", "\\u", "list", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "name_", "=_", "'", "list", "\\u", "global", "\\u", "back", "ends", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "SMS", " ", "Connectivity", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "superuser_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "parameters_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "POST_", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", "else_", "self_", "._", "request_", "._", "GET_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "total_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "global", "\\u", "backends_", "(_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "count", "\\u", "only_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "column", "\\u", "names_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Gat", "ewa", "y", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Descripti", "on", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Supp", "orte", "d", " ", "Count", "rie", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Action", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "=_", "self_", "._", "pagina", "tion", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "initiate", "\\u", "new", "\\u", "form", "'_", ":_", "Initiat", "e", "Add", "SMS", "Back", "end", "Form_", "(_", "is", "\\u", "superuser_", "=_", "self_", "._", "request_", "._", "couch", "\\u", "user_", "._", "is", "\\u", "superuser_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "paginated", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "backends_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "global", "\\u", "backends_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "offset_", "=_", "self_", "._", "skip_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "limit_", "=_", "self_", "._", "limit_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "backend_", "in_", "backends_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "self_", "._", "\\u", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "backend_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "gateway", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\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", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "self_", ",_", "backend_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "backend_", "._", "support", "ed", "\\u", "countries_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "backend_", "._", "support", "ed", "\\u", "countries_", "[_", "0_", "]_", "==_", "'*'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "support", "ed", "\\u", "countr", "y", "\\u", "names_", "=_", "\\u_", "(_", "'", "Multipl", "e", "%", "s", "'_", ")_", "%_", "'*'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "support", "ed", "\\u", "countr", "y", "\\u", "names_", "=_", "',", " ", "'_", "._", "join_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u_", "(_", "countr", "y", "\\u", "name", "\\u", "from", "\\u", "code_", "(_", "int_", "(_", "c_", ")_", ")_", ")_", "for_", "c_", "in_", "backend_", "._", "support", "ed", "\\u", "countries_", "]_", ")_", "\\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 ", " _", "support", "ed", "\\u", "countr", "y", "\\u", "names_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "backend_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "backend_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "backend_", "._", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "support", "ed", "\\u", "countr", "ies", "'_", ":_", "support", "ed", "\\u", "countr", "y", "\\u", "names_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "edit", "Ur", "l", "'_", ":_", "reverse_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Edit", "Global", "Gat", "ewa", "y", "View_", "._", "url", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "backend_", "._", "hq", "\\u", "api", "\\u", "id_", ",_", "backend_", "._", "pk_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "Modal", "Id", "'_", ":_", "'", "delete", "\\u", "%", "s", "'_", "%_", "backend_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "back", "end", "\\u", "from", "\\u", "item", "\\u", "id_", "(_", "self_", ",_", "item", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "\\u", "id_", "=_", "int_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "backend_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "load_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "item", "\\u", "id_", ",_", "backend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Ba", "d", "SMS", "Config", "Exception_", ",_", "SQL", "Mob", "ile", "Backend_", "._", "Do", "es", "Not", "Exist_", ",_", "Type", "Error_", ",_", "Value", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\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", "delete", "d\\u", "item", "\\u", "data_", "(_", "self_", ",_", "item", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "\\u", "id_", ",_", "backend_", "=_", "self_", "._", "\\u", "get", "\\u", "back", "end", "\\u", "from", "\\u", "item", "\\u", "id_", "(_", "item", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "backend_", "._", "is", "\\u", "global_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Do", " ", "not", " ", "actual", "ly", " ", "delete", " ", "so", " ", "tha", "t", " ", "linkage", " ", "alw", "ay", "s", " ", "exist", "s", " ", "bet", "ween", " ", "SMS", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mob", "ile", "Back", "end", " ", "for", " ", "bill", "able", " ", "history_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "backend_", "._", "soft", "\\u", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "self_", "._", "\\u", "fmt", "\\u", "back", "end", "\\u", "data_", "(_", "backend_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "gateway", "-", "delete", "d", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "allow", "ed", "\\u", "actions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actions_", "=_", "super_", "(_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", ",_", "self_", ")_", "._", "allow", "ed", "\\u", "actions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "actions_", "+_", "[_", "'", "new", "\\u", "back", "end", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "(_", "CRUD", "Pagina", "ted", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "action_", "==_", "'", "new", "\\u", "back", "end", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hq", "\\u", "api", "\\u", "id_", "=_", "request_", "._", "POST_", "[_", "'", "hq", "\\u", "api", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "hq", "\\u", "api", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "paginate", "\\u", "crud", "\\u", "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_", "class_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "add", "\\u", "global", "\\u", "gateway", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "name_", "=_", "'", "sms", "/", "add", "\\u", "gateway", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "lazy_", "(_", "\"", "Add", " ", "SMS", " ", "Gat", "ewa", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "backend_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "back", "end", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "global_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "type_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "SMS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "hq", "\\u", "api", "\\u", "id_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "hq", "\\u", "api", "\\u", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form", "\\u", "class_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "form", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", "._", "POST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "None_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "None_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "parent", "\\u", "pages_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "._", "page", "\\u", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "reverse_", "(_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "._", "url", "name_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "redirec", "t", "\\u", "to", "\\u", "gateway", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Global", "Sm", "s", "Gat", "ewa", "y", "List", "View_", "._", "url", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Add", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Gat", "ewa", "y", "View", "Mixin_", ",_", "Base", "Admi", "n", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "select", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "\\u", "superuser_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "edit", "\\u", "global", "\\u", "gateway", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "lazy_", "(_", "\"", "Edit", " ", "SMS", " ", "Gat", "ewa", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "kwargs_", "[_", "'", "back", "end", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "backend_", "(_", "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 ", " _", "backend_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "self_", "._", "back", "end", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Reso", "urc", "e", "Not", "Found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "backend_", "._", "is", "\\u", "global_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "backend_", "._", "deleted_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "backend_", "._", "hq", "\\u", "api", "\\u", "id_", "!=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "backend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form", "\\u", "class_", "=_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "form", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "self_", "._", "backend_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "self_", "._", "backend_", "._", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "repl", "y", "\\u", "to", "\\u", "phone", "\\u", "number", "'_", ":_", "self_", "._", "backend_", "._", "repl", "y", "\\u", "to", "\\u", "phone", "\\u", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "._", "update_", "(_", "self_", "._", "backend_", "._", "get", "\\u", "extra", "\\u", "fields_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "use", "\\u", "load", "\\u", "balancing", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "phone", "\\u", "numbers", "'_", "]_", "=_", "json_", "._", "dumps_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "{_", "'", "phone", "\\u", "number", "'_", ":_", "p_", "}_", "for_", "p_", "in_", "self_", "._", "backend_", "._", "load", "\\u", "balancing", "\\u", "numbers_", "]_", "\\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_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", "._", "POST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "initial_", "=_", "initial_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "self_", "._", "backend_", "._", "pk_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "form", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "initial_", "=_", "initial_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "button", "\\u", "text_", "=_", "self_", "._", "button", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "back", "end", "\\u", "id_", "=_", "self_", "._", "backend_", "._", "pk_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Edit", " ", "%", "s", " ", "Gat", "ewa", "y", "\"_", ")_", "%_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "gener", "ic", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "button", "\\u", "text_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "Update", " ", "%", "s", " ", "Gat", "ewa", "y", "\"_", ")_", "%_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "gener", "ic", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Edit", "Global", "Gat", "ewa", "y", "View_", "(_", "Add", "Global", "Gat", "ewa", "y", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ",_", "kwargs_", "=_", "self_", "._", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Subscrib", "e", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "name_", "=_", "\"", "sms", "/", "subscribe", "\\u", "sms", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "name_", "=_", "'", "subscribe", "\\u", "sms", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "Subscrib", "e", " ", "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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Subscrib", "e", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Subscrib", "e", "SMS", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Subscrib", "e", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "comm", "track", "\\u", "settings_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Domain_", "._", "get", "\\u", "by", "\\u", "name_", "(_", "self_", "._", "domain_", ")_", "._", "comm", "track", "\\u", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Subscrib", "e", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Subscrib", "e", "SMS", "Form_", "(_", "self_", "._", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "comm", "track", "\\u", "settings_", "and_", "self_", "._", "comm", "track", "\\u", "settings_", "._", "alert", "\\u", "config_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alert", "\\u", "config_", "=_", "self_", "._", "comm", "track", "\\u", "settings_", "._", "alert", "\\u", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alert", "\\u", "config_", "=_", "Alert", "Config_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "initial_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stock", "\\u", "out", "\\u", "facilit", "ies", "'_", ":_", "alert", "\\u", "config_", "._", "stock", "\\u", "out", "\\u", "facilit", "ies_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stock", "\\u", "out", "\\u", "commod", "iti", "es", "'_", ":_", "alert", "\\u", "config_", "._", "stock", "\\u", "out", "\\u", "commod", "ities_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stock", "\\u", "out", "\\u", "rate", "s", "'_", ":_", "alert", "\\u", "config_", "._", "stock", "\\u", "out", "\\u", "rates_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "non", "\\u", "report", "'_", ":_", "alert", "\\u", "config_", "._", "non", "\\u", "report_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Subscrib", "e", "SMS", "Form_", "(_", "initial_", "=_", "initial_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Subscrib", "e", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "self_", "._", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "domain", "\"_", ":_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Subscrib", "e", "SMS", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "form_", "._", "save_", "(_", "self_", "._", "comm", "track", "\\u", "settings_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "success_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Update", "d", " ", "Comm", "Care", " ", "Suppl", "y", " ", "settings", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "Subscrib", "e", "SMS", "View_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "get_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "SMS", "Languages", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "sms", "\\u", "language", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "name_", "=_", "\"", "sms", "/", "language", "s", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "Languages", "\"_", ")_", "\\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_", "SMS", "Languages", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "jq", "uer", "y", "\\u", "ui_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "domain", "\\u", "admin", "\\u", "required_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "SMS", "Languages", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Languages", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "Stand", "alo", "ne", "Translat", "ion", "Doc_", "._", "get", "\\u", "lock", "ed", "\\u", "obj_", "(_", "self_", "._", "domain_", ",_", "\"", "sms", "\"_", ",_", "create_", "=_", "True_", ")_", "as_", "tdo", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "tdo", "c_", "._", "langs_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tdo", "c_", "._", "langs_", "=_", "[_", "\"", "en", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tdo", "c_", "._", "translations_", "[_", "\"", "en", "\"_", "]_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tdo", "c_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "domain", "\"_", ":_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "lang", "s", "\"_", ":_", "tdo", "c_", "._", "langs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "bul", "k", "\\u", "upload", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "action", "\"_", ":_", "reverse_", "(_", "\"", "upload", "\\u", "sms", "\\u", "translatio", "ns", "\"_", ",_", "args_", "=_", "(_", "self_", "._", "domain_", ",_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "download", "\\u", "url", "\"_", ":_", "reverse_", "(_", "\"", "download", "\\u", "sms", "\\u", "translatio", "ns", "\"_", ",_", "args_", "=_", "(_", "self_", "._", "domain_", ",_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "adj", "ective", "\"_", ":_", "\\u_", "(_", "\"", "mess", "agin", "g", " ", "translatio", "n", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "plural", "\\u", "noun", "\"_", ":_", "\\u_", "(_", "\"", "mess", "agin", "g", " ", "translatio", "ns", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "bul", "k", "\\u", "upload", "\\u", "form", "\"_", ":_", "get", "\\u", "bul", "k", "\\u", "upload", "\\u", "form_", "(_", "context_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "context_", "\\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_", "@_", "domain", "\\u", "admin", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "edit", "\\u", "sms", "\\u", "languages_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Accept", "s", " ", "same", " ", "post", " ", "body", " ", "as", " ", "core", "hq", ".", "apps", ".", "app", "\\u", "manage", "r", ".", "views", ".", "edit", "\\u", "app", "\\u", "lang", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "Stand", "alo", "ne", "Translat", "ion", "Doc_", "._", "get", "\\u", "lock", "ed", "\\u", "obj_", "(_", "domain_", ",_", "\"", "sms", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create_", "=_", "True_", ")_", "as_", "tdo", "c_", ":_", "\\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 ", " _", "from_", "core", "hq", "_", "._", "apps_", "._", "app", "\\u", "manager_", "._", "views_", "._", "utils_", "import_", "validat", "e\\u", "langs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "langs_", ",_", "rename_", ",_", "build_", "=_", "validat", "e\\u", "langs_", "(_", "request_", ",_", "tdo", "c_", "._", "langs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "validat", "e\\u", "build_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "status_", "=_", "400_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "old_", ",_", "new_", "in_", "rename_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "old_", "!=_", "new_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tdo", "c_", "._", "translations_", "[_", "new_", "]_", "=_", "tdo", "c_", "._", "translations_", "[_", "old_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "tdo", "c_", "._", "translations_", "[_", "old_", "]_", "\\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_", "lang_", "in_", "langs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "lang_", "not_", "in_", "tdo", "c_", "._", "translations_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tdo", "c_", "._", "translations_", "[_", "lang_", "]_", "=_", "{_", "}_", "\\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_", "lang_", "in_", "tdo", "c_", "._", "translations_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "lang_", "not_", "in_", "langs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "tdo", "c_", "._", "translations_", "[_", "lang_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tdo", "c_", "._", "langs_", "=_", "langs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tdo", "c_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "json", "\\u", "response_", "(_", "langs_", ")_", "\\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_", "@_", "domain", "\\u", "admin", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "download", "\\u", "sms", "\\u", "translations_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tdo", "c_", "=_", "Stand", "alo", "ne", "Translat", "ion", "Doc_", "._", "get", "\\u", "obj_", "(_", "domain_", ",_", "\"", "sms", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "columns_", "=_", "[_", "\"", "property", "\"_", "]_", "+_", "tdo", "c_", "._", "langs_", "+_", "[_", "\"", "default", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "msg", "\\u", "ids_", "=_", "sorted_", "(_", "\\u", "MESSAGES_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "msg", "\\u", "id_", "in_", "msg", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rows_", "._", "append_", "(_", "[_", "msg", "\\u", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "lang_", "in_", "tdo", "c_", "._", "langs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "row_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "._", "append_", "(_", "tdo", "c_", "._", "translations_", "[_", "lang_", "]_", "._", "get_", "(_", "row_", "[_", "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_", "for_", "row_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "._", "append_", "(_", "\\u", "MESSAGES_", "._", "get_", "(_", "row_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "temp_", "=_", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "(_", "(_", "\"", "translatio", "ns", "\"_", ",_", "tuple_", "(_", "columns_", ")_", ")_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "(_", "(_", "\"", "translatio", "ns", "\"_", ",_", "tuple_", "(_", "rows_", ")_", ")_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "export", "\\u", "raw_", "(_", "headers_", ",_", "data_", ",_", "temp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "export", "\\u", "response_", "(_", "temp_", ",_", "Format_", "._", "XL", "S", "\\u", "2007_", ",_", "\"", "translatio", "ns", "\"_", ")_", "\\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_", "@_", "domain", "\\u", "admin", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "get", "\\u", "file_", "(_", "\"", "bul", "k", "\\u", "upload", "\\u", "file", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "upload", "\\u", "sms", "\\u", "translations_", "(_", "request_", ",_", "domain_", ")_", ":_", "\\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 ", " _", "workbook_", "=_", "Workbook", "JSONR", "eader", "_", "(_", "request_", "._", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "translations_", "=_", "workbook_", "._", "get", "\\u", "worksheet_", "(_", "title_", "=_", "'", "translatio", "ns", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "Stand", "alo", "ne", "Translat", "ion", "Doc_", "._", "get", "\\u", "lock", "ed", "\\u", "obj_", "(_", "domain_", ",_", "\"", "sms", "\"_", ")_", "as_", "tdo", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg", "\\u", "ids_", "=_", "sorted_", "(_", "\\u", "MESSAGES_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "lang_", "in_", "tdo", "c_", "._", "langs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "lang_", "]_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "row_", "in_", "translations_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "lang_", "in_", "tdo", "c_", "._", "langs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "row_", "._", "get_", "(_", "lang_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "msg", "\\u", "id_", "=_", "row_", "[_", "\"", "property", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg", "\\u", "id_", "in_", "msg", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "val_", "=_", "row_", "[_", "lang_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "val_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "val_", "=_", "str_", "(_", "val_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "val_", "=_", "val_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "lang_", "]_", "[_", "msg", "\\u", "id_", "]_", "=_", "val_", "\\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_", "tdo", "c_", "._", "translations_", "=_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tdo", "c_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "messages_", "._", "success_", "(_", "request_", ",_", "\\u_", "(_", "\"", "SMS", " ", "Translat", "ion", "s", " ", "Update", "d", ".\"_", ")_", ")_", "\\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 ", " _", "notif", "y", "\\u", "exception_", "(_", "request_", ",_", "'", "SMS", " ", "Upload", " ", "Translat", "ion", "s", " ", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "error_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Update", " ", "fail", "ed", ".", " ", "We", "'", "re", " ", "look", "ing", " ", "int", "o", " ", "it", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "sms", "\\u", "language", "s", "'_", ",_", "args_", "=_", "[_", "domain_", "]_", ")_", ")_", "\\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_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "\"", "sms", "\\u", "settings", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "name_", "=_", "\"", "sms", "/", "settings", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "SMS", " ", "Sett", "ings", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u_", "(_", "\"", "SMS", " ", "Sett", "ings", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "self_", "._", "url", "name_", ",_", "args_", "=_", "[_", "self_", "._", "domain_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "previe", "wer", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "couch", "\\u", "user_", "._", "is", "\\u", "previe", "wer", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "welcome", "\\u", "message", "\\u", "recipient_", "(_", "self_", ",_", "domain", "\\u", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "case_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "mobile", "\\u", "worker_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "ALL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "domain", "\\u", "obj_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "case_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "CASE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "domain", "\\u", "obj_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "mobile", "\\u", "worker_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "MOB", "ILE", "\\u", "WORKER", "_", "\\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_", "WEL", "COM", "E", "\\u", "RECIP", "IENT", "\\u", "NONE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Sett", "ings", "Form_", "(_", "self_", "._", "request_", "._", "POST_", ",_", "cch", "q", "\\u", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cch", "q", "\\u", "is", "\\u", "previe", "wer", "_", "=_", "self_", "._", "previe", "wer", "_", ")_", "\\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 ", " _", "domain", "\\u", "obj_", "=_", "Domain_", "._", "get", "\\u", "by", "\\u", "name_", "(_", "self_", "._", "domain_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enable", "d\\u", "disabled_", "=_", "lambda_", "b_", ":_", "(_", "ENABLED_", "if_", "b_", "else_", "DISABLED_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "custom_", "=_", "lambda_", "b_", ":_", "(_", "CUSTOM", "_", "if_", "b_", "else_", "DEFAULT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "default", "\\u", "sms", "\\u", "response", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "domain", "\\u", "obj_", "._", "use", "\\u", "default", "\\u", "sms", "\\u", "response_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\\u", "sms", "\\u", "response", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "default", "\\u", "sms", "\\u", "response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "restrict", "ed", "\\u", "sms", "\\u", "times", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "len_", "(_", "domain", "\\u", "obj_", "._", "restrict", "ed", "\\u", "sms", "\\u", "times_", ")_", ">_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "restrict", "ed", "\\u", "sms", "\\u", "times", "\\u", "json", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "w_", "._", "to", "\\u", "json_", "(_", ")_", "for_", "w_", "in_", "domain", "\\u", "obj_", "._", "restrict", "ed", "\\u", "sms", "\\u", "times_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "send", "\\u", "to", "\\u", "duplicated", "\\u", "case", "\\u", "numbers", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "domain", "\\u", "obj_", "._", "send", "\\u", "to", "\\u", "duplicated", "\\u", "case", "\\u", "numbers_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "custom", "\\u", "case", "\\u", "user", "name", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "custom_", "(_", "domain", "\\u", "obj_", "._", "custom", "\\u", "case", "\\u", "username_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "case", "\\u", "user", "name", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "custom", "\\u", "case", "\\u", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "custom", "\\u", "message", "\\u", "count", "\\u", "threshol", "d", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "custom_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "chat", "\\u", "message", "\\u", "count", "\\u", "threshold_", "is_", "not_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "message", "\\u", "count", "\\u", "threshol", "d", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "chat", "\\u", "message", "\\u", "count", "\\u", "threshold_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "sms", "\\u", "conversation", "\\u", "times", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "len_", "(_", "domain", "\\u", "obj_", "._", "sms", "\\u", "conversation", "\\u", "times_", ")_", ">_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "conversation", "\\u", "times", "\\u", "json", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "w_", "._", "to", "\\u", "json_", "(_", ")_", "for_", "w_", "in_", "domain", "\\u", "obj_", "._", "sms", "\\u", "conversation", "\\u", "times_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "conversation", "\\u", "length", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "conversation", "\\u", "length_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "survey", "\\u", "traffic", "\\u", "option", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SHOW", "\\u", "ALL_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "domain", "\\u", "obj_", "._", "filter", "\\u", "survey", "s", "\\u", "from", "\\u", "chat_", "else_", "\\u\\u\\uNL\\u\\u\\u_", "SHOW", "\\u", "INVALID", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "domain", "\\u", "obj_", "._", "show", "\\u", "invalid", "\\u", "survey", "\\u", "response", "s", "\\u", "in", "\\u", "chat_", "else_", "\\u\\u\\uNL\\u\\u\\u_", "HID", "E", "\\u", "ALL_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "count", "\\u", "message", "s", "\\u", "as", "\\u", "read", "\\u", "by", "\\u", "any", "one", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "domain", "\\u", "obj_", "._", "count", "\\u", "message", "s", "\\u", "as", "\\u", "read", "\\u", "by", "\\u", "any", "one_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "custom", "\\u", "chat", "\\u", "template", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "custom_", "(_", "domain", "\\u", "obj_", "._", "custom", "\\u", "chat", "\\u", "template_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "chat", "\\u", "template", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "custom", "\\u", "chat", "\\u", "template_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "enable", "d", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "enabled_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "type", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "owner", "\\u", "id", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "owner", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "user", "\\u", "id", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "user", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enable", "d", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "enable", "d\\u", "disabled_", "(_", "domain", "\\u", "obj_", "._", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enabled_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "registration", "\\u", "welcome", "\\u", "message", "\"_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "welcome", "\\u", "message", "\\u", "recipient_", "(_", "domain", "\\u", "obj_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "Sett", "ings", "Form_", "(_", "initial_", "=_", "initial_", ",_", "cch", "q", "\\u", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cch", "q", "\\u", "is", "\\u", "previe", "wer", "_", "=_", "self_", "._", "previe", "wer", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "self_", "._", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "self_", "._", "form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain", "\\u", "obj_", "=_", "Domain_", "._", "get", "\\u", "by", "\\u", "name_", "(_", "self_", "._", "domain_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "field", "\\u", "map_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "use", "\\u", "default", "\\u", "sms", "\\u", "response", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "use", "\\u", "default", "\\u", "sms", "\\u", "response", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "default", "\\u", "sms", "\\u", "response", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\\u", "sms", "\\u", "response", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "custom", "\\u", "case", "\\u", "user", "name", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "case", "\\u", "user", "name", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "send", "\\u", "to", "\\u", "duplicated", "\\u", "case", "\\u", "numbers", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "send", "\\u", "to", "\\u", "duplicated", "\\u", "case", "\\u", "numbers", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "sms", "\\u", "conversation", "\\u", "length", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "conversation", "\\u", "length", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "count", "\\u", "message", "s", "\\u", "as", "\\u", "read", "\\u", "by", "\\u", "any", "one", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "count", "\\u", "message", "s", "\\u", "as", "\\u", "read", "\\u", "by", "\\u", "any", "one", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "chat", "\\u", "message", "\\u", "count", "\\u", "threshol", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "message", "\\u", "count", "\\u", "threshol", "d", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "restrict", "ed", "\\u", "sms", "\\u", "times", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "restrict", "ed", "\\u", "sms", "\\u", "times", "\\u", "json", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "sms", "\\u", "conversation", "\\u", "times", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "conversation", "\\u", "times", "\\u", "json", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enable", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enable", "d", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "previe", "wer", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "map_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "custom", "\\u", "chat", "\\u", "template", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "custom", "\\u", "chat", "\\u", "template", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "(_", "model", "\\u", "field", "\\u", "name_", ",_", "form", "\\u", "field", "\\u", "name_", ")_", "in_", "field", "\\u", "map_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "domain", "\\u", "obj_", ",_", "model", "\\u", "field", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "form", "\\u", "field", "\\u", "name_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "survey", "\\u", "traffic", "\\u", "option_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "\"", "survey", "\\u", "traffic", "\\u", "option", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "survey", "\\u", "traffic", "\\u", "option_", "==_", "HID", "E", "\\u", "ALL_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain", "\\u", "obj_", "._", "filter", "\\u", "survey", "s", "\\u", "from", "\\u", "chat_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "._", "show", "\\u", "invalid", "\\u", "survey", "\\u", "response", "s", "\\u", "in", "\\u", "chat_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "survey", "\\u", "traffic", "\\u", "option_", "==_", "SHOW", "\\u", "INVALID", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain", "\\u", "obj_", "._", "filter", "\\u", "survey", "s", "\\u", "from", "\\u", "chat_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "._", "show", "\\u", "invalid", "\\u", "survey", "\\u", "response", "s", "\\u", "in", "\\u", "chat_", "=_", "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 ", " _", "domain", "\\u", "obj_", "._", "filter", "\\u", "survey", "s", "\\u", "from", "\\u", "chat_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "._", "show", "\\u", "invalid", "\\u", "survey", "\\u", "response", "s", "\\u", "in", "\\u", "chat_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "enable", "d", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "enabled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "type_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "type", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "owner", "\\u", "id_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "owner", "\\u", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "user", "\\u", "id_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sms", "\\u", "case", "\\u", "registration", "\\u", "user", "\\u", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain", "\\u", "obj_", "._", "sms", "\\u", "case", "\\u", "registration", "\\u", "enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "domain", "\\u", "obj_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "case_", "=_", "form_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "mobile", "\\u", "worker_", "=_", "form_", "._", "enable", "\\u", "registration", "\\u", "welcome", "\\u", "sms", "\\u", "for", "\\u", "mobile", "\\u", "worker_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "domain", "\\u", "obj_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "success_", "(_", "request_", ",_", "\\u_", "(_", "\"", "Change", "s", " ", "Save", "d", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "get_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SMS", "Sett", "ings", "View_", "(_", "Base", "Messag", "ing", "Sect", "ion", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "domain", "\\u", "admin", "\\u", "required_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "require", "s", "\\u", "privilege", "\\u", "with", "\\u", "fallback_", "(_", "privilege", "s_", "._", "OUT", "BOUND", "\\u", "SMS", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "boots", "trap", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "use", "\\u", "timep", "ick", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "SMS", "Sett", "ings", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "name_", "=_", "'", "sms", "/", "manage", "\\u", "registration", "\\u", "invitation", "s", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "name_", "=_", "'", "sms", "\\u", "manage", "\\u", "registration", "\\u", "invitation", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page", "\\u", "title_", "=_", "uge", "ttext", "\\u", "lazy_", "(_", "'", "Manage", " ", "Registration", " ", "Invitation", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "limit", "\\u", "text_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "invitation", "s", " ", "per", " ", "page", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "empty", "\\u", "notification_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "No", " ", "registration", " ", "invitation", "s", " ", "sent", " ", "ye", "t", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "load", "ing", "\\u", "message_", "=_", "uge", "ttext", "\\u", "noop_", "(_", "\"", "Load", "ing", " ", "invitation", "s", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "strict", "\\u", "domain", "\\u", "fetch", "ing_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "invitation", "s", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Sen", "d", "Registration", "Inv", "iation", "s", "Form_", "(_", "self_", "._", "request_", "._", "POST_", ",_", "domain_", "=_", "self_", "._", "domain_", ")_", "\\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_", "Sen", "d", "Registration", "Inv", "iation", "s", "Form_", "(_", "domain_", "=_", "self_", "._", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "project", "\\u", "timezone_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "get", "\\u", "timezon", "e\\u", "for", "\\u", "user_", "(_", "None_", ",_", "self_", "._", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "parameters_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "request_", "._", "POST_", "if_", "self_", "._", "request_", "._", "method_", "==_", "'", "POST", "'_", "else_", "self_", "._", "request_", "._", "GET_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "page", "\\u", "context_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "=_", "self_", "._", "pagina", "tion", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "self_", "._", "invitation", "s", "\\u", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enable", "d", "'_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "domain", "\\u", "object_", "._", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enabled_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "total_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Self", "Registration", "Invitation", "_", "._", "objects_", "._", "filter_", "(_", "domain_", "=_", "self_", "._", "domain_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "column", "\\u", "names_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "Creat", "ed", " ", "On", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "Phone", " ", "Number", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "Status", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "Expir", "ation", " ", "Date", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "Applica", "tion", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "Phone", " ", "Type", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "format\\u", "status_", "(_", "self_", ",_", "invitation", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "invitation", "_", "._", "status_", "==_", "Self", "Registration", "Invitation", "_", "._", "STATUS", "\\u", "REGISTER", "ED_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "register", "ed", "\\u", "date_", "=_", "(_", "Server", "Time_", "(_", "invitation", "_", "._", "register", "ed", "\\u", "date_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "user", "\\u", "time_", "(_", "self_", "._", "project", "\\u", "timezone_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "done_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "strftime_", "(_", "SERVER", "\\u", "DATETIME", "\\u", "FORMAT_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u_", "(_", "\"", "Register", "ed", " ", "on", " ", "%", "(", "date", ")", "s", "\"_", ")_", "%_", "{_", "'", "date", "'_", ":_", "register", "ed", "\\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 ", " _", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "Self", "Registration", "Invitation", "_", "._", "STATUS", "\\u", "PENDING_", ":_", "\\u_", "(_", "\"", "Pend", "ing", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Self", "Registration", "Invitation", "_", "._", "STATUS", "\\u", "EXPIRE", "D_", ":_", "\\u_", "(_", "\"", "Expire", "d", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "._", "get_", "(_", "invitation", "_", "._", "status_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "paginated", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "invitation", "s_", "=_", "Self", "Registration", "Invitation", "_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "created", "\\u", "date", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doc", "\\u", "info", "\\u", "cache_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "invitation", "_", "in_", "invitation", "s_", "[_", "self_", "._", "skip_", ":_", "self_", "._", "skip_", "+_", "self_", "._", "limit_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "invitation", "_", "._", "app", "\\u", "id_", "in_", "doc", "\\u", "info", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "doc", "\\u", "info_", "=_", "doc", "\\u", "info", "\\u", "cache_", "[_", "invitation", "_", "._", "app", "\\u", "id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "doc", "\\u", "info_", "=_", "get", "\\u", "doc", "\\u", "info", "\\u", "by", "\\u", "id_", "(_", "self_", "._", "domain_", ",_", "invitation", "_", "._", "app", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doc", "\\u", "info", "\\u", "cache_", "[_", "invitation", "_", "._", "app", "\\u", "id_", "]_", "=_", "doc", "\\u", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "yield_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "Data", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "invitation", "_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "created", "\\u", "date", "'_", ":_", "(_", "Server", "Time_", "(_", "invitation", "_", "._", "created", "\\u", "date_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "user", "\\u", "time_", "(_", "self_", "._", "project", "\\u", "timezone_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "done_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "strftime_", "(_", "SERVER", "\\u", "DATETIME", "\\u", "FORMAT_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "phone", "\\u", "number", "'_", ":_", "'+", "%", "s", "'_", "%_", "invitation", "_", "._", "phone", "\\u", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ":_", "self_", "._", "format\\u", "status_", "(_", "invitation", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "expir", "ation", "\\u", "date", "'_", ":_", "invitation", "_", "._", "expir", "ation", "\\u", "date_", "._", "strftime_", "(_", "SERVER", "\\u", "DAT", "E", "\\u", "FORMAT_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "name", "'_", ":_", "doc", "\\u", "info_", "._", "display_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "link", "'_", ":_", "doc", "\\u", "info_", "._", "link_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "phone", "\\u", "type", "'_", ":_", "dict_", "(_", "Self", "Registration", "Invitation", "_", "._", "PHONE", "\\u", "TYPE", "\\u", "CHOICES_", ")_", "._", "get_", "(_", "invitation", "_", "._", "phone", "\\u", "type_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "'", "invitation", "s", "-", "template", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manage", "Registration", "Invitation", "s", "View_", "(_", "Base", "Advance", "d", "Messag", "ing", "Sect", "ion", "View_", ",_", "CRUD", "Pagina", "ted", "View", "Mixin_", ")_", ":_", "\\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_", "post_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "request_", "._", "POST_", "._", "get_", "(_", "'", "action", "'_", ")_", "==_", "'", "invite", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "domain", "\\u", "object_", "._", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "get_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "invitation", "s", "\\u", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "phone", "\\u", "numbers_", "=_", "self_", "._", "invitation", "s", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "phone", "\\u", "numbers", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "\\u", "id_", "=_", "self_", "._", "invitation", "s", "\\u", "form_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "app", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "Self", "Registration", "Invitation", "_", "._", "initiate", "\\u", "workflow_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "phone", "\\u", "numbers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "app", "\\u", "id_", "=_", "app", "\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success", "\\u", "numbers_", ",_", "invalid", "\\u", "format\\u", "numbers_", ",_", "numbers", "\\u", "in", "\\u", "use_", "=_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "success", "\\u", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "messages_", "._", "success_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Invitation", "s", " ", "sent", " ", "to", ":", " ", "%", "(", "phone", "\\u", "numbers", ")", "s", "\"_", ")_", "%_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "phone", "\\u", "numbers", "'_", ":_", "','_", "._", "join_", "(_", "success", "\\u", "numbers_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "invalid", "\\u", "format\\u", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "messages_", "._", "error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Invitation", "s", " ", "coul", "d", " ", "not", " ", "be", " ", "sent", " ", "to", ":", " ", "%", "(", "phone", "\\u", "numbers", ")", "s", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", "se", " ", "number", "(", "s", ")", " ", "are", " ", "in", " ", "an", " ", "invalid", " ", "format", ".\"_", ")_", "%_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "phone", "\\u", "numbers", "'_", ":_", "','_", "._", "join_", "(_", "invalid", "\\u", "format\\u", "numbers_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "numbers", "\\u", "in", "\\u", "use_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "messages_", "._", "error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Invitation", "s", " ", "coul", "d", " ", "not", " ", "be", " ", "sent", " ", "to", ":", " ", "%", "(", "phone", "\\u", "numbers", ")", "s", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", "se", " ", "number", "(", "s", ")", " ", "are", " ", "alr", "ead", "y", " ", "in", " ", "use", ".\"_", ")_", "%_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "phone", "\\u", "numbers", "'_", ":_", "','_", "._", "join_", "(_", "numbers", "\\u", "in", "\\u", "use_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "get_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\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_", "self_", "._", "domain", "\\u", "object_", "._", "sms", "\\u", "mobile", "\\u", "worker", "\\u", "registration", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "paginate", "\\u", "crud", "\\u", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Invitation", "App", "Info", "View_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "name_", "=_", "'", "sms", "\\u", "registration", "\\u", "invitation", "\\u", "app", "\\u", "info", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Invitation", "App", "Info", "View_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "token_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "token_", "=_", "self_", "._", "kwargs_", "._", "get_", "(_", "'", "token", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Invitation", "App", "Info", "View_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "memoized", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "invitation", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "invitation", "_", "=_", "Self", "Registration", "Invitation", "_", "._", "by", "\\u", "token_", "(_", "self_", "._", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "invitation", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "invitation", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Invitation", "App", "Info", "View_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "invitation", "_", "._", "od", "k", "\\u", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "url_", "=_", "str_", "(_", "self_", "._", "invitation", "_", "._", "od", "k", "\\u", "url_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "'", "cca", "pp", ":", " ", "%", "s", " ", "signa", "ture", ":", " ", "%", "s", "'_", "%_", "(_", "url_", ",_", "sign_", "(_", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "base64_", "._", "b64encode_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Invitation", "App", "Info", "View_", "(_", "View_", ",_", "Doma", "in", "View", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "get_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Inco", "ming", "Back", "end", "View_", "(_", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Inco", "ming", "Back", "end", "View_", "(_", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "api", "\\u", "key_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\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 ", " _", "api", "\\u", "user_", "=_", "Ap", "i", "User_", "._", "get_", "(_", "'", "Ap", "i", "User", "-%", "s", "'_", "%_", "api", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Reso", "urc", "e", "Not", "Found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "status_", "=_", "401_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "api", "\\u", "user_", "._", "doc", "\\u", "type_", "!=_", "'", "Ap", "i", "User", "'_", "or_", "not_", "api", "\\u", "user_", "._", "has", "\\u", "permission_", "(_", "PERMISSION", "\\u", "POST", "\\u", "SMS", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "status_", "=_", "401_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "Inco", "ming", "Back", "end", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "api", "\\u", "key_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "New", "Inco", "ming", "Back", "end", "View_", "(_", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "domain_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "back", "end", "\\u", "couch", "\\u", "id_", "=_", "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_", "[SEP]_", "class_", "New", "Inco", "ming", "Back", "end", "View_", "(_", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "back", "end", "\\u", "class_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "return", " ", "the", " ", "model", " ", "class", " ", "of", " ", "the", " ", "back", "end", " ", "(", "a", " ", "subclass", " ", "of", " ", "SQL", "Mob", "ile", "Back", "end", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", "\"", "Ple", "ase", " ", "implement", " ", "this", " ", "method", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "New", "Inco", "ming", "Back", "end", "View_", "(_", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "method", "\\u", "decorator_", "(_", "csr", "f", "\\u", "exempt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "api", "\\u", "key_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\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_", "._", "domain_", ",_", "self_", "._", "back", "end", "\\u", "couch", "\\u", "id_", "=_", "SQL", "Mob", "ile", "Backend_", "._", "get", "\\u", "back", "end", "\\u", "info", "\\u", "by", "\\u", "api", "\\u", "key_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "back", "end", "\\u", "class_", "._", "get", "\\u", "api", "\\u", "id_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "key_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "SQL", "Mob", "ile", "Backend_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "status_", "=_", "401_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "New", "Inco", "ming", "Back", "end", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
ilastik/ilastik-0.5/ilastik/modules/automatic_segmentation/core/testModule.py
[ { "content": "from ilastik.core.projectClass import Project\nfrom ilastik.core.testThread import TestHelperFunctions\nfrom ilastik.modules.automatic_segmentation.core.automaticSegmentationMgr import AutomaticSegmentationModuleMgr\nimport unittest\nfrom ilastik.core import dataImpex\nfrom ilastik.core import jobMachine\nfrom ilastik import __path__ as ilastikpath\n\nfrom ilastik.core.testThread import setUp, tearDown\n\n#*******************************************************************************\n# A u t o m a t i c S e g m e n t a t i o n T e s t P r o j e c t *\n#*******************************************************************************\n\n \n\n#*******************************************************************************\n# T e s t W h o l e M o d u l e N o r m a l 2 D *\n#*******************************************************************************\n\n \n#*******************************************************************************\n# T e s t W h o l e M o d u l e I n v e r t e d 2 D *\n#*******************************************************************************\n\n\n#*******************************************************************************\n# T e s t W h o l e M o d u l e N o r m a l 3 D *\n#*******************************************************************************\n\n \n#*******************************************************************************\n# T e s t W h o l e M o d u l e I n v e r t e d 3 D *\n#*******************************************************************************\n\n\n#*******************************************************************************\n# i f _ _ n a m e _ _ = = \" _ _ m a i n _ _ \" *\n#*******************************************************************************\n\nif __name__ == \"__main__\":\n unittest.main()\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class AutomaticSegmentationTestProject(object):\n # this class is used to set up a default project which is then used for testing functionality, \n # hopefully, this will reduced code redundancy", "metadata": "root.AutomaticSegmentationTestProject", "header": "['module', '___EOS___']", "index": 14 }, { "content": " def __init__(self, image_filename, borderOverlay_filename, groundtruth_filename):\n \n self.image_filename = image_filename\n self.borderOverlay_filename = borderOverlay_filename\n self.groundtruth_filename = groundtruth_filename\n \n self.testdir = ilastikpath[0] + \"/testdata/automatic_segmentation/\"\n\n # fix random seed\n from ilastik.core.randomSeed import RandomSeed\n RandomSeed.setRandomSeed(42)\n \n # create project\n self.project = Project('Project Name', 'Labeler', 'Description')\n self.dataMgr = self.project.dataMgr\n \n # create file list and load data\n path = str(self.testdir + self.image_filename) # the image is not really used since we load the threshold overlay from a file, however, we need it to set the correct dimensions \n fileList = []\n fileList.append(path)\n self.project.addFile(fileList)\n \n # create automatic segmentation manager\n self.automaticSegmentationMgr = AutomaticSegmentationModuleMgr(self.dataMgr)\n \n # setup inputs\n self.inputOverlays = []\n self.inputOverlays.append(self.dataMgr[self.dataMgr._activeImageNumber].overlayMgr[\"Raw Data\"])\n \n # calculate segmentation results\n # ...import border indicator\n self.border_indicator_ov = dataImpex.DataImpex.importOverlay(self.dataMgr[self.dataMgr._activeImageNumber], str(self.testdir + borderOverlay_filename), \"\")\n self.input = self.border_indicator_ov._data[0,:,:,:,0]\n # ...normalize it\n self.input = self.automaticSegmentationMgr.normalizePotential(self.input)\n # ...invert it twice, this should give us the original again :-)\n self.input = self.automaticSegmentationMgr.invertPotential(self.input)\n self.input = self.automaticSegmentationMgr.invertPotential(self.input)\n \n # overlay lists and filenames\n self.listOfResultOverlays = []\n self.listOfFilenames = []\n self.listOfResultOverlays.append(\"Auto Segmentation/Segmentation\")\n self.listOfFilenames.append(self.testdir + self.groundtruth_filename)", "metadata": "root.AutomaticSegmentationTestProject.__init__", "header": "['class', 'AutomaticSegmentationTestProject', '(', 'object', ')', ':', '___NEWLINE___', '# this class is used to set up a default project which is then used for testing functionality, ', '___NL___', '# hopefully, this will reduced code redundancy', '___NL___', '___EOS___']", "index": 17 }, { "content": "class TestWholeModuleNormal2D(unittest.TestCase):\n \n ", "metadata": "root.TestWholeModuleNormal2D", "header": "['module', '___EOS___']", "index": 67 }, { "content": " def setUp(self):\n #print \"setUp\"\n self.testProject = AutomaticSegmentationTestProject(\"test_image_gray.png\", \"border_overlay_gaussian_gradient_magnitude_3.5.h5\", \"gt_automatic_segmentation_normal.h5\")", "metadata": "root.TestWholeModuleNormal2D.setUp", "header": "['class', 'TestWholeModuleNormal2D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 69 }, { "content": " def test_WholeModule(self):\n # compute results\n self.testProject.automaticSegmentationMgr.computeResults(self.testProject.input)\n # ...add overlays\n self.testProject.automaticSegmentationMgr.finalizeResults()\n \n #obtained = self.testProject.dataMgr[self.testProject.dataMgr._activeImageNumber].overlayMgr[self.testProject.listOfResultOverlays[0]]\n #dataImpex.DataImpex.exportOverlay(\"c:/new_segmentation_result\", \"h5\", obtained)\n \n # compare obtained result to ground truth result\n equalOverlays = TestHelperFunctions.compareResultsWithFile(self.testProject.automaticSegmentationMgr, self.testProject.listOfResultOverlays, self.testProject.listOfFilenames)\n self.assertEqual(equalOverlays, True)", "metadata": "root.TestWholeModuleNormal2D.test_WholeModule", "header": "['class', 'TestWholeModuleNormal2D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 73 }, { "content": "class TestWholeModuleInverted2D(unittest.TestCase):\n \n ", "metadata": "root.TestWholeModuleInverted2D", "header": "['module', '___EOS___']", "index": 90 }, { "content": " def setUp(self):\n #print \"setUp\"\n self.testProject = AutomaticSegmentationTestProject(\"test_image_gray.png\", \"border_overlay_laplacian_of_gaussians_3.5.h5\", \"gt_automatic_segmentation_inverted.h5\")", "metadata": "root.TestWholeModuleInverted2D.setUp", "header": "['class', 'TestWholeModuleInverted2D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 92 }, { "content": " def test_WholeModule(self):\n # compute results\n self.testProject.automaticSegmentationMgr.computeResults(self.testProject.input)\n # ...add overlays\n self.testProject.automaticSegmentationMgr.finalizeResults()\n \n # compare obtained result to ground truth result\n equalOverlays = TestHelperFunctions.compareResultsWithFile(self.testProject.automaticSegmentationMgr, self.testProject.listOfResultOverlays, self.testProject.listOfFilenames)\n self.assertEqual(equalOverlays, True)", "metadata": "root.TestWholeModuleInverted2D.test_WholeModule", "header": "['class', 'TestWholeModuleInverted2D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 96 }, { "content": "class TestWholeModuleNormal3D(unittest.TestCase):\n \n ", "metadata": "root.TestWholeModuleNormal3D", "header": "['module', '___EOS___']", "index": 110 }, { "content": " def setUp(self):\n self.testProject = AutomaticSegmentationTestProject(\"neurocube.h5\", \"neurocube_border_overlay_gaussian_gradient_magnitude_1.h5\", \"neurocube_gt_automatic_segmentation_normal.h5\")", "metadata": "root.TestWholeModuleNormal3D.setUp", "header": "['class', 'TestWholeModuleNormal3D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 112 }, { "content": " def test_WholeModule(self):\n # compute results\n self.testProject.automaticSegmentationMgr.computeResults(self.testProject.input)\n # ...add overlays\n self.testProject.automaticSegmentationMgr.finalizeResults()\n \n # compare obtained result to ground truth result\n equalOverlays = TestHelperFunctions.compareResultsWithFile(self.testProject.automaticSegmentationMgr, self.testProject.listOfResultOverlays, self.testProject.listOfFilenames)\n self.assertEqual(equalOverlays, True)", "metadata": "root.TestWholeModuleNormal3D.test_WholeModule", "header": "['class', 'TestWholeModuleNormal3D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 115 }, { "content": "class TestWholeModuleInverted3D(unittest.TestCase):\n \n ", "metadata": "root.TestWholeModuleInverted3D", "header": "['module', '___EOS___']", "index": 129 }, { "content": " def setUp(self):\n #print \"setUp\"\n self.testProject = AutomaticSegmentationTestProject(\"neurocube.h5\", \"neurocube_border_overlay_laplacian_of_gaussians_1.h5\", \"neurocube_gt_automatic_segmentation_inverted.h5\")", "metadata": "root.TestWholeModuleInverted3D.setUp", "header": "['class', 'TestWholeModuleInverted3D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 131 }, { "content": " def test_WholeModule(self):\n # compute results\n self.testProject.automaticSegmentationMgr.computeResults(self.testProject.input)\n # ...add overlays\n self.testProject.automaticSegmentationMgr.finalizeResults()\n \n # compare obtained result to ground truth result\n equalOverlays = TestHelperFunctions.compareResultsWithFile(self.testProject.automaticSegmentationMgr, self.testProject.listOfResultOverlays, self.testProject.listOfFilenames)\n self.assertEqual(equalOverlays, True)", "metadata": "root.TestWholeModuleInverted3D.test_WholeModule", "header": "['class', 'TestWholeModuleInverted3D', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 135 } ]
[ { "span": "from ilastik.core import jobMachine", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 35 }, { "span": "from ilastik.core.testThread import setUp, tearDown", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 51 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "core_", "._", "project", "Class_", "import_", "Project_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "core_", "._", "test", "Thread_", "import_", "Test", "Help", "er", "Functions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "modules_", "._", "automati", "c\\u", "segmentation_", "._", "core_", "._", "automati", "c", "Segmentation", "Mgr_", "import_", "Automat", "ic", "Segmentation", "Modul", "e", "Mgr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "core_", "import_", "data", "Impe", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "core_", "import_", "job", "Machine_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ila", "sti", "k_", "import_", "\\u\\u", "path\\u\\u_", "as_", "ila", "sti", "kpa", "th_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "core_", "._", "test", "Thread_", "import_", "set", "Up_", ",_", "tear", "Down_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "***********", "***********", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "A", " ", "u", " ", "t", " ", "o", " ", "m", " ", "a", " ", "t", " ", "i", " ", "c", " ", "S", " ", "e", " ", "g", " ", "m", " ", "e", " ", "n", " ", "t", " ", "a", " ", "t", " ", "i", " ", "o", " ", "n", " ", "T", " ", "e", " ", "s", " ", "t", " ", "P", " ", "r", " ", "o", " ", "j", " ", "e", " ", "c", " ", "t", " ", " ", " ", " ", " ", " ", "*_", "\\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_", "#", " ", "T", " ", "e", " ", "s", " ", "t", " ", "W", " ", "h", " ", "o", " ", "l", " ", "e", " ", "M", " ", "o", " ", "d", " ", "u", " ", "l", " ", "e", " ", "N", " ", "o", " ", "r", " ", "m", " ", "a", " ", "l", " ", "2", " ", "D", " ", " ", " ", " ", " ", " ", "*_", "\\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_", "#", " ", "T", " ", "e", " ", "s", " ", "t", " ", "W", " ", "h", " ", "o", " ", "l", " ", "e", " ", "M", " ", "o", " ", "d", " ", "u", " ", "l", " ", "e", " ", "I", " ", "n", " ", "v", " ", "e", " ", "r", " ", "t", " ", "e", " ", "d", " ", "2", " ", "D", " ", " ", " ", " ", " ", " ", "*_", "\\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_", "#", " ", "T", " ", "e", " ", "s", " ", "t", " ", "W", " ", "h", " ", "o", " ", "l", " ", "e", " ", "M", " ", "o", " ", "d", " ", "u", " ", "l", " ", "e", " ", "N", " ", "o", " ", "r", " ", "m", " ", "a", " ", "l", " ", "3", " ", "D", " ", " ", " ", " ", " ", " ", "*_", "\\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_", "#", " ", "T", " ", "e", " ", "s", " ", "t", " ", "W", " ", "h", " ", "o", " ", "l", " ", "e", " ", "M", " ", "o", " ", "d", " ", "u", " ", "l", " ", "e", " ", "I", " ", "n", " ", "v", " ", "e", " ", "r", " ", "t", " ", "e", " ", "d", " ", "3", " ", "D", " ", " ", " ", " ", " ", " ", "*_", "\\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_", "#", " ", "i", " ", "f", " ", " ", " ", "\\u", " ", "\\u", " ", "n", " ", "a", " ", "m", " ", "e", " ", "\\u", " ", "\\u", " ", " ", " ", "=", " ", "=", " ", " ", " ", "\"", " ", "\\u", " ", "\\u", " ", "m", " ", "a", " ", "i", " ", "n", " ", "\\u", " ", "\\u", " ", "\"", " ", " ", " ", " ", " ", " ", "*_", "\\u\\u\\uNL\\u\\u\\u_", "#", "***********", "***********", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unittest_", "._", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Automat", "ic", "Segmentation", "Test", "Project_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "class", " ", "is", " ", "used", " ", "to", " ", "set", " ", "up", " ", "a", " ", "default", " ", "project", " ", "whi", "ch", " ", "is", " ", "then", " ", "used", " ", "for", " ", "testi", "ng", " ", "functional", "it", "y", ",", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hop", "efu", "ll", "y", ",", " ", "this", " ", "will", " ", "reduce", "d", " ", "code", " ", "redu", "ndancy", "_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Automat", "ic", "Segmentation", "Test", "Project_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "class", " ", "is", " ", "used", " ", "to", " ", "set", " ", "up", " ", "a", " ", "default", " ", "project", " ", "whi", "ch", " ", "is", " ", "then", " ", "used", " ", "for", " ", "testi", "ng", " ", "functional", "it", "y", ",", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hop", "efu", "ll", "y", ",", " ", "this", " ", "will", " ", "reduce", "d", " ", "code", " ", "redu", "ndancy", "_", "\\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\\u", "init\\u\\u_", "(_", "self_", ",_", "image", "\\u", "filename_", ",_", "border", "Overla", "y", "\\u", "filename_", ",_", "ground", "truth", "\\u", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "image", "\\u", "filename_", "=_", "image", "\\u", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "border", "Overla", "y", "\\u", "filename_", "=_", "border", "Overla", "y", "\\u", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ground", "truth", "\\u", "filename_", "=_", "ground", "truth", "\\u", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "testdir_", "=_", "ila", "sti", "kpa", "th_", "[_", "0_", "]_", "+_", "\"/", "testd", "ata", "/", "automati", "c\\u", "segmentation", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fix", " ", "random", " ", "seed_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ila", "sti", "k_", "._", "core_", "._", "random", "Seed_", "import_", "Random", "Seed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Random", "Seed_", "._", "set", "Random", "Seed_", "(_", "42_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "project_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "project_", "=_", "Project_", "(_", "'", "Project", " ", "Name", "'_", ",_", "'", "Label", "er", "'_", ",_", "'", "Descripti", "on", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data", "Mgr_", "=_", "self_", "._", "project_", "._", "data", "Mgr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "file", " ", "list", " ", "and", " ", "load", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "str_", "(_", "self_", "._", "testdir_", "+_", "self_", "._", "image", "\\u", "filename_", ")_", "#", " ", "the", " ", "image", " ", "is", " ", "not", " ", "reall", "y", " ", "used", " ", "sinc", "e", " ", "we", " ", "load", " ", "the", " ", "threshol", "d", " ", "overlay", " ", "from", " ", "a", " ", "file", ",", " ", "how", "ever", ",", " ", "we", " ", "need", " ", "it", " ", "to", " ", "set", " ", "the", " ", "correct", " ", "dimension", "s", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "List_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "List_", "._", "append_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "project_", "._", "add", "File_", "(_", "file", "List_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "automati", "c", " ", "segmentation", " ", "manager_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "automati", "c", "Segmentation", "Mgr_", "=_", "Automat", "ic", "Segmentation", "Modul", "e", "Mgr_", "(_", "self_", "._", "data", "Mgr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "setup", " ", "inputs_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "input", "Overla", "ys_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Overla", "ys_", "._", "append_", "(_", "self_", "._", "data", "Mgr_", "[_", "self_", "._", "data", "Mgr_", "._", "\\u", "active", "Image", "Number_", "]_", "._", "overlay", "Mgr_", "[_", "\"", "Ra", "w", " ", "Data", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "calcul", "ate", " ", "segmentation", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "...", "import", " ", "border", " ", "indicator_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "border", "\\u", "indicat", "or", "\\u", "ov_", "=_", "data", "Impe", "x_", "._", "Data", "Impe", "x_", "._", "import", "Overla", "y_", "(_", "self_", "._", "data", "Mgr_", "[_", "self_", "._", "data", "Mgr_", "._", "\\u", "active", "Image", "Number_", "]_", ",_", "str_", "(_", "self_", "._", "testdir_", "+_", "border", "Overla", "y", "\\u", "filename_", ")_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input_", "=_", "self_", "._", "border", "\\u", "indicat", "or", "\\u", "ov_", "._", "\\u", "data_", "[_", "0_", ",_", ":_", ",_", ":_", ",_", ":_", ",_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", "normali", "ze", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "input_", "=_", "self_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "normali", "ze", "Pot", "ential_", "(_", "self_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", "invert", " ", "it", " ", "twi", "ce", ",", " ", "this", " ", "shou", "ld", " ", "give", " ", "us", " ", "the", " ", "original", " ", "again", " ", ":-", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "input_", "=_", "self_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "invert", "Pot", "ential_", "(_", "self_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input_", "=_", "self_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "invert", "Pot", "ential_", "(_", "self_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "overlay", " ", "lists", " ", "and", " ", "filenames_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "list", "Of", "Result", "Overla", "ys_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "list", "Of", "File", "names_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "list", "Of", "Result", "Overla", "ys_", "._", "append_", "(_", "\"", "Auto", " ", "Segmentation", "/", "Segmentation", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "list", "Of", "File", "names_", "._", "append_", "(_", "self_", "._", "testdir_", "+_", "self_", "._", "ground", "truth", "\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Test", "Who", "le", "Modul", "e", "Normal", "2", "D_", "(_", "unittest_", "._", "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_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Normal", "2", "D_", "(_", "unittest_", "._", "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_", "#", "print", " ", "\"", "set", "Up", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "=_", "Automat", "ic", "Segmentation", "Test", "Project_", "(_", "\"", "test\\u", "image", "\\u", "gray", ".", "png", "\"_", ",_", "\"", "border", "\\u", "overlay", "\\u", "gauss", "ian", "\\u", "gradi", "ent", "\\u", "magnitude", "\\u", "3.5", ".", "h5", "\"_", ",_", "\"", "gt", "\\u", "automati", "c\\u", "segmentation", "\\u", "normal", ".", "h5", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Normal", "2", "D_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Who", "le", "Module_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "compute", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "compute", "Results_", "(_", "self_", "._", "test", "Project_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", "add", " ", "overlay", "s_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "finalize", "Results_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "obtain", "ed", " ", "=", " ", "self", ".", "test", "Project", ".", "data", "Mgr", "[", "self", ".", "test", "Project", ".", "data", "Mgr", ".\\u", "active", "Image", "Number", "].", "overlay", "Mgr", "[", "self", ".", "test", "Project", ".", "list", "Of", "Result", "Overla", "ys", "[", "0", "]]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "data", "Impe", "x", ".", "Data", "Impe", "x", ".", "export", "Overla", "y", "(\"", "c", ":/", "new", "\\u", "segmentation", "\\u", "result", "\",", " ", "\"", "h5", "\",", " ", "obtain", "ed", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compare", " ", "obtain", "ed", " ", "result", " ", "to", " ", "ground", " ", "truth", " ", "result_", "\\u\\u\\uNL\\u\\u\\u_", "equal", "Overla", "ys_", "=_", "Test", "Help", "er", "Functions_", "._", "compare", "Result", "s", "With", "File_", "(_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "Result", "Overla", "ys_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "File", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equal", "Overla", "ys_", ",_", "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_", "Test", "Who", "le", "Modul", "e", "Invert", "ed", "2", "D_", "(_", "unittest_", "._", "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_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Invert", "ed", "2", "D_", "(_", "unittest_", "._", "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_", "#", "print", " ", "\"", "set", "Up", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "=_", "Automat", "ic", "Segmentation", "Test", "Project_", "(_", "\"", "test\\u", "image", "\\u", "gray", ".", "png", "\"_", ",_", "\"", "border", "\\u", "overlay", "\\u", "laplac", "ian", "\\u", "of", "\\u", "gauss", "ian", "s", "\\u", "3.5", ".", "h5", "\"_", ",_", "\"", "gt", "\\u", "automati", "c\\u", "segmentation", "\\u", "inverted", ".", "h5", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Invert", "ed", "2", "D_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Who", "le", "Module_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "compute", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "compute", "Results_", "(_", "self_", "._", "test", "Project_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", "add", " ", "overlay", "s_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "finalize", "Results_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compare", " ", "obtain", "ed", " ", "result", " ", "to", " ", "ground", " ", "truth", " ", "result_", "\\u\\u\\uNL\\u\\u\\u_", "equal", "Overla", "ys_", "=_", "Test", "Help", "er", "Functions_", "._", "compare", "Result", "s", "With", "File_", "(_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "Result", "Overla", "ys_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "File", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equal", "Overla", "ys_", ",_", "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_", "Test", "Who", "le", "Modul", "e", "Normal", "3", "D_", "(_", "unittest_", "._", "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_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Normal", "3", "D_", "(_", "unittest_", "._", "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_", "._", "test", "Project_", "=_", "Automat", "ic", "Segmentation", "Test", "Project_", "(_", "\"", "neuro", "cube", ".", "h5", "\"_", ",_", "\"", "neuro", "cube", "\\u", "border", "\\u", "overlay", "\\u", "gauss", "ian", "\\u", "gradi", "ent", "\\u", "magnitude", "\\u", "1", ".", "h5", "\"_", ",_", "\"", "neuro", "cube", "\\u", "gt", "\\u", "automati", "c\\u", "segmentation", "\\u", "normal", ".", "h5", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Normal", "3", "D_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Who", "le", "Module_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "compute", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "compute", "Results_", "(_", "self_", "._", "test", "Project_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", "add", " ", "overlay", "s_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "finalize", "Results_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compare", " ", "obtain", "ed", " ", "result", " ", "to", " ", "ground", " ", "truth", " ", "result_", "\\u\\u\\uNL\\u\\u\\u_", "equal", "Overla", "ys_", "=_", "Test", "Help", "er", "Functions_", "._", "compare", "Result", "s", "With", "File_", "(_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "Result", "Overla", "ys_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "File", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equal", "Overla", "ys_", ",_", "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_", "Test", "Who", "le", "Modul", "e", "Invert", "ed", "3", "D_", "(_", "unittest_", "._", "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_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Invert", "ed", "3", "D_", "(_", "unittest_", "._", "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_", "#", "print", " ", "\"", "set", "Up", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "=_", "Automat", "ic", "Segmentation", "Test", "Project_", "(_", "\"", "neuro", "cube", ".", "h5", "\"_", ",_", "\"", "neuro", "cube", "\\u", "border", "\\u", "overlay", "\\u", "laplac", "ian", "\\u", "of", "\\u", "gauss", "ian", "s", "\\u", "1", ".", "h5", "\"_", ",_", "\"", "neuro", "cube", "\\u", "gt", "\\u", "automati", "c\\u", "segmentation", "\\u", "inverted", ".", "h5", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Who", "le", "Modul", "e", "Invert", "ed", "3", "D_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Who", "le", "Module_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "compute", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "compute", "Results_", "(_", "self_", "._", "test", "Project_", "._", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", "add", " ", "overlay", "s_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", "._", "finalize", "Results_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compare", " ", "obtain", "ed", " ", "result", " ", "to", " ", "ground", " ", "truth", " ", "result_", "\\u\\u\\uNL\\u\\u\\u_", "equal", "Overla", "ys_", "=_", "Test", "Help", "er", "Functions_", "._", "compare", "Result", "s", "With", "File_", "(_", "self_", "._", "test", "Project_", "._", "automati", "c", "Segmentation", "Mgr_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "Result", "Overla", "ys_", ",_", "self_", "._", "test", "Project_", "._", "list", "Of", "File", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equal", "Overla", "ys_", ",_", "True_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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"#!/usr/bin/env python\n\n\"\"\"\nUsage:\n tig init\n tig commit <msg>\n tig checkout <start-point> [-b <branch-name>]\n tig diff\n tig log\n tig branch\n tig merge <branch>\n\nOptions:\n -b <branch-name> Branch name to checkout.\n\"\"\"\n\nimport sys\nimport docopt\nimport os\nimport shutil\nimport difflib\nimport hashlib\nimport json\nimport time\nimport tempfile\nimport subprocess\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def __sha1(content):\n sha1sum = hashlib.sha1()\n sha1sum.update(content)\n return sha1sum.hexdigest()", "metadata": "root.__sha1", "header": "['module', '___EOS___']", "index": 28 }, { "content": "def __read_file(filename):\n with open(filename) as my_file:\n return my_file.read()", "metadata": "root.__read_file", "header": "['module', '___EOS___']", "index": 34 }, { "content": "def __write_file(filename, content):\n with open(filename, \"w\") as my_file:\n return my_file.write(content)", "metadata": "root.__write_file", "header": "['module', '___EOS___']", "index": 39 }, { "content": "def __storedb(content):\n sha1sum = __sha1(content)\n __write_file(\".tig/objects/{0}\".format(sha1sum), content)\n return sha1sum", "metadata": "root.__storedb", "header": "['module', '___EOS___']", "index": 44 }, { "content": "def __getdb(sha1sum):\n return __read_file(\".tig/objects/{0}\".format(sha1sum))", "metadata": "root.__getdb", "header": "['module', '___EOS___']", "index": 50 }, { "content": "def __content_from_commit(sha1sum):\n return json.loads(__getdb(sha1sum))[\"content\"]", "metadata": "root.__content_from_commit", "header": "['module', '___EOS___']", "index": 54 }, { "content": "def __get_branches():\n return os.listdir(\".tig/refs/heads\")", "metadata": "root.__get_branches", "header": "['module', '___EOS___']", "index": 58 }, { "content": "def __set_head(rev):\n if rev in __get_branches():\n __write_file(\".tig/HEAD\", \"ref: refs/heads/{0}\".format(rev))\n else:\n __write_file(\".tig/HEAD\", rev)", "metadata": "root.__set_head", "header": "['module', '___EOS___']", "index": 62 }, { "content": "def __get_current_branch():\n head_rev = __read_file(\".tig/HEAD\")\n if head_rev[:4] != \"ref:\":\n return None\n\n branch_path = head_rev[4:].strip()\n branch_name = os.path.basename(branch_path)\n\n return branch_name", "metadata": "root.__get_current_branch", "header": "['module', '___EOS___']", "index": 69 }, { "content": "def __get_head_commit():\n branch = __get_current_branch()\n if branch == None:\n return __read_file(\".tig/HEAD\")\n else:\n return __read_file(\".tig/refs/heads/{0}\".format(branch))", "metadata": "root.__get_head_commit", "header": "['module', '___EOS___']", "index": 80 }, { "content": "def __set_branch_commit(branch, commit_sha1sum):\n __write_file(\".tig/refs/heads/{0}\".format(branch), commit_sha1sum)", "metadata": "root.__set_branch_commit", "header": "['module', '___EOS___']", "index": 88 }, { "content": "def __get_branch_commit(branch):\n return __read_file(\".tig/refs/heads/{0}\".format(branch))", "metadata": "root.__get_branch_commit", "header": "['module', '___EOS___']", "index": 92 }, { "content": "def init():\n os.makedirs(\".tig/objects\")\n os.makedirs(\".tig/refs/heads\")\n \n __set_branch_commit(\"master\", \"0\")\n __set_head(\"master\")", "metadata": "root.init", "header": "['module', '___EOS___']", "index": 96 }, { "content": "def branch():\n current = __get_current_branch()\n for branch in sorted(__get_branches()):\n star = \"*\" if branch == current else \" \"\n print \"{0}{1}\".format(star, branch)", "metadata": "root.branch", "header": "['module', '___EOS___']", "index": 104 }, { "content": "def __create_commit(content_sha1sum, parents, msg):\n sha1sum_commit = __storedb(json.dumps({\n \"content\": content_sha1sum,\n \"parent\": parents,\n \"log-msg\": msg,\n \"author\": os.getenv(\"USER\"),\n \"time\": int(time.time())\n }, indent=4))\n return sha1sum_commit", "metadata": "root.__create_commit", "header": "['module', '___EOS___']", "index": 111 }, { "content": "def commit(msg):\n branch = __get_current_branch()\n if branch == None:\n print \"tig: not at tip\"\n return\n\n master_rev = __get_branch_commit(branch)\n sha1sum_content = __storedb(__read_file(\"file.txt\"))\n sha1sum_commit = __create_commit(sha1sum_content, [master_rev], msg)\n __set_branch_commit(branch, sha1sum_commit)\n\n print sha1sum_commit", "metadata": "root.commit", "header": "['module', '___EOS___']", "index": 122 }, { "content": "def __is_branch(start_point):\n return start_point in __get_branches()", "metadata": "root.__is_branch", "header": "['module', '___EOS___']", "index": 136 }, { "content": "def __commit_from_start_point(start_point):\n if __is_branch(start_point):\n return __get_branch_commit(start_point)\n\n return start_point", "metadata": "root.__commit_from_start_point", "header": "['module', '___EOS___']", "index": 140 }, { "content": "def __update_working_copy(start_point):\n commit_sha1sum = __commit_from_start_point(start_point)\n content_sha1sum = __content_from_commit(commit_sha1sum)\n content = __getdb(content_sha1sum)\n \n __write_file(\"file.txt\", content)\n return commit_sha1sum", "metadata": "root.__update_working_copy", "header": "['module', '___EOS___']", "index": 147 }, { "content": "def checkout(start_point, new_branch):\n commit_sha1sum = __update_working_copy(start_point)\n\n if new_branch is None:\n __set_head(start_point)\n else:\n __set_branch_commit(new_branch, commit_sha1sum)\n __set_head(new_branch)", "metadata": "root.checkout", "header": "['module', '___EOS___']", "index": 155 }, { "content": "def diff():\n commit_sha1sum = __get_head_commit()\n content_sha1sum = __content_from_commit(commit_sha1sum)\n\n orig_content = __getdb(content_sha1sum)\n orig_content = orig_content.splitlines(True)\n\n curr_content = __read_file(\"file.txt\")\n curr_content = curr_content.splitlines(True)\n \n lines = difflib.unified_diff(orig_content, curr_content, \"a/file.txt\", \"b/file.txt\")\n print(\"\".join(lines))", "metadata": "root.diff", "header": "['module', '___EOS___']", "index": 165 }, { "content": "def log():\n commit_sha1sum = __get_head_commit()\n \n while True:\n commit = json.loads(__getdb(commit_sha1sum))\n print commit_sha1sum[:6], commit[\"log-msg\"]\n commit_sha1sum = commit[\"parent\"][0]\n if commit_sha1sum == \"0\":\n break", "metadata": "root.log", "header": "['module', '___EOS___']", "index": 179 }, { "content": "def merge(branch):\n pass", "metadata": "root.merge", "header": "['module', '___EOS___']", "index": 190 }, { "content": "def main():\n args = docopt.docopt(__doc__)\n if args[\"commit\"]:\n commit(args[\"<msg>\"])\n elif args[\"checkout\"]:\n checkout(args[\"<start-point>\"], args[\"-b\"])\n elif args[\"init\"]:\n init()\n elif args[\"diff\"]:\n diff()\n elif args[\"log\"]:\n log()\n elif args[\"branch\"]:\n branch()\n elif args[\"merge\"]:\n merge(args[\"<branch>\"])\n else:\n # Not reached\n pass", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 194 } ]
[ { "span": "import sys", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 10 }, { "span": "import shutil", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 13 }, { "span": "import tempfile", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 15 }, { "span": "import subprocess", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Us", "age", ":", "\\", "10", ";", " ", " ", "tig", " ", "init", "\\", "10", ";", " ", " ", "tig", " ", "commit", " ", "<", "msg", ">", "\\", "10", ";", " ", " ", "tig", " ", "check", "out", " ", "<", "start", "-", "point", ">", " ", "[-", "b", " ", "<", "branch", "-", "name", ">]", "\\", "10", ";", " ", " ", "tig", " ", "diff", "\\", "10", ";", " ", " ", "tig", " ", "log", "\\", "10", ";", " ", " ", "tig", " ", "branch", "\\", "10", ";", " ", " ", "tig", " ", "merge", " ", "<", "branch", ">", "\\", "10", ";", "\\", "10", ";", "Optio", "ns", ":", "\\", "10", ";", " ", " ", "-", "b", " ", "<", "branch", "-", "name", ">", " ", " ", " ", " ", "Branc", "h", " ", "name", " ", "to", " ", "check", "out", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "docopt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "difflib", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\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\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "sha1_", "(_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sha1", "sum_", "=_", "hashlib_", "._", "sha1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sha1", "sum_", "._", "update_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "sha1", "sum_", "._", "hexdigest_", "(_", ")_", "\\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\\u", "read", "\\u", "file_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "filename_", ")_", "as_", "my", "\\u", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "my", "\\u", "file_", "._", "read_", "(_", ")_", "\\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_", "\\u\\u", "write", "\\u", "file_", "(_", "filename_", ",_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "filename_", ",_", "\"", "w", "\"_", ")_", "as_", "my", "\\u", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "my", "\\u", "file_", "._", "write_", "(_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "store", "db_", "(_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sha1", "sum_", "=_", "\\u\\u", "sha1_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "write", "\\u", "file_", "(_", "\".", "tig", "/", "object", "s", "/{", "0", "}\"_", "._", "format_", "(_", "sha1", "sum_", ")_", ",_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "sha1", "sum_", "\\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\\u", "getd", "b_", "(_", "sha1", "sum_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u", "read", "\\u", "file_", "(_", "\".", "tig", "/", "object", "s", "/{", "0", "}\"_", "._", "format_", "(_", "sha1", "sum_", ")_", ")_", "\\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\\u", "content", "\\u", "from", "\\u", "commit_", "(_", "sha1", "sum_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json_", "._", "loads_", "(_", "\\u\\u", "getd", "b_", "(_", "sha1", "sum_", ")_", ")_", "[_", "\"", "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_", "\\u\\u", "get", "\\u", "branches_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "os_", "._", "listdir_", "(_", "\".", "tig", "/", "refs", "/", "head", "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_", "\\u\\u", "set\\u", "head_", "(_", "rev_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "rev_", "in_", "\\u\\u", "get", "\\u", "branches_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "write", "\\u", "file_", "(_", "\".", "tig", "/", "HEAD", "\"_", ",_", "\"", "ref", ":", " ", "refs", "/", "head", "s", "/{", "0", "}\"_", "._", "format_", "(_", "rev_", ")_", ")_", "\\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\\u", "write", "\\u", "file_", "(_", "\".", "tig", "/", "HEAD", "\"_", ",_", "rev_", ")_", "\\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_", "\\u\\u", "get", "\\u", "current", "\\u", "branch_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "head", "\\u", "rev_", "=_", "\\u\\u", "read", "\\u", "file_", "(_", "\".", "tig", "/", "HEAD", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "head", "\\u", "rev_", "[_", ":_", "4_", "]_", "!=_", "\"", "ref", ":\"_", ":_", "\\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_", "branch", "\\u", "path_", "=_", "head", "\\u", "rev_", "[_", "4_", ":_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "branch", "\\u", "name_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "branch", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "branch", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "get", "\\u", "head", "\\u", "commit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "branch_", "=_", "\\u\\u", "get", "\\u", "current", "\\u", "branch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "branch_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u", "read", "\\u", "file_", "(_", "\".", "tig", "/", "HEAD", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u", "read", "\\u", "file_", "(_", "\".", "tig", "/", "refs", "/", "head", "s", "/{", "0", "}\"_", "._", "format_", "(_", "branch_", ")_", ")_", "\\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_", "\\u\\u", "set\\u", "branch", "\\u", "commit_", "(_", "branch_", ",_", "commit", "\\u", "sha1", "sum_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "write", "\\u", "file_", "(_", "\".", "tig", "/", "refs", "/", "head", "s", "/{", "0", "}\"_", "._", "format_", "(_", "branch_", ")_", ",_", "commit", "\\u", "sha1", "sum_", ")_", "\\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\\u", "get", "\\u", "branch", "\\u", "commit_", "(_", "branch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u", "read", "\\u", "file_", "(_", "\".", "tig", "/", "refs", "/", "head", "s", "/{", "0", "}\"_", "._", "format_", "(_", "branch_", ")_", ")_", "\\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_", "init_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "\".", "tig", "/", "object", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "makedirs_", "(_", "\".", "tig", "/", "refs", "/", "head", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "set\\u", "branch", "\\u", "commit_", "(_", "\"", "master", "\"_", ",_", "\"", "0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "set\\u", "head_", "(_", "\"", "master", "\"_", ")_", "\\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_", "branch_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current_", "=_", "\\u\\u", "get", "\\u", "current", "\\u", "branch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "branch_", "in_", "sorted_", "(_", "\\u\\u", "get", "\\u", "branches_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "star_", "=_", "\"*\"_", "if_", "branch_", "==_", "current_", "else_", "\"", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"{", "0", "}{", "1", "}\"_", "._", "format_", "(_", "star_", ",_", "branch_", ")_", "\\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_", "\\u\\u", "create", "\\u", "commit_", "(_", "content", "\\u", "sha1", "sum_", ",_", "parents_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sha1", "sum", "\\u", "commit_", "=_", "\\u\\u", "store", "db_", "(_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "content", "\"_", ":_", "content", "\\u", "sha1", "sum_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parent", "\"_", ":_", "parents_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "log", "-", "msg", "\"_", ":_", "msg_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "author", "\"_", ":_", "os_", "._", "getenv_", "(_", "\"", "USER", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "time", "\"_", ":_", "int_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "indent_", "=_", "4_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "sha1", "sum", "\\u", "commit_", "\\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_", "commit_", "(_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "branch_", "=_", "\\u\\u", "get", "\\u", "current", "\\u", "branch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "branch_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "tig", ":", " ", "not", " ", "at", " ", "tip", "\"_", "\\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_", "master", "\\u", "rev_", "=_", "\\u\\u", "get", "\\u", "branch", "\\u", "commit_", "(_", "branch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sha1", "sum", "\\u", "content_", "=_", "\\u\\u", "store", "db_", "(_", "\\u\\u", "read", "\\u", "file_", "(_", "\"", "file", ".", "txt", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sha1", "sum", "\\u", "commit_", "=_", "\\u\\u", "create", "\\u", "commit_", "(_", "sha1", "sum", "\\u", "content_", ",_", "[_", "master", "\\u", "rev_", "]_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "set\\u", "branch", "\\u", "commit_", "(_", "branch_", ",_", "sha1", "sum", "\\u", "commit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "sha1", "sum", "\\u", "commit_", "\\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\\u", "is", "\\u", "branch_", "(_", "start", "\\u", "point_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "start", "\\u", "point_", "in_", "\\u\\u", "get", "\\u", "branches_", "(_", ")_", "\\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\\u", "commit", "\\u", "from", "\\u", "start", "\\u", "point_", "(_", "start", "\\u", "point_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u\\u", "is", "\\u", "branch_", "(_", "start", "\\u", "point_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u", "get", "\\u", "branch", "\\u", "commit_", "(_", "start", "\\u", "point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "start", "\\u", "point_", "\\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\\u", "update", "\\u", "working", "\\u", "copy_", "(_", "start", "\\u", "point_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commit", "\\u", "sha1", "sum_", "=_", "\\u\\u", "commit", "\\u", "from", "\\u", "start", "\\u", "point_", "(_", "start", "\\u", "point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "sha1", "sum_", "=_", "\\u\\u", "content", "\\u", "from", "\\u", "commit_", "(_", "commit", "\\u", "sha1", "sum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "\\u\\u", "getd", "b_", "(_", "content", "\\u", "sha1", "sum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "write", "\\u", "file_", "(_", "\"", "file", ".", "txt", "\"_", ",_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "commit", "\\u", "sha1", "sum_", "\\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_", "checkout_", "(_", "start", "\\u", "point_", ",_", "new", "\\u", "branch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commit", "\\u", "sha1", "sum_", "=_", "\\u\\u", "update", "\\u", "working", "\\u", "copy_", "(_", "start", "\\u", "point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "new", "\\u", "branch_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "set\\u", "head_", "(_", "start", "\\u", "point_", ")_", "\\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\\u", "set\\u", "branch", "\\u", "commit_", "(_", "new", "\\u", "branch_", ",_", "commit", "\\u", "sha1", "sum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "set\\u", "head_", "(_", "new", "\\u", "branch_", ")_", "\\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_", "diff_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commit", "\\u", "sha1", "sum_", "=_", "\\u\\u", "get", "\\u", "head", "\\u", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "sha1", "sum_", "=_", "\\u\\u", "content", "\\u", "from", "\\u", "commit_", "(_", "commit", "\\u", "sha1", "sum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "orig", "\\u", "content_", "=_", "\\u\\u", "getd", "b_", "(_", "content", "\\u", "sha1", "sum_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orig", "\\u", "content_", "=_", "orig", "\\u", "content_", "._", "splitlines_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "curr", "\\u", "content_", "=_", "\\u\\u", "read", "\\u", "file_", "(_", "\"", "file", ".", "txt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "\\u", "content_", "=_", "curr", "\\u", "content_", "._", "splitlines_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lines_", "=_", "difflib", "_", "._", "unifie", "d\\u", "diff_", "(_", "orig", "\\u", "content_", ",_", "curr", "\\u", "content_", ",_", "\"", "a", "/", "file", ".", "txt", "\"_", ",_", "\"", "b", "/", "file", ".", "txt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"\"_", "._", "join_", "(_", "lines_", ")_", ")_", "\\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_", "log_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commit", "\\u", "sha1", "sum_", "=_", "\\u\\u", "get", "\\u", "head", "\\u", "commit_", "(_", ")_", "\\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 ", " _", "commit_", "=_", "json_", "._", "loads_", "(_", "\\u\\u", "getd", "b_", "(_", "commit", "\\u", "sha1", "sum_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "commit", "\\u", "sha1", "sum_", "[_", ":_", "6_", "]_", ",_", "commit_", "[_", "\"", "log", "-", "msg", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "commit", "\\u", "sha1", "sum_", "=_", "commit_", "[_", "\"", "parent", "\"_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "commit", "\\u", "sha1", "sum_", "==_", "\"", "0", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\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_", "merge_", "(_", "branch_", ")_", ":_", "\\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_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "docopt_", "._", "docopt_", "(_", "\\u\\u", "doc\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "[_", "\"", "commit", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commit_", "(_", "args_", "[_", "\"<", "msg", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "args_", "[_", "\"", "check", "out", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checkout_", "(_", "args_", "[_", "\"<", "start", "-", "point", ">\"_", "]_", ",_", "args_", "[_", "\"-", "b", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "args_", "[_", "\"", "init", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "args_", "[_", "\"", "diff", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "diff_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "args_", "[_", "\"", "log", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "args_", "[_", "\"", "branch", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "branch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "args_", "[_", "\"", "merge", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "merge_", "(_", "args_", "[_", "\"<", "branch", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", " ", "reache", "d_", "\\u\\u\\uNL\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 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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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 ]
Unused import
saga-project/BigJob/examples/pilot-api/example-pilot-compute-direct.py
[ { "content": "import sys\nimport os\nimport time\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n\nsys.path.append(os.path.join(os.path.dirname(__file__), \"../..\"))\nfrom pilot import PilotComputeService, ComputeDataService, State\n\nCOORDINATION_URL = \"redis://localhost:6379\"\n\nif __name__ == \"__main__\": \n \n pilot_compute_service = PilotComputeService(coordination_url=COORDINATION_URL)\n\n # create pilot job service and initiate a pilot job\n pilot_compute_description = {\n \"service_url\": 'fork://localhost',\n \"number_of_processes\": 1, \n #\"working_directory\": os.path.join(os.getcwd(), \"agent\"),\n #\"file_transfer\": [\"ssh://\" + os.path.dirname(os.path.abspath(__file__)) \n # + \"/../test.txt > BIGJOB_WORK_DIR\"]\n }\n \n pilotjob = pilot_compute_service.create_pilot(pilot_compute_description=pilot_compute_description)\n \n # start compute unit\n compute_unit_description = {\n \"executable\": \"/bin/echo\",\n \"arguments\": [\"$TBD_DIR\"],\n \"number_of_processes\": 1,\n \"environment\": [\"TBD_DIR=/tmp\"],\n \"output\": \"stdout.txt\",\n \"error\": \"stderr.txt\", \n \"file_transfer\": [\"ssh://\" + os.path.dirname(os.path.abspath(__file__)) \n + \"/../test.txt > BIGJOB_WORK_DIR\"]\n } \n \n compute_unit = pilotjob.submit_compute_unit(compute_unit_description)\n logging.debug(\"Finished submission. Waiting for completion of CU\")\n compute_unit.wait()\n \n print str(compute_unit.get_details())\n \n logging.debug(\"Terminate Pilot Compute Service\")\n pilot_compute_service.cancel()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import time", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 11 }, { "span": "from pilot import PilotComputeService, ComputeDataService, State", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 64 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "basic", "Config_", "(_", "level_", "=_", "logging_", "._", "DEBUG_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "\"../..", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pilot", "_", "import_", "Pilo", "t", "Compute", "Service_", ",_", "Compute", "Data", "Service_", ",_", "State_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "COORD", "INATION", "\\u", "URL_", "=_", "\"", "redis", "://", "local", "host", ":", "6379", "\"_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pilot", "\\u", "compute", "\\u", "service_", "=_", "Pilo", "t", "Compute", "Service_", "(_", "coordin", "ation", "\\u", "url_", "=_", "COORD", "INATION", "\\u", "URL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "pilot", " ", "job", " ", "service", " ", "and", " ", "initiate", " ", "a", " ", "pilot", " ", "job_", "\\u\\u\\uNL\\u\\u\\u_", "pilot", "\\u", "compute", "\\u", "description_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "service", "\\u", "url", "\"_", ":_", "'", "fork", "://", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "number", "\\u", "of", "\\u", "process", "es", "\"_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "working", "\\u", "director", "y", "\":", " ", "os", ".", "path", ".", "join", "(", "os", ".", "getc", "wd", "()", ",", " ", "\"", "agent", "\")", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "file", "\\u", "transfer", "\":", " ", "[\"", "ssh", "://", "\"", " ", "+", " ", "os", ".", "path", ".", "dir", "name", "(", "os", ".", "path", ".", "abs", "path", "(\\u", "\\u", "file", "\\u\\u)", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", "+", " ", "\"/.", "./", "test", ".", "txt", " ", ">", " ", "BIG", "JOB", "\\u", "WORK", "\\u", "DIR", "\"]", "_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pilot", "job_", "=_", "pilot", "\\u", "compute", "\\u", "service_", "._", "create", "\\u", "pilot", "_", "(_", "pilot", "\\u", "compute", "\\u", "description_", "=_", "pilot", "\\u", "compute", "\\u", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "start", " ", "compute", " ", "unit_", "\\u\\u\\uNL\\u\\u\\u_", "compute", "\\u", "unit", "\\u", "description_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "executable", "\"_", ":_", "\"/", "bin", "/", "echo", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "argu", "ment", "s", "\"_", ":_", "[_", "\"$", "TB", "D", "\\u", "DIR", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "number", "\\u", "of", "\\u", "process", "es", "\"_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "environ", "ment", "\"_", ":_", "[_", "\"", "TB", "D", "\\u", "DIR", "=", "/", "tmp", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "output", "\"_", ":_", "\"", "stdout", ".", "txt", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "error", "\"_", ":_", "\"", "std", "err", ".", "txt", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "file", "\\u", "transfer", "\"_", ":_", "[_", "\"", "ssh", "://\"_", "+_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "\"/.", "./", "test", ".", "txt", " ", ">", " ", "BIG", "JOB", "\\u", "WORK", "\\u", "DIR", "\"_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "compute", "\\u", "unit_", "=_", "pilot", "job_", "._", "submit", "\\u", "compute", "\\u", "unit_", "(_", "compute", "\\u", "unit", "\\u", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "\"", "Finish", "ed", " ", "subm", "ission", ".", " ", "Wait", "ing", " ", "for", " ", "completion", " ", "of", " ", "CU", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compute", "\\u", "unit_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "str_", "(_", "compute", "\\u", "unit_", "._", "get", "\\u", "details_", "(_", ")_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
stanford-gfx/Horus/Code/flashlight/quadrotor2d.py
[ { "content": "from pylab import *\n\nimport matplotlib.animation\nimport scipy.interpolate\nimport scipy.integrate\nimport sklearn\nimport sklearn.preprocessing\nimport control\nimport transformations\nimport sympy\nimport sympy.matrices\nimport sympy.physics\nimport sympy.physics.mechanics\nimport sympy.physics.mechanics.functions\nimport trigutils\nimport sympyutils\nimport pathutils\n\n\n\nm = 1.0 # mass\ng = 9.8 # gravity\nd = 1.0 # distance from arm to center\nI = m*d**2.0 # moment of intertia\n\nf_gravity_world = matrix([-m*g,0]).T\nf_external_world = f_gravity_world\n\nconstruct_sympy_expressions = False\n\n\n\nif construct_sympy_expressions:\n\n print \"Constructing sympy symbols...\"\n\n d_expr = sympy.Symbol(\"d\")\n m_expr = sympy.Symbol(\"m\")\n I_expr = sympy.Symbol(\"I\")\n\n f_external_expr, f_external_expr_entries = sympyutils.construct_matrix_and_entries(\"f_e\",(2,1))\n\n t_expr = sympy.Symbol(\"t\")\n\n p_y_expr = sympy.physics.mechanics.dynamicsymbols(\"p_y\")\n p_x_expr = sympy.physics.mechanics.dynamicsymbols(\"p_x\")\n theta_expr = sympy.physics.mechanics.dynamicsymbols(\"theta\")\n\n q_expr = sympy.Matrix([p_y_expr,p_x_expr,theta_expr])\n q_dot_expr = q_expr.diff(t_expr)\n\n u_expr, u_expr_entries = sympyutils.construct_matrix_and_entries(\"u\",(2,1))\n\n print \"Constructing sympy expressions...\"\n\n H_00_expr = sympy.Matrix(m_expr*sympy.eye(2))\n H_01_expr = sympy.Matrix.zeros(2,1)\n H_10_expr = sympy.Matrix.zeros(1,2)\n H_11_expr = sympy.Matrix([I_expr])\n\n C_00_expr = sympy.Matrix.zeros(2,2)\n C_01_expr = sympy.Matrix.zeros(2,1)\n C_10_expr = sympy.Matrix.zeros(1,2)\n C_11_expr = sympy.Matrix.zeros(1,1)\n\n G_0_expr = -f_external_expr\n G_1_expr = sympy.Matrix.zeros(1,1)\n\n B_0_expr = sympy.Matrix( [ [sympy.cos(theta_expr),sympy.cos(theta_expr)], [-sympy.sin(theta_expr),-sympy.sin(theta_expr)] ] )\n B_1_expr = sympy.Matrix( [ [-d_expr,d_expr] ] )\n\n H_expr = sympyutils.construct_matrix_from_block_matrix( sympy.Matrix( [ [H_00_expr, H_01_expr], [H_10_expr, H_11_expr] ] ) )\n C_expr = sympyutils.construct_matrix_from_block_matrix( sympy.Matrix( [ [C_00_expr, C_01_expr], [C_10_expr, C_11_expr] ] ) )\n G_expr = sympyutils.construct_matrix_from_block_matrix( sympy.Matrix( [ [G_0_expr], [G_1_expr] ] ) )\n B_expr = sympyutils.construct_matrix_from_block_matrix( sympy.Matrix( [ [B_0_expr], [B_1_expr] ] ) )\n\n q_dot_dot_expr = H_expr.inv()*(B_expr*u_expr - (C_expr*q_dot_expr + G_expr))\n\n dqdotdot_dq_expr = q_dot_dot_expr.jacobian(q_expr)\n dqdotdot_dqdot_expr = q_dot_dot_expr.jacobian(q_dot_expr)\n\n const_syms = hstack( [ d_expr, m_expr, I_expr, matrix(f_external_expr).A1 ] )\n x_and_u_syms = hstack( [ matrix(q_expr).A1, matrix(q_dot_expr).A1, matrix(u_expr).A1 ] )\n\n print \"Substituting physical constants into sympy expressions...\"\n\n const_vals = hstack( [ d, m, I, f_external_world.A1 ] )\n const_subs = dict(zip(const_syms,const_vals))\n\n dqdotdot_dq_expr = sympyutils.nsimplify_matrix(dqdotdot_dq_expr.subs(const_subs))\n dqdotdot_dqdot_expr = sympyutils.nsimplify_matrix(dqdotdot_dqdot_expr.subs(const_subs))\n\n print \"Dummifying sympy expressions...\"\n\n dqdotdot_dq_expr_dummy, dqdotdot_dq_expr_dummy_syms = sympyutils.dummify(dqdotdot_dq_expr, x_and_u_syms)\n dqdotdot_dqdot_expr_dummy, dqdotdot_dqdot_expr_dummy_syms = sympyutils.dummify(dqdotdot_dqdot_expr,x_and_u_syms)\n\n print \"Saving sympy expressions...\"\n\n current_source_file_path = pathutils.get_current_source_file_path()\n\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dq_expr_dummy.dat\", \"w\") as f: f.write(sympy.srepr(dqdotdot_dq_expr_dummy))\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dqdot_expr_dummy.dat\", \"w\") as f: f.write(sympy.srepr(dqdotdot_dqdot_expr_dummy))\n\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dq_expr_dummy_syms.dat\", \"w\") as f: f.write(sympy.srepr(sympy.Matrix(dqdotdot_dq_expr_dummy_syms)))\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dqdot_expr_dummy_syms.dat\", \"w\") as f: f.write(sympy.srepr(sympy.Matrix(dqdotdot_dqdot_expr_dummy_syms)))\n\nelse:\n\n print \"Loading sympy expressions...\"\n\n current_source_file_path = pathutils.get_current_source_file_path()\n\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dq_expr_dummy.dat\", \"r\") as f: dqdotdot_dq_expr_dummy = sympy.sympify(f.read())\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dqdot_expr_dummy.dat\", \"r\") as f: dqdotdot_dqdot_expr_dummy = sympy.sympify(f.read())\n\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dq_expr_dummy_syms.dat\", \"r\") as f: dqdotdot_dq_expr_dummy_syms = array(sympy.sympify(f.read())).squeeze()\n with open(current_source_file_path+\"/data/sympy/quadrotor2d_dqdotdot_dqdot_expr_dummy_syms.dat\", \"r\") as f: dqdotdot_dqdot_expr_dummy_syms = array(sympy.sympify(f.read())).squeeze()\n\nprint \"Compiling sympy functions...\"\n\ndqdotdot_dq_anon_funcs_ufuncify = sympyutils.construct_matrix_anon_funcs_ufuncify(dqdotdot_dq_expr_dummy, dqdotdot_dq_expr_dummy_syms)\ndqdotdot_dqdot_anon_funcs_ufuncify = sympyutils.construct_matrix_anon_funcs_ufuncify(dqdotdot_dqdot_expr_dummy, dqdotdot_dqdot_expr_dummy_syms)\n\nprint \"Finished compiling sympy functions.\"\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 unpack_state(x):\n\n p = matrix( [ x.item(0), x.item(1) ] ).T\n theta = x.item(2)\n p_dot = matrix( [ x.item(3), x.item(4) ] ).T\n theta_dot = x.item(5)\n q = matrix( [ p.item(0), p.item(1), theta ] ).T\n q_dot = matrix( [ p_dot.item(0), p_dot.item(1), theta_dot ] ).T\n\n return p, theta, p_dot, theta_dot, q, q_dot", "metadata": "root.unpack_state", "header": "['module', '___EOS___']", "index": 128 }, { "content": "def compute_manipulator_matrices(x):\n\n p, theta, p_dot, theta_dot, q, q_dot = unpack_state(x)\n\n H_00 = matrix(m*identity(2))\n H_01 = matrix(zeros((2,1)))\n H_10 = matrix(zeros((1,2)))\n H_11 = matrix(I)\n\n C_00 = matrix(zeros((2,2)))\n C_01 = matrix(zeros((2,1)))\n C_10 = matrix(zeros((1,2)))\n C_11 = matrix(zeros((1,1)))\n\n G_0 = -f_external_world\n G_1 = matrix(zeros((1,1)))\n\n B_0 = matrix( [ [cos(theta),cos(theta)], [-sin(theta),-sin(theta)] ] )\n B_1 = matrix( [ [-d,d] ] )\n\n H = bmat( [ [H_00, H_01], [H_10, H_11] ] )\n C = bmat( [ [C_00, C_01], [C_10, C_11] ] )\n G = bmat( [ [G_0], [G_1] ] )\n B = bmat( [ [B_0], [B_1] ] )\n\n return H, C, G, B", "metadata": "root.compute_manipulator_matrices", "header": "['module', '___EOS___']", "index": 141 }, { "content": "def compute_manipulator_matrix_derivatives(x,u):\n\n p, theta, p_dot, theta_dot, q, q_dot = unpack_state(x)\n\n x_and_u_vals = hstack( [ q.A1, q_dot.A1, u.A1 ] )\n\n # slow\n # x_and_u_subs = dict(zip(x_and_u_syms,x_and_u_vals))\n # dqdotdot_dq = dqdotdot_dq_expr.subs(x_and_u_subs).evalf()\n # dqdotdot_dqdot = dqdotdot_dqdot_expr.subs(x_and_u_subs).evalf()\n\n # fast\n dqdotdot_dq = matrix(sympyutils.evaluate_matrix_anon_funcs( dqdotdot_dq_anon_funcs_ufuncify, x_and_u_vals[newaxis,:] ))\n dqdotdot_dqdot = matrix(sympyutils.evaluate_matrix_anon_funcs( dqdotdot_dqdot_anon_funcs_ufuncify, x_and_u_vals[newaxis,:] ))\n\n return dqdotdot_dq, dqdotdot_dqdot", "metadata": "root.compute_manipulator_matrix_derivatives", "header": "['module', '___EOS___']", "index": 170 }, { "content": "def compute_df_dx_and_df_du(x,u):\n\n H, C, G, B = compute_manipulator_matrices(x)\n dqdotdot_dq, dqdotdot_dqdot = compute_manipulator_matrix_derivatives(x,u)\n\n dqdot_dq = matrix(zeros((3,3)))\n dqdot_dqdot = matrix(identity(3))\n dqdotdot_dq = dqdotdot_dq\n dqdotdot_dqdot = dqdotdot_dqdot\n\n dqdot_du = matrix(zeros((3,2)))\n dqdotdot_du = H.I*B\n\n df_dx = bmat( [ [ dqdot_dq, dqdot_dqdot ], [ dqdotdot_dq, dqdotdot_dqdot ] ] )\n df_du = bmat( [ [ dqdot_du ], [ dqdotdot_du ] ] )\n\n return df_dx, df_du", "metadata": "root.compute_df_dx_and_df_du", "header": "['module', '___EOS___']", "index": 189 }, { "content": "def compute_x_dot(x,u):\n\n p, theta, p_dot, theta_dot, q, q_dot = unpack_state(x)\n H, C, G, B = compute_manipulator_matrices(x)\n\n f1 = H.I*(-G-C*q_dot)\n f2 = H.I*B\n \n q_dot_dot = f1 + f2*u\n\n x_dot = bmat([[q_dot],[q_dot_dot]])\n\n return x_dot", "metadata": "root.compute_x_dot", "header": "['module', '___EOS___']", "index": 209 }, { "content": "def compute_state_space_trajectory_and_derivatives(p,dt):\n\n f_thrust_world_norm_threshold = 0.01\n\n num_timesteps = len(p)\n\n p_dot = c_[gradient(p[:,0],dt),gradient(p[:,1],dt)]\n p_dot_dot = c_[gradient(p_dot[:,0],dt),gradient(p_dot[:,1],dt)]\n f_thrust_world = m*p_dot_dot - f_external_world.T.A\n\n f_thrust_world_norm = linalg.norm(f_thrust_world,axis=1)\n\n theta_raw = arctan2(f_thrust_world[:,0],f_thrust_world[:,1]) - (pi/2.0)\n t_tmp = arange(num_timesteps)\n theta_func = scipy.interpolate.interp1d(t_tmp[f_thrust_world_norm > f_thrust_world_norm_threshold], theta_raw[f_thrust_world_norm > f_thrust_world_norm_threshold], kind=\"linear\")\n theta = theta_func(t_tmp)\n\n theta = trigutils.compute_continuous_angle_array(theta)\n theta_dot = gradient(theta,dt)\n theta_dot_dot = gradient(theta_dot,dt)\n\n return p, p_dot, p_dot_dot, theta, theta_dot, theta_dot_dot", "metadata": "root.compute_state_space_trajectory_and_derivatives", "header": "['module', '___EOS___']", "index": 225 }, { "content": "def compute_control_trajectory(q_q_dot_q_dot_dot):\n\n p, p_dot, p_dot_dot, theta, theta_dot, theta_dot_dot = q_q_dot_q_dot_dot\n\n num_timesteps = len(p)\n \n u = zeros((num_timesteps,2))\n\n for ti in range(int(num_timesteps)):\n\n q_ti = matrix( [ p[ti,0], p[ti,1], theta[ti] ] ).T\n q_dot_ti = matrix( [ p_dot[ti,0], p_dot[ti,1], theta_dot[ti] ] ).T\n q_dot_dot_ti = matrix( [ p_dot_dot[ti,0], p_dot_dot[ti,1], theta_dot_dot[ti] ] ).T\n x_ti = bmat( [[q_ti], [q_dot_ti]] )\n\n H, C, G, B = compute_manipulator_matrices(x_ti)\n\n f1 = H.I*(-G-C*q_dot_ti)\n f2 = H.I*B\n f2_pinv = linalg.pinv(f2)\n u_ti = f2_pinv*(q_dot_dot_ti - f1)\n u[ti,:] = u_ti.T\n\n return u", "metadata": "root.compute_control_trajectory", "header": "['module', '___EOS___']", "index": 250 } ]
[ { "span": "import matplotlib.animation", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 27 }, { "span": "import sklearn", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 14 }, { "span": "import sklearn.preprocessing", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 28 }, { "span": "import control", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 14 }, { "span": "import transformations", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 22 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "pylab_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "matplotlib_", "._", "animation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "scipy_", "._", "interpolate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "scipy_", "._", "integrate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sklearn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sklearn_", "._", "preprocessing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "control_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "transformations_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sympy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sympy_", "._", "matrices_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sympy_", "._", "physics_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sympy_", "._", "physics_", "._", "mechani", "cs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sympy_", "._", "physics_", "._", "mechani", "cs_", "._", "functions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "trig", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "symp", "yu", "tils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "path", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "=_", "1.0_", "#", " ", "mass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "9.8", "_", "#", " ", "gravity", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "1.0_", "#", " ", "distance", " ", "from", " ", "arm", " ", "to", " ", "center_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "I_", "=_", "m_", "*_", "d_", "**_", "2.0_", "#", " ", "moment", " ", "of", " ", "inter", "tia", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f", "\\u", "gravity", "\\u", "world_", "=_", "matrix_", "(_", "[_", "-_", "m_", "*_", "g_", ",_", "0_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "\\u", "external", "\\u", "world_", "=_", "f", "\\u", "gravity", "\\u", "world_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "construct", "\\u", "symp", "y", "\\u", "expressions_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "construct", "\\u", "symp", "y", "\\u", "expressions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Construct", "ing", " ", "symp", "y", " ", "symbols", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "d\\u", "expr_", "=_", "sympy_", "._", "Symbol_", "(_", "\"", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m", "\\u", "expr_", "=_", "sympy_", "._", "Symbol_", "(_", "\"", "m", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "I", "\\u", "expr_", "=_", "sympy_", "._", "Symbol_", "(_", "\"", "I", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f", "\\u", "external", "\\u", "expr_", ",_", "f", "\\u", "external", "\\u", "expr", "\\u", "entries_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "and", "\\u", "entries_", "(_", "\"", "f", "\\u", "e", "\"_", ",_", "(_", "2_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t", "\\u", "expr_", "=_", "sympy_", "._", "Symbol_", "(_", "\"", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "\\u", "y", "\\u", "expr_", "=_", "sympy_", "._", "physics_", "._", "mechani", "cs_", "._", "dynamics", "ymbo", "ls_", "(_", "\"", "p", "\\u", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "x", "\\u", "expr_", "=_", "sympy_", "._", "physics_", "._", "mechani", "cs_", "._", "dynamics", "ymbo", "ls_", "(_", "\"", "p", "\\u", "x", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta", "\\u", "expr_", "=_", "sympy_", "._", "physics_", "._", "mechani", "cs_", "._", "dynamics", "ymbo", "ls_", "(_", "\"", "theta", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "q", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "(_", "[_", "p", "\\u", "y", "\\u", "expr_", ",_", "p", "\\u", "x", "\\u", "expr_", ",_", "theta", "\\u", "expr_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q", "\\u", "dot", "\\u", "expr_", "=_", "q", "\\u", "expr_", "._", "diff_", "(_", "t", "\\u", "expr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "u\\u", "expr_", ",_", "u\\u", "expr", "\\u", "entries_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "and", "\\u", "entries_", "(_", "\"", "u", "\"_", ",_", "(_", "2_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "Construct", "ing", " ", "symp", "y", " ", "express", "ion", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "H", "\\u", "00", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "(_", "m", "\\u", "expr_", "*_", "sympy_", "._", "eye_", "(_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H", "\\u", "01", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "2_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H", "\\u", "10", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "1_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H", "\\u", "11", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "(_", "[_", "I", "\\u", "expr_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "C", "\\u", "00", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "2_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "01", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "2_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "10", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "1_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "11", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "G", "\\u", "0", "\\u", "expr_", "=_", "-_", "f", "\\u", "external", "\\u", "expr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G", "\\u", "1", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "._", "zeros_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "B", "\\u", "0", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "(_", "[_", "[_", "sympy_", "._", "cos_", "(_", "theta", "\\u", "expr_", ")_", ",_", "sympy_", "._", "cos_", "(_", "theta", "\\u", "expr_", ")_", "]_", ",_", "[_", "-_", "sympy_", "._", "sin_", "(_", "theta", "\\u", "expr_", ")_", ",_", "-_", "sympy_", "._", "sin_", "(_", "theta", "\\u", "expr_", ")_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B", "\\u", "1", "\\u", "expr_", "=_", "sympy_", "._", "Matrix_", "(_", "[_", "[_", "-_", "d\\u", "expr_", ",_", "d\\u", "expr_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "H", "\\u", "expr_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "from", "\\u", "block", "\\u", "matrix_", "(_", "sympy_", "._", "Matrix_", "(_", "[_", "[_", "H", "\\u", "00", "\\u", "expr_", ",_", "H", "\\u", "01", "\\u", "expr_", "]_", ",_", "[_", "H", "\\u", "10", "\\u", "expr_", ",_", "H", "\\u", "11", "\\u", "expr_", "]_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "expr_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "from", "\\u", "block", "\\u", "matrix_", "(_", "sympy_", "._", "Matrix_", "(_", "[_", "[_", "C", "\\u", "00", "\\u", "expr_", ",_", "C", "\\u", "01", "\\u", "expr_", "]_", ",_", "[_", "C", "\\u", "10", "\\u", "expr_", ",_", "C", "\\u", "11", "\\u", "expr_", "]_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G", "\\u", "expr_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "from", "\\u", "block", "\\u", "matrix_", "(_", "sympy_", "._", "Matrix_", "(_", "[_", "[_", "G", "\\u", "0", "\\u", "expr_", "]_", ",_", "[_", "G", "\\u", "1", "\\u", "expr_", "]_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B", "\\u", "expr_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "from", "\\u", "block", "\\u", "matrix_", "(_", "sympy_", "._", "Matrix_", "(_", "[_", "[_", "B", "\\u", "0", "\\u", "expr_", "]_", ",_", "[_", "B", "\\u", "1", "\\u", "expr_", "]_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "q", "\\u", "dot", "\\u", "dot", "\\u", "expr_", "=_", "H", "\\u", "expr_", "._", "inv_", "(_", ")_", "*_", "(_", "B", "\\u", "expr_", "*_", "u\\u", "expr_", "-_", "(_", "C", "\\u", "expr_", "*_", "q", "\\u", "dot", "\\u", "expr_", "+_", "G", "\\u", "expr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr_", "=_", "q", "\\u", "dot", "\\u", "dot", "\\u", "expr_", "._", "jacobian", "_", "(_", "q", "\\u", "expr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr_", "=_", "q", "\\u", "dot", "\\u", "dot", "\\u", "expr_", "._", "jacobian", "_", "(_", "q", "\\u", "dot", "\\u", "expr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "const", "\\u", "syms_", "=_", "hstack_", "(_", "[_", "d\\u", "expr_", ",_", "m", "\\u", "expr_", ",_", "I", "\\u", "expr_", ",_", "matrix_", "(_", "f", "\\u", "external", "\\u", "expr_", ")_", "._", "A1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "\\u", "and", "\\u", "u\\u", "syms_", "=_", "hstack_", "(_", "[_", "matrix_", "(_", "q", "\\u", "expr_", ")_", "._", "A1_", ",_", "matrix_", "(_", "q", "\\u", "dot", "\\u", "expr_", ")_", "._", "A1_", ",_", "matrix_", "(_", "u\\u", "expr_", ")_", "._", "A1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "Substituti", "ng", " ", "physical", " ", "constant", "s", " ", "int", "o", " ", "symp", "y", " ", "express", "ion", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "const", "\\u", "vals_", "=_", "hstack_", "(_", "[_", "d_", ",_", "m_", ",_", "I_", ",_", "f", "\\u", "external", "\\u", "world_", "._", "A1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "const", "\\u", "subs_", "=_", "dict_", "(_", "zip_", "(_", "const", "\\u", "syms_", ",_", "const", "\\u", "vals_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr_", "=_", "symp", "yu", "tils_", "._", "nsi", "mpli", "fy", "\\u", "matrix_", "(_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr_", "._", "subs_", "(_", "const", "\\u", "subs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr_", "=_", "symp", "yu", "tils_", "._", "nsi", "mpli", "fy", "\\u", "matrix_", "(_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr_", "._", "subs_", "(_", "const", "\\u", "subs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "Du", "mmi", "fy", "ing", " ", "symp", "y", " ", "express", "ion", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy_", ",_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", "=_", "symp", "yu", "tils_", "._", "dum", "mi", "fy_", "(_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr_", ",_", "x", "\\u", "and", "\\u", "u\\u", "syms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy_", ",_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", "=_", "symp", "yu", "tils_", "._", "dum", "mi", "fy_", "(_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr_", ",_", "x", "\\u", "and", "\\u", "u\\u", "syms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "Sav", "ing", " ", "symp", "y", " ", "express", "ion", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "=_", "path", "utils_", "._", "get", "\\u", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", ".", "dat", "\"_", ",_", "\"", "w", "\"_", ")_", "as_", "f_", ":_", "f_", "._", "write_", "(_", "sympy_", "._", "sre", "pr_", "(_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", ".", "dat", "\"_", ",_", "\"", "w", "\"_", ")_", "as_", "f_", ":_", "f_", "._", "write_", "(_", "sympy_", "._", "sre", "pr_", "(_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", "\\u", "sym", "s", ".", "dat", "\"_", ",_", "\"", "w", "\"_", ")_", "as_", "f_", ":_", "f_", "._", "write_", "(_", "sympy_", "._", "sre", "pr_", "(_", "sympy_", "._", "Matrix_", "(_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", "\\u", "sym", "s", ".", "dat", "\"_", ",_", "\"", "w", "\"_", ")_", "as_", "f_", ":_", "f_", "._", "write_", "(_", "sympy_", "._", "sre", "pr_", "(_", "sympy_", "._", "Matrix_", "(_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Load", "ing", " ", "symp", "y", " ", "express", "ion", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "=_", "path", "utils_", "._", "get", "\\u", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", ".", "dat", "\"_", ",_", "\"", "r", "\"_", ")_", "as_", "f_", ":_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy_", "=_", "sympy_", "._", "symp", "ify_", "(_", "f_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", ".", "dat", "\"_", ",_", "\"", "r", "\"_", ")_", "as_", "f_", ":_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy_", "=_", "sympy_", "._", "symp", "ify_", "(_", "f_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", "\\u", "sym", "s", ".", "dat", "\"_", ",_", "\"", "r", "\"_", ")_", "as_", "f_", ":_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", "=_", "array_", "(_", "sympy_", "._", "symp", "ify_", "(_", "f_", "._", "read_", "(_", ")_", ")_", ")_", "._", "squeeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "current", "\\u", "source", "\\u", "file", "\\u", "path_", "+_", "\"/", "data", "/", "symp", "y", "/", "quadr", "oto", "r2", "d\\u", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", "\\u", "sym", "s", ".", "dat", "\"_", ",_", "\"", "r", "\"_", ")_", "as_", "f_", ":_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", "=_", "array_", "(_", "sympy_", "._", "symp", "ify_", "(_", "f_", "._", "read_", "(_", ")_", ")_", ")_", "._", "squeeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\"", "Compil", "ing", " ", "symp", "y", " ", "function", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "\\u", "anon", "\\u", "funcs", "\\u", "ufunc", "ify_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "anon", "\\u", "funcs", "\\u", "ufunc", "ify_", "(_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy_", ",_", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "anon", "\\u", "funcs", "\\u", "ufunc", "ify_", "=_", "symp", "yu", "tils_", "._", "construct", "\\u", "matrix", "\\u", "anon", "\\u", "funcs", "\\u", "ufunc", "ify_", "(_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy_", ",_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", "\\u", "dummy", "\\u", "syms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "Finish", "ed", " ", "compil", "ing", " ", "symp", "y", " ", "function", "s", ".\"_", "\\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\\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\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "unpack", "\\u", "state_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "matrix_", "(_", "[_", "x_", "._", "item_", "(_", "0_", ")_", ",_", "x_", "._", "item_", "(_", "1_", ")_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta_", "=_", "x_", "._", "item_", "(_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "dot_", "=_", "matrix_", "(_", "[_", "x_", "._", "item_", "(_", "3_", ")_", ",_", "x_", "._", "item_", "(_", "4_", ")_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta", "\\u", "dot_", "=_", "x_", "._", "item_", "(_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "matrix_", "(_", "[_", "p_", "._", "item_", "(_", "0_", ")_", ",_", "p_", "._", "item_", "(_", "1_", ")_", ",_", "theta_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q", "\\u", "dot_", "=_", "matrix_", "(_", "[_", "p", "\\u", "dot_", "._", "item_", "(_", "0_", ")_", ",_", "p", "\\u", "dot_", "._", "item_", "(_", "1_", ")_", ",_", "theta", "\\u", "dot_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "p_", ",_", "theta_", ",_", "p", "\\u", "dot_", ",_", "theta", "\\u", "dot_", ",_", "q_", ",_", "q", "\\u", "dot_", "\\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_", "compute", "\\u", "manip", "ulator", "\\u", "matrices_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", ",_", "theta_", ",_", "p", "\\u", "dot_", ",_", "theta", "\\u", "dot_", ",_", "q_", ",_", "q", "\\u", "dot_", "=_", "unpack", "\\u", "state_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "H", "\\u", "00_", "=_", "matrix_", "(_", "m_", "*_", "identity_", "(_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H", "\\u", "01_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "2_", ",_", "1_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H", "\\u", "10_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "1_", ",_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H", "\\u", "11_", "=_", "matrix_", "(_", "I_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "C", "\\u", "00_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "2_", ",_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "01_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "2_", ",_", "1_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "10_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "1_", ",_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C", "\\u", "11_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "1_", ",_", "1_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "G", "\\u", "0_", "=_", "-_", "f", "\\u", "external", "\\u", "world_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G", "\\u", "1_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "1_", ",_", "1_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "B", "\\u", "0_", "=_", "matrix_", "(_", "[_", "[_", "cos_", "(_", "theta_", ")_", ",_", "cos_", "(_", "theta_", ")_", "]_", ",_", "[_", "-_", "sin_", "(_", "theta_", ")_", ",_", "-_", "sin_", "(_", "theta_", ")_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B", "\\u", "1_", "=_", "matrix_", "(_", "[_", "[_", "-_", "d_", ",_", "d_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "H_", "=_", "bma", "t_", "(_", "[_", "[_", "H", "\\u", "00_", ",_", "H", "\\u", "01_", "]_", ",_", "[_", "H", "\\u", "10_", ",_", "H", "\\u", "11_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "bma", "t_", "(_", "[_", "[_", "C", "\\u", "00_", ",_", "C", "\\u", "01_", "]_", ",_", "[_", "C", "\\u", "10_", ",_", "C", "\\u", "11_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G_", "=_", "bma", "t_", "(_", "[_", "[_", "G", "\\u", "0_", "]_", ",_", "[_", "G", "\\u", "1_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B_", "=_", "bma", "t_", "(_", "[_", "[_", "B", "\\u", "0_", "]_", ",_", "[_", "B", "\\u", "1_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "H_", ",_", "C_", ",_", "G_", ",_", "B_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "compute", "\\u", "manip", "ulator", "\\u", "matrix", "\\u", "derivatives", "_", "(_", "x_", ",_", "u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", ",_", "theta_", ",_", "p", "\\u", "dot_", ",_", "theta", "\\u", "dot_", ",_", "q_", ",_", "q", "\\u", "dot_", "=_", "unpack", "\\u", "state_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "x", "\\u", "and", "\\u", "u\\u", "vals_", "=_", "hstack_", "(_", "[_", "q_", "._", "A1_", ",_", "q", "\\u", "dot_", "._", "A1_", ",_", "u_", "._", "A1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "slow_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "x", "\\u", "and", "\\u", "u\\u", "subs", " ", " ", " ", "=", " ", "dict", "(", "zip", "(", "x", "\\u", "and", "\\u", "u\\u", "sym", "s", ",", "x", "\\u", "and", "\\u", "u\\u", "vals", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dq", "dot", "dot", "\\u", "dq", " ", " ", " ", " ", "=", " ", "dq", "dot", "dot", "\\u", "dq", "\\u", "expr", ".", "subs", "(", "x", "\\u", "and", "\\u", "u\\u", "subs", ").", "eval", "f", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dq", "dot", "dot", "\\u", "dq", "dot", " ", "=", " ", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "expr", ".", "subs", "(", "x", "\\u", "and", "\\u", "u\\u", "subs", ").", "eval", "f", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fast_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq_", "=_", "matrix_", "(_", "symp", "yu", "tils_", "._", "evaluate", "\\u", "matrix", "\\u", "anon", "\\u", "funcs_", "(_", "dq", "dot", "dot", "\\u", "dq", "\\u", "anon", "\\u", "funcs", "\\u", "ufunc", "ify_", ",_", "x", "\\u", "and", "\\u", "u\\u", "vals_", "[_", "newaxis_", ",_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "dot_", "=_", "matrix_", "(_", "symp", "yu", "tils_", "._", "evaluate", "\\u", "matrix", "\\u", "anon", "\\u", "funcs_", "(_", "dq", "dot", "dot", "\\u", "dq", "dot", "\\u", "anon", "\\u", "funcs", "\\u", "ufunc", "ify_", ",_", "x", "\\u", "and", "\\u", "u\\u", "vals_", "[_", "newaxis_", ",_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "dq", "dot", "dot", "\\u", "dq_", ",_", "dq", "dot", "dot", "\\u", "dq", "dot_", "\\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_", "compute", "\\u", "df", "\\u", "dx", "\\u", "and", "\\u", "df", "\\u", "du_", "(_", "x_", ",_", "u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "H_", ",_", "C_", ",_", "G_", ",_", "B_", "=_", "compute", "\\u", "manip", "ulator", "\\u", "matrices_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq_", ",_", "dq", "dot", "dot", "\\u", "dq", "dot_", "=_", "compute", "\\u", "manip", "ulator", "\\u", "matrix", "\\u", "derivatives", "_", "(_", "x_", ",_", "u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "\\u", "dq_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "3_", ",_", "3_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "\\u", "dq", "dot_", "=_", "matrix_", "(_", "identity_", "(_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq_", "=_", "dq", "dot", "dot", "\\u", "dq_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "dq", "dot_", "=_", "dq", "dot", "dot", "\\u", "dq", "dot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dq", "dot", "\\u", "du_", "=_", "matrix_", "(_", "zeros_", "(_", "(_", "3_", ",_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dq", "dot", "dot", "\\u", "du_", "=_", "H_", "._", "I_", "*_", "B_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "df", "\\u", "dx_", "=_", "bma", "t_", "(_", "[_", "[_", "dq", "dot", "\\u", "dq_", ",_", "dq", "dot", "\\u", "dq", "dot_", "]_", ",_", "[_", "dq", "dot", "dot", "\\u", "dq_", ",_", "dq", "dot", "dot", "\\u", "dq", "dot_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "df", "\\u", "du_", "=_", "bma", "t_", "(_", "[_", "[_", "dq", "dot", "\\u", "du_", "]_", ",_", "[_", "dq", "dot", "dot", "\\u", "du_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "df", "\\u", "dx_", ",_", "df", "\\u", "du_", "\\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_", "compute", "\\u", "x", "\\u", "dot_", "(_", "x_", ",_", "u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", ",_", "theta_", ",_", "p", "\\u", "dot_", ",_", "theta", "\\u", "dot_", ",_", "q_", ",_", "q", "\\u", "dot_", "=_", "unpack", "\\u", "state_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H_", ",_", "C_", ",_", "G_", ",_", "B_", "=_", "compute", "\\u", "manip", "ulator", "\\u", "matrices_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f1_", "=_", "H_", "._", "I_", "*_", "(_", "-_", "G_", "-_", "C_", "*_", "q", "\\u", "dot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f2_", "=_", "H_", "._", "I_", "*_", "B_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "q", "\\u", "dot", "\\u", "dot_", "=_", "f1_", "+_", "f2_", "*_", "u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "x", "\\u", "dot_", "=_", "bma", "t_", "(_", "[_", "[_", "q", "\\u", "dot_", "]_", ",_", "[_", "q", "\\u", "dot", "\\u", "dot_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "x", "\\u", "dot_", "\\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_", "compute", "\\u", "state", "\\u", "space", "\\u", "trajecto", "ry", "\\u", "and", "\\u", "derivatives", "_", "(_", "p_", ",_", "dt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f", "\\u", "thrust", "\\u", "world", "\\u", "norm", "\\u", "threshold_", "=_", "0.01_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "timesteps_", "=_", "len_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "\\u", "dot_", "=_", "c\\u", "_", "[_", "gradient_", "(_", "p_", "[_", ":_", ",_", "0_", "]_", ",_", "dt_", ")_", ",_", "gradient_", "(_", "p_", "[_", ":_", ",_", "1_", "]_", ",_", "dt_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "dot", "\\u", "dot_", "=_", "c\\u", "_", "[_", "gradient_", "(_", "p", "\\u", "dot_", "[_", ":_", ",_", "0_", "]_", ",_", "dt_", ")_", ",_", "gradient_", "(_", "p", "\\u", "dot_", "[_", ":_", ",_", "1_", "]_", ",_", "dt_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "\\u", "thrust", "\\u", "world_", "=_", "m_", "*_", "p", "\\u", "dot", "\\u", "dot_", "-_", "f", "\\u", "external", "\\u", "world_", "._", "T_", "._", "A_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f", "\\u", "thrust", "\\u", "world", "\\u", "norm_", "=_", "linalg_", "._", "norm_", "(_", "f", "\\u", "thrust", "\\u", "world_", ",_", "axis_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "theta", "\\u", "raw_", "=_", "arctan", "2_", "(_", "f", "\\u", "thrust", "\\u", "world_", "[_", ":_", ",_", "0_", "]_", ",_", "f", "\\u", "thrust", "\\u", "world_", "[_", ":_", ",_", "1_", "]_", ")_", "-_", "(_", "pi_", "/_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t", "\\u", "tmp_", "=_", "arange_", "(_", "num", "\\u", "timesteps_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta", "\\u", "func_", "=_", "scipy_", "._", "interpolate_", "._", "interp1d_", "(_", "t", "\\u", "tmp_", "[_", "f", "\\u", "thrust", "\\u", "world", "\\u", "norm_", ">_", "f", "\\u", "thrust", "\\u", "world", "\\u", "norm", "\\u", "threshold_", "]_", ",_", "theta", "\\u", "raw_", "[_", "f", "\\u", "thrust", "\\u", "world", "\\u", "norm_", ">_", "f", "\\u", "thrust", "\\u", "world", "\\u", "norm", "\\u", "threshold_", "]_", ",_", "kind_", "=_", "\"", "linear", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta_", "=_", "theta", "\\u", "func_", "(_", "t", "\\u", "tmp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "theta_", "=_", "trig", "utils_", "._", "compute", "\\u", "continuous", "\\u", "angle", "\\u", "array_", "(_", "theta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta", "\\u", "dot_", "=_", "gradient_", "(_", "theta_", ",_", "dt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theta", "\\u", "dot", "\\u", "dot_", "=_", "gradient_", "(_", "theta", "\\u", "dot_", ",_", "dt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "p_", ",_", "p", "\\u", "dot_", ",_", "p", "\\u", "dot", "\\u", "dot_", ",_", "theta_", ",_", "theta", "\\u", "dot_", ",_", "theta", "\\u", "dot", "\\u", "dot_", "\\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_", "compute", "\\u", "control", "\\u", "trajectory_", "(_", "q", "\\u", "q", "\\u", "dot", "\\u", "q", "\\u", "dot", "\\u", "dot_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", ",_", "p", "\\u", "dot_", ",_", "p", "\\u", "dot", "\\u", "dot_", ",_", "theta_", ",_", "theta", "\\u", "dot_", ",_", "theta", "\\u", "dot", "\\u", "dot_", "=_", "q", "\\u", "q", "\\u", "dot", "\\u", "q", "\\u", "dot", "\\u", "dot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "timesteps_", "=_", "len_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "u_", "=_", "zeros_", "(_", "(_", "num", "\\u", "timesteps_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "ti_", "in_", "range_", "(_", "int_", "(_", "num", "\\u", "timesteps_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q", "\\u", "ti_", "=_", "matrix_", "(_", "[_", "p_", "[_", "ti_", ",_", "0_", "]_", ",_", "p_", "[_", "ti_", ",_", "1_", "]_", ",_", "theta_", "[_", "ti_", "]_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q", "\\u", "dot", "\\u", "ti_", "=_", "matrix_", "(_", "[_", "p", "\\u", "dot_", "[_", "ti_", ",_", "0_", "]_", ",_", "p", "\\u", "dot_", "[_", "ti_", ",_", "1_", "]_", ",_", "theta", "\\u", "dot_", "[_", "ti_", "]_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q", "\\u", "dot", "\\u", "dot", "\\u", "ti_", "=_", "matrix_", "(_", "[_", "p", "\\u", "dot", "\\u", "dot_", "[_", "ti_", ",_", "0_", "]_", ",_", "p", "\\u", "dot", "\\u", "dot_", "[_", "ti_", ",_", "1_", "]_", ",_", "theta", "\\u", "dot", "\\u", "dot_", "[_", "ti_", "]_", "]_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "\\u", "ti_", "=_", "bma", "t_", "(_", "[_", "[_", "q", "\\u", "ti_", "]_", ",_", "[_", "q", "\\u", "dot", "\\u", "ti_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "H_", ",_", "C_", ",_", "G_", ",_", "B_", "=_", "compute", "\\u", "manip", "ulator", "\\u", "matrices_", "(_", "x", "\\u", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f1_", "=_", "H_", "._", "I_", "*_", "(_", "-_", "G_", "-_", "C_", "*_", "q", "\\u", "dot", "\\u", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f2_", "=_", "H_", "._", "I_", "*_", "B_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f2", "\\u", "pin", "v_", "=_", "linalg_", "._", "pin", "v_", "(_", "f2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u\\u", "ti_", "=_", "f2", "\\u", "pin", "v_", "*_", "(_", "q", "\\u", "dot", "\\u", "dot", "\\u", "ti_", "-_", "f1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "[_", "ti_", ",_", ":_", "]_", "=_", "u\\u", "ti_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "u_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
ilblackdragon/django-blogs/blog/migrations/0001_initial.py
[ { "content": "\nfrom south.db import db\nfrom django.db import models\nfrom blog.models import *\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration:\n \n \n \n \n \n \n \n models = {\n 'auth.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']\", 'blank': 'True'})\n },\n 'auth.permission': {\n 'Meta': {'unique_together': \"(('content_type', 'codename'),)\"},\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 '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']\", 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\n 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\n 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),\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']\", 'blank': 'True'}),\n 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\n },\n 'blog.post': {\n 'allow_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),\n 'author': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'added_posts'\", 'to': \"orm['auth.User']\"}),\n 'body': ('django.db.models.fields.TextField', [], {}),\n 'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n 'creator_ip': ('django.db.models.fields.IPAddressField', [], {'max_length': '15', 'null': 'True', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'markup': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),\n 'publish': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),\n 'status': ('django.db.models.fields.IntegerField', [], {'default': '2'}),\n 'tags': ('tagging.fields.TagField', [], {}),\n 'tease': ('django.db.models.fields.TextField', [], {'blank': 'True'}),\n 'title': ('django.db.models.fields.CharField', [], {'max_length': '200'}),\n 'updated_at': ('django.db.models.fields.DateTimeField', [], {})\n },\n 'contenttypes.contenttype': {\n 'Meta': {'unique_together': \"(('app_label', 'model'),)\", '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 }\n \n complete_apps = ['blog']", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 5 }, { "content": " def forwards(self, orm):\n \n # Adding model 'Post'\n db.create_table('blog_post', (\n ('id', orm['blog.Post:id']),\n ('title', orm['blog.Post:title']),\n ('slug', orm['blog.Post:slug']),\n ('author', orm['blog.Post:author']),\n ('creator_ip', orm['blog.Post:creator_ip']),\n ('body', orm['blog.Post:body']),\n ('tease', orm['blog.Post:tease']),\n ('status', orm['blog.Post:status']),\n ('allow_comments', orm['blog.Post:allow_comments']),\n ('publish', orm['blog.Post:publish']),\n ('created_at', orm['blog.Post:created_at']),\n ('updated_at', orm['blog.Post:updated_at']),\n ('markup', orm['blog.Post:markup']),\n ('tags', orm['blog.Post:tags']),\n ))\n db.send_create_signal('blog', ['Post'])", "metadata": "root.Migration.forwards", "header": "['class', 'Migration', ':', '___EOS___']", "index": 7 }, { "content": " def backwards(self, orm):\n \n # Deleting model 'Post'\n db.delete_table('blog_post')", "metadata": "root.Migration.backwards", "header": "['class', 'Migration', ':', '___EOS___']", "index": 30 } ]
[ { "span": "from django.db import models", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "south_", "._", "db_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "blog_", "._", "models_", "import_", "*_", "\\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_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "'", "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", "']\"_", ",_", "'", "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", "'_", ":_", "{_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "content", "\\u", "type", "',", " ", "'", "code", "name", "'),)\"_", "}_", ",_", "\\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_", "'", "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", "']\"_", ",_", "'", "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", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "sta", "ff", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "super", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\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", "']\"_", ",_", "'", "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_", "'", "blog", ".", "post", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "allow", "\\u", "comment", "s", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "adde", "d\\u", "posts", "'\"_", ",_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "body", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "created", "\\u", "at", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", ".", "now", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "creat", "or", "\\u", "ip", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "IPA", "ddress", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "15", "'_", ",_", "'", "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_", "'", "markup", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "20", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "publi", "sh", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", ".", "now", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Sl", "ug", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", ",_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "2", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tags", "'_", ":_", "(_", "'", "tagging", ".", "fields", ".", "Ta", "g", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tea", "se", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "200", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "update", "d\\u", "at", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contenttype", "s", ".", "contenttype", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "app", "\\u", "label", "',", " ", "'", "model", "'),)\"_", ",_", "'", "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_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "apps_", "=_", "[_", "'", "blog", "'_", "]_", "[SEP]_", "class_", "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_", "#", " ", "Add", "ing", " ", "model", " ", "'", "Post", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "create", "\\u", "table_", "(_", "'", "blog", "\\u", "post", "'_", ",_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "id", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "id", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "title", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "title", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "slug", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "slug", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "author", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "author", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "creat", "or", "\\u", "ip", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "creat", "or", "\\u", "ip", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "body", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "body", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "tea", "se", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "tea", "se", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "status", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "status", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "allow", "\\u", "comment", "s", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "allow", "\\u", "comment", "s", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "publi", "sh", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "publi", "sh", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "created", "\\u", "at", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "created", "\\u", "at", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "update", "d\\u", "at", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "update", "d\\u", "at", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "markup", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "markup", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "tags", "'_", ",_", "orm_", "[_", "'", "blog", ".", "Post", ":", "tags", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "send", "\\u", "create", "\\u", "signal_", "(_", "'", "blog", "'_", ",_", "[_", "'", "Post", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "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_", "#", " ", "Del", "eti", "ng", " ", "model", " ", "'", "Post", "'_", "\\u\\u\\uNL\\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, 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 ]
Unused import
lambdalisue/django-permission/src/permission/tests/test_utils/test_permissions.py
[ { "content": "# To run doctest\nimport permission.utils.permissions\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import permission.utils.permissions", "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_", "#", " ", "To", " ", "run", " ", "doctest_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "permission_", "._", "utils_", "._", "permissions_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1 ]
Unused import
zmap/ztag/ztag/annotations/FtpRouterBoard.py
[ { "content": "import re\nfrom ztag.annotation import Annotation\nfrom ztag.annotation import OperatingSystem\nfrom ztag.annotation import Type\nfrom ztag.annotation import Manufacturer\nfrom ztag import protocols\nimport ztag.test\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class FtpRouterBoard(Annotation):\n protocol = protocols.FTP\n subprotocol = protocols.FTP.BANNER\n port = None\n\n manufact_1_re = re.compile(\n \"^220 \\d+ -> SXT.+ \\(MikroTik \\d+\\.\\d+(\\.\\d+)?\\) ready\",\n re.IGNORECASE\n )\n\n manufact_2_re = re.compile(\n \"^220 \\d+ -> \\d+[A-Z]?((-5Hn(D)?)|(-5Hn-MMCX))? FTP server \\(MikroTik \\d+\\.\\d+(\\.\\d+)?\\) ready\",\n re.IGNORECASE\n )\n\n product_re = re.compile(\"^220 \\d+ -> (.+) FTP server\", re.IGNORECASE)\n\n implementation_re = re.compile(\n \"^220 .+ FTP server \\(MikroTik (\\d+(?:\\.\\d+)*)\\)\",\n re.IGNORECASE\n )\n\n tests = {\n \"FtpRouterBoard_1\": {\n \"global_metadata\": {\n \"manufacturer\": Manufacturer.ROUTER_BOARD,\n \"product\": \"711-5HnD\"\n },\n \"local_metadata\": {\n \"product\": \"MikroTik\",\n \"version\": \"6.10\"\n }\n }\n }\n\n\n \"\"\" Tests\n \"220 002279 -> SXT 5nD r2 FTP server (MikroTik 6.23) ready\\r\\n\"\n \"220 003252 -> SXT 5nD r2 FTP server (MikroTik 6.20) ready\\r\\n\"\n \"220 003142 -> 711-5Hn-MMCX FTP server (MikroTik 6.26) ready\\r\\n\"\n \"220 004259 -> SXT 5HnD FTP server (MikroTik 6.12) ready\\r\\n\"\n \"220 004602 -> SXT 5HPnD FTP server (MikroTik 6.20) ready\\r\\n\"\n \"220 002853 -> 411 FTP server (MikroTik 6.26) ready\\r\\n\"\n \"220 002619 -> 411 FTP server (MikroTik 6.26) ready\\r\\n\"\n \"220 003940 -> 711-5HnD FTP server (MikroTik 6.10) ready\\r\\n\"\n \"220 005337 -> SXT 5nD r2 FTP server (MikroTik 6.13) ready\\r\\n\"\n \"220 001840 -> SXT 5nD r2 FTP server (MikroTik 6.13) ready\\r\\n\"\n \"220 003952 -> SXT 5HnD FTP server (MikroTik 6.29.1) ready\\r\\n\"\n \"220 004063 -> SXT 5HnD FTP server (MikroTik 6.19) ready\\r\\n\"\n \"220 005911 -> SXT 5nD r2 FTP server (MikroTik 6.13) ready\\r\\n\"\n \"220 006515 -> SXT 5nD r2 FTP server (MikroTik 6.19) ready\\r\\n\"\n \"220 005436 -> SXT 5nD r2 FTP server (MikroTik 6.13) ready\\r\\n\"\n \"220 000557 -> SXT 5HPnD FTP server (MikroTik 6.12) ready\\r\\n\"\n \"220 000771 -> SXT 5HnD FTP server (MikroTik 6.12) ready\\r\\n\"\n \"220 002549 -> 411 FTP server (MikroTik 6.27) ready\\r\\n\"\n \"\"\"", "metadata": "root.FtpRouterBoard", "header": "['module', '___EOS___']", "index": 9 }, { "content": " def process(self, obj, meta):\n banner = obj[\"banner\"]\n\n if (\n self.manufact_1_re.search(banner) or\n self.manufact_2_re.search(banner)\n ):\n\n meta.global_metadata.manufacturer = Manufacturer.ROUTER_BOARD\n\n product = self.product_re.search(banner).group(1)\n meta.global_metadata.product = product\n\n meta.local_metadata.product = \"MikroTik\"\n\n implementation = self.implementation_re.search(banner)\n meta.local_metadata.version = implementation.group(1)\n\n return meta", "metadata": "root.FtpRouterBoard.process", "header": "['class', 'FtpRouterBoard', '(', 'Annotation', ')', ':', '___EOS___']", "index": 44 } ]
[ { "span": "from ztag.annotation import OperatingSystem", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 43 }, { "span": "from ztag.annotation import Type", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 32 }, { "span": "import ztag.test", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 16 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zt", "ag_", "._", "annotation_", "import_", "Annotation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zt", "ag_", "._", "annotation_", "import_", "Opera", "ting", "System_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zt", "ag_", "._", "annotation_", "import_", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zt", "ag_", "._", "annotation_", "import_", "Manufacturer", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zt", "ag_", "import_", "protocols_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "zt", "ag_", "._", "test_", "\\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_", "class_", "Ft", "p", "Route", "r", "Board_", "(_", "Annotation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "protocol_", "=_", "protocols_", "._", "FTP", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subpro", "toco", "l_", "=_", "protocols_", "._", "FTP", "_", "._", "BAN", "NER", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "port_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "manu", "fact", "\\u", "1", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "^", "220", " ", "\\\\", "d", "+", " ", "->", " ", "SX", "T", ".+", " ", "\\\\(", "Mik", "ro", "Ti", "k", " ", "\\\\", "d", "+\\\\.", "\\\\", "d", "+(", "\\\\.\\\\", "d", "+)?", "\\\\)", " ", "read", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "re_", "._", "IGNORECASE_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "manu", "fact", "\\u", "2", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "^", "220", " ", "\\\\", "d", "+", " ", "->", " ", "\\\\", "d", "+[", "A", "-", "Z", "]?", "((", "-", "5", "Hn", "(", "D", ")?", ")|(", "-", "5", "Hn", "-", "MM", "CX", "))", "?", " ", "FTP", " ", "server", " ", "\\\\(", "Mik", "ro", "Ti", "k", " ", "\\\\", "d", "+\\\\.", "\\\\", "d", "+(", "\\\\.\\\\", "d", "+)?", "\\\\)", " ", "read", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "re_", "._", "IGNORECASE_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "product", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "\"", "^", "220", " ", "\\\\", "d", "+", " ", "->", " ", "(.+", ")", " ", "FTP", " ", "server", "\"_", ",_", "re_", "._", "IGNORECASE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "implementation", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "^", "220", " ", ".+", " ", "FTP", " ", "server", " ", "\\\\(", "Mik", "ro", "Ti", "k", " ", "(\\\\", "d", "+(?", ":\\\\", ".\\\\", "d", "+)", "*)\\\\", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "re_", "._", "IGNORECASE_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tests_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ft", "p", "Route", "r", "Boa", "rd", "\\u", "1", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "global", "\\u", "metadata", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "manufactur", "er", "\"_", ":_", "Manufacturer", "_", "._", "ROUTER", "\\u", "BOARD", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "product", "\"_", ":_", "\"", "711", "-", "5", "Hn", "D", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "local", "\\u", "metadata", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "product", "\"_", ":_", "\"", "Mik", "ro", "Ti", "k", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "version", "\"_", ":_", "\"", "6.1", "0", "\"_", "\\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\\uDEDENT\\u\\u\\u_", "\"\"\"", " ", "Test", "s", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0022", "7", "9", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "3", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "003", "252", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "0", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "003", "142", " ", "->", " ", "711", "-", "5", "Hn", "-", "MM", "CX", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "6", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "004", "259", " ", "->", " ", "SX", "T", " ", "5", "Hn", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "2", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "004", "602", " ", "->", " ", "SX", "T", " ", "5", "HP", "n", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "0", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "002", "853", " ", "->", " ", "411", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "6", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "002", "619", " ", "->", " ", "411", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "6", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0039", "40", " ", "->", " ", "711", "-", "5", "Hn", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "0", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "005", "337", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "3", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0018", "40", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "3", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0039", "5", "2", " ", "->", " ", "SX", "T", " ", "5", "Hn", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "9.1", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0040", "6", "3", " ", "->", " ", "SX", "T", " ", "5", "Hn", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "9", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "005", "911", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "3", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "006", "515", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "9", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "005", "436", " ", "->", " ", "SX", "T", " ", "5", "n", "D", " ", "r2", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "3", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0005", "5", "7", " ", "->", " ", "SX", "T", " ", "5", "HP", "n", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "2", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0007", "7", "1", " ", "->", " ", "SX", "T", " ", "5", "Hn", "D", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.1", "2", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", "220", " ", "0025", "4", "9", " ", "->", " ", "411", " ", "FTP", " ", "server", " ", "(", "Mik", "ro", "Ti", "k", " ", "6.2", "7", ")", " ", "read", "y", "\\\\", "r", "\\\\", "n", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "[SEP]_", "class_", "Ft", "p", "Route", "r", "Board_", "(_", "Annotation_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "process_", "(_", "self_", ",_", "obj_", ",_", "meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "banner_", "=_", "obj_", "[_", "\"", "banner", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "manu", "fact", "\\u", "1", "\\u", "re_", "._", "search_", "(_", "banner_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "manu", "fact", "\\u", "2", "\\u", "re_", "._", "search_", "(_", "banner_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "meta_", "._", "global", "\\u", "metadata_", "._", "manufacturer_", "=_", "Manufacturer", "_", "._", "ROUTER", "\\u", "BOARD", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "product_", "=_", "self_", "._", "product", "\\u", "re_", "._", "search_", "(_", "banner_", ")_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "global", "\\u", "metadata_", "._", "product_", "=_", "product_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "meta_", "._", "local", "\\u", "metadata_", "._", "product_", "=_", "\"", "Mik", "ro", "Ti", "k", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "implementation_", "=_", "self_", "._", "implementation", "\\u", "re_", "._", "search_", "(_", "banner_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "local", "\\u", "metadata_", "._", "version_", "=_", "implementation_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 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, 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, 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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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 ]
Testing equality to None
viblo/pymunk/dump/body_bench_cffi.py
[ { "content": " def __init__(self, x_or_pair=None, y = None):\n if x_or_pair != None:\n if y == None:\n self.x = x_or_pair[0]\n self.y = x_or_pair[1]\n else:\n self.x = x_or_pair\n self.y = y", "metadata": "root.Vec2d.__init__", "header": "['class', 'Vec2d', '(', ')', ':', '# this would be very fast in pypy', '___NEWLINE___', '#class Vec2d(ctypes.Structure):', '___NL___', '___EOS___']", "index": 120 } ]
[ { "span": "y == None:", "start_line": 122, "start_column": 15, "end_line": 122, "end_column": 24 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Vec2", "d_", "(_", ")_", ":_", "#", " ", "this", " ", "wou", "ld", " ", "be", " ", "very", " ", "fast", " ", "in", " ", "pypy", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "class", " ", "Vec2", "d", "(", "ctype", "s", ".", "Structur", "e", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "x", "\\u", "or", "\\u", "pair_", "=_", "None_", ",_", "y_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "x", "\\u", "or", "\\u", "pair_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "y_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "x_", "=_", "x", "\\u", "or", "\\u", "pair_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "y_", "=_", "x", "\\u", "or", "\\u", "pair_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "x_", "=_", "x", "\\u", "or", "\\u", "pair_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "y_", "=_", "y_", "\\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, 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 ]
Missing call to `__init__` during object initialization
skyostil/tracy/src/generator/Cheetah/ImportManager.py
[ { "content": " def __init__(self, path):\n self.path = path", "metadata": "root.Owner.__init__", "header": "['class', 'Owner', ':', '___EOS___']", "index": 173 }, { "content": "class BuiltinImportDirector(ImportDirector):\n \"\"\"Directs imports of builtin modules\"\"\"\n", "metadata": "root.BuiltinImportDirector", "header": "['module', '___EOS___']", "index": 257 }, { "content": " def __init__(self):\n self.path = 'Builtins'", "metadata": "root.BuiltinImportDirector.__init__", "header": "['class', 'BuiltinImportDirector', '(', 'ImportDirector', ')', ':', '___EOS___']", "index": 259 }, { "content": "class FrozenImportDirector(ImportDirector):\n \"\"\"Directs imports of frozen modules\"\"\"\n \n", "metadata": "root.FrozenImportDirector", "header": "['module', '___EOS___']", "index": 268 }, { "content": " def __init__(self):\n self.path = 'FrozenModules'", "metadata": "root.FrozenImportDirector.__init__", "header": "['class', 'FrozenImportDirector', '(', 'ImportDirector', ')', ':', '___EOS___']", "index": 271 }, { "content": "class RegistryImportDirector(ImportDirector):\n \"\"\"Directs imports of modules stored in the Windows Registry\"\"\"\n\n ", "metadata": "root.RegistryImportDirector", "header": "['module', '___EOS___']", "index": 284 }, { "content": " def __init__(self):\n self.path = \"WindowsRegistry\"\n self.map = {}\n try:\n import win32api\n ## import win32con\n except ImportError:\n pass\n else:\n HKEY_CURRENT_USER = -2147483647\n HKEY_LOCAL_MACHINE = -2147483646\n KEY_ALL_ACCESS = 983103\n subkey = r\"Software\\Python\\PythonCore\\%s\\Modules\" % sys.winver\n for root in (HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE):\n try:\n hkey = win32api.RegOpenKeyEx(root, subkey, 0, KEY_ALL_ACCESS)\n except:\n pass\n else:\n numsubkeys, numvalues, lastmodified = win32api.RegQueryInfoKey(hkey)\n for i in range(numsubkeys):\n subkeyname = win32api.RegEnumKey(hkey, i)\n hskey = win32api.RegOpenKeyEx(hkey, subkeyname, 0, KEY_ALL_ACCESS)\n val = win32api.RegQueryValueEx(hskey, '')\n desc = getDescr(val[0])\n self.map[subkeyname] = (val[0], desc)\n hskey.Close()\n hkey.Close()\n break", "metadata": "root.RegistryImportDirector.__init__", "header": "['class', 'RegistryImportDirector', '(', 'ImportDirector', ')', ':', '___EOS___']", "index": 287 }, { "content": "class PathImportDirector(ImportDirector):\n \"\"\"Directs imports of modules stored on the filesystem.\"\"\"\n\n \n ", "metadata": "root.PathImportDirector", "header": "['module', '___EOS___']", "index": 327 }, { "content": " def __init__(self, pathlist=None, importers=None, ownertypes=None):\n if pathlist is None:\n self.path = sys.path\n else:\n self.path = pathlist\n if ownertypes == None:\n self._ownertypes = _globalOwnerTypes\n else:\n self._ownertypes = ownertypes\n if importers:\n self._shadowPath = importers\n else:\n self._shadowPath = {}\n self._inMakeOwner = False\n self._building = {}", "metadata": "root.PathImportDirector.__init__", "header": "['class', 'PathImportDirector', '(', 'ImportDirector', ')', ':', '___EOS___']", "index": 330 } ]
[ { "span": "class BuiltinImportDirector(ImportDirector):", "start_line": 257, "start_column": 0, "end_line": 257, "end_column": 44 }, { "span": "class FrozenImportDirector(ImportDirector):", "start_line": 268, "start_column": 0, "end_line": 268, "end_column": 43 }, { "span": "class RegistryImportDirector(ImportDirector):", "start_line": 284, "start_column": 0, "end_line": 284, "end_column": 45 }, { "span": "class PathImportDirector(ImportDirector):", "start_line": 327, "start_column": 0, "end_line": 327, "end_column": 41 } ]
[ { "span": "def __init__(self, path):", "start_line": 173, "start_column": 4, "end_line": 173, "end_column": 29 }, { "span": "def __init__(self):", "start_line": 259, "start_column": 4, "end_line": 259, "end_column": 23 }, { "span": "def __init__(self):", "start_line": 271, "start_column": 4, "end_line": 271, "end_column": 23 }, { "span": "def __init__(self):", "start_line": 287, "start_column": 4, "end_line": 287, "end_column": 23 }, { "span": "def __init__(self, pathlist=None, importers=None, ownertypes=None):", "start_line": 330, "start_column": 4, "end_line": 330, "end_column": 71 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Owner_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "path_", "=_", "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_", "class_", "Bu", "ilt", "in", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Direct", "s", " ", "import", "s", " ", "of", " ", "bui", "lti", "n", " ", "module", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Bu", "ilt", "in", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\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 ", " _", "self_", "._", "path_", "=_", "'", "Bu", "ilt", "ins", "'_", "\\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_", "Fro", "zen", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Direct", "s", " ", "import", "s", " ", "of", " ", "frozen", " ", "module", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Fro", "zen", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\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 ", " _", "self_", "._", "path_", "=_", "'", "Fro", "zen", "Modul", "es", "'_", "\\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_", "Regi", "stry", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Direct", "s", " ", "import", "s", " ", "of", " ", "module", "s", " ", "store", "d", " ", "in", " ", "the", " ", "Window", "s", " ", "Regi", "stry", "\"\"\"_", "\\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_", "Regi", "stry", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\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 ", " _", "self_", "._", "path_", "=_", "\"", "Window", "s", "Regi", "stry", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "map_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "win32", "api_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "import", " ", "win32con_", "\\u\\u\\uNL\\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\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HKEY", "\\u", "CURREN", "T", "\\u", "USER_", "=_", "-_", "2147483647", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "HKEY", "\\u", "LOCAL", "\\u", "MACHINE", "_", "=_", "-_", "214", "748", "364", "6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "KEY", "\\u", "ALL", "\\u", "ACCESS", "_", "=_", "983", "103_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subkey", "_", "=_", "r", "\"", "Sof", "twa", "re", "\\\\", "Pyth", "on", "\\\\", "Pyth", "on", "Core", "\\\\", "%", "s", "\\\\", "Modul", "es", "\"_", "%_", "sys_", "._", "win", "ver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "root_", "in_", "(_", "HKEY", "\\u", "CURREN", "T", "\\u", "USER_", ",_", "HKEY", "\\u", "LOCAL", "\\u", "MACHINE", "_", ")_", ":_", "\\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 ", " ", "_", "hk", "ey_", "=_", "win32", "api_", "._", "Reg", "Open", "Key", "Ex_", "(_", "root_", ",_", "subkey", "_", ",_", "0_", ",_", "KEY", "\\u", "ALL", "\\u", "ACCESS", "_", ")_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "nums", "ub", "keys_", ",_", "num", "values_", ",_", "lastm", "odi", "fied", "_", "=_", "win32", "api_", "._", "Reg", "Query", "Info", "Key_", "(_", "hk", "ey_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "nums", "ub", "keys_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "subkey", "name_", "=_", "win32", "api_", "._", "Reg", "Enum", "Key_", "(_", "hk", "ey_", ",_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hs", "key_", "=_", "win32", "api_", "._", "Reg", "Open", "Key", "Ex_", "(_", "hk", "ey_", ",_", "subkey", "name_", ",_", "0_", ",_", "KEY", "\\u", "ALL", "\\u", "ACCESS", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "val_", "=_", "win32", "api_", "._", "Reg", "Query", "Value", "Ex_", "(_", "hs", "key_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "desc_", "=_", "get", "Descr", "_", "(_", "val_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "map_", "[_", "subkey", "name_", "]_", "=_", "(_", "val_", "[_", "0_", "]_", ",_", "desc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hs", "key_", "._", "Close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hk", "ey_", "._", "Close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\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_", "Path", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Direct", "s", " ", "import", "s", " ", "of", " ", "module", "s", " ", "store", "d", " ", "on", " ", "the", " ", "filesystem", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Path", "Import", "Director", "_", "(_", "Import", "Director", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "pathli", "st_", "=_", "None_", ",_", "importer", "s_", "=_", "None_", ",_", "owner", "types_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pathli", "st_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "path_", "=_", "sys_", "._", "path_", "\\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_", "._", "path_", "=_", "pathli", "st_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "owner", "types_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "owner", "types_", "=_", "\\u", "global", "Owne", "r", "Types_", "\\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", "owner", "types_", "=_", "owner", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "importer", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "shadow", "Path_", "=_", "importer", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "shadow", "Path_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "in", "Make", "Owner_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "building_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
saltstack/salt/tests/unit/utils/which_test.py
[ { "content": " @patch('salt.utils.which', lambda exe: None)\n def test_missing_binary_in_linux(self):\n self.assertTrue(\n salt.utils.which('this-binary-does-not-exist') is None\n )", "metadata": "root.TestWhich.test_missing_binary_in_linux", "header": "['class', 'TestWhich', '(', 'integration', '.', 'TestCase', ')', ':', '___EOS___']", "index": 26 } ]
[ { "span": "self.assertTrue(\n salt.utils.which('this-binary-does-not-exist') is None\n )", "start_line": 28, "start_column": 8, "end_line": 30, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Whi", "ch_", "(_", "integration_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "patch_", "(_", "'", "salt", ".", "util", "s", ".", "whi", "ch", "'_", ",_", "lambda_", "exe_", ":_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "missi", "ng", "\\u", "binar", "y", "\\u", "in", "\\u", "linux_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "salt_", "._", "utils_", "._", "which_", "(_", "'", "this", "-", "binar", "y", "-", "doe", "s", "-", "not", "-", "exist", "'_", ")_", "is_", "None_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\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, 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, 2 ]
Unused import
ManiacalLabs/BiblioPixel/bibliopixel/drivers/network.py
[ { "content": "from driver_base import DriverBase\nimport socket\nimport sys\nimport time\n\nimport os\nos.sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\nimport log\n\n\n\n\n\n\n\nMANIFEST = [\n {\n \"id\": \"network\",\n \"class\": DriverNetwork,\n \"type\": \"driver\",\n \"display\": \"Network\",\n \"desc\": \"Sends pixel data over the network to a reciever.\",\n \"params\": [{\n \"id\": \"num\",\n \"label\": \"# Pixels\",\n \"type\": \"int\",\n \"default\": 0,\n \"min\": 0,\n \"help\": \"Total pixels in display. May use Width AND Height instead.\"\n }, {\n \"id\": \"width\",\n \"label\": \"Width\",\n \"type\": \"int\",\n \"default\": 0,\n \"min\": 0,\n \"help\": \"Width of display. Set if using a matrix.\"\n }, {\n \"id\": \"height\",\n \"label\": \"Height\",\n \"type\": \"int\",\n \"default\": 0,\n \"min\": 0,\n \"help\": \"Height of display. Set if using a matrix.\"\n }, {\n \"id\": \"host\",\n \"label\": \"Pixel Size\",\n \"type\": \"str\",\n \"default\": \"localhost\",\n \"help\": \"Receiver host to connect to.\"\n }, {\n \"id\": \"port\",\n \"label\": \"Port\",\n \"type\": \"int\",\n \"default\": 3142,\n \"help\": \"Port to connect to.\"\n }]\n }\n]\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class CMDTYPE:\n SETUP_DATA = 1 # reserved for future use\n PIXEL_DATA = 2\n BRIGHTNESS = 3", "metadata": "root.CMDTYPE", "header": "['module', '___EOS___']", "index": 10 }, { "content": "class RETURN_CODES:\n SUCCESS = 255 # All is well\n ERROR = 0 # Generic error\n ERROR_SIZE = 1 # Data receieved does not match given command length\n ERROR_UNSUPPORTED = 2 # Unsupported command", "metadata": "root.RETURN_CODES", "header": "['module', '___EOS___']", "index": 16 }, { "content": "class DriverNetwork(DriverBase):\n \"\"\"Driver for communicating with another device on the network.\"\"\"\n\n\n\n\n # Push new data to strand\n", "metadata": "root.DriverNetwork", "header": "['module', '___EOS___']", "index": 23 }, { "content": " def __init__(self, num=0, width=0, height=0, host=\"localhost\", port=3142):\n super(DriverNetwork, self).__init__(num, width, height)\n\n self._host = host\n self._port = port", "metadata": "root.DriverNetwork.__init__", "header": "['class', 'DriverNetwork', '(', 'DriverBase', ')', ':', '___EOS___']", "index": 26 }, { "content": " def _generateHeader(self, cmd, size):\n packet = bytearray()\n packet.append(cmd)\n packet.append(size & 0xFF)\n packet.append(size >> 8)\n return packet", "metadata": "root.DriverNetwork._generateHeader", "header": "['class', 'DriverNetwork', '(', 'DriverBase', ')', ':', '___EOS___']", "index": 32 }, { "content": " def _connect(self):\n try:\n s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n s.connect((self._host, self._port))\n return s\n except socket.gaierror:\n error = \"Unable to connect to or resolve host: {}\".format(\n self._host)\n log.error(error)\n raise IOError(error)", "metadata": "root.DriverNetwork._connect", "header": "['class', 'DriverNetwork', '(', 'DriverBase', ')', ':', '___EOS___']", "index": 39 }, { "content": " def update(self, data):\n try:\n s = self._connect()\n\n count = self.bufByteCount\n packet = self._generateHeader(CMDTYPE.PIXEL_DATA, count)\n\n packet.extend(data)\n\n s.sendall(packet)\n\n resp = ord(s.recv(1))\n\n s.close()\n\n if resp != RETURN_CODES.SUCCESS:\n log.warning(\"Bytecount mismatch! %s\", resp)\n\n except Exception as e:\n log.exception(e)\n error = \"Problem communicating with network receiver!\"\n log.error(error)\n raise IOError(error)", "metadata": "root.DriverNetwork.update", "header": "['class', 'DriverNetwork', '(', 'DriverBase', ')', ':', '___EOS___']", "index": 51 }, { "content": " def setMasterBrightness(self, brightness):\n packet = self._generateHeader(CMDTYPE.BRIGHTNESS, 1)\n packet.append(brightness)\n s = self._connect()\n s.sendall(packet)\n resp = ord(s.recv(1))\n if resp != RETURN_CODES.SUCCESS:\n return False\n else:\n return True", "metadata": "root.DriverNetwork.setMasterBrightness", "header": "['class', 'DriverNetwork', '(', 'DriverBase', ')', ':', '___EOS___']", "index": 75 } ]
[ { "span": "import sys", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 10 }, { "span": "import time", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "driver", "\\u", "base_", "import_", "Drive", "r", "Base_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\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_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "sys_", "._", "path_", "._", "insert_", "(_", "0_", ",_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "log_", "\\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_", "MANIFEST", "_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "network", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "class", "\"_", ":_", "Drive", "r", "Network_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "driver", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "display", "\"_", ":_", "\"", "Network", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "desc", "\"_", ":_", "\"", "Sen", "ds", " ", "pixel", " ", "data", " ", "over", " ", "the", " ", "network", " ", "to", " ", "a", " ", "recieve", "r", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "params", "\"_", ":_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "num", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "label", "\"_", ":_", "\"#", " ", "Pixels", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "min", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "help", "\"_", ":_", "\"", "Total", " ", "pixel", "s", " ", "in", " ", "display", ".", " ", "Ma", "y", " ", "use", " ", "Wid", "th", " ", "AND", " ", "Hei", "ght", " ", "inst", "ead", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "widt", "h", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "label", "\"_", ":_", "\"", "Wid", "th", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "min", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "help", "\"_", ":_", "\"", "Wid", "th", " ", "of", " ", "display", ".", " ", "Set", " ", "if", " ", "usi", "ng", " ", "a", " ", "matrix", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "height", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "label", "\"_", ":_", "\"", "Hei", "ght", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "min", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "help", "\"_", ":_", "\"", "Hei", "ght", " ", "of", " ", "display", ".", " ", "Set", " ", "if", " ", "usi", "ng", " ", "a", " ", "matrix", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "host", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "label", "\"_", ":_", "\"", "Pix", "el", " ", "Size", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "str", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\"_", ":_", "\"", "local", "host", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "help", "\"_", ":_", "\"", "Receive", "r", " ", "host", " ", "to", " ", "connect", " ", "to", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "port", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "label", "\"_", ":_", "\"", "Port", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "default", "\"_", ":_", "314", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "help", "\"_", ":_", "\"", "Port", " ", "to", " ", "connect", " ", "to", ".\"_", "\\u\\u\\uNL\\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_", "CMD", "TYPE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SETUP", "\\u", "DATA_", "=_", "1_", "#", " ", "reserve", "d", " ", "for", " ", "future", " ", "use_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PIXEL", "\\u", "DATA_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BRIGHT", "NESS", "_", "=_", "3_", "\\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_", "RETURN", "\\u", "CODES_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SUCCESS_", "=_", "255_", "#", " ", "All", " ", "is", " ", "well_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ERROR_", "=_", "0_", "#", " ", "Gene", "ric", " ", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ERROR", "\\u", "SIZE_", "=_", "1_", "#", " ", "Data", " ", "rece", "ieve", "d", " ", "doe", "s", " ", "not", " ", "match", " ", "give", "n", " ", "command", " ", "length_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ERROR", "\\u", "UNSU", "PPO", "RTED", "_", "=_", "2_", "#", " ", "Unsu", "ppo", "rted", " ", "command_", "\\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_", "Drive", "r", "Network_", "(_", "Drive", "r", "Base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Drive", "r", " ", "for", " ", "communicati", "ng", " ", "with", " ", "anot", "her", " ", "device", " ", "on", " ", "the", " ", "network", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Push", " ", "new", " ", "data", " ", "to", " ", "strand_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Drive", "r", "Network_", "(_", "Drive", "r", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "num_", "=_", "0_", ",_", "width_", "=_", "0_", ",_", "height_", "=_", "0_", ",_", "host_", "=_", "\"", "local", "host", "\"_", ",_", "port_", "=_", "314", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Drive", "r", "Network_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "num_", ",_", "width_", ",_", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "host_", "=_", "host_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "port_", "=_", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Drive", "r", "Network_", "(_", "Drive", "r", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "generat", "e", "Header_", "(_", "self_", ",_", "cmd_", ",_", "size_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "packet_", "=_", "bytearray_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packet_", "._", "append_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packet_", "._", "append_", "(_", "size_", "&_", "0xFF_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packet_", "._", "append_", "(_", "size_", ">>_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "packet_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Drive", "r", "Network_", "(_", "Drive", "r", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "connect_", "(_", "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 ", " _", "s_", "=_", "socket_", "._", "socket_", "(_", "socket_", "._", "AF", "\\u", "INET_", ",_", "socket_", "._", "SOCK", "\\u", "STREAM_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "connect_", "(_", "(_", "self_", "._", "\\u", "host_", ",_", "self_", "._", "\\u", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "gai", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error_", "=_", "\"", "Una", "ble", " ", "to", " ", "connect", " ", "to", " ", "or", " ", "resolve", " ", "host", ":", " ", "{}\"_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "error_", "(_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "IO", "Error_", "(_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Drive", "r", "Network_", "(_", "Drive", "r", "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_", "def_", "update_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "self_", "._", "\\u", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "count_", "=_", "self_", "._", "buf", "Byte", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packet_", "=_", "self_", "._", "\\u", "generat", "e", "Header_", "(_", "CMD", "TYPE_", "._", "PIXEL", "\\u", "DATA_", ",_", "count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "packet_", "._", "extend_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "._", "sendall_", "(_", "packet_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resp_", "=_", "ord_", "(_", "s_", "._", "recv_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "resp_", "!=_", "RETURN", "\\u", "CODES_", "._", "SUCCESS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "warning_", "(_", "\"", "Byte", "count", " ", "mism", "atch", "!", " ", "%", "s", "\"_", ",_", "resp_", ")_", "\\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_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "exception_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "\"", "Prob", "lem", " ", "communicati", "ng", " ", "with", " ", "network", " ", "receive", "r", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "error_", "(_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "IO", "Error_", "(_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Drive", "r", "Network_", "(_", "Drive", "r", "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_", "def_", "set", "Master", "Bright", "ness_", "(_", "self_", ",_", "brightness_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "packet_", "=_", "self_", "._", "\\u", "generat", "e", "Header_", "(_", "CMD", "TYPE_", "._", "BRIGHT", "NESS", "_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packet_", "._", "append_", "(_", "brightness_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "self_", "._", "\\u", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "sendall_", "(_", "packet_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resp_", "=_", "ord_", "(_", "s_", "._", "recv_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "resp_", "!=_", "RETURN", "\\u", "CODES_", "._", "SUCCESS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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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, 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 ]
Unused import
cloudera/hue/desktop/core/ext-py/openpyxl-2.3.0-b2/openpyxl/reader/__init__.py
[ { "content": "from __future__ import absolute_import\n# Copyright (c) 2010-2015 openpyxl\n\n\"\"\"Imports for the openpyxl.reader namespace.\"\"\"\n\n# package imports\nfrom openpyxl.reader import excel\nfrom openpyxl.reader import strings\nfrom openpyxl.reader import style\nfrom openpyxl.reader import workbook\nfrom openpyxl.reader import worksheet\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from openpyxl.reader import excel", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 33 }, { "span": "from openpyxl.reader import strings", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 35 }, { "span": "from openpyxl.reader import style", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 33 }, { "span": "from openpyxl.reader import workbook", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 36 }, { "span": "from openpyxl.reader import worksheet", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 37 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2010", "-", "201", "5", " ", "openp", "yx", "l_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Imports", " ", "for", " ", "the", " ", "openp", "yx", "l", ".", "reader", " ", "namespace", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "package", " ", "imports_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "openp", "yx", "l_", "._", "reader_", "import_", "excel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openp", "yx", "l_", "._", "reader_", "import_", "strings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openp", "yx", "l_", "._", "reader_", "import_", "style_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openp", "yx", "l_", "._", "reader_", "import_", "workbook_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openp", "yx", "l_", "._", "reader_", "import_", "worksheet_" ]
[ 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, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1 ]
Imprecise assert
mc706/django-angular-scaffold/angular_scaffold/tests/startservice_test.py
[ { "content": " def test_view(self):\n generate_service(self.BASE_DIR, 'test', '/', 'tests')\n self.assertTrue(\n os.path.exists(os.path.join(self.BASE_DIR, 'assets', 'app', 'services', 'testService.js')))\n with open(os.path.join(self.BASE_DIR, 'assets', 'app', 'services', 'testService.js'), 'r') as js:\n service = js.read()\n self.assertTrue('listTests' in service)\n self.assertTrue('getTest' in service)\n self.assertTrue('createTest' in service)\n self.assertTrue('updateTest' in service)\n self.assertTrue('deleteTest' in service)", "metadata": "root.StartServiceTest.test_view", "header": "['class', 'StartServiceTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 15 } ]
[ { "span": "self.assertTrue('listTests' in service)", "start_line": 21, "start_column": 12, "end_line": 21, "end_column": 51 }, { "span": "self.assertTrue('getTest' in service)", "start_line": 22, "start_column": 12, "end_line": 22, "end_column": 49 }, { "span": "self.assertTrue('createTest' in service)", "start_line": 23, "start_column": 12, "end_line": 23, "end_column": 52 }, { "span": "self.assertTrue('updateTest' in service)", "start_line": 24, "start_column": 12, "end_line": 24, "end_column": 52 }, { "span": "self.assertTrue('deleteTest' in service)", "start_line": 25, "start_column": 12, "end_line": 25, "end_column": 52 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Start", "Service", "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", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "generat", "e\\u", "service_", "(_", "self_", "._", "BASE", "\\u", "DIR_", ",_", "'", "test", "'_", ",_", "'/'_", ",_", "'", "tests", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "path_", "._", "exists_", "(_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "BASE", "\\u", "DIR_", ",_", "'", "asset", "s", "'_", ",_", "'", "app", "'_", ",_", "'", "service", "s", "'_", ",_", "'", "test", "Service", ".", "js", "'_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "BASE", "\\u", "DIR_", ",_", "'", "asset", "s", "'_", ",_", "'", "app", "'_", ",_", "'", "service", "s", "'_", ",_", "'", "test", "Service", ".", "js", "'_", ")_", ",_", "'", "r", "'_", ")_", "as_", "js_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "service_", "=_", "js_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "list", "Test", "s", "'_", "in_", "service_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "get", "Test", "'_", "in_", "service_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "create", "Test", "'_", "in_", "service_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "update", "Test", "'_", "in_", "service_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "delete", "Test", "'_", "in_", "service_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
SheffieldML/GPy/GPy/testing/examples_tests.py
[ { "content": "# Copyright (c) 2012, GPy authors (see AUTHORS.txt).\n# Licensed under the BSD 3-clause license (see LICENSE.txt)\n\nimport unittest\nimport numpy as np\nimport GPy\nimport inspect\nimport pkgutil\nimport os\nimport random\nfrom nose.tools import nottest\nimport sys\nimport itertools\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n print(\"Running unit tests, please be (very) patient...\")\n # unittest.main()\n test_models()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ExamplesTests(unittest.TestCase):\n", "metadata": "root.ExamplesTests", "header": "['module', '___EOS___']", "index": 14 }, { "content": " def _checkgrad(self, Model):\n self.assertTrue(Model.checkgrad())", "metadata": "root.ExamplesTests._checkgrad", "header": "['class', 'ExamplesTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 15 }, { "content": " def _model_instance(self, Model):\n self.assertTrue(isinstance(Model, GPy.models))", "metadata": "root.ExamplesTests._model_instance", "header": "['class', 'ExamplesTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 18 }, { "content": "def model_checkgrads(model):\n model.randomize()\n #NOTE: Step as 1e-4, this should be acceptable for more peaky models\n return model.checkgrad(step=1e-4)", "metadata": "root.model_checkgrads", "header": "['module', '___EOS___']", "index": 21 }, { "content": "def model_instance(model):\n return isinstance(model, GPy.core.model.Model)", "metadata": "root.model_instance", "header": "['module', '___EOS___']", "index": 26 }, { "content": "def flatten_nested(lst):\n result = []\n for element in lst:\n if hasattr(element, '__iter__'):\n result.extend(flatten_nested(element))\n else:\n result.append(element)\n return result", "metadata": "root.flatten_nested", "header": "['module', '___EOS___']", "index": 29 }, { "content": "@nottest\ndef test_models():\n optimize=False\n plot=True\n examples_path = os.path.dirname(GPy.examples.__file__)\n # Load modules\n failing_models = {}\n for loader, module_name, is_pkg in pkgutil.iter_modules([examples_path]):\n # Load examples\n module_examples = loader.find_module(module_name).load_module(module_name)\n print(\"MODULE\", module_examples)\n print(\"Before\")\n print(inspect.getmembers(module_examples, predicate=inspect.isfunction))\n functions = [ func for func in inspect.getmembers(module_examples, predicate=inspect.isfunction) if func[0].startswith('_') is False ][::-1]\n print(\"After\")\n print(functions)\n for example in functions:\n if example[0] in ['epomeo_gpx']:\n #These are the edge cases that we might want to handle specially\n if example[0] == 'epomeo_gpx' and not GPy.util.datasets.gpxpy_available:\n print(\"Skipping as gpxpy is not available to parse GPS\")\n continue\n\n print(\"Testing example: \", example[0])\n # Generate model\n\n try:\n models = [ example[1](optimize=optimize, plot=plot) ]\n #If more than one model returned, flatten them\n models = flatten_nested(models)\n except Exception as e:\n failing_models[example[0]] = \"Cannot make model: \\n{e}\".format(e=e)\n else:\n print(models)\n model_checkgrads.description = 'test_checkgrads_%s' % example[0]\n try:\n for model in models:\n if not model_checkgrads(model):\n failing_models[model_checkgrads.description] = False\n except Exception as e:\n failing_models[model_checkgrads.description] = e\n\n model_instance.description = 'test_instance_%s' % example[0]\n try:\n for model in models:\n if not model_instance(model):\n failing_models[model_instance.description] = False\n except Exception as e:\n failing_models[model_instance.description] = e\n\n #yield model_checkgrads, model\n #yield model_instance, model\n\n print(\"Finished checking module {m}\".format(m=module_name))\n if len(failing_models.keys()) > 0:\n print(\"Failing models: \")\n print(failing_models)\n\n if len(failing_models.keys()) > 0:\n print(failing_models)\n raise Exception(failing_models)", "metadata": "root.test_models", "header": "['module', '___EOS___']", "index": 38 } ]
[ { "span": "import numpy as np", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 18 }, { "span": "import random", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 13 }, { "span": "import sys", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 10 }, { "span": "import itertools", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 16 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2012", ",", " ", "GP", "y", " ", "author", "s", " ", "(", "see", " ", "AUTHOR", "S", ".", "txt", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "under", " ", "the", " ", "BS", "D", " ", "3", "-", "clause", " ", "license", " ", "(", "see", " ", "LICENSE", ".", "txt", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "GP", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "inspect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pkg", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nose_", "._", "tools_", "import_", "not", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "itertools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Run", "ning", " ", "unit", " ", "tests", ",", " ", "plea", "se", " ", "be", " ", "(", "very", ")", " ", "patien", "t", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "unittest", ".", "main", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "models_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Exam", "ples", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Exam", "ples", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u", "check", "grad_", "(_", "self_", ",_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "Model_", "._", "check", "grad_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "ples", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "model", "\\u", "instance_", "(_", "self_", ",_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "Model_", ",_", "GP", "y_", "._", "models_", ")_", ")_", "\\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_", "model", "\\u", "check", "grads_", "(_", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "._", "randomize", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "NOTE", ":", " ", "Step", " ", "as", " ", "1e-", "4", ",", " ", "this", " ", "shou", "ld", " ", "be", " ", "acceptabl", "e", " ", "for", " ", "more", " ", "peak", "y", " ", "models_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "model_", "._", "check", "grad_", "(_", "step_", "=_", "1e-4_", ")_", "\\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_", "model", "\\u", "instance_", "(_", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "isinstance_", "(_", "model_", ",_", "GP", "y_", "._", "core_", "._", "model_", "._", "Model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "flat", "ten", "\\u", "nested_", "(_", "lst_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "element_", "in_", "lst_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "element_", ",_", "'\\u", "\\u", "iter", "\\u\\u'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "extend_", "(_", "flat", "ten", "\\u", "nested_", "(_", "element_", ")_", ")_", "\\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_", "._", "append_", "(_", "element_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "not", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "models_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "optimize_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "example", "s", "\\u", "path_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "GP", "y_", "._", "examples_", "._", "\\u\\u", "file\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Load", " ", "modules_", "\\u\\u\\uNL\\u\\u\\u_", "faili", "ng", "\\u", "models_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "loader_", ",_", "module", "\\u", "name_", ",_", "is", "\\u", "pkg_", "in_", "pkg", "util_", "._", "iter", "\\u", "modules_", "(_", "[_", "example", "s", "\\u", "path_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Load", " ", "examples_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "examples_", "=_", "loader_", "._", "find", "\\u", "module_", "(_", "module", "\\u", "name_", ")_", "._", "load", "\\u", "module_", "(_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "MODUL", "E", "\"_", ",_", "module", "\\u", "examples_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Be", "fore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "inspect_", "._", "getmember", "s_", "(_", "module", "\\u", "examples_", ",_", "predicate_", "=_", "inspect_", "._", "isf", "unction_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "functions_", "=_", "[_", "func_", "for_", "func_", "in_", "inspect_", "._", "getmember", "s_", "(_", "module", "\\u", "examples_", ",_", "predicate_", "=_", "inspect_", "._", "isf", "unction_", ")_", "if_", "func_", "[_", "0_", "]_", "._", "startswith_", "(_", "'\\u'_", ")_", "is_", "False_", "]_", "[_", ":_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Af", "ter", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "functions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "example_", "in_", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "example_", "[_", "0_", "]_", "in_", "[_", "'", "epo", "meo", "\\u", "gpx", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "The", "se", " ", "are", " ", "the", " ", "edge", " ", "case", "s", " ", "tha", "t", " ", "we", " ", "mig", "ht", " ", "want", " ", "to", " ", "handle", " ", "special", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "example_", "[_", "0_", "]_", "==_", "'", "epo", "meo", "\\u", "gpx", "'_", "and_", "not_", "GP", "y_", "._", "util_", "._", "datasets_", "._", "gpx", "py", "\\u", "available_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "\"", "Ski", "ppi", "ng", " ", "as", " ", "gpx", "py", " ", "is", " ", "not", " ", "avail", "able", " ", "to", " ", "parse", " ", "GPS", "\"_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "example", ":", " ", "\"_", ",_", "example_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Generate", " ", "model_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "models_", "=_", "[_", "example_", "[_", "1_", "]_", "(_", "optimize_", "=_", "optimize_", ",_", "plot_", "=_", "plot_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "If", " ", "more", " ", "than", " ", "one", " ", "model", " ", "return", "ed", ",", " ", "flat", "ten", " ", "them", "_", "\\u\\u\\uNL\\u\\u\\u_", "models_", "=_", "flat", "ten", "\\u", "nested_", "(_", "models_", ")_", "\\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 ", " _", "faili", "ng", "\\u", "models_", "[_", "example_", "[_", "0_", "]_", "]_", "=_", "\"", "Cann", "ot", " ", "make", " ", "model", ":", " ", "\\\\", "n", "{", "e", "}\"_", "._", "format_", "(_", "e_", "=_", "e_", ")_", "\\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_", "(_", "models_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model", "\\u", "check", "grads_", "._", "description_", "=_", "'", "test\\u", "check", "grads", "\\u", "%", "s", "'_", "%_", "example_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "model_", "in_", "models_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "model", "\\u", "check", "grads_", "(_", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "faili", "ng", "\\u", "models_", "[_", "model", "\\u", "check", "grads_", "._", "description_", "]_", "=_", "False_", "\\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_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "faili", "ng", "\\u", "models_", "[_", "model", "\\u", "check", "grads_", "._", "description_", "]_", "=_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "model", "\\u", "instance_", "._", "description_", "=_", "'", "test\\u", "instance", "\\u", "%", "s", "'_", "%_", "example_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "model_", "in_", "models_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "model", "\\u", "instance_", "(_", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "faili", "ng", "\\u", "models_", "[_", "model", "\\u", "instance_", "._", "description_", "]_", "=_", "False_", "\\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_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "faili", "ng", "\\u", "models_", "[_", "model", "\\u", "instance_", "._", "description_", "]_", "=_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "yield", " ", "model", "\\u", "check", "grads", ",", " ", "model_", "\\u\\u\\uNL\\u\\u\\u_", "#", "yield", " ", "model", "\\u", "instance", ",", " ", "model_", "\\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_", "print_", "(_", "\"", "Finish", "ed", " ", "checking", " ", "module", " ", "{", "m", "}\"_", "._", "format_", "(_", "m_", "=_", "module", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "faili", "ng", "\\u", "models_", "._", "keys_", "(_", ")_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Fail", "ing", " ", "model", "s", ":", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "faili", "ng", "\\u", "models_", ")_", "\\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_", "len_", "(_", "faili", "ng", "\\u", "models_", "._", "keys_", "(_", ")_", ")_", ">_", "0_", ":_", "\\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 ]
Imprecise assert
rcbops/glance-buildpackage/glance/tests/functional/test_api.py
[ { "content": " @skip_if_disabled\n def test_version_variations(self):\n \"\"\"\n We test that various calls to the images and root endpoints are\n handled properly, and that usage of the Accept: header does\n content negotiation properly.\n \"\"\"\n\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n versions = {'versions': [{\n \"id\": \"v1.1\",\n \"status\": \"CURRENT\",\n \"links\": [{\n \"rel\": \"self\",\n \"href\": \"http://0.0.0.0:%d/v1/\" % self.api_port}]}, {\n \"id\": \"v1.0\",\n \"status\": \"SUPPORTED\",\n \"links\": [{\n \"rel\": \"self\",\n \"href\": \"http://0.0.0.0:%d/v1/\" % self.api_port}]}]}\n versions_json = json.dumps(versions)\n images = {'images': []}\n images_json = json.dumps(images)\n\n # 0. GET / with no Accept: header\n # Verify version choices returned.\n # Bug lp:803260 no Accept header causes a 500 in glance-api\n path = \"http://%s:%d/\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n\n # 1. GET /images with no Accept: header\n # Verify version choices returned.\n path = \"http://%s:%d/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n\n # 2. GET /v1/images with no Accept: header\n # Verify empty images list returned.\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n self.assertEqual(content, images_json)\n\n # 3. GET / with Accept: unknown header\n # Verify version choices returned. Verify message in API log about\n # unknown accept header.\n path = \"http://%s:%d/\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n headers = {'Accept': 'unknown'}\n response, content = http.request(path, 'GET', headers=headers)\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n self.assertTrue('Unknown accept header'\n in open(self.api_server.log_file).read())\n\n # 4. GET / with an Accept: application/vnd.openstack.images-v1\n # Verify empty image list returned\n path = \"http://%s:%d/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n headers = {'Accept': 'application/vnd.openstack.images-v1'}\n response, content = http.request(path, 'GET', headers=headers)\n self.assertEqual(response.status, 200)\n self.assertEqual(content, images_json)\n\n # 5. GET /images with a Accept: application/vnd.openstack.compute-v1\n # header. Verify version choices returned. Verify message in API log\n # about unknown accept header.\n path = \"http://%s:%d/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n headers = {'Accept': 'application/vnd.openstack.compute-v1'}\n response, content = http.request(path, 'GET', headers=headers)\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n self.assertTrue('Unknown accept header'\n in open(self.api_server.log_file).read())\n\n # 6. GET /v1.0/images with no Accept: header\n # Verify empty image list returned\n path = \"http://%s:%d/v1.0/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n self.assertEqual(content, images_json)\n\n # 7. GET /v1.a/images with no Accept: header\n # Verify empty image list returned\n path = \"http://%s:%d/v1.a/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n self.assertEqual(content, images_json)\n\n # 8. GET /va.1/images with no Accept: header\n # Verify version choices returned\n path = \"http://%s:%d/va.1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n\n # 9. GET /versions with no Accept: header\n # Verify version choices returned\n path = \"http://%s:%d/versions\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n\n # 10. GET /versions with a Accept: application/vnd.openstack.images-v1\n # header. Verify version choices returned.\n path = \"http://%s:%d/versions\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n headers = {'Accept': 'application/vnd.openstack.images-v1'}\n response, content = http.request(path, 'GET', headers=headers)\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n\n # 11. GET /v1/versions with no Accept: header\n # Verify 404 returned\n path = \"http://%s:%d/v1/versions\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 404)\n\n # 12. GET /v2/versions with no Accept: header\n # Verify version choices returned\n path = \"http://%s:%d/v2/versions\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n\n # 13. GET /images with a Accept: application/vnd.openstack.compute-v2\n # header. Verify version choices returned. Verify message in API log\n # about unknown version in accept header.\n path = \"http://%s:%d/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n headers = {'Accept': 'application/vnd.openstack.images-v2'}\n response, content = http.request(path, 'GET', headers=headers)\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n self.assertTrue('Unknown accept header'\n in open(self.api_server.log_file).read())\n\n # 14. GET /v1.2/images with no Accept: header\n # Verify version choices returned\n path = \"http://%s:%d/v1.2/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 300)\n self.assertEqual(content, versions_json)\n self.assertTrue('Unknown version in versioned URI'\n in open(self.api_server.log_file).read())\n\n self.stop_servers()", "metadata": "root.TestApi.test_version_variations", "header": "['class', 'TestApi', '(', 'functional', '.', 'FunctionalTest', ')', ':', '___EOS___']", "index": 410 }, { "content": " @skip_if_disabled\n def test_filtered_images(self):\n \"\"\"\n Set up four test images and ensure each query param filter works\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n # 0. GET /images\n # Verify no public images\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n self.assertEqual(content, '{\"images\": []}')\n\n image_ids = []\n\n # 1. POST /images with three public images, and one private image\n # with various attributes\n headers = {'Content-Type': 'application/octet-stream',\n 'X-Image-Meta-Name': 'Image1',\n 'X-Image-Meta-Status': 'active',\n 'X-Image-Meta-Container-Format': 'ovf',\n 'X-Image-Meta-Disk-Format': 'vdi',\n 'X-Image-Meta-Size': '19',\n 'X-Image-Meta-Is-Public': 'True',\n 'X-Image-Meta-Protected': 'True',\n 'X-Image-Meta-Property-pants': 'are on'}\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'POST', headers=headers)\n self.assertEqual(response.status, 201)\n data = json.loads(content)\n self.assertEqual(data['image']['properties']['pants'], \"are on\")\n self.assertEqual(data['image']['is_public'], True)\n image_ids.append(data['image']['id'])\n\n headers = {'Content-Type': 'application/octet-stream',\n 'X-Image-Meta-Name': 'My Image!',\n 'X-Image-Meta-Status': 'active',\n 'X-Image-Meta-Container-Format': 'ovf',\n 'X-Image-Meta-Disk-Format': 'vhd',\n 'X-Image-Meta-Size': '20',\n 'X-Image-Meta-Is-Public': 'True',\n 'X-Image-Meta-Protected': 'False',\n 'X-Image-Meta-Property-pants': 'are on'}\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'POST', headers=headers)\n self.assertEqual(response.status, 201)\n data = json.loads(content)\n self.assertEqual(data['image']['properties']['pants'], \"are on\")\n self.assertEqual(data['image']['is_public'], True)\n image_ids.append(data['image']['id'])\n\n headers = {'Content-Type': 'application/octet-stream',\n 'X-Image-Meta-Name': 'My Image!',\n 'X-Image-Meta-Status': 'saving',\n 'X-Image-Meta-Container-Format': 'ami',\n 'X-Image-Meta-Disk-Format': 'ami',\n 'X-Image-Meta-Size': '21',\n 'X-Image-Meta-Is-Public': 'True',\n 'X-Image-Meta-Protected': 'False',\n 'X-Image-Meta-Property-pants': 'are off'}\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'POST', headers=headers)\n self.assertEqual(response.status, 201)\n data = json.loads(content)\n self.assertEqual(data['image']['properties']['pants'], \"are off\")\n self.assertEqual(data['image']['is_public'], True)\n image_ids.append(data['image']['id'])\n\n headers = {'Content-Type': 'application/octet-stream',\n 'X-Image-Meta-Name': 'My Private Image',\n 'X-Image-Meta-Status': 'active',\n 'X-Image-Meta-Container-Format': 'ami',\n 'X-Image-Meta-Disk-Format': 'ami',\n 'X-Image-Meta-Size': '22',\n 'X-Image-Meta-Is-Public': 'False',\n 'X-Image-Meta-Protected': 'False'}\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'POST', headers=headers)\n self.assertEqual(response.status, 201)\n data = json.loads(content)\n self.assertEqual(data['image']['is_public'], False)\n image_ids.append(data['image']['id'])\n\n # 2. GET /images\n # Verify three public images\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 3)\n\n # 3. GET /images with name filter\n # Verify correct images returned with name\n params = \"name=My%20Image!\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 2)\n for image in data['images']:\n self.assertEqual(image['name'], \"My Image!\")\n\n # 4. GET /images with status filter\n # Verify correct images returned with status\n params = \"status=queued\"\n path = \"http://%s:%d/v1/images/detail?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 3)\n for image in data['images']:\n self.assertEqual(image['status'], \"queued\")\n\n params = \"status=active\"\n path = \"http://%s:%d/v1/images/detail?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 0)\n\n # 5. GET /images with container_format filter\n # Verify correct images returned with container_format\n params = \"container_format=ovf\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 2)\n for image in data['images']:\n self.assertEqual(image['container_format'], \"ovf\")\n\n # 6. GET /images with disk_format filter\n # Verify correct images returned with disk_format\n params = \"disk_format=vdi\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 1)\n for image in data['images']:\n self.assertEqual(image['disk_format'], \"vdi\")\n\n # 7. GET /images with size_max filter\n # Verify correct images returned with size <= expected\n params = \"size_max=20\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 2)\n for image in data['images']:\n self.assertTrue(image['size'] <= 20)\n\n # 8. GET /images with size_min filter\n # Verify correct images returned with size >= expected\n params = \"size_min=20\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 2)\n for image in data['images']:\n self.assertTrue(image['size'] >= 20)\n\n # 9. Get /images with is_public=None filter\n # Verify correct images returned with property\n # Bug lp:803656 Support is_public in filtering\n params = \"is_public=None\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 4)\n\n # 10. Get /images with is_public=False filter\n # Verify correct images returned with property\n # Bug lp:803656 Support is_public in filtering\n params = \"is_public=False\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 1)\n for image in data['images']:\n self.assertEqual(image['name'], \"My Private Image\")\n\n # 11. Get /images with is_public=True filter\n # Verify correct images returned with property\n # Bug lp:803656 Support is_public in filtering\n params = \"is_public=True\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 3)\n for image in data['images']:\n self.assertNotEqual(image['name'], \"My Private Image\")\n\n # 12. Get /images with protected=False filter\n # Verify correct images returned with property\n params = \"protected=False\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 2)\n for image in data['images']:\n self.assertNotEqual(image['name'], \"Image1\")\n\n # 13. Get /images with protected=True filter\n # Verify correct images returned with property\n params = \"protected=True\"\n path = \"http://%s:%d/v1/images?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 1)\n for image in data['images']:\n self.assertEqual(image['name'], \"Image1\")\n\n # 14. GET /images with property filter\n # Verify correct images returned with property\n params = \"property-pants=are%20on\"\n path = \"http://%s:%d/v1/images/detail?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 2)\n for image in data['images']:\n self.assertEqual(image['properties']['pants'], \"are on\")\n\n # 15. GET /images with property filter and name filter\n # Verify correct images returned with property and name\n # Make sure you quote the url when using more than one param!\n params = \"name=My%20Image!&property-pants=are%20on\"\n path = \"http://%s:%d/v1/images/detail?%s\" % (\n \"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 1)\n for image in data['images']:\n self.assertEqual(image['properties']['pants'], \"are on\")\n self.assertEqual(image['name'], \"My Image!\")\n\n # 16. GET /images with past changes-since filter\n dt1 = datetime.datetime.utcnow() - datetime.timedelta(1)\n iso1 = utils.isotime(dt1)\n params = \"changes-since=%s\" % iso1\n path = \"http://%s:%d/v1/images?%s\" % (\"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 3)\n\n # 17. GET /images with future changes-since filter\n dt2 = datetime.datetime.utcnow() + datetime.timedelta(1)\n iso2 = utils.isotime(dt2)\n params = \"changes-since=%s\" % iso2\n path = \"http://%s:%d/v1/images?%s\" % (\"0.0.0.0\", self.api_port, params)\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n data = json.loads(content)\n self.assertEqual(len(data['images']), 0)\n\n self.stop_servers()", "metadata": "root.TestApi.test_filtered_images", "header": "['class', 'TestApi', '(', 'functional', '.', 'FunctionalTest', ')', ':', '___EOS___']", "index": 642 } ]
[ { "span": "self.assertTrue('Unknown accept header'\n in open(self.api_server.log_file).read())", "start_line": 470, "start_column": 8, "end_line": 471, "end_column": 65 }, { "span": "self.assertTrue('Unknown accept header'\n in open(self.api_server.log_file).read())", "start_line": 491, "start_column": 8, "end_line": 492, "end_column": 65 }, { "span": "self.assertTrue('Unknown accept header'\n in open(self.api_server.log_file).read())", "start_line": 559, "start_column": 8, "end_line": 560, "end_column": 65 }, { "span": "self.assertTrue('Unknown version in versioned URI'\n in open(self.api_server.log_file).read())", "start_line": 569, "start_column": 8, "end_line": 570, "end_column": 65 }, { "span": "self.assertTrue(image['size'] <= 20)", "start_line": 806, "start_column": 12, "end_line": 806, "end_column": 48 }, { "span": "self.assertTrue(image['size'] >= 20)", "start_line": 818, "start_column": 12, "end_line": 818, "end_column": 48 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Api_", "(_", "functional_", "._", "Function", "al", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "version", "\\u", "variations", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "test", " ", "tha", "t", " ", "vari", "ous", " ", "calls", " ", "to", " ", "the", " ", "images", " ", "and", " ", "root", " ", "endpoint", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "handle", "d", " ", "proper", "ly", ",", " ", "and", " ", "tha", "t", " ", "usage", " ", "of", " ", "the", " ", "Accept", ":", " ", "header", " ", "doe", "s", "\\", "10", ";", " ", " ", " ", " ", "content", " ", "negotiat", "ion", " ", "proper", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "versions_", "=_", "{_", "'", "version", "s", "'_", ":_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "v1", ".1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "status", "\"_", ":_", "\"", "CURREN", "T", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "link", "s", "\"_", ":_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "rel", "\"_", ":_", "\"", "self", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "href", "\"_", ":_", "\"", "http", "://", "0.", "0.", "0.", "0", ":", "%", "d", "/", "v1", "/\"_", "%_", "self_", "._", "api", "\\u", "port_", "}_", "]_", "}_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "\"", "v1", ".0", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "status", "\"_", ":_", "\"", "SUPPORTED", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "link", "s", "\"_", ":_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "rel", "\"_", ":_", "\"", "self", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "href", "\"_", ":_", "\"", "http", "://", "0.", "0.", "0.", "0", ":", "%", "d", "/", "v1", "/\"_", "%_", "self_", "._", "api", "\\u", "port_", "}_", "]_", "}_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "s", "\\u", "json_", "=_", "json_", "._", "dumps_", "(_", "versions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", "=_", "{_", "'", "images", "'_", ":_", "[_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images", "\\u", "json_", "=_", "json_", "._", "dumps_", "(_", "images_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "0.", " ", "GET", " ", "/", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "return", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bug", " ", "lp", ":", "803", "260", " ", " ", "no", " ", "Accept", " ", "header", " ", "caus", "es", " ", "a", " ", "500", " ", "in", " ", "gla", "nce", "-", "api_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "return", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", ".", " ", "GET", " ", "/", "v1", "/", "images", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "empty", " ", "images", " ", "list", " ", "return", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "images", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "3", ".", " ", "GET", " ", "/", " ", "with", " ", "Accept", ":", " ", "unknown", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "return", "ed", ".", " ", "Verify", " ", "message", " ", "in", " ", "API", " ", "log", " ", "about_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "unknown", " ", "accept", " ", "header", "._", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "Accept", "'_", ":_", "'", "unknown", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "Un", "know", "n", " ", "accept", " ", "header", "'_", "\\u\\u\\uNL\\u\\u\\u_", "in_", "open_", "(_", "self_", "._", "api", "\\u", "server_", "._", "log", "\\u", "file_", ")_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "4", ".", " ", "GET", " ", "/", " ", "with", " ", "an", " ", "Accept", ":", " ", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "images", "-", "v1_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "empty", " ", "image", " ", "list", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "Accept", "'_", ":_", "'", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "images", "-", "v1", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "images", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "5", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "a", " ", "Accept", ":", " ", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "compute", "-", "v1_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "header", ".", " ", "Verify", " ", "version", " ", "choice", "s", " ", "return", "ed", ".", " ", "Verify", " ", "message", " ", "in", " ", "API", " ", "log_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "abo", "ut", " ", "unknown", " ", "accept", " ", "header", "._", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "Accept", "'_", ":_", "'", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "compute", "-", "v1", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "Un", "know", "n", " ", "accept", " ", "header", "'_", "\\u\\u\\uNL\\u\\u\\u_", "in_", "open_", "(_", "self_", "._", "api", "\\u", "server_", "._", "log", "\\u", "file_", ")_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "6", ".", " ", "GET", " ", "/", "v1", ".0", "/", "images", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "empty", " ", "image", " ", "list", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", ".0", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "images", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "7", ".", " ", "GET", " ", "/", "v1", ".", "a", "/", "images", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "empty", " ", "image", " ", "list", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", ".", "a", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "images", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "8", ".", " ", "GET", " ", "/", "va", ".1", "/", "images", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "va", ".1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "9", ".", " ", "GET", " ", "/", "version", "s", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "version", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "10.", " ", "GET", " ", "/", "version", "s", " ", "with", " ", "a", " ", "Accept", ":", " ", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "images", "-", "v1_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "header", ".", " ", "Verify", " ", "version", " ", "choice", "s", " ", "return", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "version", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "Accept", "'_", ":_", "'", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "images", "-", "v1", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "11.", " ", "GET", " ", "/", "v1", "/", "version", "s", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "404", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "version", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "404_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "12.", " ", "GET", " ", "/", "v2", "/", "version", "s", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v2", "/", "version", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "13.", " ", "GET", " ", "/", "images", " ", "with", " ", "a", " ", "Accept", ":", " ", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "compute", "-", "v2_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "header", ".", " ", "Verify", " ", "version", " ", "choice", "s", " ", "return", "ed", ".", " ", "Verify", " ", "message", " ", "in", " ", "API", " ", "log_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "abo", "ut", " ", "unknown", " ", "version", " ", "in", " ", "accept", " ", "header", "._", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "Accept", "'_", ":_", "'", "applica", "tion", "/", "vn", "d", ".", "openst", "ack", ".", "images", "-", "v2", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "Un", "know", "n", " ", "accept", " ", "header", "'_", "\\u\\u\\uNL\\u\\u\\u_", "in_", "open_", "(_", "self_", "._", "api", "\\u", "server_", "._", "log", "\\u", "file_", ")_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "14.", " ", "GET", " ", "/", "v1", ".2", "/", "images", " ", "with", " ", "no", " ", "Accept", ":", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "version", " ", "choice", "s", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", ".2", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "version", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "Un", "know", "n", " ", "version", " ", "in", " ", "versioned", " ", "URI", "'_", "\\u\\u\\uNL\\u\\u\\u_", "in_", "open_", "(_", "self_", "._", "api", "\\u", "server_", "._", "log", "\\u", "file_", ")_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Api_", "(_", "functional_", "._", "Function", "al", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "filter", "ed", "\\u", "images_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Set", " ", "up", " ", "four", " ", "test", " ", "images", " ", "and", " ", "ensure", " ", "each", " ", "query", " ", "param", " ", "filter", " ", "works", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "0.", " ", "GET", " ", "/", "images_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "no", " ", "public", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "'{", "\"", "images", "\":", " ", "[]", "}'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "ids_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ".", " ", "POST", " ", "/", "images", " ", "with", " ", "three", " ", "public", " ", "images", ",", " ", "and", " ", "one", " ", "private", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "vari", "ous", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "{_", "'", "Conten", "t", "-", "Type", "'_", ":_", "'", "applica", "tion", "/", "oct", "et", "-", "stream", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Name", "'_", ":_", "'", "Image", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Status", "'_", ":_", "'", "active", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Containe", "r", "-", "Format", "'_", ":_", "'", "ov", "f", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Disk", "-", "Format", "'_", ":_", "'", "vdi", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Size", "'_", ":_", "'", "1", "9", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Is", "-", "Public", "'_", ":_", "'", "Tru", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Protect", "ed", "'_", ":_", "'", "Tru", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Proper", "ty", "-", "pant", "s", "'_", ":_", "'", "are", " ", "on", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "POST", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "proper", "ties", "'_", "]_", "[_", "'", "pant", "s", "'_", "]_", ",_", "\"", "are", " ", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "is", "\\u", "public", "'_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "ids_", "._", "append_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "{_", "'", "Conten", "t", "-", "Type", "'_", ":_", "'", "applica", "tion", "/", "oct", "et", "-", "stream", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Name", "'_", ":_", "'", "My", " ", "Image", "!'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Status", "'_", ":_", "'", "active", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Containe", "r", "-", "Format", "'_", ":_", "'", "ov", "f", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Disk", "-", "Format", "'_", ":_", "'", "vhd", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Size", "'_", ":_", "'", "20", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Is", "-", "Public", "'_", ":_", "'", "Tru", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Protect", "ed", "'_", ":_", "'", "Fal", "se", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Proper", "ty", "-", "pant", "s", "'_", ":_", "'", "are", " ", "on", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "POST", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "proper", "ties", "'_", "]_", "[_", "'", "pant", "s", "'_", "]_", ",_", "\"", "are", " ", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "is", "\\u", "public", "'_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "ids_", "._", "append_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "{_", "'", "Conten", "t", "-", "Type", "'_", ":_", "'", "applica", "tion", "/", "oct", "et", "-", "stream", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Name", "'_", ":_", "'", "My", " ", "Image", "!'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Status", "'_", ":_", "'", "saving", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Containe", "r", "-", "Format", "'_", ":_", "'", "ami", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Disk", "-", "Format", "'_", ":_", "'", "ami", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Size", "'_", ":_", "'", "21", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Is", "-", "Public", "'_", ":_", "'", "Tru", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Protect", "ed", "'_", ":_", "'", "Fal", "se", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Proper", "ty", "-", "pant", "s", "'_", ":_", "'", "are", " ", "off", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "POST", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "proper", "ties", "'_", "]_", "[_", "'", "pant", "s", "'_", "]_", ",_", "\"", "are", " ", "off", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "is", "\\u", "public", "'_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "ids_", "._", "append_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "{_", "'", "Conten", "t", "-", "Type", "'_", ":_", "'", "applica", "tion", "/", "oct", "et", "-", "stream", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Name", "'_", ":_", "'", "My", " ", "Priva", "te", " ", "Image", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Status", "'_", ":_", "'", "active", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Containe", "r", "-", "Format", "'_", ":_", "'", "ami", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Disk", "-", "Format", "'_", ":_", "'", "ami", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Size", "'_", ":_", "'", "2", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Is", "-", "Public", "'_", ":_", "'", "Fal", "se", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Protect", "ed", "'_", ":_", "'", "Fal", "se", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "POST", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "is", "\\u", "public", "'_", "]_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "ids_", "._", "append_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", ".", " ", "GET", " ", "/", "images_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "three", " ", "public", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "3", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "name", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "=_", "\"", "name", "=", "My", "%", "20", "Image", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "name", "'_", "]_", ",_", "\"", "My", " ", "Image", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "4", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "status", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "status_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "status", "=", "queue", "d", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "deta", "il", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "status", "'_", "]_", ",_", "\"", "queue", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "status", "=", "active", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "deta", "il", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "5", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "container", "\\u", "format", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "container", "\\u", "format_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "=_", "\"", "container", "\\u", "format", "=", "ov", "f", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "container", "\\u", "format", "'_", "]_", ",_", "\"", "ov", "f", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "6", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "disk", "\\u", "format", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "disk", "\\u", "format_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "disk", "\\u", "format", "=", "vdi", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "disk", "\\u", "format", "'_", "]_", ",_", "\"", "vdi", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "7", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "size", "\\u", "max", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "size", " ", "<=", " ", "expected_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "size", "\\u", "max", "=", "20", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "image_", "[_", "'", "size", "'_", "]_", "<=_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "8", ".", " ", "GET", " ", "/", "images", " ", "with", " ", "size", "\\u", "min", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "size", " ", ">=", " ", "expected_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "size", "\\u", "min", "=", "20", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "image_", "[_", "'", "size", "'_", "]_", ">=_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "9", ".", " ", "Get", " ", "/", "images", " ", "with", " ", "is", "\\u", "public", "=", "Non", "e", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bug", " ", "lp", ":", "803", "656", " ", " ", "Supp", "ort", " ", "is", "\\u", "public", " ", "in", " ", "filtering", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "is", "\\u", "public", "=", "Non", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "10.", " ", "Get", " ", "/", "images", " ", "with", " ", "is", "\\u", "public", "=", "Fal", "se", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bug", " ", "lp", ":", "803", "656", " ", " ", "Supp", "ort", " ", "is", "\\u", "public", " ", "in", " ", "filtering", "_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "=_", "\"", "is", "\\u", "public", "=", "Fal", "se", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "name", "'_", "]_", ",_", "\"", "My", " ", "Priva", "te", " ", "Image", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "11.", " ", "Get", " ", "/", "images", " ", "with", " ", "is", "\\u", "public", "=", "Tru", "e", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bug", " ", "lp", ":", "803", "656", " ", " ", "Supp", "ort", " ", "is", "\\u", "public", " ", "in", " ", "filtering", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "is", "\\u", "public", "=", "Tru", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Not", "Equal_", "(_", "image_", "[_", "'", "name", "'_", "]_", ",_", "\"", "My", " ", "Priva", "te", " ", "Image", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "12.", " ", "Get", " ", "/", "images", " ", "with", " ", "protect", "ed", "=", "Fal", "se", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "protect", "ed", "=", "Fal", "se", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Not", "Equal_", "(_", "image_", "[_", "'", "name", "'_", "]_", ",_", "\"", "Image", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "13.", " ", "Get", " ", "/", "images", " ", "with", " ", "protect", "ed", "=", "Tru", "e", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "protect", "ed", "=", "Tru", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "name", "'_", "]_", ",_", "\"", "Image", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "14.", " ", "GET", " ", "/", "images", " ", "with", " ", "property", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "property", "-", "pant", "s", "=", "are", "%", "20", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "deta", "il", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "proper", "ties", "'_", "]_", "[_", "'", "pant", "s", "'_", "]_", ",_", "\"", "are", " ", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "15.", " ", "GET", " ", "/", "images", " ", "with", " ", "property", " ", "filter", " ", "and", " ", "name", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "correct", " ", "images", " ", "return", "ed", " ", "with", " ", "property", " ", "and", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "you", " ", "quote", " ", "the", " ", "url", " ", "whe", "n", " ", "usi", "ng", " ", "more", " ", "than", " ", "one", " ", "param", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "\"", "name", "=", "My", "%", "20", "Image", "!", "&", "property", "-", "pant", "s", "=", "are", "%", "20", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "deta", "il", "?", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "image_", "in_", "data_", "[_", "'", "images", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "proper", "ties", "'_", "]_", "[_", "'", "pant", "s", "'_", "]_", ",_", "\"", "are", " ", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "image_", "[_", "'", "name", "'_", "]_", ",_", "\"", "My", " ", "Image", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "16.", " ", "GET", " ", "/", "images", " ", "with", " ", "past", " ", "change", "s", "-", "sinc", "e", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dt", "1_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "-_", "datetime_", "._", "timedelta_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iso", "1_", "=_", "utils_", "._", "isot", "ime_", "(_", "dt", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "\"", "change", "s", "-", "sinc", "e", "=", "%", "s", "\"_", "%_", "iso", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "17.", " ", "GET", " ", "/", "images", " ", "with", " ", "future", " ", "change", "s", "-", "sinc", "e", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "dt", "2_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "+_", "datetime_", "._", "timedelta_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iso", "2_", "=_", "utils_", "._", "isot", "ime_", "(_", "dt", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "\"", "change", "s", "-", "sinc", "e", "=", "%", "s", "\"_", "%_", "iso", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "?", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "data_", "[_", "'", "images", "'_", "]_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\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,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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 ]
Except block handles 'BaseException'
benbaptist/minecraft-wrapper/src/backups.py
[ { "content": "\tdef onTick(self, payload):\n\t\tself.interval += 1\n\t\tif not self.config[\"Backups\"][\"enabled\"]: return\n\t\tif time.time() - self.time > self.config[\"Backups\"][\"backup-interval\"]:\n\t\t\tself.time = time.time()\n\t\t\tif not os.path.exists(self.config[\"Backups\"][\"backup-location\"]):\n\t\t\t\tos.mkdir(self.config[\"Backups\"][\"backup-location\"])\n\t\t\tif len(self.backups) == 0 and os.path.exists(self.config[\"Backups\"][\"backup-location\"] + \"/backups.json\"):\n\t\t\t\twith open(self.config[\"Backups\"][\"backup-location\"] + \"/backups.json\", \"r\") as f:\n\t\t\t\t\ttry: self.backups = json.loads(f.read())\n\t\t\t\t\texcept:\n\t\t\t\t\t\tself.log.error(\"NOTE - backups.json was unreadable. It might be corrupted. Backups will no longer be automatically pruned.\")\n\t\t\t\t\t\tself.wrapper.callEvent(\"wrapper.backupFailure\", {\"reasonCode\": 4, \"reasonText\": \"backups.json is corrupted. Please contact an administer instantly, as this may be critical.\"})\n\t\t\t\t\t\tself.backups = []\n\t\t\telse:\n\t\t\t\tif len(os.listdir(self.config[\"Backups\"][\"backup-location\"])) > 0:\n\t\t\t\t\t# import old backups from previous versions of Wrapper.py\n\t\t\t\t\tbackupTimestamps = []\n\t\t\t\t\tfor backupNames in os.listdir(self.config[\"Backups\"][\"backup-location\"]):\n\t\t\t\t\t\ttry:\n\t\t\t\t\t\t\tbackupTimestamps.append(int(backupNames[backupNames.find('-')+1:backupNames.find('.')]))\n\t\t\t\t\t\texcept:\n\t\t\t\t\t\t\tpass\n\t\t\t\t\tbackupTimestamps.sort()\n\t\t\t\t\tfor backupI in backupTimestamps:\n\t\t\t\t\t\tself.backups.append((int(backupI), \"backup-%s.tar\" % str(backupI)))\n\t\t\ttimestamp = int(time.time())\n\t\t\tself.console(\"save-all\")\n\t\t\tself.console(\"save-off\")\n\t\t\ttime.sleep(0.5)\n\t\n\t\t\tif not os.path.exists(str(self.config[\"Backups\"][\"backup-location\"])):\n\t\t\t\tos.mkdir(self.config[\"Backups\"][\"backup-location\"])\n\t\t\t\n\t\t\tfilename = \"backup-%s.tar\" % datetime.datetime.fromtimestamp(int(timestamp)).strftime(\"%Y-%m-%d_%H.%M.%S\")\n\t\t\tif self.config[\"Backups\"][\"backup-compression\"]:\n\t\t\t\tfilename += \".gz\"\n\t\t\t\targuments = [\"tar\", \"czf\", \"%s/%s\" % (self.config[\"Backups\"][\"backup-location\"].replace(\" \", \"\\\\ \"), filename)]\n\t\t\telse:\n\t\t\t\targuments = [\"tar\", \"cfpv\", \"%s/%s\" % (self.config[\"Backups\"][\"backup-location\"], filename)]\n\t\t\t\n\t\t\t# Check if tar is installed\n\t\t\twhich = \"where\" if platform.system() == \"Windows\" else \"which\"\n\t\t\tif not subprocess.call([which, \"tar\"]) == 0:\n\t\t\t\tself.wrapper.callEvent(\"wrapper.backupFailure\", {\"reasonCode\": 1, \"reasonText\": \"Tar is not installed. Please install tar before trying to make backups.\"})\n\t\t\t\tself.log.error(\"The backup could not begin, because tar does not appear to be installed!\")\n\t\t\t\tself.log.error(\"If you are on a Linux-based system, please install it through your preferred package manager.\")\n\t\t\t\tself.log.error(\"If you are on Windows, you can find GNU/Tar from this link: http://goo.gl/SpJSVM\")\n\t\t\t\treturn\n\t\t\t\n\t\t\tif not self.wrapper.callEvent(\"wrapper.backupBegin\", {\"file\": filename}):\n\t\t\t\tself.log.warn(\"A backup was scheduled, but was cancelled by a plugin!\")\n\t\t\t\treturn\n\t\t\tif self.config[\"Backups\"][\"backup-notification\"]:\n\t\t\t\tself.broadcast(\"&cBacking up... lag may occur!\")\n\t\t\t\n\t\t\tfor file in self.config[\"Backups\"][\"backup-folders\"]:\n\t\t\t\tif os.path.exists(file):\n\t\t\t\t\targuments.append(file)\n\t\t\t\telse:\n\t\t\t\t\tself.log.warn(\"Backup file '%s' does not exist - cancelling backup\" % file)\n\t\t\t\t\tself.wrapper.callEvent(\"wrapper.backupFailure\", {\"reasonCode\": 3, \"reasonText\": \"Backup file '%s' does not exist.\" % file})\n\t\t\t\t\treturn \n\t\t\tstatusCode = os.system(\" \".join(arguments))\n\t\t\tself.console(\"save-on\")\n\t\t\tif self.config[\"Backups\"][\"backup-notification\"]:\n\t\t\t\tself.broadcast(\"&aBackup complete!\")\n\t\t\tself.wrapper.callEvent(\"wrapper.backupEnd\", {\"file\": filename, \"status\": statusCode})\n\t\t\tself.backups.append((timestamp, filename))\n\t\t\t\n\t\t\tif len(self.backups) > self.config[\"Backups\"][\"backups-keep\"]:\n\t\t\t\tself.log.info(\"Deleting old backups...\")\n\t\t\t\twhile len(self.backups) > self.config[\"Backups\"][\"backups-keep\"]:\n\t\t\t\t\tbackup = self.backups[0]\n\t\t\t\t\tif not self.wrapper.callEvent(\"wrapper.backupDelete\", {\"file\": filename}): break\n\t\t\t\t\ttry:\n\t\t\t\t\t\tos.remove('%s/%s' % (self.config[\"Backups\"][\"backup-location\"], backup[1]))\n\t\t\t\t\texcept:\n\t\t\t\t\t\tprint \"Failed to delete\"\n\t\t\t\t\tself.log.info(\"Deleting old backup: %s\" % datetime.datetime.fromtimestamp(int(backup[0])).strftime('%Y-%m-%d_%H:%M:%S'))\n\t\t\t\t\think = self.backups[0][1][:]\n\t\t\t\t\tdel self.backups[0]\n\t\t\tf = open(self.config[\"Backups\"][\"backup-location\"] + \"/backups.json\", \"w\")\n\t\t\tf.write(json.dumps(self.backups))\n\t\t\tf.close()\t\n\t\t\t\n\t\t\tif not os.path.exists(self.config[\"Backups\"][\"backup-location\"] + \"/\" + filename):\n\t\t\t\tself.wrapper.callEvent(\"wrapper.backupFailure\", {\"reasonCode\": 2, \"reasonText\": \"Backup file didn't exist after the tar command executed - assuming failure.\"})", "metadata": "root.Backups.onTick", "header": "['class', 'Backups', ':', '___EOS___']", "index": 19 } ]
[ { "span": "except:", "start_line": 29, "start_column": 5, "end_line": 29, "end_column": 12 }, { "span": "except:", "start_line": 40, "start_column": 6, "end_line": 40, "end_column": 13 }, { "span": "except:", "start_line": 96, "start_column": 5, "end_line": 96, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Back", "ups_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Tic", "k_", "(_", "self_", ",_", "payload_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "interval_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "enable", "d", "\"_", "]_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "time_", "._", "time_", "(_", ")_", "-_", "self_", "._", "time_", ">_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "interval", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "self_", "._", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "os_", "._", "mkdir_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "backups_", ")_", "==_", "0_", "and_", "os_", "._", "path_", "._", "exists_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", "+_", "\"/", "backup", "s", ".", "json", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "with_", "open_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", "+_", "\"/", "backup", "s", ".", "json", "\"_", ",_", "\"", "r", "\"_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "try_", ":_", "self_", "._", "backups_", "=_", "json_", "._", "loads_", "(_", "f_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "self_", "._", "log_", "._", "error_", "(_", "\"", "NOTE", " ", "-", " ", "backup", "s", ".", "json", " ", "was", " ", "unread", "able", ".", " ", "It", " ", "mig", "ht", " ", "be", " ", "corrupted", ".", " ", "Back", "ups", " ", "will", " ", "no", " ", "long", "er", " ", "be", " ", "automati", "call", "y", " ", "pruned", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "Fail", "ure", "\"_", ",_", "{_", "\"", "reason", "Code", "\"_", ":_", "4_", ",_", "\"", "reason", "Text", "\"_", ":_", "\"", "backup", "s", ".", "json", " ", "is", " ", "corrupted", ".", " ", "Ple", "ase", " ", "contact", " ", "an", " ", "admin", "iste", "r", " ", "instant", "ly", ",", " ", "as", " ", "this", " ", "may", " ", "be", " ", "critic", "al", ".\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "backups_", "=_", "[_", "]_", "\\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\t", "\t\t\t_", "if_", "len_", "(_", "os_", "._", "listdir_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ")_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "import", " ", "old", " ", "backup", "s", " ", "from", " ", "previ", "ous", " ", "version", "s", " ", "of", " ", "Wrapper", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "backup", "Timest", "amps", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "backup", "Names_", "in_", "os_", "._", "listdir_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ")_", ":_", "\\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_", "backup", "Timest", "amps", "_", "._", "append_", "(_", "int_", "(_", "backup", "Names_", "[_", "backup", "Names_", "._", "find_", "(_", "'-'_", ")_", "+_", "1_", ":_", "backup", "Names_", "._", "find_", "(_", "'.'_", ")_", "]_", ")_", ")_", "\\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_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "backup", "Timest", "amps", "_", "._", "sort_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "backup", "I_", "in_", "backup", "Timest", "amps", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "self_", "._", "backups_", "._", "append_", "(_", "(_", "int_", "(_", "backup", "I_", ")_", ",_", "\"", "backup", "-%", "s", ".", "tar", "\"_", "%_", "str_", "(_", "backup", "I_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "timestamp_", "=_", "int_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "console_", "(_", "\"", "save", "-", "all", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "console_", "(_", "\"", "save", "-", "off", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "str_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "os_", "._", "mkdir_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "filename_", "=_", "\"", "backup", "-%", "s", ".", "tar", "\"_", "%_", "datetime_", "._", "datetime_", "._", "fromtimestamp_", "(_", "int_", "(_", "timestamp_", ")_", ")_", "._", "strftime_", "(_", "\"%", "Y", "-%", "m", "-%", "d\\u", "%", "H", ".", "%", "M", ".", "%", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "compress", "ion", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "filename_", "+=_", "\".", "gz", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arguments_", "=_", "[_", "\"", "tar", "\"_", ",_", "\"", "cz", "f", "\"_", ",_", "\"%", "s", "/", "%", "s", "\"_", "%_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", "._", "replace_", "(_", "\"", " ", "\"_", ",_", "\"\\\\\\\\", " ", "\"_", ")_", ",_", "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\t", "\t\t\t_", "arguments_", "=_", "[_", "\"", "tar", "\"_", ",_", "\"", "cf", "pv", "\"_", ",_", "\"%", "s", "/", "%", "s", "\"_", "%_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ",_", "filename_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "tar", " ", "is", " ", "installed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "which_", "=_", "\"", "where", "\"_", "if_", "platform_", "._", "system_", "(_", ")_", "==_", "\"", "Window", "s", "\"_", "else_", "\"", "whi", "ch", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "subprocess_", "._", "call_", "(_", "[_", "which_", ",_", "\"", "tar", "\"_", "]_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "Fail", "ure", "\"_", ",_", "{_", "\"", "reason", "Code", "\"_", ":_", "1_", ",_", "\"", "reason", "Text", "\"_", ":_", "\"", "Tar", " ", "is", " ", "not", " ", "install", "ed", ".", " ", "Ple", "ase", " ", "install", " ", "tar", " ", "bef", "ore", " ", "try", "ing", " ", "to", " ", "make", " ", "backup", "s", ".\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log_", "._", "error_", "(_", "\"", "The", " ", "backup", " ", "coul", "d", " ", "not", " ", "begin", ",", " ", "bec", "aus", "e", " ", "tar", " ", "doe", "s", " ", "not", " ", "appear", " ", "to", " ", "be", " ", "install", "ed", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log_", "._", "error_", "(_", "\"", "If", " ", "you", " ", "are", " ", "on", " ", "a", " ", "Lin", "ux", "-", "based", " ", "system", ",", " ", "plea", "se", " ", "install", " ", "it", " ", "through", " ", "your", " ", "prefer", "red", " ", "package", " ", "manage", "r", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log_", "._", "error_", "(_", "\"", "If", " ", "you", " ", "are", " ", "on", " ", "Window", "s", ",", " ", "you", " ", "can", " ", "find", " ", "GN", "U", "/", "Tar", " ", "from", " ", "this", " ", "link", ":", " ", "http", "://", "goo", ".", "gl", "/", "Sp", "JS", "VM", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "Begin", "\"_", ",_", "{_", "\"", "file", "\"_", ":_", "filename_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "log_", "._", "warn_", "(_", "\"", "A", " ", "backup", " ", "was", " ", "schedule", "d", ",", " ", "but", " ", "was", " ", "cancel", "led", " ", "by", " ", "a", " ", "plugin", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "notification", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "broadcast_", "(_", "\"&", "c", "Back", "ing", " ", "up", "...", " ", "lag", " ", "may", " ", "occur", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "file_", "in_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "folder", "s", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "arguments_", "._", "append_", "(_", "file_", ")_", "\\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_", "self_", "._", "log_", "._", "warn_", "(_", "\"", "Back", "up", " ", "file", " ", "'%", "s", "'", " ", "doe", "s", " ", "not", " ", "exist", " ", "-", " ", "cancel", "ling", " ", "backup", "\"_", "%_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "Fail", "ure", "\"_", ",_", "{_", "\"", "reason", "Code", "\"_", ":_", "3_", ",_", "\"", "reason", "Text", "\"_", ":_", "\"", "Back", "up", " ", "file", " ", "'%", "s", "'", " ", "doe", "s", " ", "not", " ", "exist", ".\"_", "%_", "file_", "}_", ")_", "\\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_", "status", "Code_", "=_", "os_", "._", "system_", "(_", "\"", " ", "\"_", "._", "join_", "(_", "arguments_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "console_", "(_", "\"", "save", "-", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "notification", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "broadcast_", "(_", "\"&", "a", "Back", "up", " ", "complete", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "End", "\"_", ",_", "{_", "\"", "file", "\"_", ":_", "filename_", ",_", "\"", "status", "\"_", ":_", "status", "Code_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "backups_", "._", "append_", "(_", "(_", "timestamp_", ",_", "filename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "backups_", ")_", ">_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "s", "-", "keep", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "log_", "._", "info_", "(_", "\"", "Del", "eti", "ng", " ", "old", " ", "backup", "s", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "len_", "(_", "self_", "._", "backups_", ")_", ">_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "s", "-", "keep", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "backup_", "=_", "self_", "._", "backups_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "Delete", "\"_", ",_", "{_", "\"", "file", "\"_", ":_", "filename_", "}_", ")_", ":_", "break_", "\\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_", "os_", "._", "remove_", "(_", "'%", "s", "/", "%", "s", "'_", "%_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", ",_", "backup_", "[_", "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\t", "\t\t\t\t\t_", "print_", "\"", "Fail", "ed", " ", "to", " ", "delete", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "log_", "._", "info_", "(_", "\"", "Del", "eti", "ng", " ", "old", " ", "backup", ":", " ", "%", "s", "\"_", "%_", "datetime_", "._", "datetime_", "._", "fromtimestamp_", "(_", "int_", "(_", "backup_", "[_", "0_", "]_", ")_", ")_", "._", "strftime_", "(_", "'%", "Y", "-%", "m", "-%", "d\\u", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hin", "k_", "=_", "self_", "._", "backups_", "[_", "0_", "]_", "[_", "1_", "]_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "backups_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "=_", "open_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", "+_", "\"/", "backup", "s", ".", "json", "\"_", ",_", "\"", "w", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "json_", "._", "dumps_", "(_", "self_", "._", "backups_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "self_", "._", "config_", "[_", "\"", "Back", "ups", "\"_", "]_", "[_", "\"", "backup", "-", "location", "\"_", "]_", "+_", "\"/\"_", "+_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "wrapper_", "._", "call", "Event_", "(_", "\"", "wrapp", "er", ".", "backup", "Fail", "ure", "\"_", ",_", "{_", "\"", "reason", "Code", "\"_", ":_", "2_", ",_", "\"", "reason", "Text", "\"_", ":_", "\"", "Back", "up", " ", "file", " ", "did", "n", "'", "t", " ", "exist", " ", "after", " ", "the", " ", "tar", " ", "command", " ", "executed", " ", "-", " ", "ass", "umi", "ng", " ", "fail", "ure", ".\"_", "}_", ")_" ]
[ 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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from flask import *\nfrom pymongo import MongoClient\n\nimport utils\nfrom auth import *\n\napp = Flask(__name__)\napp.register_blueprint(auth)\napp.debug = True\napp.secret_key = os.environ['APP_SECRET']\napp.jinja_env.add_extension('pyjade.ext.jinja.PyJadeExtension')\n\ndb_name = os.environ['DB_NAME']\nmongo = MongoClient(os.environ['MONGO_URI'])\nusers_db = mongo[db_name].users\nteams_db = mongo[db_name].teams\n\nusers_db.ensure_index(\"uniqname\", unique=True, dropDups=True);\nteams_db.ensure_index(\"id\", unique=True, dropDups=True);\n\nMAX_TEAM_MEMBERS = 3\n\n#utils.fixTeamDB(teams_db, users_db)\n\n\n#API to ADD/EDIT User\n\n\n#API to ADD/EDIT team\n\n#to quit a team\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@app.route('/')\ndef main():\n return render_template(\"index.jade\")", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 29 }, { "content": "@app.route('/user', methods=[\"GET\",\"POST\"])\n@auth_check\ndef user(github):\n \n user_info = getGHcreds(github)\n user = users_db.find_one({ \"github\": user_info[\"github\"] })\n\n if request.method == \"GET\":\n\n if user:\n user_info[\"uniqname\"] = user[\"uniqname\"]\n user_info[\"team_id\"] = user[\"team_id\"]\n\n return render_template('user.jade', **user_info)\n\n else: #POST\n user_info[\"uniqname\"] = request.json[\"uniqname\"]\n team_id = user_info[\"team_id\"] = request.json[\"team_id\"]\n\n team = teams_db.find_one({\"id\":team_id})\n\n #check if team exists\n if (team_id != \"\") and (not team):\n return json.dumps({\"error\":\"Invalid Team Id!\"})\n\n # check if team is full\n if team and team[\"size\"] >= MAX_TEAM_MEMBERS and user[\"team_id\"] != team_id:\n return json.dumps({\"error\": \"Team is Full! Maximum Team Size is \" + str(MAX_TEAM_MEMBERS)})\n\n # save the user\n users_db.update({ \"github\":user_info[\"github\"] }, user_info, upsert= True);\n\n # increment user count for team \n if team and (not user or user[\"team_id\"] != team_id):\n # user is new to the team\n team[\"size\"] += 1\n teams_db.update({ \"id\": team_id }, team)\n\n return json.dumps({\"success\" : 'ok'})", "metadata": "root.user", "header": "['module', '___EOS___']", "index": 34 }, { "content": "@app.route('/team/<id>', methods=[\"GET\",\"POST\"])\n@auth_check\ndef team(github, id):\n\n user = getGHcreds(github)\n\n team = teams_db.find_one({\"id\":id})\n\n #view UI for team\n if request.method == \"GET\":\n # team id doesnt exist in DB\n if not team: team = {}\n\n # team is valid\n team[\"members\"] = []\n seenUser = False\n for member in users_db.find({ \"team_id\":id }):\n team[\"members\"].append(member)\n if member[\"github\"] == user[\"github\"]: \n seenUser = True\n\n # prevent others from changing group\n if not seenUser: \n team = {}\n \n return render_template('team.jade', **team)\n\n else: #POST\n\n team[\"name\"] = request.json[\"name\"]\n teams_db.update({\"id\": id}, team);\n return json.dumps({\"success\" : 'ok'})", "metadata": "root.team", "header": "['module', '___EOS___']", "index": 76 }, { "content": "@app.route('/quit/<id>', methods=[\"GET\",\"POST\"])\n@auth_check\ndef quit(github, id):\n user_info = getGHcreds(github)\n user = users_db.find_one({ \"github\": user_info[\"github\"] })\n team = teams_db.find_one({\"id\":id})\n\n # remeber old team\n old_team = user['team_id']\n # remove them from the team\n user['team_id'] = \"\"\n users_db.update({ \"github\":user[\"github\"] }, user);\n\n # make sure they're on the team\n if team and old_team == id:\n\n team[\"size\"] -= 1\n # one team member left\n if team[\"size\"] <= 0:\n teams_db.remove({ \"id\": id })\n # keep the team\n else:\n teams_db.update({ \"id\": id }, team)\n \n return redirect(\"/user\") ", "metadata": "root.quit", "header": "['module', '___EOS___']", "index": 110 }, { "content": "@app.route('/key', methods=[\"POST\"])\n@auth_check\ndef key(github):\n\n user = getGHcreds(github)\n key = request.form[\"key\"];\n\n team = {\n \"id\": key,\n \"name\": \"\",\n \"creator\": user[\"github\"],\n \"size\": 0\n }\n # todo: check that user is not in a team already!\n teams_db.insert(team);\n\n return \"done\"", "metadata": "root.key", "header": "['module', '___EOS___']", "index": 136 }, { "content": "@app.route('/create/<id>') # create a project repo for every group: eg. projectId_groupid\n@auth_check\n@admin_check\ndef create_proj(github, id):\n\n return Response(utils.createProj(teams_db, users_db, github, id), mimetype='text/event-stream')", "metadata": "root.create_proj", "header": "['module', '___EOS___']", "index": 154 }, { "content": "@app.route('/fix_teams') # fix team counts (you probably wont need this)\n@auth_check\n@admin_check\ndef fix_teams(github):\n\n return Response(utils.fixTeamDB(teams_db, users_db), mimetype='text/event-stream')", "metadata": "root.fix_teams", "header": "['module', '___EOS___']", "index": 161 }, { "content": "@app.route('/csv') # get a csv for all the team members in each group\n@auth_check\n@admin_check\ndef csv(github):\n\n csv = \"team_id,user1,user2,user3,count\\n\"\n for team in teams_db.find({\"size\": { \"$ne\": 0 }}):\n csv += team['id'] + \",\"\n i = MAX_TEAM_MEMBERS\n for user in users_db.find({\"team_id\":team['id']}):\n csv += user['uniqname'] + \",\"\n i-=1\n\n while i:\n csv += \",\"\n i-=1;\n\n csv += str(team['size']) + \"\\n\"\n\n response = Response(csv, mimetype='text/csv')\n response.headers['Content-Disposition'] = 'attachment; filename=teams.csv'\n\n return response", "metadata": "root.csv", "header": "['module', '___EOS___']", "index": 168 } ]
[ { "span": "import sys", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 10 }, { "span": "from github import Github", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 25 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "github_", "import_", "Git", "hub_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pymongo_", "import_", "Mon", "go", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "auth_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "Flask_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "register", "\\u", "blueprint_", "(_", "auth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "debug_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "secret", "\\u", "key_", "=_", "os_", "._", "environ_", "[_", "'", "APP", "\\u", "SEC", "RET", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "jin", "ja", "\\u", "env_", "._", "add", "\\u", "extension_", "(_", "'", "pyj", "ade", ".", "ext", ".", "jin", "ja", ".", "Py", "Ja", "de", "Ext", "ensi", "on", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db", "\\u", "name_", "=_", "os_", "._", "environ_", "[_", "'", "DB", "\\u", "NAME", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mongo_", "=_", "Mon", "go", "Client_", "(_", "os_", "._", "environ_", "[_", "'", "MONGO", "\\u", "URI", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users", "\\u", "db_", "=_", "mongo_", "[_", "db", "\\u", "name_", "]_", "._", "users_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "team", "s", "\\u", "db_", "=_", "mongo_", "[_", "db", "\\u", "name_", "]_", "._", "teams_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users", "\\u", "db_", "._", "ensure", "\\u", "index_", "(_", "\"", "uniq", "name", "\"_", ",_", "unique_", "=_", "True_", ",_", "drop", "Dup", "s_", "=_", "True_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "team", "s", "\\u", "db_", "._", "ensure", "\\u", "index_", "(_", "\"", "id", "\"_", ",_", "unique_", "=_", "True_", ",_", "drop", "Dup", "s_", "=_", "True_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "MAX", "\\u", "TEAM", "\\u", "MEMBER", "S_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "util", "s", ".", "fix", "Tea", "m", "DB", "(", "team", "s", "\\u", "db", ",", " ", "users", "\\u", "db", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "API", " ", "to", " ", "ADD", "/", "EDIT", " ", "User_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "API", " ", "to", " ", "ADD", "/", "EDIT", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "to", " ", "quit", " ", "a", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "@_", "app_", "._", "route_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "render", "\\u", "template_", "(_", "\"", "index", ".", "jad", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "user", "'_", ",_", "methods_", "=_", "[_", "\"", "GET", "\"_", ",_", "\"", "POST", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "user_", "(_", "github_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "info_", "=_", "get", "GH", "creds_", "(_", "github_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "users", "\\u", "db_", "._", "find", "\\u", "one_", "(_", "{_", "\"", "git", "hub", "\"_", ":_", "user", "\\u", "info_", "[_", "\"", "git", "hub", "\"_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "GET", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "info_", "[_", "\"", "uniq", "name", "\"_", "]_", "=_", "user_", "[_", "\"", "uniq", "name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "info_", "[_", "\"", "team", "\\u", "id", "\"_", "]_", "=_", "user_", "[_", "\"", "team", "\\u", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "user", ".", "jad", "e", "'_", ",_", "**_", "user", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", "POST_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "info_", "[_", "\"", "uniq", "name", "\"_", "]_", "=_", "request_", "._", "json_", "[_", "\"", "uniq", "name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "team", "\\u", "id_", "=_", "user", "\\u", "info_", "[_", "\"", "team", "\\u", "id", "\"_", "]_", "=_", "request_", "._", "json_", "[_", "\"", "team", "\\u", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "team_", "=_", "team", "s", "\\u", "db_", "._", "find", "\\u", "one_", "(_", "{_", "\"", "id", "\"_", ":_", "team", "\\u", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "check", " ", "if", " ", "team", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "team", "\\u", "id_", "!=_", "\"\"_", ")_", "and_", "(_", "not_", "team_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json_", "._", "dumps_", "(_", "{_", "\"", "error", "\"_", ":_", "\"", "Inva", "lid", " ", "Tea", "m", " ", "Id", "!\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "team", " ", "is", " ", "full_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "team_", "and_", "team_", "[_", "\"", "size", "\"_", "]_", ">=_", "MAX", "\\u", "TEAM", "\\u", "MEMBER", "S_", "and_", "user_", "[_", "\"", "team", "\\u", "id", "\"_", "]_", "!=_", "team", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json_", "._", "dumps_", "(_", "{_", "\"", "error", "\"_", ":_", "\"", "Tea", "m", " ", "is", " ", "Full", "!", " ", "Maxim", "um", " ", "Tea", "m", " ", "Size", " ", "is", " ", "\"_", "+_", "str_", "(_", "MAX", "\\u", "TEAM", "\\u", "MEMBER", "S_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "save", " ", "the", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "users", "\\u", "db_", "._", "update_", "(_", "{_", "\"", "git", "hub", "\"_", ":_", "user", "\\u", "info_", "[_", "\"", "git", "hub", "\"_", "]_", "}_", ",_", "user", "\\u", "info_", ",_", "upsert_", "=_", "True_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "increment", " ", "user", " ", "count", " ", "for", " ", "team", " _", "\\u\\u\\uNL\\u\\u\\u_", "if_", "team_", "and_", "(_", "not_", "user_", "or_", "user_", "[_", "\"", "team", "\\u", "id", "\"_", "]_", "!=_", "team", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "user", " ", "is", " ", "new", " ", "to", " ", "the", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team_", "[_", "\"", "size", "\"_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "team", "s", "\\u", "db_", "._", "update_", "(_", "{_", "\"", "id", "\"_", ":_", "team", "\\u", "id_", "}_", ",_", "team_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "json_", "._", "dumps_", "(_", "{_", "\"", "success", "\"_", ":_", "'", "ok", "'_", "}_", ")_", "\\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_", "@_", "app_", "._", "route_", "(_", "'/", "team", "/", "<", "id", ">'_", ",_", "methods_", "=_", "[_", "\"", "GET", "\"_", ",_", "\"", "POST", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "team_", "(_", "github_", ",_", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "get", "GH", "creds_", "(_", "github_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "team_", "=_", "team", "s", "\\u", "db_", "._", "find", "\\u", "one_", "(_", "{_", "\"", "id", "\"_", ":_", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "view", " ", "UI", " ", "for", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "GET", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "team", " ", "id", " ", "doesnt", " ", "exist", " ", "in", " ", "DB_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "team_", ":_", "team_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "team", " ", "is", " ", "valid_", "\\u\\u\\uNL\\u\\u\\u_", "team_", "[_", "\"", "member", "s", "\"_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "see", "n", "User_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "member_", "in_", "users", "\\u", "db_", "._", "find_", "(_", "{_", "\"", "team", "\\u", "id", "\"_", ":_", "id_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team_", "[_", "\"", "member", "s", "\"_", "]_", "._", "append_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "member_", "[_", "\"", "git", "hub", "\"_", "]_", "==_", "user_", "[_", "\"", "git", "hub", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "see", "n", "User_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "prevent", " ", "other", "s", " ", "from", " ", "chang", "ing", " ", "group_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "see", "n", "User_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "team", ".", "jad", "e", "'_", ",_", "**_", "team_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", "POST_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team_", "[_", "\"", "name", "\"_", "]_", "=_", "request_", "._", "json_", "[_", "\"", "name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "team", "s", "\\u", "db_", "._", "update_", "(_", "{_", "\"", "id", "\"_", ":_", "id_", "}_", ",_", "team_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "json_", "._", "dumps_", "(_", "{_", "\"", "success", "\"_", ":_", "'", "ok", "'_", "}_", ")_", "\\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_", "@_", "app_", "._", "route_", "(_", "'/", "quit", "/", "<", "id", ">'_", ",_", "methods_", "=_", "[_", "\"", "GET", "\"_", ",_", "\"", "POST", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "quit_", "(_", "github_", ",_", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "info_", "=_", "get", "GH", "creds_", "(_", "github_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "users", "\\u", "db_", "._", "find", "\\u", "one_", "(_", "{_", "\"", "git", "hub", "\"_", ":_", "user", "\\u", "info_", "[_", "\"", "git", "hub", "\"_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "team_", "=_", "team", "s", "\\u", "db_", "._", "find", "\\u", "one_", "(_", "{_", "\"", "id", "\"_", ":_", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "reme", "ber", " ", "old", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "old", "\\u", "team_", "=_", "user_", "[_", "'", "team", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "them", " ", "from", " ", "the", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "[_", "'", "team", "\\u", "id", "'_", "]_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users", "\\u", "db_", "._", "update_", "(_", "{_", "\"", "git", "hub", "\"_", ":_", "user_", "[_", "\"", "git", "hub", "\"_", "]_", "}_", ",_", "user_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "make", " ", "sure", " ", "the", "y", "'", "re", " ", "on", " ", "the", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "team_", "and_", "old", "\\u", "team_", "==_", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team_", "[_", "\"", "size", "\"_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "one", " ", "team", " ", "member", " ", "left_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "team_", "[_", "\"", "size", "\"_", "]_", "<=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team", "s", "\\u", "db_", "._", "remove_", "(_", "{_", "\"", "id", "\"_", ":_", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "keep", " ", "the", " ", "team_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "team", "s", "\\u", "db_", "._", "update_", "(_", "{_", "\"", "id", "\"_", ":_", "id_", "}_", ",_", "team_", ")_", "\\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_", "redirect_", "(_", "\"/", "user", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "key", "'_", ",_", "methods_", "=_", "[_", "\"", "POST", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "key_", "(_", "github_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "get", "GH", "creds_", "(_", "github_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key_", "=_", "request_", "._", "form_", "[_", "\"", "key", "\"_", "]_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "team_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "creat", "or", "\"_", ":_", "user_", "[_", "\"", "git", "hub", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "size", "\"_", ":_", "0_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "todo", ":", " ", "check", " ", "tha", "t", " ", "user", " ", "is", " ", "not", " ", "in", " ", "a", " ", "team", " ", "alr", "ead", "y", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "team", "s", "\\u", "db_", "._", "insert_", "(_", "team_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\"", "don", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "create", "/", "<", "id", ">'_", ")_", "#", " ", "create", " ", "a", " ", "project", " ", "repo", " ", "for", " ", "every", " ", "group", ":", " ", "eg", ".", " ", "project", "Id", "\\u", "groupid", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "admin", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create", "\\u", "proj_", "(_", "github_", ",_", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Response_", "(_", "utils_", "._", "create", "Proj", "_", "(_", "team", "s", "\\u", "db_", ",_", "users", "\\u", "db_", ",_", "github_", ",_", "id_", ")_", ",_", "mimetype_", "=_", "'", "text", "/", "event", "-", "stream", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "fix", "\\u", "team", "s", "'_", ")_", "#", " ", "fix", " ", "team", " ", "count", "s", " ", "(", "you", " ", "probab", "ly", " ", "won", "t", " ", "need", " ", "this", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "admin", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "fix", "\\u", "teams_", "(_", "github_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Response_", "(_", "utils_", "._", "fix", "Tea", "m", "DB_", "(_", "team", "s", "\\u", "db_", ",_", "users", "\\u", "db_", ")_", ",_", "mimetype_", "=_", "'", "text", "/", "event", "-", "stream", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "csv", "'_", ")_", "#", " ", "get", " ", "a", " ", "csv", " ", "for", " ", "all", " ", "the", " ", "team", " ", "member", "s", " ", "in", " ", "each", " ", "group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "auth", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "admin", "\\u", "check_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "csv_", "(_", "github_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "csv_", "=_", "\"", "team", "\\u", "id", ",", "user", "1", ",", "user", "2", ",", "user3", ",", "count", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "team_", "in_", "team", "s", "\\u", "db_", "._", "find_", "(_", "{_", "\"", "size", "\"_", ":_", "{_", "\"$", "ne", "\"_", ":_", "0_", "}_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "csv_", "+=_", "team_", "[_", "'", "id", "'_", "]_", "+_", "\",\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "MAX", "\\u", "TEAM", "\\u", "MEMBER", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "users", "\\u", "db_", "._", "find_", "(_", "{_", "\"", "team", "\\u", "id", "\"_", ":_", "team_", "[_", "'", "id", "'_", "]_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "csv_", "+=_", "user_", "[_", "'", "uniq", "name", "'_", "]_", "+_", "\",\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "i_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "csv_", "+=_", "\",\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "-=_", "1_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "csv_", "+=_", "str_", "(_", "team_", "[_", "'", "size", "'_", "]_", ")_", "+_", "\"\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "Response_", "(_", "csv_", ",_", "mimetype_", "=_", "'", "text", "/", "csv", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "headers_", "[_", "'", "Conten", "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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 ]
Unused import
denizalti/concoord/concoord/clientproxy.py
[ { "content": "'''\n@author: Deniz Altinbuken, Emin Gun Sirer\n@note: ConCoord Client Proxy\n@copyright: See LICENSE\n'''\nimport os, random, select, socket, sys, threading, time\nfrom threading import Lock\nimport cPickle as pickle\nfrom concoord.pack import *\nfrom concoord.enums import *\nfrom concoord.utils import *\nfrom concoord.exception import *\nfrom concoord.connection import ConnectionPool, Connection\nfrom concoord.message import *\nfrom concoord.pvalue import PValueSet\ntry:\n import dns\n import dns.resolver\n import dns.exception\nexcept:\n print(\"Install dnspython: http://www.dnspython.org/\")\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ClientProxy():\n\n\n\n\n\n\n\n", "metadata": "root.ClientProxy", "header": "['module', '___EOS___']", "index": 22 }, { "content": " def __init__(self, bootstrap, timeout=60, debug=False, token=None):\n self.debug = debug\n self.timeout = timeout\n self.domainname = None\n self.token = token\n self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)\n self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)\n self.writelock = Lock()\n\n self.bootstraplist = self.discoverbootstrap(bootstrap)\n if len(self.bootstraplist) == 0:\n raise ConnectionError(\"No bootstrap found\")\n if not self.connecttobootstrap():\n raise ConnectionError(\"Cannot connect to any bootstrap\")\n myaddr = findOwnIP()\n myport = self.socket.getsockname()[1]\n self.me = Peer(myaddr, myport, NODE_CLIENT)\n self.commandnumber = random.randint(1, sys.maxint)", "metadata": "root.ClientProxy.__init__", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 23 }, { "content": " def _getipportpairs(self, bootaddr, bootport):\n for node in socket.getaddrinfo(bootaddr, bootport, socket.AF_INET, socket.SOCK_STREAM):\n yield (node[4][0],bootport)", "metadata": "root.ClientProxy._getipportpairs", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 43 }, { "content": " def getbootstrapfromdomain(self, domainname):\n tmpbootstraplist = []\n try:\n answers = dns.resolver.query('_concoord._tcp.'+domainname, 'SRV')\n for rdata in answers:\n for peer in self._getipportpairs(str(rdata.target), rdata.port):\n if peer not in tmpbootstraplist:\n tmpbootstraplist.append(peer)\n except (dns.resolver.NXDOMAIN, dns.exception.Timeout):\n if self.debug: print \"Cannot resolve name\"\n return tmpbootstraplist", "metadata": "root.ClientProxy.getbootstrapfromdomain", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 47 }, { "content": " def discoverbootstrap(self, givenbootstrap):\n tmpbootstraplist = []\n try:\n for bootstrap in givenbootstrap.split(\",\"):\n bootstrap = bootstrap.strip()\n # The bootstrap list is read only during initialization\n if bootstrap.find(\":\") >= 0:\n bootaddr,bootport = bootstrap.split(\":\")\n for peer in self._getipportpairs(bootaddr, int(bootport)):\n if peer not in tmpbootstraplist:\n tmpbootstraplist.append(peer)\n else:\n self.domainname = bootstrap\n tmpbootstraplist = self.getbootstrapfromdomain(self.domainname)\n except ValueError:\n if self.debug: print \"bootstrap usage: ipaddr1:port1,ipaddr2:port2 or domainname\"\n self._graceexit()\n return tmpbootstraplist", "metadata": "root.ClientProxy.discoverbootstrap", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 59 }, { "content": " def connecttobootstrap(self):\n connected = False\n for boottuple in self.bootstraplist:\n try:\n self.socket.close()\n self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)\n self.socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)\n self.socket.connect(boottuple)\n self.conn = Connection(self.socket)\n self.conn.settimeout(CLIENTRESENDTIMEOUT)\n self.bootstrap = boottuple\n connected = True\n if self.debug: print \"Connected to new bootstrap: \", boottuple\n break\n except socket.error, e:\n if self.debug: print \"Socket.Error: \", e\n continue\n return connected", "metadata": "root.ClientProxy.connecttobootstrap", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 78 }, { "content": " def trynewbootstrap(self):\n if self.domainname:\n self.bootstraplist = self.getbootstrapfromdomain(self.domainname)\n else:\n oldbootstrap = self.bootstraplist.pop(0)\n self.bootstraplist.append(oldbootstrap)\n return self.connecttobootstrap()", "metadata": "root.ClientProxy.trynewbootstrap", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 97 }, { "content": " def invoke_command(self, *args):\n # create a request descriptor\n resend = True\n sendcount = -1\n lastreplycode = -1\n self.commandnumber += 1\n clientmsg = create_message(MSG_CLIENTREQUEST, self.me,\n {FLD_PROPOSAL: Proposal(self.me, self.commandnumber, args),\n FLD_TOKEN: self.token,\n FLD_CLIENTBATCH: False})\n while True:\n sendcount += 1\n clientmsg[FLD_SENDCOUNT] = sendcount\n # send the clientrequest\n if resend:\n success = self.conn.send(clientmsg)\n if not success:\n self.reconfigure()\n continue\n resend = False\n # Receive reply\n try:\n for reply in self.conn.received_bytes():\n if reply and reply.type == MSG_CLIENTREPLY:\n if reply.replycode == CR_OK:\n return reply.reply\n elif reply.replycode == CR_UNBLOCK:\n # actionable response, wake up the thread\n assert lastreplycode == CR_BLOCK, \"unblocked thread not previously blocked\"\n return reply.reply\n elif reply.replycode == CR_EXCEPTION:\n raise Exception(pickle.loads(reply.reply))\n elif reply.replycode == CR_INPROGRESS or reply.replycode == CR_BLOCK:\n # the thread is already waiting, no need to do anything\n lastreplycode = reply.replycode\n # go wait for another message\n continue\n elif reply.replycode == CR_REJECTED or reply.replycode == CR_LEADERNOTREADY:\n resend = True\n self.reconfigure()\n continue\n else:\n print \"Unknown Client Reply Code.\"\n except ConnectionError:\n resend = True\n self.reconfigure()\n continue\n except KeyboardInterrupt:\n self._graceexit()", "metadata": "root.ClientProxy.invoke_command", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 105 }, { "content": " def reconfigure(self):\n if not self.trynewbootstrap():\n raise ConnectionError(\"Cannot connect to any bootstrap\")", "metadata": "root.ClientProxy.reconfigure", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 155 }, { "content": " def _graceexit(self):\n os._exit(0)", "metadata": "root.ClientProxy._graceexit", "header": "['class', 'ClientProxy', '(', ')', ':', '___EOS___']", "index": 159 } ]
[ { "span": "import os, random, select, socket, sys, threading, time", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 55 }, { "span": "from concoord.connection import ConnectionPool, Connection", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 58 }, { "span": "from concoord.pvalue import PValueSet", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 37 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "@", "author", ":", " ", "Den", "iz", " ", "Alt", "inb", "uk", "en", ",", " ", "Emi", "n", " ", "Gun", " ", "Si", "rer", "\\", "10", ";", "@", "note", ":", " ", "Con", "Coord", " ", "Client", " ", "Pro", "xy", "\\", "10", ";", "@", "copyr", "ight", ":", " ", "See", " ", "LICENSE", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "random_", ",_", "select_", ",_", "socket_", ",_", "sys_", ",_", "threading_", ",_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "threading_", "import_", "Lock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "c", "Pickle_", "as_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "pack_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "enums_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "utils_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "exception_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "connection_", "import_", "Connect", "ion", "Pool_", ",_", "Connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "message_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "pvalue_", "import_", "PV", "alu", "e", "Set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "dns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "dns_", "._", "resolver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "dns_", "._", "exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Install", " ", "dns", "python", ":", " ", "http", "://", "www", ".", "dns", "python", ".", "org", "/\"_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\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_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\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_", ",_", "bootstrap_", ",_", "timeout_", "=_", "60_", ",_", "debug_", "=_", "False_", ",_", "token_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "debug_", "=_", "debug_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timeout_", "=_", "timeout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "domain", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "token_", "=_", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "=_", "socket_", "._", "socket_", "(_", "socket_", "._", "AF", "\\u", "INET_", ",_", "socket_", "._", "SOCK", "\\u", "STREAM_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "setsockopt_", "(_", "socket_", "._", "SOL", "\\u", "SOCKET_", ",_", "socket_", "._", "SO", "\\u", "REUSE", "ADDR_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "setsockopt_", "(_", "socket_", "._", "IPP", "ROTO", "\\u", "TCP_", ",_", "socket_", "._", "TC", "P", "\\u", "NODE", "LA", "Y_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "lock_", "=_", "Lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "boots", "trap", "list_", "=_", "self_", "._", "discove", "rbo", "ots", "trap_", "(_", "bootstrap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "boots", "trap", "list_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Connect", "ion", "Error_", "(_", "\"", "No", " ", "boots", "trap", " ", "found", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "connect", "tob", "oot", "stra", "p_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Connect", "ion", "Error_", "(_", "\"", "Cann", "ot", " ", "connect", " ", "to", " ", "any", " ", "boots", "trap", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mya", "ddr_", "=_", "find", "Own", "IP_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "myp", "ort_", "=_", "self_", "._", "socket_", "._", "getsockname", "_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "me_", "=_", "Peer", "_", "(_", "mya", "ddr_", ",_", "myp", "ort_", ",_", "NODE", "\\u", "CLIENT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "number_", "=_", "random_", "._", "randint_", "(_", "1_", ",_", "sys_", "._", "maxint_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "geti", "ppo", "rtp", "airs", "_", "(_", "self_", ",_", "boot", "addr_", ",_", "boot", "port_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "node_", "in_", "socket_", "._", "getadd", "rin", "fo_", "(_", "boot", "addr_", ",_", "boot", "port_", ",_", "socket_", "._", "AF", "\\u", "INET_", ",_", "socket_", "._", "SOCK", "\\u", "STREAM_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "(_", "node_", "[_", "4_", "]_", "[_", "0_", "]_", ",_", "boot", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\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_", "getb", "oot", "stra", "pf", "rom", "domain_", "(_", "self_", ",_", "domain", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmp", "boots", "trap", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "answers_", "=_", "dns_", "._", "resolver_", "._", "query_", "(_", "'\\u", "conc", "oor", "d", ".\\u", "tcp", ".'_", "+_", "domain", "name_", ",_", "'", "SRV", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rdata_", "in_", "answers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "peer_", "in_", "self_", "._", "\\u", "geti", "ppo", "rtp", "airs", "_", "(_", "str_", "(_", "rdata_", "._", "target_", ")_", ",_", "rdata_", "._", "port_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "peer_", "not_", "in_", "tmp", "boots", "trap", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "tmp", "boots", "trap", "list_", "._", "append_", "(_", "peer_", ")_", "\\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_", "except_", "(_", "dns_", "._", "resolver_", "._", "NX", "DOMAIN_", ",_", "dns_", "._", "exception_", "._", "Timeout_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "print_", "\"", "Cann", "ot", " ", "resolve", " ", "name", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "tmp", "boots", "trap", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "discove", "rbo", "ots", "trap_", "(_", "self_", ",_", "give", "nbo", "ots", "trap_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmp", "boots", "trap", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "bootstrap_", "in_", "give", "nbo", "ots", "trap_", "._", "split_", "(_", "\",\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bootstrap_", "=_", "bootstrap_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "boots", "trap", " ", "list", " ", "is", " ", "read", " ", "only", " ", "dur", "ing", " ", "initialization", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "bootstrap_", "._", "find_", "(_", "\":\"_", ")_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "boot", "addr_", ",_", "boot", "port_", "=_", "bootstrap_", "._", "split_", "(_", "\":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "peer_", "in_", "self_", "._", "\\u", "geti", "ppo", "rtp", "airs", "_", "(_", "boot", "addr_", ",_", "int_", "(_", "boot", "port_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "peer_", "not_", "in_", "tmp", "boots", "trap", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "tmp", "boots", "trap", "list_", "._", "append_", "(_", "peer_", ")_", "\\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_", "._", "domain", "name_", "=_", "bootstrap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp", "boots", "trap", "list_", "=_", "self_", "._", "getb", "oot", "stra", "pf", "rom", "domain_", "(_", "self_", "._", "domain", "name_", ")_", "\\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_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "print_", "\"", "boots", "trap", " ", "usage", ":", " ", "ipadd", "r1", ":", "port", "1", ",", "ipadd", "r2", ":", "port", "2", " ", "or", " ", "domain", "name", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "grace", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "tmp", "boots", "trap", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connect", "tob", "oot", "stra", "p_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "connected_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "boot", "tuple_", "in_", "self_", "._", "boots", "trap", "list_", ":_", "\\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_", "._", "socket_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "=_", "socket_", "._", "socket_", "(_", "socket_", "._", "AF", "\\u", "INET_", ",_", "socket_", "._", "SOCK", "\\u", "STREAM_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "setsockopt_", "(_", "socket_", "._", "SOL", "\\u", "SOCKET_", ",_", "socket_", "._", "SO", "\\u", "REUSE", "ADDR_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "connect_", "(_", "boot", "tuple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "conn_", "=_", "Connection_", "(_", "self_", "._", "socket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "conn_", "._", "settimeout_", "(_", "CLIENT", "RESE", "ND", "TIMEOUT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bootstrap_", "=_", "boot", "tuple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connected_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "print_", "\"", "Connect", "ed", " ", "to", " ", "new", " ", "boots", "trap", ":", " ", "\"_", ",_", "boot", "tuple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "print_", "\"", "Sock", "et", ".", "Error", ":", " ", "\"_", ",_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "connected_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "try", "newb", "oot", "stra", "p_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "domain", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "boots", "trap", "list_", "=_", "self_", "._", "getb", "oot", "stra", "pf", "rom", "domain_", "(_", "self_", "._", "domain", "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 ", " _", "old", "bootstrap_", "=_", "self_", "._", "boots", "trap", "list_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "boots", "trap", "list_", "._", "append_", "(_", "old", "bootstrap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "connect", "tob", "oot", "stra", "p_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "invoke", "\\u", "command_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "create", " ", "a", " ", "request", " ", "descriptor_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resen", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "count_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lastr", "epl", "yco", "de_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "number_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "msg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REQUEST_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "PROP", "OS", "AL_", ":_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "self_", "._", "command", "number_", ",_", "args_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "TOKEN_", ":_", "self_", "._", "token_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "CLIENT", "BATCH", "_", ":_", "False_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "send", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "msg_", "[_", "FL", "D", "\\u", "SEND", "COUNT_", "]_", "=_", "send", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "the", " ", "client", "request_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "resen", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "success_", "=_", "self_", "._", "conn_", "._", "send_", "(_", "client", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "reconfigur", "e_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "resen", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Receive", " ", "reply_", "\\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 ", " _", "for_", "reply_", "in_", "self_", "._", "conn_", "._", "receive", "d\\u", "bytes_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "reply_", "and_", "reply_", "._", "type_", "==_", "MS", "G", "\\u", "CLIENT", "REPLY_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "OK_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "reply_", "._", "reply_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "UN", "BLOCK_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "action", "able", " ", "response", ",", " ", "wake", " ", "up", " ", "the", " ", "thread_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "assert_", "lastr", "epl", "yco", "de_", "==_", "CR", "\\u", "BLOCK_", ",_", "\"", "unbl", "ock", "ed", " ", "thread", " ", "not", " ", "previ", "ously", " ", "block", "ed", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "reply_", "._", "reply_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "EXCEPTION_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "Exception_", "(_", "pickle_", "._", "loads_", "(_", "reply_", "._", "reply_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "IN", "PROGRESS", "_", "or_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "BLOCK_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "thread", " ", "is", " ", "alr", "ead", "y", " ", "wait", "ing", ",", " ", "no", " ", "need", " ", "to", " ", "do", " ", "anyt", "hing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "lastr", "epl", "yco", "de_", "=_", "reply_", "._", "repl", "yco", "de_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "go", " ", "wait", " ", "for", " ", "anot", "her", " ", "message_", "\\u\\u\\uNL\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "REJECT", "ED_", "or_", "reply_", "._", "repl", "yco", "de_", "==_", "CR", "\\u", "LEA", "DER", "NOT", "READY", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "resen", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reconfigur", "e_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\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_", "\"", "Un", "know", "n", " ", "Client", " ", "Repl", "y", " ", "Code", ".\"_", "\\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_", "except_", "Connect", "ion", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resen", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reconfigur", "e_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "board", "Interrupt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "grace", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Proxy_", "(_", ")_", ":_", "\\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_", "reconfigur", "e_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "try", "newb", "oot", "stra", "p_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Connect", "ion", "Error_", "(_", "\"", "Cann", "ot", " ", "connect", " ", "to", " ", "any", " ", "boots", "trap", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u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be the case though\n# from distutils.core import setup\nfrom distutils.core import setup\t\nfrom distutils.extension import Extension\nfrom Cython.Distutils import build_ext\nimport os.path\nimport sys\nimport numpy.core\n\n\nnumpy_include_dir = os.path.join(os.path.dirname(numpy.core.__file__),'include')\nfiboheap_include_dir = os.path.join('zen','util')\n\next_modules = [\tExtension('zen.graph', ['zen/graph.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.digraph', ['zen/digraph.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.bipartite', ['zen/bipartite.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.degree', ['zen/degree.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.hypergraph', ['zen/hypergraph.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.util.fiboheap', ['zen/util/fiboheap.pyx', 'zen/util/fib.c'], include_dirs=[numpy_include_dir]),\nExtension('zen.util.queue', ['zen/util/queue.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.io.edgelist', ['zen/io/edgelist.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.io.hedgelist', ['zen/io/hedgelist.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.io.rdot', ['zen/io/rdot.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.io.scn', ['zen/io/scn.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.io.memlist', ['zen/io/memlist.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.clustering', ['zen/algorithms/clustering.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.components', ['zen/algorithms/components.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.randomize', ['zen/randomize.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.centrality', ['zen/algorithms/centrality.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.layout.spring_layout', ['zen/layout/spring_layout.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.layout.random_layout', ['zen/layout/random_layout.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.layout.forceatlas_layout', ['zen/layout/forceatlas_layout.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.layout.fruchtermanreingold_layout', ['zen/layout/fruchtermanreingold_layout.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.shortest_path', ['zen/algorithms/shortest_path.pyx'], include_dirs=[numpy_include_dir, fiboheap_include_dir]),\nExtension('zen.algorithms.properties', ['zen/algorithms/properties.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.modularity', ['zen/algorithms/modularity.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.spanning', ['zen/algorithms/spanning.pyx'], include_dirs=[numpy_include_dir, fiboheap_include_dir]),\nExtension('zen.algorithms.matching', ['zen/algorithms/matching.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.generating.rgm', ['zen/generating/rgm.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.community.communityset', ['zen/algorithms/community/communityset.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.community.overlapping_communityset', ['zen/algorithms/community/overlapping_communityset.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.community.lpa', ['zen/algorithms/community/lpa.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.community.label_rank', ['zen/algorithms/community/label_rank.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.community.spectral_modularity', ['zen/algorithms/community/spectral_modularity.pyx'], include_dirs=[numpy_include_dir]),\nExtension('zen.algorithms.community.louvain', ['zen/algorithms/community/louvain.pyx'], include_dirs=[numpy_include_dir])]\n\n\nsetup(\n\tname = 'Zen Library',\n\tversion = '0.9',\n\tcmdclass = {'build_ext': build_ext},\n\text_modules = ext_modules,\n\tpackages = ['zen','zen.data','zen.drawing','zen.generating','zen.io','zen.layout',\n\t\t\t\t'zen.tests','zen.util','zen.algorithms.community','zen.benchmarks',\n\t\t\t\t'zen.algorithms', 'zen.algorithms.flow', 'zen.control'],\n\tpackage_data = {'zen' : ['*.pxd'],\n\t'zen.algorithms' : ['*.pxd'],\n\t'zen.algorithms.community' : ['*.pxd'],\n\t'zen.drawing' : ['*.pxd'],\n\t'zen.data' : ['*.scn','*.elist','*.gml'],\n\t'zen.generating' : ['*.pxd'],\n\t'zen.io' : ['*.pxd'],\n\t'zen.layout' : ['*.pxd'],\n\t'zen.tests' : ['*.pxd','*.scn','*.elist','*.helist','*.rdot', '*.memlist', '*.gml'],\n\t'zen.util' : ['*.pxd'],\n\t'zen.data' : ['*.scn','*.gml'] },\n\t# # dependencies\n\tsetup_requires = ['distribute','cython>=0.14'],\n\tinstall_requires = ['numpy>=1.6.1','matplotlib>=1.0.1', 'networkx'],\n\t#\n\t# # testing suite\n\t# test_suite = 'zen.test',\n\t#\n\t# # project metadata\n\tauthor = 'Derek Ruths',\n\tauthor_email = '[email protected]',\n\tdescription = 'Zen is a high-performance, easy-to-use network library developed specifically for Python.',\n\tlicense = 'BSD',\n\turl = 'http://zen.networkdynamics.org',\n\tdownload_url = 'https://github.com/networkdynamics/zenlib'\n)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "'zen.data' ", "start_line": 62, "start_column": 1, "end_line": 62, "end_column": 11 } ]
[ { "span": "'zen.data' ", "start_line": 68, "start_column": 1, "end_line": 68, "end_column": 11 } ]
1
true
[ "[CLS]_", "Duplicate", "_", "key_", "in_", "dict_", "literal_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "setup", "tool", "s", " ", "import", " ", "setup_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "except", " ", "Import", "Error", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "#", "Thi", "s", " ", "shou", "ld", " ", "not", " ", "be", " ", "the", " ", "case", " ", "tho", "ugh", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "distutils", ".", "core", " ", "import", " ", "setup_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "distutils_", "._", "core_", "import_", "setup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "distutils_", "._", "extension_", "import_", "Extension_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Cython", "_", "._", "Dist", "utils_", "import_", "build", "\\u", "ext_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "._", "core_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nump", "y", "\\u", "include", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "numpy_", "._", "core_", "._", "\\u\\u", "file\\u\\u_", ")_", ",_", "'", "include", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fibo", "heap", "\\u", "include", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "'", "zen", "'_", ",_", "'", "util", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ext", "\\u", "modules_", "=_", "[_", "Extension_", "(_", "'", "zen", ".", "graph", "'_", ",_", "[_", "'", "zen", "/", "graph", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "digraph", "'_", ",_", "[_", "'", "zen", "/", "digraph", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "bip", "arti", "te", "'_", ",_", "[_", "'", "zen", "/", "bip", "arti", "te", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "degr", "ee", "'_", ",_", "[_", "'", "zen", "/", "degr", "ee", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "hyper", "graph", "'_", ",_", "[_", "'", "zen", "/", "hyper", "graph", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "util", ".", "fibo", "heap", "'_", ",_", "[_", "'", "zen", "/", "util", "/", "fibo", "heap", ".", "pyx", "'_", ",_", "'", "zen", "/", "util", "/", "fib", ".", "c", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "util", ".", "queue", "'_", ",_", "[_", "'", "zen", "/", "util", "/", "queue", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "io", ".", "edgelist", "'_", ",_", "[_", "'", "zen", "/", "io", "/", "edgelist", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "io", ".", "hed", "gel", "ist", "'_", ",_", "[_", "'", "zen", "/", "io", "/", "hed", "gel", "ist", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "io", ".", "rdo", "t", "'_", ",_", "[_", "'", "zen", "/", "io", "/", "rdo", "t", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "io", ".", "sc", "n", "'_", ",_", "[_", "'", "zen", "/", "io", "/", "sc", "n", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "io", ".", "mem", "list", "'_", ",_", "[_", "'", "zen", "/", "io", "/", "mem", "list", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "clusteri", "ng", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "clusteri", "ng", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "component", "s", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "component", "s", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "randomize", "'_", ",_", "[_", "'", "zen", "/", "randomize", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "centrali", "ty", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "centrali", "ty", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "layout", ".", "spring", "\\u", "layout", "'_", ",_", "[_", "'", "zen", "/", "layout", "/", "spring", "\\u", "layout", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "layout", ".", "random", "\\u", "layout", "'_", ",_", "[_", "'", "zen", "/", "layout", "/", "random", "\\u", "layout", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "layout", ".", "force", "atlas", "\\u", "layout", "'_", ",_", "[_", "'", "zen", "/", "layout", "/", "force", "atlas", "\\u", "layout", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "layout", ".", "fru", "cht", "erm", "an", "rein", "gold", "\\u", "layout", "'_", ",_", "[_", "'", "zen", "/", "layout", "/", "fru", "cht", "erm", "an", "rein", "gold", "\\u", "layout", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "short", "est", "\\u", "path", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "short", "est", "\\u", "path", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", ",_", "fibo", "heap", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "proper", "ties", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "proper", "ties", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "modula", "rity", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "modula", "rity", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "spanning", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "spanning", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", ",_", "fibo", "heap", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "matchi", "ng", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "matchi", "ng", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "generat", "ing", ".", "rg", "m", "'_", ",_", "[_", "'", "zen", "/", "generat", "ing", "/", "rg", "m", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", ".", "communi", "ty", "set", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "communi", "ty", "/", "communi", "ty", "set", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", ".", "overlapping", "\\u", "communi", "ty", "set", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "communi", "ty", "/", "overlapping", "\\u", "communi", "ty", "set", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", ".", "lpa", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "communi", "ty", "/", "lpa", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", ".", "label", "\\u", "rank", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "communi", "ty", "/", "label", "\\u", "rank", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", ".", "spectral", "\\u", "modula", "rity", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "communi", "ty", "/", "spectral", "\\u", "modula", "rity", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Extension_", "(_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", ".", "lou", "va", "in", "'_", ",_", "[_", "'", "zen", "/", "algo", "rit", "hms", "/", "communi", "ty", "/", "lou", "va", "in", ".", "pyx", "'_", "]_", ",_", "include", "\\u", "dirs_", "=_", "[_", "nump", "y", "\\u", "include", "\\u", "dir_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "setup_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "'", "Ze", "n", " ", "Libr", "ary", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "0.", "9", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cmdclass_", "=_", "{_", "'", "build", "\\u", "ext", "'_", ":_", "build", "\\u", "ext_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ext", "\\u", "modules_", "=_", "ext", "\\u", "modules_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "packages_", "=_", "[_", "'", "zen", "'_", ",_", "'", "zen", ".", "data", "'_", ",_", "'", "zen", ".", "drawing", "'_", ",_", "'", "zen", ".", "generat", "ing", "'_", ",_", "'", "zen", ".", "io", "'_", ",_", "'", "zen", ".", "layout", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "tests", "'_", ",_", "'", "zen", ".", "util", "'_", ",_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", "'_", ",_", "'", "zen", ".", "benchmarks", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "algo", "rit", "hms", "'_", ",_", "'", "zen", ".", "algo", "rit", "hms", ".", "flow", "'_", ",_", "'", "zen", ".", "control", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "package", "\\u", "data_", "=_", "{_", "'", "zen", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "algo", "rit", "hms", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "algo", "rit", "hms", ".", "communi", "ty", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "drawing", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "data", "'_", ":_", "[_", "'*", ".", "sc", "n", "'_", ",_", "'*", ".", "elist", "'_", ",_", "'*", ".", "gm", "l", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "generat", "ing", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "io", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "layout", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "tests", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", ",_", "'*", ".", "sc", "n", "'_", ",_", "'*", ".", "elist", "'_", ",_", "'*", ".", "heli", "st", "'_", ",_", "'*", ".", "rdo", "t", "'_", ",_", "'*", ".", "mem", "list", "'_", ",_", "'*", ".", "gm", "l", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "util", "'_", ":_", "[_", "'*", ".", "px", "d", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zen", ".", "data", "'_", ":_", "[_", "'*", ".", "sc", "n", "'_", ",_", "'*", ".", "gm", "l", "'_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "#", " ", "dependencies_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "requires_", "=_", "[_", "'", "distribute", "'_", ",_", "'", "cython", ">=", "0.14", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "install", "\\u", "requires_", "=_", "[_", "'", "nump", "y", ">=", "1.6", ".1", "'_", ",_", "'", "mat", "plotlib", ">=", "1.0", ".1", "'_", ",_", "'", "networkx", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "#", " ", "testi", "ng", " ", "suite_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test\\u", "suit", "e", " ", "=", " ", "'", "zen", ".", "test", "',", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "#", " ", "project", " ", "metadata_", "\\u\\u\\uNL\\u\\u\\u_", "author_", "=_", "'", "Der", "ek", " ", "Ru", "ths", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author", "\\u", "email_", "=_", "'", "dru", "ths", "@", "networkd", "yna", "mic", "s", ".", "org", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'", "Ze", "n", " ", "is", " ", "a", " ", "high", "-", "perform", "anc", "e", ",", " ", "easy", "-", "to", "-", "use", " ", "network", " ", "librar", "y", " ", "develop", "ed", " ", "specifica", "ll", "y", " ", "for", " ", "Pyth", "on", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "license_", "=_", "'", "BS", "D", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "'", "http", "://", "zen", ".", "networkd", "yna", "mic", "s", ".", "org", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "download", "\\u", "url_", "=_", "'", "https", "://", "git", "hub", ".", "com", "/", "networkd", "yna", "mic", "s", "/", "zen", "lib", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Imprecise assert
biocore/scikit-bio/skbio/alignment/tests/test_tabular_msa.py
[ { "content": " def test_no_sequences(self):\n msa = TabularMSA([], index=[])\n\n self.assertFalse('' in msa)\n self.assertFalse('foo' in msa)", "metadata": "root.TestContains.test_no_sequences", "header": "['class', 'TestContains', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 773 }, { "content": " def test_with_str_labels(self):\n msa = TabularMSA([RNA('AU'), RNA('A.')], index=['foo', 'bar'])\n\n self.assertTrue('foo' in msa)\n self.assertTrue('bar' in msa)\n self.assertFalse('baz' in msa)\n self.assertFalse(0 in msa)", "metadata": "root.TestContains.test_with_str_labels", "header": "['class', 'TestContains', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 779 }, { "content": " def test_with_int_labels(self):\n msa = TabularMSA([RNA('AU'), RNA('A.')], index=[42, -1])\n\n self.assertTrue(42 in msa)\n self.assertTrue(-1 in msa)\n self.assertFalse(0 in msa)\n self.assertFalse('foo' in msa)", "metadata": "root.TestContains.test_with_int_labels", "header": "['class', 'TestContains', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 787 }, { "content": " def test_ties(self):\n msa = TabularMSA([DNA('A-'),\n DNA('C-'),\n DNA('G-')])\n\n cons = msa.consensus()\n\n self.assertTrue(cons in [DNA('A-'), DNA('C-'), DNA('G-')])", "metadata": "root.TestConsensus.test_ties", "header": "['class', 'TestConsensus', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 2708 }, { "content": " def test_ties_with_gaps(self):\n msa = TabularMSA([DNA('-'),\n DNA('.'),\n DNA('T'),\n DNA('T')])\n\n cons = msa.consensus()\n\n self.assertTrue(cons in [DNA('T'), DNA('-')])", "metadata": "root.TestConsensus.test_ties_with_gaps", "header": "['class', 'TestConsensus', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 2717 } ]
[ { "span": "self.assertFalse('' in msa)", "start_line": 776, "start_column": 8, "end_line": 776, "end_column": 35 }, { "span": "self.assertFalse('foo' in msa)", "start_line": 777, "start_column": 8, "end_line": 777, "end_column": 38 }, { "span": "self.assertTrue('foo' in msa)", "start_line": 782, "start_column": 8, "end_line": 782, "end_column": 37 }, { "span": "self.assertTrue('bar' in msa)", "start_line": 783, "start_column": 8, "end_line": 783, "end_column": 37 }, { "span": "self.assertFalse('baz' in msa)", "start_line": 784, "start_column": 8, "end_line": 784, "end_column": 38 }, { "span": "self.assertFalse(0 in msa)", "start_line": 785, "start_column": 8, "end_line": 785, "end_column": 34 }, { "span": "self.assertTrue(42 in msa)", "start_line": 790, "start_column": 8, "end_line": 790, "end_column": 34 }, { "span": "self.assertTrue(-1 in msa)", "start_line": 791, "start_column": 8, "end_line": 791, "end_column": 34 }, { "span": "self.assertFalse(0 in msa)", "start_line": 792, "start_column": 8, "end_line": 792, "end_column": 34 }, { "span": "self.assertFalse('foo' in msa)", "start_line": 793, "start_column": 8, "end_line": 793, "end_column": 38 }, { "span": "self.assertTrue(cons in [DNA('A-'), DNA('C-'), DNA('G-')])", "start_line": 2715, "start_column": 8, "end_line": 2715, "end_column": 66 }, { "span": "self.assertTrue(cons in [DNA('T'), DNA('-')])", "start_line": 2725, "start_column": 8, "end_line": 2725, "end_column": 53 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Contains_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "no", "\\u", "sequences_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msa", "_", "=_", "Tab", "ular", "MS", "A_", "(_", "[_", "]_", ",_", "index_", "=_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "''_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "'", "foo", "'_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Contains_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "with", "\\u", "str", "\\u", "labels_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msa", "_", "=_", "Tab", "ular", "MS", "A_", "(_", "[_", "RNA", "_", "(_", "'", "AU", "'_", ")_", ",_", "RNA", "_", "(_", "'", "A", ".'_", ")_", "]_", ",_", "index_", "=_", "[_", "'", "foo", "'_", ",_", "'", "bar", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "foo", "'_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "bar", "'_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "'", "ba", "z", "'_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "0_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Contains_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "with", "\\u", "int\\u", "labels_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msa", "_", "=_", "Tab", "ular", "MS", "A_", "(_", "[_", "RNA", "_", "(_", "'", "AU", "'_", ")_", ",_", "RNA", "_", "(_", "'", "A", ".'_", ")_", "]_", ",_", "index_", "=_", "[_", "42_", ",_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "42_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "-_", "1_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "0_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "'", "foo", "'_", "in_", "msa", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Conse", "nsu", "s_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ties_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msa", "_", "=_", "Tab", "ular", "MS", "A_", "(_", "[_", "DNA", "_", "(_", "'", "A", "-'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DNA", "_", "(_", "'", "C", "-'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DNA", "_", "(_", "'", "G", "-'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cons_", "=_", "msa", "_", "._", "consensus", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "cons_", "in_", "[_", "DNA", "_", "(_", "'", "A", "-'_", ")_", ",_", "DNA", "_", "(_", "'", "C", "-'_", ")_", ",_", "DNA", "_", "(_", "'", "G", "-'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Conse", "nsu", "s_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ties", "\\u", "with", "\\u", "gaps_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msa", "_", "=_", "Tab", "ular", "MS", "A_", "(_", "[_", "DNA", "_", "(_", "'-'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DNA", "_", "(_", "'.'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DNA", "_", "(_", "'", "T", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DNA", "_", "(_", "'", "T", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cons_", "=_", "msa", "_", "._", "consensus", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "cons_", "in_", "[_", "DNA", "_", "(_", "'", "T", "'_", ")_", ",_", "DNA", "_", "(_", "'-'_", ")_", "]_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1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en/src/basename_ranker_test.py
[ { "content": " def test_rank_subclasses_lower_ranked_than_base(self):\n # this tests that hitting all words counts higher than hitting some of the words\n base_rank = self.ranker.rank_query(\"rwhvm\", \"render_widget_host_view.h\")\n subclass_rank = self.ranker.rank_query(\"rwhvm\", \"render_widget_host_view_subclass.h\")\n self.assertTrue(base_rank > subclass_rank)", "metadata": "root.BasenameRankerTest.test_rank_subclasses_lower_ranked_than_base", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 142 }, { "content": " def _assertRankDecreasesOrStaysTheSame(self, query, names):\n \"\"\"\n Makes suer that the first element in the array has highest rank\n and subsequent items have decreasing or equal rank.\n \"\"\"\n ranks = [self.ranker.rank_query(query, n) for n in names]\n nw = [self.ranker.get_num_words(n) for n in names]\n basic_ranks = [self.ranker._get_basic_rank(query, n) for n in names]\n for i in range(1, len(ranks)):\n changeInRank = ranks[i] - ranks[i-1]\n self.assertTrue(changeInRank <= 0)", "metadata": "root.BasenameRankerTest._assertRankDecreasesOrStaysTheSame", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 159 }, { "content": " def test_rank_order_puts_tests_second(self):\n q = \"ccframerate\"\n a1 = self.ranker.rank_query(q, 'CCFrameRateController.cpp')\n a2 = self.ranker.rank_query(q, 'CCFrameRateController.h')\n b = self.ranker.rank_query(q, 'CCFrameRateControllerTest.cpp')\n\n # This is a hard test to pass because ccframera(te) ties to (Te)st\n # if you weight non-word matches equally.\n self.assertTrue(a1 > b);\n self.assertTrue(a2 > b);\n\n q = \"chrome_switches\"\n a1 = self.ranker.rank_query(q, 'chrome_switches.cc')\n a2 = self.ranker.rank_query(q, 'chrome_switches.h')\n b = self.ranker.rank_query(q, 'chrome_switches_uitest.cc')\n self.assertTrue(a1 > b);\n self.assertTrue(a2 > b);", "metadata": "root.BasenameRankerTest.test_rank_order_puts_tests_second", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 176 }, { "content": " def test_rank_order_for_hierarchy_puts_prefixed_second(self):\n q = \"ccframerate\"\n a = self.ranker.rank_query(q, 'CCFrameRateController.cpp')\n b1 = self.ranker.rank_query(q, 'webcore_platform.CCFrameRateController.o.d')\n b2 = self.ranker.rank_query(q, 'webkit_unit_tests.CCFrameRateControllerTest.o.d')\n self.assertTrue(a > b1);\n # FAILS because ccframera(te) ties to (Te)st\n # self.assertTrue(a > b2);", "metadata": "root.BasenameRankerTest.test_rank_order_for_hierarchy_puts_prefixed_second", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 194 }, { "content": " def test_rank_order_puts_tests_second_2(self):\n q = \"ccdelaybassedti\"\n a1 = self.ranker.rank_query(q, 'CCDelayBasedTimeSource.cpp')\n a2 = self.ranker.rank_query(q, 'CCDelayBasedTimeSource.h')\n b = self.ranker.rank_query(q, 'CCDelayBasedTimeSourceTest.cpp')\n self.assertTrue(a1 > b);\n self.assertTrue(a2 > b);\n\n q = \"LayerTexture\"\n a = self.ranker.rank_query(q, 'LayerTexture.cpp')\n b = self.ranker.rank_query(q, 'LayerTextureSubImage.cpp')\n self.assertTrue(a > b)", "metadata": "root.BasenameRankerTest.test_rank_order_puts_tests_second_2", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 203 }, { "content": " def test_refinement_improves_rank_query(self):\n a = self.ranker.rank_query('render_', 'render_widget.cc')\n b = self.ranker.rank_query('render_widget', 'render_widget.cc')\n self.assertTrue(b > a)", "metadata": "root.BasenameRankerTest.test_refinement_improves_rank_query", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 216 }, { "content": " def test_document_rank(self):\n a = self.ranker.rank_query('document.cpp', 'Document.cpp')\n b = self.ranker.rank_query('document.cpp', 'AccessibleDocument.cpp')\n self.assertTrue(a > b)", "metadata": "root.BasenameRankerTest.test_document_rank", "header": "['class', 'BasenameRankerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 221 } ]
[ { "span": "self.assertTrue(base_rank > subclass_rank)", "start_line": 146, "start_column": 4, "end_line": 146, "end_column": 46 }, { "span": "self.assertTrue(changeInRank <= 0)", "start_line": 169, "start_column": 6, "end_line": 169, "end_column": 40 }, { "span": "self.assertTrue(a1 > b);", "start_line": 184, "start_column": 4, "end_line": 184, "end_column": 27 }, { "span": "self.assertTrue(a2 > b);", "start_line": 185, "start_column": 4, "end_line": 185, "end_column": 27 }, { "span": "self.assertTrue(a1 > b);", "start_line": 191, "start_column": 4, "end_line": 191, "end_column": 27 }, { "span": "self.assertTrue(a2 > b);", "start_line": 192, "start_column": 4, "end_line": 192, "end_column": 27 }, { "span": "self.assertTrue(a > b1);", "start_line": 199, "start_column": 4, "end_line": 199, "end_column": 27 }, { "span": "self.assertTrue(a1 > b);", "start_line": 208, "start_column": 4, "end_line": 208, "end_column": 27 }, { "span": "self.assertTrue(a2 > b);", "start_line": 209, "start_column": 4, "end_line": 209, "end_column": 27 }, { "span": "self.assertTrue(a > b)", "start_line": 214, "start_column": 4, "end_line": 214, "end_column": 26 }, { "span": "self.assertTrue(b > a)", "start_line": 219, "start_column": 4, "end_line": 219, "end_column": 26 }, { "span": "self.assertTrue(a > b)", "start_line": 224, "start_column": 4, "end_line": 224, "end_column": 26 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "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", "rank", "\\u", "subclasses", "\\u", "lower", "\\u", "ranked", "\\u", "than", "\\u", "base_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "tests", " ", "tha", "t", " ", "hit", "ting", " ", "all", " ", "words", " ", "count", "s", " ", "higher", " ", "than", " ", "hit", "ting", " ", "some", " ", "of", " ", "the", " ", "words_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "base", "\\u", "rank_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "\"", "rw", "hv", "m", "\"_", ",_", "\"", "render", "\\u", "widget", "\\u", "host", "\\u", "view", ".", "h", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subclass", "\\u", "rank_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "\"", "rw", "hv", "m", "\"_", ",_", "\"", "render", "\\u", "widget", "\\u", "host", "\\u", "view", "\\u", "subclass", ".", "h", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "base", "\\u", "rank_", ">_", "subclass", "\\u", "rank_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "assert", "Rank", "Decre", "ases", "Or", "Sta", "ys", "The", "Sam", "e_", "(_", "self_", ",_", "query_", ",_", "names_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Make", "s", " ", "su", "er", " ", "tha", "t", " ", "the", " ", "first", " ", "element", " ", "in", " ", "the", " ", "array", " ", "has", " ", "high", "est", " ", "rank", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "subsequen", "t", " ", "items", " ", "have", " ", "decre", "asin", "g", " ", "or", " ", "equal", " ", "rank", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ranks_", "=_", "[_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "query_", ",_", "n_", ")_", "for_", "n_", "in_", "names_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nw_", "=_", "[_", "self_", "._", "rank", "er_", "._", "get", "\\u", "num", "\\u", "words_", "(_", "n_", ")_", "for_", "n_", "in_", "names_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "basic", "\\u", "ranks_", "=_", "[_", "self_", "._", "rank", "er_", "._", "\\u", "get", "\\u", "basic", "\\u", "rank_", "(_", "query_", ",_", "n_", ")_", "for_", "n_", "in_", "names_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "1_", ",_", "len_", "(_", "ranks_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "change", "In", "Rank_", "=_", "ranks_", "[_", "i_", "]_", "-_", "ranks_", "[_", "i_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "change", "In", "Rank_", "<=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "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", "rank", "\\u", "order", "\\u", "puts", "\\u", "tests", "\\u", "second_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "\"", "ccf", "rame", "rate", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CC", "Frame", "Rat", "e", "Controlle", "r", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CC", "Frame", "Rat", "e", "Controlle", "r", ".", "h", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CC", "Frame", "Rat", "e", "Controlle", "r", "Test", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "hard", " ", "test", " ", "to", " ", "pass", " ", "bec", "aus", "e", " ", "ccf", "rame", "ra", "(", "te", ")", " ", "ties", " ", "to", " ", "(", "Te", ")", "st_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "you", " ", "weight", " ", "non", "-", "word", " ", "matche", "s", " ", "equal", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a1_", ">_", "b_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a2_", ">_", "b_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "q_", "=_", "\"", "chrome", "\\u", "switche", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "chrome", "\\u", "switche", "s", ".", "cc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "chrome", "\\u", "switche", "s", ".", "h", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "chrome", "\\u", "switche", "s", "\\u", "uit", "est", ".", "cc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a1_", ">_", "b_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a2_", ">_", "b_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "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", "rank", "\\u", "order", "\\u", "for", "\\u", "hier", "arch", "y", "\\u", "puts", "\\u", "prefixed", "\\u", "second_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "\"", "ccf", "rame", "rate", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CC", "Frame", "Rat", "e", "Controlle", "r", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b1_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "webc", "ore", "\\u", "platform", ".", "CC", "Frame", "Rat", "e", "Controlle", "r", ".", "o", ".", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b2_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "webkit", "\\u", "unit", "\\u", "tests", ".", "CC", "Frame", "Rat", "e", "Controlle", "r", "Test", ".", "o", ".", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a_", ">_", "b1_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FAIL", "S", " ", "bec", "aus", "e", " ", "ccf", "rame", "ra", "(", "te", ")", " ", "ties", " ", "to", " ", "(", "Te", ")", "st_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "assert", "Tru", "e", "(", "a", " ", ">", " ", "b2", ");", "_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "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", "rank", "\\u", "order", "\\u", "puts", "\\u", "tests", "\\u", "second", "\\u", "2_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "\"", "ccd", "ela", "yb", "ass", "edt", "i", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CCD", "ela", "y", "Base", "d", "Time", "Sou", "rce", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CCD", "ela", "y", "Base", "d", "Time", "Sou", "rce", ".", "h", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "CCD", "ela", "y", "Base", "d", "Time", "Sou", "rce", "Test", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a1_", ">_", "b_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a2_", ">_", "b_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "q_", "=_", "\"", "Layer", "Text", "ure", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "Layer", "Text", "ure", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "q_", ",_", "'", "Layer", "Text", "ure", "Sub", "Image", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a_", ">_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "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", "refinement", "\\u", "improve", "s", "\\u", "rank", "\\u", "query_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "'", "render", "\\u'_", ",_", "'", "render", "\\u", "widget", ".", "cc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "'", "render", "\\u", "widget", "'_", ",_", "'", "render", "\\u", "widget", ".", "cc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "b_", ">_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "name", "Rank", "er", "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", "document", "\\u", "rank_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "'", "document", ".", "cpp", "'_", ",_", "'", "Document", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "rank", "er_", "._", "rank", "\\u", "query_", "(_", "'", "document", ".", "cpp", "'_", ",_", "'", "Accessib", "le", "Document", ".", "cpp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "a_", ">_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Redundant comparison
grundprinzip/sublemacspro/jove.py
[ { "content": " def append_from_cursor(self):\n # Figure out the contents to the right of the last region in the current selected state, and\n # append characters from there.\n si = self.current\n if len(si.search) > 0 and not si.selected:\n # search is failing - no point in adding from current cursor!\n return\n\n view = self.view\n limit = view.size()\n if si.selected:\n # grab end of most recent item\n point = si.selected[-1].end()\n else:\n point = self.point[0].b\n if point >= limit:\n return\n\n # now push new states for each character we append to the search string\n helper = self.util\n search = si.search\n separators = SettingsManager.get(\"sbp_word_separators\", default_sbp_word_separators)\n case_sensitive = re.search(r'[A-Z]', search) is not None\n\n def append_one(ch):\n if not case_sensitive:\n ch = ch.lower()\n if self.regex and ch in \"{}()[].*+\":\n return \"\\\\\" + ch\n return ch\n\n if point < limit:\n # append at least one character, word character or not\n search += append_one(view.substr(point))\n point += 1\n self.on_change(search)\n\n # now insert word characters\n while point < limit and helper.is_word_char(point, True, separators):\n ch = view.substr(point)\n search += append_one(ch)\n self.on_change(search)\n point += 1\n self.set_text(self.current.search)", "metadata": "root.ISearchInfo.append_from_cursor", "header": "['class', 'ISearchInfo', '(', ')', ':', '___EOS___']", "index": 2063 } ]
[ { "span": "point < limit:", "start_line": 2094, "start_column": 11, "end_line": 2094, "end_column": 24 } ]
[ { "span": "point >= limit:", "start_line": 2078, "start_column": 11, "end_line": 2078, "end_column": 25 } ]
1
true
[ "[CLS]_", "Redu", "ndan", "t_", "comparison_", "[SEP]_", "class_", "IS", "ear", "ch", "Info_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "append", "\\u", "from", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fig", "ure", " ", "out", " ", "the", " ", "content", "s", " ", "to", " ", "the", " ", "right", " ", "of", " ", "the", " ", "last", " ", "region", " ", "in", " ", "the", " ", "current", " ", "selecte", "d", " ", "state", ",", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "append", " ", "character", "s", " ", "from", " ", "there", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "si_", "=_", "self_", "._", "current_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "si_", "._", "search_", ")_", ">_", "0_", "and_", "not_", "si_", "._", "selected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "search", " ", "is", " ", "faili", "ng", " ", "-", " ", "no", " ", "point", " ", "in", " ", "addin", "g", " ", "from", " ", "current", " ", "cursor", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "view_", "=_", "self_", "._", "view_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "limit_", "=_", "view_", "._", "size_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "si_", "._", "selected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "gra", "b", " ", "end", " ", "of", " ", "most", " ", "recent", " ", "item_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point_", "=_", "si_", "._", "selected_", "[_", "-_", "1_", "]_", "._", "end_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point_", "=_", "self_", "._", "point_", "[_", "0_", "]_", "._", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "point_", ">=_", "limit_", ":_", "\\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_", "#", " ", "now", " ", "push", " ", "new", " ", "state", "s", " ", "for", " ", "each", " ", "character", " ", "we", " ", "append", " ", "to", " ", "the", " ", "search", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "helper_", "=_", "self_", "._", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "search_", "=_", "si_", "._", "search_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "separators_", "=_", "Sett", "ings", "Manager_", "._", "get_", "(_", "\"", "sb", "p", "\\u", "word", "\\u", "separator", "s", "\"_", ",_", "default", "\\u", "sb", "p", "\\u", "word", "\\u", "separators_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case", "\\u", "sensitive_", "=_", "re_", "._", "search_", "(_", "r", "'[", "A", "-", "Z", "]'_", ",_", "search_", ")_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "append", "\\u", "one_", "(_", "ch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "case", "\\u", "sensitive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ch_", "=_", "ch_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "regex_", "and_", "ch_", "in_", "\"{}", "()[", "].", "*+", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"\\\\\\\\\"_", "+_", "ch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "ch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "point_", "<_", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "append", " ", "at", " ", "leas", "t", " ", "one", " ", "character", ",", " ", "word", " ", "character", " ", "or", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "search_", "+=_", "append", "\\u", "one_", "(_", "view_", "._", "substr_", "(_", "point_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "point_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "on", "\\u", "change_", "(_", "search_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "insert", " ", "word", " ", "characters_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "point_", "<_", "limit_", "and_", "helper_", "._", "is", "\\u", "word", "\\u", "char_", "(_", "point_", ",_", "True_", ",_", "separators_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ch_", "=_", "view_", "._", "substr_", "(_", "point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "search_", "+=_", "append", "\\u", "one_", "(_", "ch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "on", "\\u", "change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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, 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 ]
Testing equality to None
lebedov/scikit-cuda/skcuda/cusolver.py
[ { "content": "#!/usr/bin/env python\n\n\"\"\"\nPython interface to CUSOLVER functions.\n\nNote: this module does not explicitly depend on PyCUDA.\n\"\"\"\n\nfrom . import cudart\n\nif int(cudart._cudart_version) < 7000:\n raise ImportError('CUSOLVER library only available in CUDA 7.0 and later')\n\nimport ctypes\nimport sys\n\nimport numpy as np\n\nfrom . import cuda\n\n# Load library:\n_version_list = [7.5, 7.0]\nif 'linux' in sys.platform:\n _libcusolver_libname_list = ['libcusolver.so'] + \\\n ['libsolver.so.%s' % v for v in _version_list]\nelif sys.platform == 'darwin':\n _libcusolver_libname_list = ['libcusolver.dylib']\nelif sys.platform == 'win32':\n if sys.maxsize > 2**32:\n _libcusolver_libname_list = ['cusolver.dll'] + \\\n ['cusolver64_%s.dll' % int(10*v) for v in _version_list]\n else:\n _libcusolver_libname_list = ['cusolver.dll'] + \\\n ['cusolver32_%s.dll' % int(10*v) for v in _version_list]\nelse:\n raise RuntimeError('unsupported platform')\n\n# Print understandable error message when library cannot be found:\n_libcusolver = None\nfor _libcusolver_libname in _libcusolver_libname_list:\n try:\n if sys.platform == 'win32':\n _libcusolver = ctypes.windll.LoadLibrary(_libcusolver_libname)\n else:\n _libcusolver = ctypes.cdll.LoadLibrary(_libcusolver_libname)\n except OSError:\n pass\n else:\n break\nif _libcusolver == None:\n raise OSError('cusolver library not found')\n\n\n\n\n\n\n\n\n\n\n\n\n\nCUSOLVER_EXCEPTIONS = {\n 1: CUSOLVER_STATUS_NOT_INITIALIZED,\n 2: CUSOLVER_STATUS_ALLOC_FAILED,\n 3: CUSOLVER_STATUS_INVALID_VALUE,\n 4: CUSOLVER_STATUS_ARCH_MISMATCH,\n 5: CUSOLVER_STATUS_MAPPING_ERROR,\n 6: CUSOLVER_STATUS_EXECUTION_FAILED,\n 7: CUSOLVER_STATUS_INTERNAL_ERROR,\n 8: CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED,\n 9: CUSOLVER_STATUS_NOT_SUPPORTED,\n 10: CUSOLVER_STATUS_ZERO_PIVOT,\n 11: CUSOLVER_STATUS_INVALID_LICENSE\n}\n\n\n# Helper functions:\n\n_libcusolver.cusolverDnCreate.restype = int\n_libcusolver.cusolverDnCreate.argtypes = [ctypes.c_void_p]\n\n_libcusolver.cusolverDnDestroy.restype = int\n_libcusolver.cusolverDnDestroy.argtypes = [ctypes.c_void_p]\n\n_libcusolver.cusolverDnSetStream.restype = int\n_libcusolver.cusolverDnSetStream.argtypes = [ctypes.c_int,\n ctypes.c_int]\n\n_libcusolver.cusolverDnGetStream.restype = int\n_libcusolver.cusolverDnGetStream.argtypes = [ctypes.c_int,\n ctypes.c_void_p]\n\n# Dense solver functions:\n\n# SGETRF, DGETRF, CGETRF, ZGETRF\n_libcusolver.cusolverDnSgetrf_bufferSize.restype = int\n_libcusolver.cusolverDnSgetrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnSgetrf.restype = int\n_libcusolver.cusolverDnSgetrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgetrf_bufferSize.restype = int\n_libcusolver.cusolverDnDgetrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgetrf.restype = int\n_libcusolver.cusolverDnDgetrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgetrf_bufferSize.restype = int\n_libcusolver.cusolverDnCgetrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgetrf.restype = int\n_libcusolver.cusolverDnCgetrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgetrf_bufferSize.restype = int\n_libcusolver.cusolverDnZgetrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgetrf.restype = int\n_libcusolver.cusolverDnZgetrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n# SGETRS, DGETRS, CGETRS, ZGETRS\n_libcusolver.cusolverDnSgetrs.restype = int\n_libcusolver.cusolverDnSgetrs.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgetrs.restype = int\n_libcusolver.cusolverDnDgetrs.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgetrs.restype = int\n_libcusolver.cusolverDnCgetrs.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgetrs.restype = int\n_libcusolver.cusolverDnZgetrs.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n# SGESVD, DGESVD, CGESVD, ZGESVD\n_libcusolver.cusolverDnSgesvd_bufferSize.restype = int\n_libcusolver.cusolverDnSgesvd_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnSgesvd.restype = int\n_libcusolver.cusolverDnSgesvd.argtypes = [ctypes.c_void_p,\n ctypes.c_char,\n ctypes.c_char,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgesvd_bufferSize.restype = int\n_libcusolver.cusolverDnDgesvd_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgesvd.restype = int\n_libcusolver.cusolverDnDgesvd.argtypes = [ctypes.c_void_p,\n ctypes.c_char,\n ctypes.c_char,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgesvd_bufferSize.restype = int\n_libcusolver.cusolverDnCgesvd_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgesvd.restype = int\n_libcusolver.cusolverDnCgesvd.argtypes = [ctypes.c_void_p,\n ctypes.c_char,\n ctypes.c_char,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgesvd_bufferSize.restype = int\n_libcusolver.cusolverDnZgesvd_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgesvd.restype = int\n_libcusolver.cusolverDnZgesvd.argtypes = [ctypes.c_void_p,\n ctypes.c_char,\n ctypes.c_char,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p]\n\n# SGEQRF, DGEQRF, CGEQRF, ZGEQRF\n_libcusolver.cusolverDnSgeqrf_bufferSize.restype = int\n_libcusolver.cusolverDnSgeqrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnSgeqrf.restype = int\n_libcusolver.cusolverDnSgeqrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgeqrf_bufferSize.restype = int\n_libcusolver.cusolverDnDgeqrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnDgeqrf.restype = int\n_libcusolver.cusolverDnDgeqrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgeqrf_bufferSize.restype = int\n_libcusolver.cusolverDnCgeqrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnCgeqrf.restype = int\n_libcusolver.cusolverDnCgeqrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgeqrf_bufferSize.restype = int\n_libcusolver.cusolverDnZgeqrf_bufferSize.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n\n_libcusolver.cusolverDnZgeqrf.restype = int\n_libcusolver.cusolverDnZgeqrf.argtypes = [ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p,\n ctypes.c_void_p,\n ctypes.c_int,\n ctypes.c_void_p]\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "_libcusolver == None:", "start_line": 49, "start_column": 3, "end_line": 49, "end_column": 23 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Pyth", "on", " ", "interface", " ", "to", " ", "CU", "SOL", "VER", " ", "function", "s", ".", "\\", "10", ";", "\\", "10", ";", "Not", "e", ":", " ", "this", " ", "module", " ", "doe", "s", " ", "not", " ", "explicit", "ly", " ", "depend", " ", "on", " ", "Py", "CU", "DA", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "import_", "cud", "art_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "int_", "(_", "cud", "art_", "._", "\\u", "cud", "art", "\\u", "version_", ")_", "<_", "7000", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Import", "Error_", "(_", "'", "CU", "SOL", "VER", " ", "librar", "y", " ", "only", " ", "avail", "able", " ", "in", " ", "CU", "DA", " ", "7.0", " ", "and", " ", "late", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "ctypes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "import_", "cuda_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Load", " ", "librar", "y", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "version", "\\u", "list_", "=_", "[_", "7.5_", ",_", "7.0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "linux", "'_", "in_", "sys_", "._", "platform_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "libc", "uso", "lver", "\\u", "libname", "\\u", "list_", "=_", "[_", "'", "libc", "uso", "lver", ".", "so", "'_", "]_", "+_", "[_", "'", "libs", "olve", "r", ".", "so", ".", "%", "s", "'_", "%_", "v_", "for_", "v_", "in_", "\\u", "version", "\\u", "list_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "sys_", "._", "platform_", "==_", "'", "dar", "win", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "libc", "uso", "lver", "\\u", "libname", "\\u", "list_", "=_", "[_", "'", "libc", "uso", "lver", ".", "dylib", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "sys_", "._", "platform_", "==_", "'", "win32", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sys_", "._", "maxsize_", ">_", "2_", "**_", "32_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "libc", "uso", "lver", "\\u", "libname", "\\u", "list_", "=_", "[_", "'", "cus", "olve", "r", ".", "dll", "'_", "]_", "+_", "[_", "'", "cus", "olve", "r", "64", "\\u", "%", "s", ".", "dll", "'_", "%_", "int_", "(_", "10_", "*_", "v_", ")_", "for_", "v_", "in_", "\\u", "version", "\\u", "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 ", " _", "\\u", "libc", "uso", "lver", "\\u", "libname", "\\u", "list_", "=_", "[_", "'", "cus", "olve", "r", ".", "dll", "'_", "]_", "+_", "[_", "'", "cus", "olve", "r3", "2", "\\u", "%", "s", ".", "dll", "'_", "%_", "int_", "(_", "10_", "*_", "v_", ")_", "for_", "v_", "in_", "\\u", "version", "\\u", "list_", "]_", "\\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_", "Run", "time", "Error_", "(_", "'", "unsup", "porte", "d", " ", "platform", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Print", " ", "underst", "anda", "ble", " ", "error", " ", "message", " ", "whe", "n", " ", "librar", "y", " ", "cann", "ot", " ", "be", " ", "found", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "\\u", "libc", "uso", "lver", "\\u", "libname", "_", "in_", "\\u", "libc", "uso", "lver", "\\u", "libname", "\\u", "list_", ":_", "\\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_", "sys_", "._", "platform_", "==_", "'", "win32", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "libc", "uso", "lver", "_", "=_", "ctypes_", "._", "windll_", "._", "Load", "Library_", "(_", "\\u", "libc", "uso", "lver", "\\u", "libname", "_", ")_", "\\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", "libc", "uso", "lver", "_", "=_", "ctypes_", "._", "cdl", "l_", "._", "Load", "Library_", "(_", "\\u", "libc", "uso", "lver", "\\u", "libname", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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_", "\\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_", "if_", "\\u", "libc", "uso", "lver", "_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OSE", "rror_", "(_", "'", "cus", "olve", "r", " ", "librar", "y", " ", "not", " ", "found", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "CU", "SOL", "VER", "\\u", "EXCEPTION", "S_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "1_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "NOT", "\\u", "INITIAL", "IZED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "ALLOC", "\\u", "FAILED_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "3_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "INVALID", "\\u", "VALUE_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "4_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "ARCH", "\\u", "MIS", "MATCH_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "5_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "MAPPING", "\\u", "ERROR_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "6_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "EXECUT", "ION", "\\u", "FAILED_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "7_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "INTERN", "AL", "\\u", "ERROR_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "8_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "MATRIX", "\\u", "TYPE", "\\u", "NOT", "\\u", "SUPPORTED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "9_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "NOT", "\\u", "SUPPORTED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "10_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "ZERO", "\\u", "PI", "VO", "T_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "11_", ":_", "CU", "SOL", "VER", "\\u", "STATUS", "\\u", "INVALID", "\\u", "LICENSE", "_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Help", "er", " ", "function", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Create_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Create_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Destroy_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Destroy_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Set", "Stream_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Set", "Stream_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Get", "Stream_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Get", "Stream_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Den", "se", " ", "solve", "r", " ", "function", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SG", "ETR", "F", ",", " ", "DG", "ETR", "F", ",", " ", "CG", "ETR", "F", ",", " ", "ZG", "ETR", "F_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "etr", "f", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "etr", "f", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "etr", "f_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "etr", "f_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "etr", "f", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "etr", "f", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "etr", "f_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "etr", "f_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "etr", "f", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "etr", "f", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "etr", "f_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "etr", "f_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "getr", "f", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "getr", "f", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "getr", "f_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "getr", "f_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SG", "ETR", "S", ",", " ", "DG", "ETR", "S", ",", " ", "CG", "ETR", "S", ",", " ", "ZG", "ETR", "S_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "etr", "s_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "etr", "s_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "etr", "s_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "etr", "s_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "etr", "s_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "etr", "s_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "getr", "s_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "getr", "s_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SG", "ES", "VD", ",", " ", "DG", "ES", "VD", ",", " ", "CG", "ES", "VD", ",", " ", "ZG", "ES", "VD", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "es", "vd", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "es", "vd", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "es", "vd_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "es", "vd_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "es", "vd", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "es", "vd", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "es", "vd_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "es", "vd_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "es", "vd", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "es", "vd", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "es", "vd_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "es", "vd_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ges", "vd", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ges", "vd", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ges", "vd_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ges", "vd_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "char_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SG", "EQ", "RF", ",", " ", "DG", "EQ", "RF", ",", " ", "CG", "EQ", "RF", ",", " ", "ZG", "EQ", "RF", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "eq", "rf", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "eq", "rf", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "eq", "rf_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Sg", "eq", "rf_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "eq", "rf", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "eq", "rf", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "eq", "rf_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Dg", "eq", "rf_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "eq", "rf", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "eq", "rf", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "eq", "rf_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Cg", "eq", "rf_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ge", "qr", "f", "\\u", "buffer", "Size_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ge", "qr", "f", "\\u", "buffer", "Size_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ge", "qr", "f_", "._", "restype_", "=_", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "libc", "uso", "lver", "_", "._", "cus", "olve", "r", "Dn", "Z", "ge", "qr", "f_", "._", "argtypes_", "=_", "[_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ctypes_", "._", "c\\u", "voi", "d\\u", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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, 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 2, 2, 2 ]
Wrong number of arguments in a call
jmcnamara/XlsxWriter/xlsxwriter/compat_collections.py
[ { "content": "\"\"\"\nFrom the GC3Pie project: https://code.google.com/p/gc3pie/\n\nA backport of the Python standard `collections` package, providing\n`namedtuple` and `defaultdict` also on Python 2.4 and 2.5.\n\nThis package actually imports your Python `collections`, and adds\nits own versions of `namedtuple` and `defaultdict` only if they are\nmissing.\n\"\"\"\n\nfrom collections import *\nimport sys\n\ntry:\n defaultdict\nexcept NameError:\n\n\ntry:\n namedtuple\nexcept NameError:\n # Use Raymond Hettinger's original `namedtuple` package.\n #\n # Source originally taken from:\n # http://code.activestate.com/recipes/500261-named-tuples/\n from operator import itemgetter as _itemgetter\n from keyword import iskeyword as _iskeyword\n import sys as _sys\n\n\n\nif __name__ == '__main__':\n # verify that instances can be pickled\n from cPickle import loads, dumps\n Point = namedtuple('Point', 'x, y', True)\n p = Point(x=10, y=20)\n assert p == loads(dumps(p, -1))\n\n # test and demonstrate ability to override methods\n\n for p in Point(3, 4), Point(14, 5), Point(9. / 7, 6):\n print(p)\n\n\n print(Point(11, 22)._replace(x=100))\n\n import doctest\n TestResults = namedtuple('TestResults', 'failed attempted')\n print(TestResults(*doctest.testmod()))\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def namedtuple(typename, field_names, verbose=False, rename=False):\n \"\"\"Returns a new subclass of tuple with named fields.\n\n >>> Point = namedtuple('Point', 'x y')\n >>> Point.__doc__ # docstring for the new class\n 'Point(x, y)'\n >>> p = Point(11, y=22) # instantiate with positional args or keywords\n >>> p[0] + p[1] # indexable like a plain tuple\n 33\n >>> x, y = p # unpack like a regular tuple\n >>> x, y\n (11, 22)\n >>> p.x + p.y # fields also accessible by name\n 33\n >>> d = p._asdict() # convert to a dictionary\n >>> d['x']\n 11\n >>> Point(**d) # convert from a dictionary\n Point(x=11, y=22)\n >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields\n Point(x=100, y=22)\n\n \"\"\"\n\n # Parse and validate the field names. Validation serves two purposes,\n # generating informative error messages and preventing template injection attacks.\n if isinstance(field_names, basestring):\n field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas\n field_names = tuple(map(str, field_names))\n if rename:\n names = list(field_names)\n seen = set()\n for i, name in enumerate(names):\n if (not min(c.isalnum() or c == '_' for c in name)\n or _iskeyword(name)\n or not name or name[0].isdigit()\n or name.startswith('_')\n or name in seen):\n names[i] = '_%d' % i\n\n seen.add(name)\n field_names = tuple(names)\n for name in (typename,) + field_names:\n if not min(c.isalnum() or c == '_' for c in name):\n raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name)\n if _iskeyword(name):\n raise ValueError('Type names and field names cannot be a keyword: %r' % name)\n if name[0].isdigit():\n raise ValueError('Type names and field names cannot start with a number: %r' % name)\n seen_names = set()\n for name in field_names:\n if name.startswith('_') and not rename:\n raise ValueError('Field names cannot start with an underscore: %r' % name)\n if name in seen_names:\n raise ValueError('Encountered duplicate field name: %r' % name)\n seen_names.add(name)\n\n # Create and fill-in the class template\n numfields = len(field_names)\n argtxt = repr(field_names).replace(\"'\", \"\")[1:-1] # tuple repr without parens or quotes\n reprtxt = ', '.join('%s=%%r' % name for name in field_names)\n template = '''class %(typename)s(tuple):\n '%(typename)s(%(argtxt)s)' \\n\n __slots__ = () \\n\n _fields = %(field_names)r \\n\n def __new__(_cls, %(argtxt)s):\n return _tuple.__new__(_cls, (%(argtxt)s)) \\n\n @classmethod\n def _make(cls, iterable, new=tuple.__new__, len=len):\n 'Make a new %(typename)s object from a sequence or iterable'\n result = new(cls, iterable)\n if len(result) != %(numfields)d:\n raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result))\n return result \\n\n def __repr__(self):\n return '%(typename)s(%(reprtxt)s)' %% self \\n\n def _asdict(self):\n 'Return a new dict which maps field names to their values'\n return dict(zip(self._fields, self)) \\n\n def _replace(_self, **kwds):\n 'Return a new %(typename)s object replacing specified fields with new values'\n result = _self._make(map(kwds.pop, %(field_names)r, _self))\n if kwds:\n raise ValueError('Got unexpected field names: %%r' %% kwds.keys())\n return result \\n\n def __getnewargs__(self):\n return tuple(self) \\n\\n''' % locals()\n for i, name in enumerate(field_names):\n template += ' %s = _property(_itemgetter(%d))\\n' % (name, i)\n if verbose:\n print(template)\n\n # Execute the template string in a temporary namespace\n namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename,\n _property=property, _tuple=tuple)\n try:\n exec(template) in namespace\n except SyntaxError:\n e = sys.exc_info()[1]\n raise SyntaxError(str(e) + ':\\n' + template)\n result = namespace[typename]\n\n # For pickling to work, the __module__ variable needs to be set to the frame\n # where the named tuple is created. Bypass this step in environments where\n # sys._getframe is not defined (Jython for example) or sys._getframe is not\n # defined for arguments greater than 0 (IronPython).\n try:\n result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__')\n except (AttributeError, ValueError):\n pass\n\n return result", "metadata": "root.namedtuple", "header": "['module', '___EOS___']", "index": 51 } ]
[ { "span": "namedtuple('Point', 'x, y', True)", "start_line": 168, "start_column": 12, "end_line": 168, "end_column": 45 } ]
[]
1
false
[ "[CLS]_", "Wro", "ng_", "number_", "of_", "arguments_", "in_", "a_", "call_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Fro", "m", " ", "the", " ", "GC", "3", "Pie", " ", "project", ":", " ", "https", "://", "code", ".", "google", ".", "com", "/", "p", "/", "gc", "3p", "ie", "/", "\\", "10", ";", "\\", "10", ";", "A", " ", "backp", "ort", " ", "of", " ", "the", " ", "Pyth", "on", " ", "standard", " ", "`", "collection", "s", "`", " ", "package", ",", " ", "provi", "ding", "\\", "10", ";", "`", "namedtupl", "e", "`", " ", "and", " ", "`", "default", "dict", "`", " ", "als", "o", " ", "on", " ", "Pyth", "on", " ", "2.4", " ", "and", " ", "2.5", ".", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "package", " ", "actual", "ly", " ", "import", "s", " ", "your", " ", "Pyth", "on", " ", "`", "collection", "s", "`", ",", " ", "and", " ", "adds", "\\", "10", ";", "its", " ", "own", " ", "version", "s", " ", "of", " ", "`", "namedtupl", "e", "`", " ", "and", " ", "`", "default", "dict", "`", " ", "only", " ", "if", " ", "the", "y", " ", "are", "\\", "10", ";", "missi", "ng", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "collections_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\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 ", " _", "defaultdict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", ":_", "\\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\\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 ", " _", "namedtuple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Us", "e", " ", "Ray", "mond", " ", "He", "tting", "er", "'", "s", " ", "original", " ", "`", "namedtupl", "e", "`", " ", "package", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sou", "rce", " ", "original", "ly", " ", "take", "n", " ", "from", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "code", ".", "active", "state", ".", "com", "/", "recip", "es", "/", "500", "261", "-", "named", "-", "tuple", "s", "/_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "operator_", "import_", "itemgetter_", "as_", "\\u", "itemgetter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "keyword_", "import_", "isk", "ey", "word_", "as_", "\\u", "isk", "ey", "word_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "as_", "\\u", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "verify", " ", "tha", "t", " ", "instance", "s", " ", "can", " ", "be", " ", "pickled", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "c", "Pickle_", "import_", "loads_", ",_", "dumps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Point_", "=_", "namedtuple_", "(_", "'", "Point", "'_", ",_", "'", "x", ",", " ", "y", "'_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "Point_", "(_", "x_", "=_", "10_", ",_", "y_", "=_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "p_", "==_", "loads_", "(_", "dumps_", "(_", "p_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "and", " ", "demonstrat", "e", " ", "abilit", "y", " ", "to", " ", "override", " ", "methods_", "\\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_", "p_", "in_", "Point_", "(_", "3_", ",_", "4_", ")_", ",_", "Point_", "(_", "14_", ",_", "5_", ")_", ",_", "Point_", "(_", "9._", "/_", "7_", ",_", "6_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "p_", ")_", "\\u\\u\\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_", "print_", "(_", "Point_", "(_", "11_", ",_", "22_", ")_", "._", "\\u", "replace_", "(_", "x_", "=_", "100_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "doctest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Results_", "=_", "namedtuple_", "(_", "'", "Test", "Result", "s", "'_", ",_", "'", "fail", "ed", " ", "atte", "mpte", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "Test", "Results_", "(_", "*_", "doctest_", "._", "testmod_", "(_", ")_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "namedtuple_", "(_", "typename_", ",_", "field", "\\u", "names_", ",_", "verbose_", "=_", "False_", ",_", "rename_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "a", " ", "new", " ", "subclass", " ", "of", " ", "tuple", " ", "with", " ", "named", " ", "fields", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "Point", " ", "=", " ", "namedtupl", "e", "('", "Point", "',", " ", "'", "x", " ", "y", "')", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "Point", ".\\u", "\\u", "doc", "\\u\\u", " ", "#", " ", "docstr", "ing", " ", "for", " ", "the", " ", "new", " ", "class", "\\", "10", ";", " ", " ", " ", " ", "'", "Point", "(", "x", ",", " ", "y", ")'", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "p", " ", "=", " ", "Point", "(", "11", ",", " ", "y", "=", "2", "2", ")", " ", " ", " ", " ", " ", "#", " ", "instantiate", " ", "with", " ", "positional", " ", "args", " ", "or", " ", "keywords", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "p", "[", "0", "]", " ", "+", " ", "p", "[", "1", "]", " ", " ", " ", "#", " ", "index", "able", " ", "like", " ", "a", " ", "plain", " ", "tuple", "\\", "10", ";", " ", " ", " ", " ", "3", "3", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "x", ",", " ", "y", " ", "=", " ", "p", " ", " ", "#", " ", "unpack", " ", "like", " ", "a", " ", "regular", " ", "tuple", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "x", ",", " ", "y", "\\", "10", ";", " ", " ", " ", " ", "(", "11", ",", " ", "2", "2", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "p", ".", "x", " ", "+", " ", "p", ".", "y", " ", " ", " ", " ", " ", "#", " ", "fields", " ", "als", "o", " ", "accessible", " ", "by", " ", "name", "\\", "10", ";", " ", " ", " ", " ", "3", "3", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "d", " ", "=", " ", "p", ".\\u", "asd", "ict", "()", " ", " ", " ", " ", " ", "#", " ", "convert", " ", "to", " ", "a", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "d", "['", "x", "']", "\\", "10", ";", " ", " ", " ", " ", "11", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "Point", "(*", "*", "d", ")", " ", " ", " ", " ", "#", " ", "convert", " ", "from", " ", "a", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "Point", "(", "x", "=", "11", ",", " ", "y", "=", "2", "2", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "p", ".\\u", "replace", "(", "x", "=", "100", ")", " ", " ", " ", "#", " ", "\\u", "replace", "()", " ", "is", " ", "like", " ", "str", ".", "replace", "()", " ", "but", " ", "target", "s", " ", "named", " ", "fields", "\\", "10", ";", " ", " ", " ", " ", "Point", "(", "x", "=", "100", ",", " ", "y", "=", "2", "2", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pars", "e", " ", "and", " ", "validat", "e", " ", "the", " ", "field", " ", "names", ".", " ", " ", "Validat", "ion", " ", "serve", "s", " ", "two", " ", "purpose", "s", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "ing", " ", "informati", "ve", " ", "error", " ", "message", "s", " ", "and", " ", "prevent", "ing", " ", "template", " ", "injection", " ", "attacks", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "field", "\\u", "names_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "names_", "=_", "field", "\\u", "names_", "._", "replace_", "(_", "','_", ",_", "'", " ", "'_", ")_", "._", "split_", "(_", ")_", "#", " ", "names", " ", "separate", "d", " ", "by", " ", "whitespace", " ", "and", "/", "or", " ", "commas", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "field", "\\u", "names_", "=_", "tuple_", "(_", "map_", "(_", "str_", ",_", "field", "\\u", "names_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rename_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "names_", "=_", "list_", "(_", "field", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "seen_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "name_", "in_", "enumerate_", "(_", "names_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "not_", "min_", "(_", "c_", "._", "isal", "num_", "(_", ")_", "or_", "c_", "==_", "'\\u'_", "for_", "c_", "in_", "name_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "\\u", "isk", "ey", "word_", "(_", "name_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "not_", "name_", "or_", "name_", "[_", "0_", "]_", "._", "isdigit_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "name_", "._", "startswith_", "(_", "'\\u'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "name_", "in_", "seen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "names_", "[_", "i_", "]_", "=_", "'\\u", "%", "d", "'_", "%_", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "seen_", "._", "add_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "field", "\\u", "names_", "=_", "tuple_", "(_", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "name_", "in_", "(_", "typename_", ",_", ")_", "+_", "field", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "min_", "(_", "c_", "._", "isal", "num_", "(_", ")_", "or_", "c_", "==_", "'\\u'_", "for_", "c_", "in_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Type", " ", "names", " ", "and", " ", "field", " ", "names", " ", "can", " ", "only", " ", "contain", " ", "alphanumeric", " ", "character", "s", " ", "and", " ", "underscore", "s", ":", " ", "%", "r", "'_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u", "isk", "ey", "word_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Type", " ", "names", " ", "and", " ", "field", " ", "names", " ", "cann", "ot", " ", "be", " ", "a", " ", "keyw", "ord", ":", " ", "%", "r", "'_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "name_", "[_", "0_", "]_", "._", "isdigit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Type", " ", "names", " ", "and", " ", "field", " ", "names", " ", "cann", "ot", " ", "start", " ", "with", " ", "a", " ", "number", ":", " ", "%", "r", "'_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "see", "n", "\\u", "names_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "name_", "in_", "field", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "name_", "._", "startswith_", "(_", "'\\u'_", ")_", "and_", "not_", "rename_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Field", " ", "names", " ", "cann", "ot", " ", "start", " ", "with", " ", "an", " ", "underscore", ":", " ", "%", "r", "'_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "name_", "in_", "see", "n", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Enco", "unter", "ed", " ", "duplicat", "e", " ", "field", " ", "name", ":", " ", "%", "r", "'_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "see", "n", "\\u", "names_", "._", "add_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "and", " ", "fill", "-", "in", " ", "the", " ", "class", " ", "template_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "numf", "ields", "_", "=_", "len_", "(_", "field", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arg", "txt_", "=_", "repr_", "(_", "field", "\\u", "names_", ")_", "._", "replace_", "(_", "\"'\"_", ",_", "\"\"_", ")_", "[_", "1_", ":_", "-_", "1_", "]_", "#", " ", "tuple", " ", "repr", " ", "with", "out", " ", "paren", "s", " ", "or", " ", "quotes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repr", "txt_", "=_", "',", " ", "'_", "._", "join_", "(_", "'%", "s", "=", "%%", "r", "'_", "%_", "name_", "for_", "name_", "in_", "field", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "'''", "class", " ", "%", "(", "type", "name", ")", "s", "(", "tuple", "):", "\\", "10", ";", " ", " ", " ", " ", "'%", "(", "type", "name", ")", "s", "(%", "(", "arg", "txt", ")", "s", ")'", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "\\u\\u", "slot", "s", "\\u\\u", " ", "=", " ", "()", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "\\u", "fields", " ", "=", " ", "%", "(", "field", "\\u", "names", ")", "r", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "\\u\\u", "new", "\\u\\u", "(\\u", "cls", ",", " ", "%", "(", "arg", "txt", ")", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "\\u", "tuple", ".\\u", "\\u", "new", "\\u\\u", "(\\u", "cls", ",", " ", "(%", "(", "arg", "txt", ")", "s", "))", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "@", "class", "method", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "\\u", "make", "(", "cls", ",", " ", "iterable", ",", " ", "new", "=", "tuple", ".\\u", "\\u", "new", "\\u\\u", ",", " ", "len", "=", "len", "):", "\\", "10", ";", " ", " ", " ", " ", "'", "Make", " ", "a", " ", "new", " ", "%", "(", "type", "name", ")", "s", " ", "object", " ", "from", " ", "a", " ", "sequence", " ", "or", " ", "iterable", "'", "\\", "10", ";", " ", " ", " ", " ", "result", " ", "=", " ", "new", "(", "cls", ",", " ", "iterable", ")", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "len", "(", "result", ")", " ", "!=", " ", "%", "(", "numf", "ields", ")", "d", ":", "\\", "10", ";", " ", " ", "raise", " ", "Type", "Error", "('", "Expect", "ed", " ", "%", "(", "numf", "ields", ")", "d", " ", "argu", "ment", "s", ",", " ", "got", " ", "%%", "d", "'", " ", "%%", " ", "len", "(", "result", "))\\", "10", ";", " ", " ", " ", " ", "return", " ", "result", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "\\u\\u", "repr", "\\u\\u", "(", "self", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "'%", "(", "type", "name", ")", "s", "(%", "(", "repr", "txt", ")", "s", ")'", " ", "%%", " ", "self", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "\\u", "asd", "ict", "(", "self", "):", "\\", "10", ";", " ", " ", " ", " ", "'", "Return", " ", "a", " ", "new", " ", "dict", " ", "whi", "ch", " ", "maps", " ", "field", " ", "names", " ", "to", " ", "thei", "r", " ", "values", "'", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "dict", "(", "zip", "(", "self", ".\\u", "fields", ",", " ", "self", "))", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "\\u", "replace", "(\\u", "self", ",", " ", "**", "kwd", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "'", "Return", " ", "a", " ", "new", " ", "%", "(", "type", "name", ")", "s", " ", "object", " ", "repla", "cing", " ", "specified", " ", "fields", " ", "with", " ", "new", " ", "values", "'", "\\", "10", ";", " ", " ", " ", " ", "result", " ", "=", " ", "\\u", "self", ".\\u", "make", "(", "map", "(", "kwd", "s", ".", "pop", ",", " ", "%", "(", "field", "\\u", "names", ")", "r", ",", " ", "\\u", "self", "))\\", "10", ";", " ", " ", " ", " ", "if", " ", "kwd", "s", ":", "\\", "10", ";", " ", " ", "raise", " ", "Value", "Error", "('", "Got", " ", "unexpected", " ", "field", " ", "names", ":", " ", "%%", "r", "'", " ", "%%", " ", "kwd", "s", ".", "keys", "())", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "result", " ", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "\\u\\u", "getne", "war", "gs", "\\u\\u", "(", "self", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "tuple", "(", "self", ")", " ", "\\\\", "n", "\\\\", "n", "'''_", "%_", "locals_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "name_", "in_", "enumerate_", "(_", "field", "\\u", "names_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template_", "+=_", "'", " ", " ", " ", " ", "%", "s", " ", "=", " ", "\\u", "property", "(\\u", "item", "getter", "(%", "d", "))\\", "\\", "n", "'_", "%_", "(_", "name_", ",_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "template_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "template", " ", "string", " ", "in", " ", "a", " ", "temporar", "y", " ", "namespace_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "namespace_", "=_", "dict_", "(_", "\\u", "itemgetter_", "=_", "\\u", "itemgetter_", ",_", "\\u\\u", "name\\u\\u_", "=_", "'", "namedtupl", "e\\u", "%", "s", "'_", "%_", "typename_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "property_", "=_", "property_", ",_", "\\u", "tuple_", "=_", "tuple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec_", "(_", "template_", ")_", "in_", "namespace_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Syntax", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Syntax", "Error_", "(_", "str_", "(_", "e_", ")_", "+_", "':", "\\\\", "n", "'_", "+_", "template_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "namespace_", "[_", "typename_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "pick", "ling", " ", "to", " ", "work", ",", " ", "the", " ", "\\u\\u", "module", "\\u\\u", " ", "variab", "le", " ", "need", "s", " ", "to", " ", "be", " ", "set", " ", "to", " ", "the", " ", "frame_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "where", " ", "the", " ", "named", " ", "tuple", " ", "is", " ", "created", ".", " ", " ", "By", "pass", " ", "this", " ", "step", " ", "in", " ", "environ", "ment", "s", " ", "where_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sys", ".\\u", "getf", "rame", " ", "is", " ", "not", " ", "defin", "ed", " ", "(", "Jy", "tho", "n", " ", "for", " ", "example", ")", " ", "or", " ", "sys", ".\\u", "getf", "rame", " ", "is", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defin", "ed", " ", "for", " ", "argu", "ment", "s", " ", "great", "er", " ", "than", " ", "0", " ", "(", "Iron", "Pyth", "on", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "\\u\\u", "module\\u\\u_", "=_", "\\u", "sys_", "._", "\\u", "getframe_", "(_", "1_", ")_", "._", "f", "\\u", "globals_", "._", "get_", "(_", "'\\u", "\\u", "name", "\\u\\u'_", ",_", "'\\u", "\\u", "main", "\\u\\u'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(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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 ]
Unused import
abdesslem/two_factor_auth/app.py
[ { "content": "import os\nimport base64\nfrom flask import Flask, render_template, redirect, url_for, flash, session, \\\n abort\nfrom werkzeug.security import generate_password_hash, check_password_hash\nfrom flask.ext.sqlalchemy import SQLAlchemy\nfrom flask.ext.login import LoginManager, UserMixin, login_user, logout_user, \\\n current_user\nfrom flask.ext.bootstrap import Bootstrap\nfrom flask.ext.wtf import Form\nfrom wtforms import StringField, PasswordField, SubmitField, RadioField\nfrom wtforms.validators import Required, Length, EqualTo\nfrom random import randint\nfrom twilio.rest import TwilioRestClient\nimport twilio\n\n# create application instance\napp = Flask(__name__)\napp.config.from_object('config')\n\n# initialize extensions\nbootstrap = Bootstrap(app)\ndb = SQLAlchemy(app)\nlm = LoginManager(app)\n\n\n# Send the token via SMS or Voice depending of the user preferred method\n\n# TODO Generate more secure token\n\n\n\n\n\n\n\n\n\n\n\n\n\n# TODO Limit the number of false request (brute force prevention)\n\n\n\n\n# create database tables if they don't exist yet\ndb.create_all()\n\n\nif __name__ == '__main__':\n app.run(host='0.0.0.0', debug=True)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def sendToken(username, token):\n user = User.query.filter_by(username=username).first()\n client = TwilioRestClient()\n if user.method == 'SMS':\n try:\n message = client.messages.create(\n body=\"Your token is:\" + str(token), # Use the token to complete login\n to=user.phone,\n from_= app.config['PHONE_NUMBER'],\n )\n\t flash('Token sent with success !!')\n\texcept twilio.TwilioRestException as e:\n print e\n\t flash(u'Error while sending the token', 'error')\n elif user.method == 'Voice':\n try:\n call = client.calls.create(to=user.phone, from_=app.config['PHONE_NUMBER'],\n url=\"http://twimlets.com/message?Message%5B0%5D=Your%20token%20is%20\"+str(token)+\"&\")\n flash('Token sent with success !!')\n except twilio.TwilioRestException as e:\n \t\tprint e\n\t\tflash(u'Error while sending the token', 'error')", "metadata": "root.sendToken", "header": "['module', '___EOS___']", "index": 27 }, { "content": "def generateToken():\n #return randint(100000, 999999)\n return \"123456\"", "metadata": "root.generateToken", "header": "['module', '___EOS___']", "index": 51 }, { "content": "class User(UserMixin, db.Model):\n \"\"\"User model.\"\"\"\n __tablename__ = 'users'\n id = db.Column(db.Integer, primary_key=True)\n username = db.Column(db.String(64), index=True)\n password_hash = db.Column(db.String(128))\n phone = db.Column(db.String(64))\n method = db.Column(db.String(16))\n \n\n\n", "metadata": "root.User", "header": "['module', '___EOS___']", "index": 56 }, { "content": " def __init__(self, **kwargs):\n super(User, self).__init__(**kwargs)", "metadata": "root.User.__init__", "header": "['class', 'User', '(', 'UserMixin', ',', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 65 }, { "content": " @property\n def password(self):\n raise AttributeError('password is not a readable attribute')", "metadata": "root.User.password", "header": "['class', 'User', '(', 'UserMixin', ',', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 68 }, { "content": " @password.setter\n def password(self, password):\n self.password_hash = generate_password_hash(password)", "metadata": "root.User.password", "header": "['class', 'User', '(', 'UserMixin', ',', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 72 }, { "content": " def verify_password(self, password):\n return check_password_hash(self.password_hash, password)", "metadata": "root.User.verify_password", "header": "['class', 'User', '(', 'UserMixin', ',', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 76 }, { "content": "@lm.user_loader\ndef load_user(user_id):\n \"\"\"User loader callback for Flask-Login.\"\"\"\n return User.query.get(int(user_id))", "metadata": "root.load_user", "header": "['module', '___EOS___']", "index": 79 }, { "content": "class RegisterForm(Form):\n \"\"\"Registration form.\"\"\"\n username = StringField('Username', validators=[Required(), Length(1, 64)])\n password = PasswordField('Password', validators=[Required()])\n password_again = PasswordField('Password again',\n validators=[Required(), EqualTo('password')])\n phone = StringField('Phone', validators=[Required(), Length(1, 64)])\n method = RadioField('Preferred method:', choices=[('SMS','You will receice the code in SMS'), \\\n ('Voice','You will receive the code in a Call')])\n submit = SubmitField('Register')", "metadata": "root.RegisterForm", "header": "['module', '___EOS___']", "index": 85 }, { "content": "class LoginForm(Form):\n \"\"\"Login form.\"\"\"\n username = StringField('Username', validators=[Required(), Length(1, 64)])\n password = PasswordField('Password', validators=[Required()])\n submit = SubmitField('Login')", "metadata": "root.LoginForm", "header": "['module', '___EOS___']", "index": 97 }, { "content": "class TwoFactorForm(Form):\n \"\"\"Verification code form.\"\"\"\n token = StringField('Token', validators=[Required(), Length(6, 6)])\n submit = SubmitField('Verification')", "metadata": "root.TwoFactorForm", "header": "['module', '___EOS___']", "index": 103 }, { "content": "@app.route('/')\ndef index():\n return render_template('index.html')", "metadata": "root.index", "header": "['module', '___EOS___']", "index": 109 }, { "content": "@app.route('/voice')\ndef voice():\n return render_template('call.xml')", "metadata": "root.voice", "header": "['module', '___EOS___']", "index": 113 }, { "content": "@app.route('/register', methods=['GET', 'POST'])\ndef register():\n \"\"\"User registration route.\"\"\"\n if current_user.is_authenticated():\n # if user is logged in we get out of here\n return redirect(url_for('index'))\n form = RegisterForm()\n if form.validate_on_submit():\n user = User.query.filter_by(username=form.username.data).first()\n if user is not None:\n flash('Username already exists.')\n return redirect(url_for('register'))\n # add new user to the database\n user = User(username=form.username.data, \\\n password=form.password.data, \\\n phone=form.phone.data, \\\n method=form.method.data)\n db.session.add(user)\n db.session.commit()\n return redirect(url_for('index'))\n\n return render_template('register.html', form=form)", "metadata": "root.register", "header": "['module', '___EOS___']", "index": 117 }, { "content": "@app.route('/verification', methods=['GET', 'POST'])\ndef verification():\n \"\"\"two factor auth route.\"\"\"\n if current_user.is_authenticated():\n # if user is logged in we get out of here\n return redirect(url_for('index'))\n form = TwoFactorForm()\n if form.validate_on_submit():\n user = User.query.filter_by(username=session['username']).first()\n \tif session['token'] == form.token.data:\n # log user in\n login_user(user)\n flash('You are now logged in!')\n return redirect(url_for('index'))\n flash(' Invalid token.')\n return redirect(url_for('verification'))\n return render_template('verification.html', form=form)", "metadata": "root.verification", "header": "['module', '___EOS___']", "index": 141 }, { "content": "@app.route('/login', methods=['GET', 'POST'])\ndef login():\n \"\"\"User login route.\"\"\"\n if current_user.is_authenticated():\n # if user is logged in we get out of here\n return redirect(url_for('index'))\n form = LoginForm()\n if form.validate_on_submit():\n user = User.query.filter_by(username=form.username.data).first()\n if user is None or not user.verify_password(form.password.data):\n flash('Invalid username or password')\n return redirect(url_for('login'))\n # redirect to the two-factor auth page, passing token in the session\n session['username'] = form.username.data\n session['token'] = generateToken()\n sendToken(session['username'], session['token'])\n return redirect(url_for('verification'))\n\n return render_template('login.html', form=form)", "metadata": "root.login", "header": "['module', '___EOS___']", "index": 159 }, { "content": "@app.route('/logout')\ndef logout():\n \"\"\"User logout route.\"\"\"\n logout_user()\n return redirect(url_for('index'))", "metadata": "root.logout", "header": "['module', '___EOS___']", "index": 179 } ]
[ { "span": "import os", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 9 }, { "span": "import base64", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 13 }, { "span": "from flask import Flask, render_template, redirect, url_for, flash, session, \\\n abort", "start_line": 2, "start_column": 0, "end_line": 3, "end_column": 9 }, { "span": "from random import randint", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 26 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "import_", "Flask_", ",_", "render", "\\u", "template_", ",_", "redirect_", ",_", "url", "\\u", "for_", ",_", "flash_", ",_", "session_", ",_", "abort_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "werkzeug_", "._", "security_", "import_", "generat", "e\\u", "password", "\\u", "hash_", ",_", "check", "\\u", "password", "\\u", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "._", "ext_", "._", "sqlalchemy_", "import_", "SQL", "Alchemy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "._", "ext_", "._", "login_", "import_", "Logi", "n", "Manager_", ",_", "User", "Mixin_", ",_", "login", "\\u", "user_", ",_", "logo", "ut", "\\u", "user_", ",_", "current", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "._", "ext_", "._", "bootstrap_", "import_", "Boots", "trap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "._", "ext_", "._", "wtf", "_", "import_", "Form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wtforms_", "import_", "String", "Field_", ",_", "Passw", "ord", "Field_", ",_", "Submit", "Field_", ",_", "Radio", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wtforms_", "._", "validators_", "import_", "Required_", ",_", "Length_", ",_", "Equal", "To_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "random_", "import_", "randint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "twilio", "_", "._", "rest_", "import_", "Twi", "lio", "Rest", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "twilio", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "applica", "tion", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "Flask_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "config_", "._", "from", "\\u", "object_", "(_", "'", "config", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "initialize", " ", "extensions_", "\\u\\u\\uNL\\u\\u\\u_", "bootstrap_", "=_", "Boots", "trap_", "(_", "app_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "=_", "SQL", "Alchemy_", "(_", "app_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lm_", "=_", "Logi", "n", "Manager_", "(_", "app_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sen", "d", " ", "the", " ", "token", " ", "via", " ", "SMS", " ", "or", " ", "Voic", "e", " ", "depend", "ing", " ", "of", " ", "the", " ", "user", " ", "prefer", "red", " ", "method_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", " ", "Generate", " ", "more", " ", "secure", " ", "token_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", " ", "Limit", " ", "the", " ", "number", " ", "of", " ", "fal", "se", " ", "request", " ", "(", "brute", " ", "force", " ", "prevent", "ion", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "create", " ", "databa", "se", " ", "tables", " ", "if", " ", "the", "y", " ", "don", "'", "t", " ", "exist", " ", "ye", "t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "db_", "._", "create", "\\u", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "app_", "._", "run_", "(_", "host_", "=_", "'", "0.", "0.", "0.", "0", "'_", ",_", "debug_", "=_", "True_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "send", "Token_", "(_", "username_", ",_", "token_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "query_", "._", "filter", "\\u", "by_", "(_", "username_", "=_", "username_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "Twi", "lio", "Rest", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "user_", "._", "method_", "==_", "'", "SMS", "'_", ":_", "\\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 ", " _", "message_", "=_", "client_", "._", "messages_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "body_", "=_", "\"", "You", "r", " ", "token", " ", "is", ":\"_", "+_", "str_", "(_", "token_", ")_", ",_", "#", " ", "Us", "e", " ", "the", " ", "token", " ", "to", " ", "complete", " ", "login_", "\\u\\u\\uNL\\u\\u\\u_", "to_", "=_", "user_", "._", "phone_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "from\\u_", "=_", "app_", "._", "config_", "[_", "'", "PHONE", "\\u", "NUMB", "ER", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flash_", "(_", "'", "Token", " ", "sent", " ", "with", " ", "success", " ", "!!", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "twilio", "_", "._", "Twi", "lio", "Rest", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flash_", "(_", "u", "'", "Error", " ", "whi", "le", " ", "sendin", "g", " ", "the", " ", "token", "'_", ",_", "'", "error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "user_", "._", "method_", "==_", "'", "Voic", "e", "'_", ":_", "\\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 ", " _", "call_", "=_", "client_", "._", "calls_", "._", "create_", "(_", "to_", "=_", "user_", "._", "phone_", ",_", "from\\u_", "=_", "app_", "._", "config_", "[_", "'", "PHONE", "\\u", "NUMB", "ER", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "\"", "http", "://", "twi", "mle", "ts", ".", "com", "/", "message", "?", "Messag", "e", "%", "5", "B0", "%", "5", "D", "=", "You", "r", "%", "20", "token", "%", "20", "is", "%", "20", "\"_", "+_", "str_", "(_", "token_", ")_", "+_", "\"&\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flash_", "(_", "'", "Token", " ", "sent", " ", "with", " ", "success", " ", "!!", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "twilio", "_", "._", "Twi", "lio", "Rest", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t", "\t_", "print_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flash_", "(_", "u", "'", "Error", " ", "whi", "le", " ", "sendin", "g", " ", "the", " ", "token", "'_", ",_", "'", "error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e", "Token_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "return", " ", "rand", "int", "(", "100000", ",", " ", "999999", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "12345", "6", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "User_", "(_", "User", "Mixin_", ",_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "User", " ", "model", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "tablename\\u\\u_", "=_", "'", "users", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "id_", "=_", "db_", "._", "Column_", "(_", "db_", "._", "Integer_", ",_", "primary", "\\u", "key_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "username_", "=_", "db_", "._", "Column_", "(_", "db_", "._", "String_", "(_", "64_", ")_", ",_", "index_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password", "\\u", "hash_", "=_", "db_", "._", "Column_", "(_", "db_", "._", "String_", "(_", "128_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone_", "=_", "db_", "._", "Column_", "(_", "db_", "._", "String_", "(_", "64_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "method_", "=_", "db_", "._", "Column_", "(_", "db_", "._", "String_", "(_", "16_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "User", "Mixin_", ",_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "User_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "User", "Mixin_", ",_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "password_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Attribute", "Error_", "(_", "'", "password", " ", "is", " ", "not", " ", "a", " ", "reada", "ble", " ", "attribute", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "User", "Mixin_", ",_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "password_", "._", "setter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "password_", "(_", "self_", ",_", "password_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "password", "\\u", "hash_", "=_", "generat", "e\\u", "password", "\\u", "hash_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "User", "Mixin_", ",_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "verify", "\\u", "password_", "(_", "self_", ",_", "password_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "check", "\\u", "password", "\\u", "hash_", "(_", "self_", "._", "password", "\\u", "hash_", ",_", "password_", ")_", "\\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_", "@_", "lm_", "._", "user", "\\u", "loader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "load", "\\u", "user_", "(_", "user", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "User", " ", "load", "er", " ", "callback", " ", "for", " ", "Fla", "sk", "-", "Logi", "n", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "User_", "._", "query_", "._", "get_", "(_", "int_", "(_", "user", "\\u", "id_", ")_", ")_", "\\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_", "Register", "Form_", "(_", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Registration", " ", "form", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "username_", "=_", "String", "Field_", "(_", "'", "User", "name", "'_", ",_", "validators_", "=_", "[_", "Required_", "(_", ")_", ",_", "Length_", "(_", "1_", ",_", "64_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "Passw", "ord", "Field_", "(_", "'", "Passw", "ord", "'_", ",_", "validators_", "=_", "[_", "Required_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password", "\\u", "again", "_", "=_", "Passw", "ord", "Field_", "(_", "'", "Passw", "ord", " ", "again", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "validators_", "=_", "[_", "Required_", "(_", ")_", ",_", "Equal", "To_", "(_", "'", "password", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phone_", "=_", "String", "Field_", "(_", "'", "Phone", "'_", ",_", "validators_", "=_", "[_", "Required_", "(_", ")_", ",_", "Length_", "(_", "1_", ",_", "64_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "method_", "=_", "Radio", "Field_", "(_", "'", "Prefe", "rre", "d", " ", "method", ":'_", ",_", "choices_", "=_", "[_", "(_", "'", "SMS", "'_", ",_", "'", "You", " ", "will", " ", "rece", "ice", " ", "the", " ", "code", " ", "in", " ", "SMS", "'_", ")_", ",_", "(_", "'", "Voic", "e", "'_", ",_", "'", "You", " ", "will", " ", "receive", " ", "the", " ", "code", " ", "in", " ", "a", " ", "Call", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "submit_", "=_", "Submit", "Field_", "(_", "'", "Register", "'_", ")_", "\\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_", "Logi", "n", "Form_", "(_", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Logi", "n", " ", "form", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "username_", "=_", "String", "Field_", "(_", "'", "User", "name", "'_", ",_", "validators_", "=_", "[_", "Required_", "(_", ")_", ",_", "Length_", "(_", "1_", ",_", "64_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "Passw", "ord", "Field_", "(_", "'", "Passw", "ord", "'_", ",_", "validators_", "=_", "[_", "Required_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "submit_", "=_", "Submit", "Field_", "(_", "'", "Logi", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Tw", "o", "Factor", "Form_", "(_", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Veri", "fication", " ", "code", " ", "form", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "token_", "=_", "String", "Field_", "(_", "'", "Token", "'_", ",_", "validators_", "=_", "[_", "Required_", "(_", ")_", ",_", "Length_", "(_", "6_", ",_", "6_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "submit_", "=_", "Submit", "Field_", "(_", "'", "Veri", "fication", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "index_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "render", "\\u", "template_", "(_", "'", "index", ".", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "voice", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "voice_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "render", "\\u", "template_", "(_", "'", "call", ".", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "register", "'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", ",_", "'", "POST", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "register_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "User", " ", "registration", " ", "route", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "current", "\\u", "user_", "._", "is", "\\u", "authenticated_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "user", " ", "is", " ", "logged", " ", "in", " ", "we", " ", "get", " ", "out", " ", "of", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "index", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Register", "Form_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "validat", "e\\u", "on", "\\u", "submit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "query_", "._", "filter", "\\u", "by_", "(_", "username_", "=_", "form_", "._", "username_", "._", "data_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "user_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "flash_", "(_", "'", "User", "name", " ", "alr", "ead", "y", " ", "exist", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "register", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "add", " ", "new", " ", "user", " ", "to", " ", "the", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "user_", "=_", "User_", "(_", "username_", "=_", "form_", "._", "username_", "._", "data_", ",_", "password_", "=_", "form_", "._", "password_", "._", "data_", ",_", "phone_", "=_", "form_", "._", "phone_", "._", "data_", ",_", "method_", "=_", "form_", "._", "method_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "session_", "._", "add_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "session_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "index", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "register", ".", "html", "'_", ",_", "form_", "=_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "verification", "'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", ",_", "'", "POST", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "verification", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "two", " ", "factor", " ", "auth", " ", "route", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "current", "\\u", "user_", "._", "is", "\\u", "authenticated_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "user", " ", "is", " ", "logged", " ", "in", " ", "we", " ", "get", " ", "out", " ", "of", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "index", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Tw", "o", "Factor", "Form_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "validat", "e\\u", "on", "\\u", "submit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "query_", "._", "filter", "\\u", "by_", "(_", "username_", "=_", "session_", "[_", "'", "user", "name", "'_", "]_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "session_", "[_", "'", "token", "'_", "]_", "==_", "form_", "._", "token_", "._", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "log", " ", "user", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "login", "\\u", "user_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flash_", "(_", "'", "You", " ", "are", " ", "now", " ", "logged", " ", "in", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "index", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "flash_", "(_", "'", " ", "Inva", "lid", " ", "token", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "verification", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "verification", ".", "html", "'_", ",_", "form_", "=_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "login", "'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", ",_", "'", "POST", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "login_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "User", " ", "login", " ", "route", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "current", "\\u", "user_", "._", "is", "\\u", "authenticated_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "user", " ", "is", " ", "logged", " ", "in", " ", "we", " ", "get", " ", "out", " ", "of", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "index", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Logi", "n", "Form_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "validat", "e\\u", "on", "\\u", "submit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "query_", "._", "filter", "\\u", "by_", "(_", "username_", "=_", "form_", "._", "username_", "._", "data_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "user_", "is_", "None_", "or_", "not_", "user_", "._", "verify", "\\u", "password_", "(_", "form_", "._", "password_", "._", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "flash_", "(_", "'", "Inva", "lid", " ", "user", "name", " ", "or", " ", " ", "password", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "login", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "redirec", "t", " ", "to", " ", "the", " ", "two", "-", "factor", " ", "auth", " ", "page", ",", " ", "passi", "ng", " ", "token", " ", "in", " ", "the", " ", "session_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "[_", "'", "user", "name", "'_", "]_", "=_", "form_", "._", "username_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session_", "[_", "'", "token", "'_", "]_", "=_", "generat", "e", "Token_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "Token_", "(_", "session_", "[_", "'", "user", "name", "'_", "]_", ",_", "session_", "[_", "'", "token", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "verification", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "login", ".", "html", "'_", ",_", "form_", "=_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "logo", "ut", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "logout_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "User", " ", "logo", "ut", " ", "route", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logo", "ut", "\\u", "user_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "url", "\\u", "for_", "(_", "'", "index", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1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s3db\n\n auth.s3_impersonate(\"[email protected]\")\n admin_id = auth.user.id\n admin_pe_id = auth.s3_user_pe_id(admin_id)\n auth.s3_impersonate(\"[email protected]\")\n user_id = auth.user.id\n user_pe_id = auth.s3_user_pe_id(user_id)\n auth.s3_impersonate(None)\n\n org1 = self.org1\n org2 = self.org2\n\n users = s3db.pr_realm_users(org1)\n self.assertEqual(users, Storage())\n\n users = s3db.pr_realm_users(org2)\n self.assertEqual(users, Storage())\n\n s3db.pr_add_affiliation(org1, admin_pe_id, role=\"Volunteer\", role_type=9)\n s3db.pr_add_affiliation(org2, user_pe_id, role=\"Staff\")\n\n users = s3db.pr_realm_users(org1)\n self.assertFalse(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users(org2)\n self.assertTrue(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2])\n self.assertTrue(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users(org1, roles=\"Volunteer\")\n self.assertFalse(user_id in users)\n self.assertTrue(admin_id in users)\n\n users = s3db.pr_realm_users(org2, roles=\"Volunteer\")\n self.assertFalse(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2], roles=\"Volunteer\")\n self.assertFalse(user_id in users)\n self.assertTrue(admin_id in users)\n\n users = s3db.pr_realm_users(org1, roles=\"Staff\")\n self.assertFalse(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users(org2, roles=\"Staff\")\n self.assertTrue(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2], roles=\"Staff\")\n self.assertTrue(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2], roles=[\"Staff\", \"Volunteer\"])\n self.assertTrue(user_id in users)\n self.assertTrue(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2], role_types=1)\n self.assertTrue(user_id in users)\n self.assertFalse(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2], role_types=9)\n self.assertFalse(user_id in users)\n self.assertTrue(admin_id in users)\n\n users = s3db.pr_realm_users([org1, org2], role_types=None)\n self.assertTrue(user_id in users)\n self.assertTrue(admin_id in users)\n\n s3db.pr_remove_affiliation(org2, user_pe_id, role=\"Staff\")\n users = s3db.pr_realm_users([org1, org2], role_types=None)\n self.assertFalse(user_id in users)\n self.assertTrue(admin_id in users)\n\n # None as realm should give a list of all current users\n table = auth.settings.table_user\n query = (table.deleted != True)\n rows = current.db(query).select(table.id)\n all_users = [row.id for row in rows]\n users = s3db.pr_realm_users(None)\n self.assertTrue(all([u in users for u in all_users]))", "metadata": "root.PRTests.testGetRealmUsers", "header": "['class', 'PRTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 50 }, { "content": " def testMobilePhoneNumberValidationStandard(self):\n \"\"\" Test that validator for mobile phone number is applied \"\"\"\n\n current.deployment_settings \\\n .msg.require_international_phone_numbers = False\n\n from s3db.pr import S3ContactModel\n onvalidation = S3ContactModel.pr_contact_onvalidation\n\n form = Storage(\n vars = Storage(\n contact_method = \"SMS\",\n )\n )\n\n # valid\n form.errors = Storage()\n form.vars.value = \"0368172634\"\n onvalidation(form)\n self.assertEqual(form.vars.value, \"0368172634\")\n self.assertFalse(\"value\" in form.errors)\n\n # invalid\n form.errors = Storage()\n form.vars.value = \"036-ASBKD\"\n onvalidation(form)\n self.assertEqual(form.vars.value, \"036-ASBKD\")\n self.assertTrue(\"value\" in form.errors)", "metadata": "root.ContactValidationTests.testMobilePhoneNumberValidationStandard", "header": "['class', 'ContactValidationTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 464 }, { "content": " def testMobilePhoneNumberValidationInternational(self):\n \"\"\" Test that validator for mobile phone number is applied \"\"\"\n\n current.deployment_settings \\\n .msg.require_international_phone_numbers = True\n\n from s3db.pr import S3ContactModel\n onvalidation = S3ContactModel.pr_contact_onvalidation\n\n form = Storage(\n vars = Storage(\n contact_method = \"SMS\",\n )\n )\n\n # valid\n form.errors = Storage()\n form.vars.value = \"+46-73-3847589\"\n onvalidation(form)\n self.assertEqual(form.vars.value, \"+46733847589\")\n self.assertFalse(\"value\" in form.errors)\n\n # invalid\n form.errors = Storage()\n form.vars.value = \"0368172634\"\n onvalidation(form)\n self.assertEqual(form.vars.value, \"0368172634\")\n self.assertTrue(\"value\" in form.errors)", "metadata": "root.ContactValidationTests.testMobilePhoneNumberValidationInternational", "header": "['class', 'ContactValidationTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 494 } ]
[ { "span": "self.assertFalse(user_id in users)", "start_line": 76, "start_column": 8, "end_line": 76, "end_column": 42 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 77, "start_column": 8, "end_line": 77, "end_column": 43 }, { "span": "self.assertTrue(user_id in users)", "start_line": 80, "start_column": 8, "end_line": 80, "end_column": 41 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 81, "start_column": 8, "end_line": 81, "end_column": 43 }, { "span": "self.assertTrue(user_id in users)", "start_line": 84, "start_column": 8, "end_line": 84, "end_column": 41 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 85, "start_column": 8, "end_line": 85, "end_column": 43 }, { "span": "self.assertFalse(user_id in users)", "start_line": 88, "start_column": 8, "end_line": 88, "end_column": 42 }, { "span": "self.assertTrue(admin_id in users)", "start_line": 89, "start_column": 8, "end_line": 89, "end_column": 42 }, { "span": "self.assertFalse(user_id in users)", "start_line": 92, "start_column": 8, "end_line": 92, "end_column": 42 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 93, "start_column": 8, "end_line": 93, "end_column": 43 }, { "span": "self.assertFalse(user_id in users)", "start_line": 96, "start_column": 8, "end_line": 96, "end_column": 42 }, { "span": "self.assertTrue(admin_id in users)", "start_line": 97, "start_column": 8, "end_line": 97, "end_column": 42 }, { "span": "self.assertFalse(user_id in users)", "start_line": 100, "start_column": 8, "end_line": 100, "end_column": 42 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 101, "start_column": 8, "end_line": 101, "end_column": 43 }, { "span": "self.assertTrue(user_id in users)", "start_line": 104, "start_column": 8, "end_line": 104, "end_column": 41 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 105, "start_column": 8, "end_line": 105, "end_column": 43 }, { "span": "self.assertTrue(user_id in users)", "start_line": 108, "start_column": 8, "end_line": 108, "end_column": 41 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 109, "start_column": 8, "end_line": 109, "end_column": 43 }, { "span": "self.assertTrue(user_id in users)", "start_line": 112, "start_column": 8, "end_line": 112, "end_column": 41 }, { "span": "self.assertTrue(admin_id in users)", "start_line": 113, "start_column": 8, "end_line": 113, "end_column": 42 }, { "span": "self.assertTrue(user_id in users)", "start_line": 116, "start_column": 8, "end_line": 116, "end_column": 41 }, { "span": "self.assertFalse(admin_id in users)", "start_line": 117, "start_column": 8, "end_line": 117, "end_column": 43 }, { "span": "self.assertFalse(user_id in users)", "start_line": 120, "start_column": 8, "end_line": 120, "end_column": 42 }, { "span": "self.assertTrue(admin_id in users)", "start_line": 121, "start_column": 8, "end_line": 121, "end_column": 42 }, { "span": "self.assertTrue(user_id in users)", "start_line": 124, "start_column": 8, "end_line": 124, "end_column": 41 }, { "span": "self.assertTrue(admin_id in users)", "start_line": 125, "start_column": 8, "end_line": 125, "end_column": 42 }, { "span": "self.assertFalse(user_id in users)", "start_line": 129, "start_column": 8, "end_line": 129, "end_column": 42 }, { "span": "self.assertTrue(admin_id in users)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 42 }, { "span": "self.assertFalse(\"value\" in form.errors)", "start_line": 484, "start_column": 8, "end_line": 484, "end_column": 48 }, { "span": "self.assertTrue(\"value\" in form.errors)", "start_line": 491, "start_column": 8, "end_line": 491, "end_column": 47 }, { "span": "self.assertFalse(\"value\" in form.errors)", "start_line": 514, "start_column": 8, "end_line": 514, "end_column": 48 }, { "span": "self.assertTrue(\"value\" in form.errors)", "start_line": 521, "start_column": 8, "end_line": 521, "end_column": 47 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "PR", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Get", "Realm", "Users_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "auth_", "=_", "current_", "._", "auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s3db_", "=_", "current_", "._", "s3db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "auth_", "._", "s3", "\\u", "impersonat", "e_", "(_", "\"", "admin", "@", "example", ".", "com", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "\\u", "id_", "=_", "auth_", "._", "user_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "\\u", "pe", "\\u", "id_", "=_", "auth_", "._", "s3", "\\u", "user", "\\u", "pe", "\\u", "id_", "(_", "admin", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auth_", "._", "s3", "\\u", "impersonat", "e_", "(_", "\"", "normal", "user", "@", "example", ".", "com", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "id_", "=_", "auth_", "._", "user_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "pe", "\\u", "id_", "=_", "auth_", "._", "s3", "\\u", "user", "\\u", "pe", "\\u", "id_", "(_", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auth_", "._", "s3", "\\u", "impersonat", "e_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "org", "1_", "=_", "self_", "._", "org", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "org", "2_", "=_", "self_", "._", "org", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "users_", ",_", "Storage_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "users_", ",_", "Storage_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s3db_", "._", "pr", "\\u", "add", "\\u", "affiliation_", "(_", "org", "1_", ",_", "admin", "\\u", "pe", "\\u", "id_", ",_", "role_", "=_", "\"", "Volu", "nte", "er", "\"_", ",_", "role", "\\u", "type_", "=_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s3db_", "._", "pr", "\\u", "add", "\\u", "affiliation_", "(_", "org", "2_", ",_", "user", "\\u", "pe", "\\u", "id_", ",_", "role_", "=_", "\"", "Sta", "ff", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "1_", ",_", "roles_", "=_", "\"", "Volu", "nte", "er", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "2_", ",_", "roles_", "=_", "\"", "Volu", "nte", "er", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "roles_", "=_", "\"", "Volu", "nte", "er", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "1_", ",_", "roles_", "=_", "\"", "Sta", "ff", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "org", "2_", ",_", "roles_", "=_", "\"", "Sta", "ff", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "roles_", "=_", "\"", "Sta", "ff", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "roles_", "=_", "[_", "\"", "Sta", "ff", "\"_", ",_", "\"", "Volu", "nte", "er", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "role", "\\u", "types_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "role", "\\u", "types_", "=_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "role", "\\u", "types_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s3db_", "._", "pr", "\\u", "remove", "\\u", "affiliation_", "(_", "org", "2_", ",_", "user", "\\u", "pe", "\\u", "id_", ",_", "role_", "=_", "\"", "Sta", "ff", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "[_", "org", "1_", ",_", "org", "2_", "]_", ",_", "role", "\\u", "types_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "user", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "admin", "\\u", "id_", "in_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Non", "e", " ", "as", " ", "real", "m", " ", "shou", "ld", " ", "give", " ", "a", " ", "list", " ", "of", " ", "all", " ", "current", " ", "users_", "\\u\\u\\uNL\\u\\u\\u_", "table_", "=_", "auth_", "._", "settings_", "._", "table", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "(_", "table_", "._", "deleted_", "!=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "current_", "._", "db_", "(_", "query_", ")_", "._", "select_", "(_", "table_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "users_", "=_", "[_", "row_", "._", "id_", "for_", "row_", "in_", "rows_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "=_", "s3db_", "._", "pr", "\\u", "real", "m", "\\u", "users_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "all_", "(_", "[_", "u_", "in_", "users_", "for_", "u_", "in_", "all", "\\u", "users_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Conta", "ct", "Validat", "ion", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Mob", "ile", "Phone", "Number", "Validat", "ion", "Standard", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Test", " ", "tha", "t", " ", "validator", " ", "for", " ", "mobile", " ", "phone", " ", "number", " ", "is", " ", "applied", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current_", "._", "deploy", "ment", "\\u", "settings_", "._", "msg_", "._", "require", "\\u", "international", "\\u", "phone", "\\u", "numbers_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "s3db_", "._", "pr_", "import_", "S", "3", "Conta", "ct", "Model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "onv", "alid", "ation_", "=_", "S", "3", "Conta", "ct", "Model_", "._", "pr", "\\u", "contact", "\\u", "onv", "alid", "ation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "=_", "Storage_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "vars_", "=_", "Storage_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "contact", "\\u", "method_", "=_", "\"", "SMS", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "valid_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "errors_", "=_", "Storage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "._", "vars_", "._", "value_", "=_", "\"", "036", "817", "263", "4", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "onv", "alid", "ation_", "(_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "form_", "._", "vars_", "._", "value_", ",_", "\"", "036", "817", "263", "4", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "\"", "value", "\"_", "in_", "form_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "invalid_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "errors_", "=_", "Storage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "._", "vars_", "._", "value_", "=_", "\"", "036", "-", "AS", "BK", "D", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "onv", "alid", "ation_", "(_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "form_", "._", "vars_", "._", "value_", ",_", "\"", "036", "-", "AS", "BK", "D", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "value", "\"_", "in_", "form_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Conta", "ct", "Validat", "ion", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Mob", "ile", "Phone", "Number", "Validat", "ion", "Intern", "ation", "al_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Test", " ", "tha", "t", " ", "validator", " ", "for", " ", "mobile", " ", "phone", " ", "number", " ", "is", " ", "applied", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current_", "._", "deploy", "ment", "\\u", "settings_", "._", "msg_", "._", "require", "\\u", "international", "\\u", "phone", "\\u", "numbers_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "s3db_", "._", "pr_", "import_", "S", "3", "Conta", "ct", "Model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "onv", "alid", "ation_", "=_", "S", "3", "Conta", "ct", "Model_", "._", "pr", "\\u", "contact", "\\u", "onv", "alid", "ation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "=_", "Storage_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "vars_", "=_", "Storage_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "contact", "\\u", "method_", "=_", "\"", "SMS", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "valid_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "errors_", "=_", "Storage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "._", "vars_", "._", "value_", "=_", "\"+", "4", "6", "-", "7", "3", "-", "384", "758", "9", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "onv", "alid", "ation_", "(_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "form_", "._", "vars_", "._", "value_", ",_", "\"+", "467", "338", "475", "89", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "\"", "value", "\"_", "in_", "form_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "invalid_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "errors_", "=_", "Storage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "._", "vars_", "._", "value_", "=_", "\"", "036", "817", "263", "4", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "onv", "alid", "ation_", "(_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "form_", "._", "vars_", "._", "value_", ",_", "\"", "036", "817", "263", "4", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "value", "\"_", "in_", "form_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
open-cloud/xos/xos/synchronizers/base/deleter.py
[ { "content": "import os\nimport base64\nfrom xos.config import Config\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Deleter:\n\tmodel=None # Must be overridden\n\n\n", "metadata": "root.Deleter", "header": "['module', '___EOS___']", "index": 4 }, { "content": " def __init__(self, *args, **kwargs):\n pass", "metadata": "root.Deleter.__init__", "header": "['class', 'Deleter', ':', '___EOS___']", "index": 7 }, { "content": "\tdef call(self, pk, model_dict):\n\t\t# Fetch object from XOS db and delete it\n\t\tpass", "metadata": "root.Deleter.call", "header": "['class', 'Deleter', ':', '___EOS___']", "index": 10 }, { "content": "\tdef __call__(self, *args, **kwargs):\n\t\treturn self.call(*args, **kwargs)", "metadata": "root.Deleter.__call__", "header": "['class', 'Deleter', ':', '___EOS___']", "index": 14 } ]
[ { "span": "import os", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 9 }, { "span": "import base64", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 13 }, { "span": "from xos.config import Config", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 29 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "xo", "s_", "._", "config_", "import_", "Config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Delete", "r_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "model_", "=_", "None_", "#", " ", "Mus", "t", " ", "be", " ", "overrid", "den_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Delete", "r_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delete", "r_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "call_", "(_", "self_", ",_", "pk_", ",_", "model", "\\u", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fe", "tch", " ", "object", " ", "from", " ", "XO", "S", " ", "db", " ", "and", " ", "delete", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Delete", "r_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "call\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "call_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
Havate/havate-openstack/proto-build/gui/horizon/Horizon_GUI/openstack_dashboard/dashboards/admin/flavors/workflows.py
[ { "content": " def clean(self):\n cleaned_data = super(CreateFlavorInfoAction, self).clean()\n name = cleaned_data.get('name')\n flavor_id = cleaned_data.get('flavor_id')\n\n try:\n flavors = api.nova.flavor_list(self.request, None)\n except Exception:\n flavors = []\n msg = _('Unable to get flavor list')\n exceptions.check_message([\"Connection\", \"refused\"], msg)\n raise\n if flavors is not None:\n for flavor in flavors:\n if flavor.name == name:\n raise forms.ValidationError(\n _('The name \"%s\" is already used by another flavor.')\n % name\n )\n if flavor.id == flavor_id:\n raise forms.ValidationError(\n _('The ID \"%s\" is already used by another flavor.')\n % flavor_id\n )\n return cleaned_data", "metadata": "root.CreateFlavorInfoAction.clean", "header": "['class', 'CreateFlavorInfoAction', '(', 'workflows', '.', 'Action', ')', ':', '___EOS___']", "index": 58 }, { "content": " def clean(self):\n name = self.cleaned_data.get('name')\n flavor_id = self.cleaned_data.get('flavor_id')\n try:\n flavors = api.nova.flavor_list(self.request, None)\n except Exception:\n flavors = []\n msg = _('Unable to get flavor list')\n exceptions.check_message([\"Connection\", \"refused\"], msg)\n raise\n # Check if there is no flavor with the same name\n if flavors is not None:\n for flavor in flavors:\n if flavor.name == name and flavor.id != flavor_id:\n raise forms.ValidationError(\n _('The name \"%s\" is already used by another '\n 'flavor.') % name)\n return self.cleaned_data", "metadata": "root.UpdateFlavorInfoAction.clean", "header": "['class', 'UpdateFlavorInfoAction', '(', 'CreateFlavorInfoAction', ')', ':', '___EOS___']", "index": 225 } ]
[ { "span": "flavors ", "start_line": 66, "start_column": 12, "end_line": 66, "end_column": 19 }, { "span": "flavors ", "start_line": 231, "start_column": 12, "end_line": 231, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Creat", "e", "Fla", "vor", "Info", "Action_", "(_", "workflows_", "._", "Action_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clean", "ed", "\\u", "data_", "=_", "super_", "(_", "Creat", "e", "Fla", "vor", "Info", "Action_", ",_", "self_", ")_", "._", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flavor", "\\u", "id_", "=_", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "flavor", "\\u", "id", "'_", ")_", "\\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 ", " _", "flavors_", "=_", "api_", "._", "nova_", "._", "flavor", "\\u", "list_", "(_", "self_", "._", "request_", ",_", "None_", ")_", "\\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 ", " _", "flavors_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "\\u_", "(_", "'", "Una", "ble", " ", "to", " ", "get", " ", "flavor", " ", "list", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exceptions_", "._", "check", "\\u", "message_", "(_", "[_", "\"", "Connect", "ion", "\"_", ",_", "\"", "refuse", "d", "\"_", "]_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "flavors_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "flavor_", "in_", "flavors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "flavor_", "._", "name_", "==_", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "forms_", "._", "Validat", "ion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "The", " ", "name", " ", "\"%", "s", "\"", " ", "is", " ", "alr", "ead", "y", " ", "used", " ", "by", " ", "anot", "her", " ", "flavor", ".'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "flavor_", "._", "id_", "==_", "flavor", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "forms_", "._", "Validat", "ion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "The", " ", "ID", " ", "\"%", "s", "\"", " ", "is", " ", "alr", "ead", "y", " ", "used", " ", "by", " ", "anot", "her", " ", "flavor", ".'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "flavor", "\\u", "id_", "\\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_", "clean", "ed", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Update", "Fla", "vor", "Info", "Action_", "(_", "Creat", "e", "Fla", "vor", "Info", "Action_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "self_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flavor", "\\u", "id_", "=_", "self_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "flavor", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "flavors_", "=_", "api_", "._", "nova_", "._", "flavor", "\\u", "list_", "(_", "self_", "._", "request_", ",_", "None_", ")_", "\\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 ", " _", "flavors_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "\\u_", "(_", "'", "Una", "ble", " ", "to", " ", "get", " ", "flavor", " ", "list", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exceptions_", "._", "check", "\\u", "message_", "(_", "[_", "\"", "Connect", "ion", "\"_", ",_", "\"", "refuse", "d", "\"_", "]_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "there", " ", "is", " ", "no", " ", "flavor", " ", "with", " ", "the", " ", "same", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "flavors_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "flavor_", "in_", "flavors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "flavor_", "._", "name_", "==_", "name_", "and_", "flavor_", "._", "id_", "!=_", "flavor", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "forms_", "._", "Validat", "ion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "'", "The", " ", "name", " ", "\"%", "s", "\"", " ", "is", " ", "alr", "ead", "y", " ", "used", " ", "by", " ", "anot", "her", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "flavor", ".'_", ")_", "%_", "name_", ")_", "\\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_", "self_", "._", "clean", "ed", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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 ]
Except block handles 'BaseException'
tzwenn/PyOpenAirMirror/common/AirPlayHandler.py
[ { "content": "\tdef checkAuth(self):\n\t\ttry:\n\t\t\tif config.password is not None:\n\t\t\t\tself.parseAuthHeader()\n\t\t\treturn True\n\t\texcept:\n\t\t\tself.requestAuth()\n\t\t\treturn False", "metadata": "root.DigestAuthHandler.checkAuth", "header": "['class', 'DigestAuthHandler', '(', 'BaseHTTPServer', '.', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 35 } ]
[ { "span": "except:", "start_line": 40, "start_column": 2, "end_line": 40, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Dig", "est", "Auth", "Handler_", "(_", "Base", "HTTP", "Server_", "._", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Auth_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "config_", "._", "password_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "self_", "._", "parse", "Auth", "Header_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "self_", "._", "request", "Auth_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]