query_name
stringlengths
13
55
code_file_path
stringlengths
14
194
context_blocks
list
answer_spans
list
supporting_fact_spans
list
example_type
int8
0
1
single_hop
bool
2 classes
subtokenized_input_sequence
list
label_sequence
list
Unused import
rcos/Observatory/observatory/todo/models.py
[ { "content": "from django.db import models\nfrom django.forms.models import ModelForm\nfrom django import forms\nfrom django.contrib import admin\nfrom django.contrib.auth.models import User,Group\nimport string, datetime\nfrom django.template.defaultfilters import slugify\n\n\n \n \n\n\n \n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class List(models.Model):\n name = models.CharField(max_length=60)\n slug = models.SlugField(max_length=60,editable=False)\n # slug = models.SlugField(max_length=60) \n group = models.ForeignKey(Group)\n \n\n \n\n \n # Custom manager lets us do things like Item.completed_tasks.all()\n objects = models.Manager()\n \n \n class Meta:\n ordering = [\"name\"] \n verbose_name_plural = \"Lists\"\n \n # Prevents (at the database level) creation of two lists with the same name in the same group\n unique_together = (\"group\", \"slug\")", "metadata": "root.List", "header": "['module', '___EOS___']", "index": 9 }, { "content": " def save(self, *args, **kwargs):\n if not self.id:\n self.slug = slugify(self.name)\n\n super(List, self).save(*args, **kwargs)", "metadata": "root.List.save", "header": "['class', 'List', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 15 }, { "content": " def __unicode__(self):\n return self.name", "metadata": "root.List.__unicode__", "header": "['class', 'List', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 23 }, { "content": " def incomplete_tasks(self):\n # Count all incomplete tasks on the current list instance\n return Item.objects.filter(list=self,completed=0)", "metadata": "root.List.incomplete_tasks", "header": "['class', 'List', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 29 }, { "content": "class Item(models.Model):\n title = models.CharField(max_length=140)\n list = models.ForeignKey(List)\n created_date = models.DateField() \n due_date = models.CharField(max_length=40,blank=True,null=True,)\n completed = models.BooleanField()\n completed_date = models.DateField(blank=True,null=True)\n created_by = models.ForeignKey(User, related_name='created_by')\n assigned_to = models.ForeignKey(User, related_name='todo_assigned_to')\n note = models.TextField(blank=True,null=True)\n priority = models.PositiveIntegerField(max_length=3)\n \n # Model method: Has due date for an instance of this object passed?\n\n\n \n # Auto-set the item creation / completed date\n\n\n class Meta:\n ordering = [\"priority\"] ", "metadata": "root.Item", "header": "['module', '___EOS___']", "index": 44 }, { "content": " def __unicode__(self):\n return self.title", "metadata": "root.Item.__unicode__", "header": "['class', 'Item', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 59 }, { "content": " def save(self):\n # Set datetime on initial item save \n if not self.id:\n self.created_date = datetime.datetime.now()\n \n # If Item is being marked complete, set the completed_date\n if self.completed :\n self.completed_date = datetime.datetime.now()\n super(Item, self).save()", "metadata": "root.Item.save", "header": "['class', 'Item', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 63 }, { "content": "class Comment(models.Model): \n \"\"\"\n Not using Django's built-in comments becase we want to be able to save \n a comment and change task details at the same time. Rolling our own since it's easy.\n \"\"\"\n author = models.ForeignKey(User)\n task = models.ForeignKey(Item)\n date = models.DateTimeField(default=datetime.datetime.now)\n body = models.TextField(blank=True)\n ", "metadata": "root.Comment", "header": "['module', '___EOS___']", "index": 78 }, { "content": " def __unicode__(self): \n return '%s - %s' % (\n self.author, \n self.date, \n ) ", "metadata": "root.Comment.__unicode__", "header": "['class', 'Comment', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 88 } ]
[ { "span": "from django.forms.models import ModelForm", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 41 }, { "span": "from django import forms", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 24 }, { "span": "from django.contrib import admin", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 32 }, { "span": "import string, datetime", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 23 } ]
[]
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_", "._", "forms_", "._", "models_", "import_", "Model", "Form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "import_", "forms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "import_", "admin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", ",_", "Group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "string_", ",_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "default", "filters_", "import_", "slugify_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "List_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slug_", "=_", "models_", "._", "Sl", "ug", "Field_", "(_", "max", "\\u", "length_", "=_", "60_", ",_", "editable_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "slug", " ", "=", " ", "model", "s", ".", "Sl", "ug", "Field", "(", "max", "\\u", "length", "=", "60", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "group_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Group_", ")_", "\\u\\u\\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_", "#", " ", "Custom", " ", "manage", "r", " ", "lets", " ", "us", " ", "do", " ", "thing", "s", " ", "like", " ", "Item", ".", "complete", "d\\u", "task", "s", ".", "all", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "objects_", "=_", "models_", "._", "Manager_", "(_", ")_", "\\u\\u\\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_", "verbo", "se", "\\u", "name", "\\u", "plural_", "=_", "\"", "List", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prev", "ents", " ", "(", "at", " ", "the", " ", "databa", "se", " ", "level", ")", " ", "creati", "on", " ", "of", " ", "two", " ", "lists", " ", "with", " ", "the", " ", "same", " ", "name", " ", "in", " ", "the", " ", "same", " ", "group_", "\\u\\u\\uNL\\u\\u\\u_", "unique", "\\u", "together_", "=_", "(_", "\"", "group", "\"_", ",_", "\"", "slug", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "List_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "slug_", "=_", "slugify_", "(_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "List_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "List_", "(_", "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_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "List_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "incomplete", "\\u", "tasks_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Count", " ", "all", " ", "incomplete", " ", "task", "s", " ", "on", " ", "the", " ", "current", " ", "list", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Item_", "._", "objects_", "._", "filter_", "(_", "list_", "=_", "self_", ",_", "completed_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Item_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "title_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "140_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "List_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "created", "\\u", "date_", "=_", "models_", "._", "Date", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "due", "\\u", "date_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "40_", ",_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completed_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "complete", "d\\u", "date_", "=_", "models_", "._", "Date", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "created", "\\u", "by_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ",_", "relate", "d\\u", "name_", "=_", "'", "created", "\\u", "by", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assign", "ed", "\\u", "to_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ",_", "relate", "d\\u", "name_", "=_", "'", "todo", "\\u", "assign", "ed", "\\u", "to", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "=_", "models_", "._", "Text", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "priority_", "=_", "models_", "._", "Posi", "tiv", "e", "Integer", "Field_", "(_", "max", "\\u", "length_", "=_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Model", " ", "method", ":", " ", "Has", " ", "due", " ", "date", " ", "for", " ", "an", " ", "instance", " ", "of", " ", "this", " ", "object", " ", "pass", "ed", "?", "_", "\\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_", "#", " ", "Auto", "-", "set", " ", "the", " ", "item", " ", "creati", "on", " ", "/", " ", "complete", "d", " ", "date_", "\\u\\u\\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_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ordering_", "=_", "[_", "\"", "priorit", "y", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Item_", "(_", "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_", "._", "title_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Item_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Set", " ", "datetime", " ", "on", " ", "initial", " ", "item", " ", "save", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "created", "\\u", "date_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "Item", " ", "is", " ", "bei", "ng", " ", "marked", " ", "complete", ",", " ", "set", " ", "the", " ", "complete", "d\\u", "date_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "completed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "complete", "d\\u", "date_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "Item_", ",_", "self_", ")_", "._", "save_", "(_", ")_", "\\u\\u\\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_", "Comment_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Not", " ", "usi", "ng", " ", "Dj", "ang", "o", "'", "s", " ", "bui", "lt", "-", "in", " ", "comment", "s", " ", "bec", "ase", " ", "we", " ", "want", " ", "to", " ", "be", " ", "able", " ", "to", " ", "save", " ", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "comment", " ", "and", " ", "change", " ", "task", " ", "deta", "il", "s", " ", "at", " ", "the", " ", "same", " ", "time", ".", " ", "Roll", "ing", " ", "our", " ", "own", " ", "sinc", "e", " ", "it", "'", "s", " ", "easy", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "author_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "task_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "default_", "=_", "datetime_", "._", "datetime_", "._", "now_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "models_", "._", "Text", "Field_", "(_", "blank_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Comment_", "(_", "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_", "'%", "s", " ", "-", " ", "%", "s", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "author_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "date_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 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/lib/ofxtools/qif_converter.py
[ { "content": " def _parse_date(self, txn_date, dayfirst=False):\n # Try as best we can to parse the date into a datetime object. Note:\n # this assumes that we never see a timestamp, just the date, in any\n # QIF date.\n if txn_date != \"UNKNOWN\":\n try:\n return dateutil.parser.parse(txn_date, dayfirst=dayfirst)\n\n except ValueError:\n # dateutil.parser doesn't recognize dates of the\n # format \"MMDDYYYY\", though it does recognize\n # \"MM/DD/YYYY\". So, if parsing has failed above,\n # try shoving in some slashes and see if that\n # parses.\n try:\n if len(txn_date) == 8:\n # The int() cast will only succeed if all 8\n # characters of txn_date are numbers. If\n # it fails, it will throw an exception we\n # can catch below.\n date_int = int(txn_date)\n # No exception? Great, keep parsing the\n # string (dateutil wants a string\n # argument).\n slashified = \"%s/%s/%s\" % (txn_date[0:2],\n txn_date[2:4],\n txn_date[4:])\n return dateutil.parser.parse(slashified,\n dayfirst=dayfirst)\n except:\n pass\n\n # If we've made it this far, our guesses have failed.\n raise ValueError(\"Unrecognized date format: '%s'.\" % txn_date)\n else:\n return \"UNKNOWN\"", "metadata": "root.QifConverter._parse_date", "header": "['class', 'QifConverter', ':', '___EOS___']", "index": 179 }, { "content": " def _clean_txn_type(self, txn):\n txn_type = \"UNKNOWN\"\n txn_amount = txn.get(\"Amount\", \"UNKNOWN\")\n txn_payee = txn.get(\"Payee\", \"UNKNOWN\")\n txn_memo = txn.get(\"Memo\", \"UNKNOWN\")\n txn_number = txn.get(\"Number\", \"UNKNOWN\")\n txn_sign = self._txn_sign(txn_amount)\n\n # Try to figure out the transaction type from the Payee or\n # Memo field.\n for typestr in self.txn_types.keys():\n if txn_number == typestr:\n # US Bank sends \"DEBIT\" or \"CREDIT\" as a check number\n # on credit card transactions.\n txn[\"Type\"] = self.txn_types[typestr]\n del txn[\"Number\"]\n break\n\n elif txn_payee.startswith(typestr + \"/\") or \\\n txn_memo.startswith(typestr + \"/\") or \\\n txn_memo == typestr or txn_payee == typestr:\n if typestr == \"ACH\" and txn_sign == \"credit\":\n txn[\"Type\"] = \"DIRECTDEP\"\n\n elif typestr == \"ACH\" and txn_sign == \"debit\":\n txn[\"Type\"] = \"DIRECTDEBIT\"\n\n else:\n txn[\"Type\"] = self.txn_types[typestr]\n break", "metadata": "root.QifConverter._clean_txn_type", "header": "['class', 'QifConverter', ':', '___EOS___']", "index": 379 } ]
[ { "span": "date_int ", "start_line": 199, "start_column": 24, "end_line": 199, "end_column": 32 }, { "span": "txn_type ", "start_line": 380, "start_column": 8, "end_line": 380, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Qi", "f", "Converter_", ":_", "\\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", "parse", "\\u", "date_", "(_", "self_", ",_", "tx", "n", "\\u", "date_", ",_", "day", "first_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "as", " ", "best", " ", "we", " ", "can", " ", "to", " ", "parse", " ", "the", " ", "date", " ", "int", "o", " ", "a", " ", "datetime", " ", "object", ".", " ", "Not", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "assume", "s", " ", "tha", "t", " ", "we", " ", "neve", "r", " ", "see", " ", "a", " ", "timestamp", ",", " ", "just", " ", "the", " ", "date", ",", " ", "in", " ", "any_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "QI", "F", " ", "date", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "tx", "n", "\\u", "date_", "!=_", "\"", "UNK", "NOW", "N", "\"_", ":_", "\\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_", "dateutil_", "._", "parser_", "._", "parse_", "(_", "tx", "n", "\\u", "date_", ",_", "day", "first_", "=_", "day", "first_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "date", "util", ".", "parser", " ", "doe", "sn", "'", "t", " ", "recognize", " ", "dates", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "format", " ", "\"", "MM", "DD", "YYY", "Y", "\",", " ", "tho", "ugh", " ", "it", " ", "doe", "s", " ", "recognize", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "MM", "/", "DD", "/", "YYY", "Y", "\".", " ", " ", "So", ",", " ", "if", " ", "pars", "ing", " ", "has", " ", "fail", "ed", " ", "above", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "sho", "ving", " ", "in", " ", "some", " ", "slash", "es", " ", "and", " ", "see", " ", "if", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "parse", "s", "._", "\\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 ", " ", "_", "if_", "len_", "(_", "tx", "n", "\\u", "date_", ")_", "==_", "8_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "int", "()", " ", "cast", " ", "will", " ", "only", " ", "succe", "ed", " ", "if", " ", "all", " ", "8_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "character", "s", " ", "of", " ", "tx", "n", "\\u", "date", " ", "are", " ", "numbers", ".", " ", " ", "If_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "it", " ", "fail", "s", ",", " ", "it", " ", "will", " ", "throw", " ", "an", " ", "exception", " ", "we", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "can", " ", "catch", " ", "belo", "w", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "date", "\\u", "int_", "=_", "int_", "(_", "tx", "n", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "exception", "?", " ", " ", "Great", ",", " ", "keep", " ", "pars", "ing", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "string", " ", "(", "date", "util", " ", "want", "s", " ", "a", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "argu", "ment", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "slash", "ified", "_", "=_", "\"%", "s", "/", "%", "s", "/", "%", "s", "\"_", "%_", "(_", "tx", "n", "\\u", "date_", "[_", "0_", ":_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tx", "n", "\\u", "date_", "[_", "2_", ":_", "4_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tx", "n", "\\u", "date_", "[_", "4_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dateutil_", "._", "parser_", "._", "parse_", "(_", "slash", "ified", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "day", "first_", "=_", "day", "first_", ")_", "\\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_", "#", " ", "If", " ", "we", "'", "ve", " ", "made", " ", "it", " ", "this", " ", "far", ",", " ", "our", " ", "guesses", " ", "have", " ", "fail", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Value", "Error_", "(_", "\"", "Unre", "cogni", "zed", " ", "date", " ", "format", ":", " ", "'%", "s", "'.\"_", "%_", "tx", "n", "\\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_", "\"", "UNK", "NOW", "N", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Qi", "f", "Converter_", ":_", "\\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", "clean", "\\u", "tx", "n", "\\u", "type_", "(_", "self_", ",_", "txn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tx", "n", "\\u", "type_", "=_", "\"", "UNK", "NOW", "N", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tx", "n", "\\u", "amount_", "=_", "txn_", "._", "get_", "(_", "\"", "Amo", "unt", "\"_", ",_", "\"", "UNK", "NOW", "N", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tx", "n", "\\u", "paye", "e_", "=_", "txn_", "._", "get_", "(_", "\"", "Pay", "ee", "\"_", ",_", "\"", "UNK", "NOW", "N", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tx", "n", "\\u", "memo_", "=_", "txn_", "._", "get_", "(_", "\"", "Memo", "\"_", ",_", "\"", "UNK", "NOW", "N", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tx", "n", "\\u", "number_", "=_", "txn_", "._", "get_", "(_", "\"", "Number", "\"_", ",_", "\"", "UNK", "NOW", "N", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tx", "n", "\\u", "sign_", "=_", "self_", "._", "\\u", "tx", "n", "\\u", "sign_", "(_", "tx", "n", "\\u", "amount_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tr", "y", " ", "to", " ", "figure", " ", "out", " ", "the", " ", "transaction", " ", "type", " ", "from", " ", "the", " ", "Pay", "ee", " ", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Memo", " ", "field", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "types", "tr_", "in_", "self_", "._", "tx", "n", "\\u", "types_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "tx", "n", "\\u", "number_", "==_", "types", "tr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "US", " ", "Bank", " ", "send", "s", " ", "\"", "DEB", "IT", "\"", " ", "or", " ", "\"", "CRED", "IT", "\"", " ", "as", " ", "a", " ", "check", " ", "number_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "on", " ", "credit", " ", "card", " ", "transaction", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "txn_", "[_", "\"", "Type", "\"_", "]_", "=_", "self_", "._", "tx", "n", "\\u", "types_", "[_", "types", "tr_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "txn_", "[_", "\"", "Number", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "tx", "n", "\\u", "paye", "e_", "._", "startswith_", "(_", "types", "tr_", "+_", "\"/\"_", ")_", "or_", "tx", "n", "\\u", "memo_", "._", "startswith_", "(_", "types", "tr_", "+_", "\"/\"_", ")_", "or_", "tx", "n", "\\u", "memo_", "==_", "types", "tr_", "or_", "tx", "n", "\\u", "paye", "e_", "==_", "types", "tr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "types", "tr_", "==_", "\"", "ACH", "\"_", "and_", "tx", "n", "\\u", "sign_", "==_", "\"", "credit", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "txn_", "[_", "\"", "Type", "\"_", "]_", "=_", "\"", "DIRECT", "DEP", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "types", "tr_", "==_", "\"", "ACH", "\"_", "and_", "tx", "n", "\\u", "sign_", "==_", "\"", "debit", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "txn_", "[_", "\"", "Type", "\"_", "]_", "=_", "\"", "DIRECT", "DEB", "IT", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "txn_", "[_", "\"", "Type", "\"_", "]_", "=_", "self_", "._", "tx", "n", "\\u", "types_", "[_", "types", "tr_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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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 ]
Unused import
CollabQ/CollabQ/appengine_django/models.py
[ { "content": "#!/usr/bin/python2.4\n#\n# Copyright 2008 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\nimport sys\nimport types\n\nfrom google.appengine.ext import db\n\nfrom django import VERSION\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom django.db.models.fields import Field\nfrom django.db.models.options import Options\nfrom django.db.models.loading import register_models, get_model\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ModelManager(object):\n \"\"\"Replacement for the default Django model manager.\"\"\"\n\n", "metadata": "root.ModelManager", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def __init__(self, owner):\n self.owner = owner", "metadata": "root.ModelManager.__init__", "header": "['class', 'ModelManager', '(', 'object', ')', ':', '___EOS___']", "index": 31 }, { "content": " def __getattr__(self, name):\n \"\"\"Pass all attribute requests through to the real model\"\"\"\n return getattr(self.owner, name)", "metadata": "root.ModelManager.__getattr__", "header": "['class', 'ModelManager', '(', 'object', ')', ':', '___EOS___']", "index": 34 }, { "content": "class ModelOptions(object):\n \"\"\"Replacement for the default Django options class.\n\n This class sits at ._meta of each model. The primary information supplied by\n this class that needs to be stubbed out is the list of fields on the model.\n \"\"\"\n\n\n class pk:\n \"\"\"Stub the primary key to always be 'key_name'\"\"\"\n name = \"key_name\"\n\n", "metadata": "root.ModelOptions", "header": "['module', '___EOS___']", "index": 39 }, { "content": " def __init__(self, cls):\n self.object_name = cls.__name__\n self.module_name = self.object_name.lower()\n model_module = sys.modules[cls.__module__]\n self.app_label = model_module.__name__.split('.')[-2]\n self.abstract = False", "metadata": "root.ModelOptions.__init__", "header": "['class', 'ModelOptions', '(', 'object', ')', ':', '___EOS___']", "index": 46 }, { "content": " def __str__(self):\n return \"%s.%s\" % (self.app_label, self.module_name)", "metadata": "root.ModelOptions.__str__", "header": "['class', 'ModelOptions', '(', 'object', ')', ':', '___EOS___']", "index": 57 }, { "content": " @property\n def many_to_many(self):\n \"\"\"The datastore does not support many to many relationships.\"\"\"\n return []", "metadata": "root.ModelOptions.many_to_many", "header": "['class', 'ModelOptions', '(', 'object', ')', ':', '___EOS___']", "index": 60 }, { "content": "class Relation(object):", "metadata": "root.Relation", "header": "['module', '___EOS___']", "index": 66 }, { "content": " def __init__(self, to):\n self.field_name = \"key_name\"", "metadata": "root.Relation.__init__", "header": "['class', 'Relation', '(', 'object', ')', ':', '___EOS___']", "index": 67 }, { "content": "def PropertyWrapper(prop):\n \"\"\"Wrapper for db.Property to make it look like a Django model Property\"\"\"\n if isinstance(prop, db.Reference):\n prop.rel = Relation(prop.reference_class)\n else:\n prop.rel = None\n prop.serialize = True\n return prop", "metadata": "root.PropertyWrapper", "header": "['module', '___EOS___']", "index": 71 }, { "content": "class PropertiedClassWithDjango(db.PropertiedClass):\n \"\"\"Metaclass for the combined Django + App Engine model class.\n\n This metaclass inherits from db.PropertiedClass in the appengine library.\n This metaclass has two additional purposes:\n 1) Register each model class created with Django (the parent class will take\n care of registering it with the appengine libraries).\n 2) Add the (minimum number) of attributes and methods to make Django believe\n the class is a normal Django model.\n\n The resulting classes are still not generally useful as Django classes and\n are intended to be used by Django only in limited situations such as loading\n and dumping fixtures.\n \"\"\"\n\n", "metadata": "root.PropertiedClassWithDjango", "header": "['module', '___EOS___']", "index": 81 }, { "content": " def __new__(cls, name, bases, attrs):\n \"\"\"Creates a combined appengine and Django model.\n\n The resulting model will be known to both the appengine libraries and\n Django.\n \"\"\"\n if name == 'BaseModel':\n # This metaclass only acts on subclasses of BaseModel.\n return super(PropertiedClassWithDjango, cls).__new__(cls, name,\n bases, attrs)\n\n new_class = super(PropertiedClassWithDjango, cls).__new__(cls, name,\n bases, attrs)\n\n new_class._meta = ModelOptions(new_class)\n new_class.objects = ModelManager(new_class)\n new_class._default_manager = new_class.objects\n new_class.DoesNotExist = types.ClassType('DoesNotExist',\n (ObjectDoesNotExist,), {})\n\n m = get_model(new_class._meta.app_label, name, False)\n if m:\n return m\n\n register_models(new_class._meta.app_label, new_class)\n return get_model(new_class._meta.app_label, name, False)", "metadata": "root.PropertiedClassWithDjango.__new__", "header": "['class', 'PropertiedClassWithDjango', '(', 'db', '.', 'PropertiedClass', ')', ':', '___EOS___']", "index": 96 }, { "content": " def __init__(cls, name, bases, attrs):\n \"\"\"Initialises the list of Django properties.\n\n This method takes care of wrapping the properties created by the superclass\n so that they look like Django properties and installing them into the\n ._meta object of the class so that Django can find them at the appropriate\n time.\n \"\"\"\n super(PropertiedClassWithDjango, cls).__init__(name, bases, attrs)\n if name == 'BaseModel':\n # This metaclass only acts on subclasses of BaseModel.\n return\n\n fields = [PropertyWrapper(p) for p in cls._properties.values()]\n cls._meta.local_fields = fields", "metadata": "root.PropertiedClassWithDjango.__init__", "header": "['class', 'PropertiedClassWithDjango', '(', 'db', '.', 'PropertiedClass', ')', ':', '___EOS___']", "index": 123 }, { "content": "class BaseModel(db.Model):\n \"\"\"Combined appengine and Django model.\n\n All models used in the application should derive from this class.\n \"\"\"\n __metaclass__ = PropertiedClassWithDjango\n \n\n\n", "metadata": "root.BaseModel", "header": "['module', '___EOS___']", "index": 140 }, { "content": " def __eq__(self, other):\n if not isinstance(other, self.__class__):\n return False\n return self._get_pk_val() == other._get_pk_val()", "metadata": "root.BaseModel.__eq__", "header": "['class', 'BaseModel', '(', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 147 }, { "content": " def __ne__(self, other):\n return not self.__eq__(other)", "metadata": "root.BaseModel.__ne__", "header": "['class', 'BaseModel', '(', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 152 }, { "content": " def _get_pk_val(self):\n \"\"\"Return the string representation of the model's key\"\"\"\n return unicode(self.key())", "metadata": "root.BaseModel._get_pk_val", "header": "['class', 'BaseModel', '(', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 155 }, { "content": " def __repr__(self):\n \"\"\"Create a string that can be used to construct an equivalent object.\n\n e.g. eval(repr(obj)) == obj\n \"\"\"\n # First, creates a dictionary of property names and values. Note that\n # property values, not property objects, has to be passed in to constructor.\n def _MakeReprTuple(prop_name):\n prop = getattr(self.__class__, prop_name)\n return (prop_name, prop.get_value_for_datastore(self))\n\n d = dict([_MakeReprTuple(prop_name) for prop_name in self.properties()])\n return \"%s(**%s)\" % (self.__class__.__name__, repr(d))", "metadata": "root.BaseModel.__repr__", "header": "['class', 'BaseModel', '(', 'db', '.', 'Model', ')', ':', '___EOS___']", "index": 159 }, { "content": "class RegistrationTestModel(BaseModel):\n \"\"\"Used to check registration with Django is working correctly.\n\n Django 0.96 only recognises models defined within an applications models\n module when get_models() is called so this definition must be here rather\n than within the associated test (tests/model_test.py).\n \"\"\"\n pass", "metadata": "root.RegistrationTestModel", "header": "['module', '___EOS___']", "index": 174 } ]
[ { "span": "from django import VERSION", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 26 }, { "span": "from django.db.models.fields import Field", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 41 }, { "span": "from django.db.models.options import Options", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "python", "2.4", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2008", " ", "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_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "ext_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "import_", "VERSION_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Object", "Do", "es", "Not", "Exist_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "fields_", "import_", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "options_", "import_", "Options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "loading_", "import_", "register", "\\u", "models_", ",_", "get", "\\u", "model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Model", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Replace", "ment", " ", "for", " ", "the", " ", "default", " ", "Dj", "ang", "o", " ", "model", " ", "manage", "r", ".\"\"\"_", "\\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_", "Model", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "owner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "owner_", "=_", "owner_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Manager_", "(_", "object_", ")_", ":_", "\\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_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Pass", " ", "all", " ", "attribute", " ", "request", "s", " ", "through", " ", "to", " ", "the", " ", "real", " ", "model", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "getattr_", "(_", "self_", "._", "owner_", ",_", "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_", "Model", "Options_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Replace", "ment", " ", "for", " ", "the", " ", "default", " ", "Dj", "ang", "o", " ", "options", " ", "class", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Thi", "s", " ", "class", " ", "sit", "s", " ", "at", " ", ".\\u", "meta", " ", "of", " ", "each", " ", "model", ".", " ", "The", " ", "primary", " ", "informati", "on", " ", "supplie", "d", " ", "by", "\\", "10", ";", " ", " ", "this", " ", "class", " ", "tha", "t", " ", "need", "s", " ", "to", " ", "be", " ", "stubbe", "d", " ", "out", " ", "is", " ", "the", " ", "list", " ", "of", " ", "fields", " ", "on", " ", "the", " ", "model", ".", "\\", "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_", "class_", "pk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Stu", "b", " ", "the", " ", "primary", " ", "key", " ", "to", " ", "alw", "ay", "s", " ", "be", " ", "'", "key", "\\u", "name", "'\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "\"", "key", "\\u", "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_", "[SEP]_", "class_", "Model", "Options_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "object\\u", "name_", "=_", "cls_", "._", "\\u\\u", "name\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "module", "\\u", "name_", "=_", "self_", "._", "object\\u", "name_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model", "\\u", "module_", "=_", "sys_", "._", "modules_", "[_", "cls_", "._", "\\u\\u", "module\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "app", "\\u", "label_", "=_", "model", "\\u", "module_", "._", "\\u\\u", "name\\u\\u_", "._", "split_", "(_", "'.'_", ")_", "[_", "-_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "abstract_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Options_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "str\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"%", "s", ".", "%", "s", "\"_", "%_", "(_", "self_", "._", "app", "\\u", "label_", ",_", "self_", "._", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Options_", "(_", "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_", "many", "\\u", "to", "\\u", "many_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "The", " ", "datast", "ore", " ", "doe", "s", " ", "not", " ", "support", " ", "many", " ", "to", " ", "many", " ", "relation", "ships", ".\"\"\"_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Relation_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Relation_", "(_", "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_", ",_", "to_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "field", "\\u", "name_", "=_", "\"", "key", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Proper", "ty", "Wrapper_", "(_", "prop_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Wrapper", " ", "for", " ", "db", ".", "Proper", "ty", " ", "to", " ", "make", " ", "it", " ", "look", " ", "like", " ", "a", " ", "Dj", "ang", "o", " ", "model", " ", "Proper", "ty", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "prop_", ",_", "db_", "._", "Reference_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prop_", "._", "rel_", "=_", "Relation_", "(_", "prop_", "._", "reference", "\\u", "class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prop_", "._", "rel_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prop_", "._", "serialize_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "prop_", "\\u\\u\\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_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", "(_", "db_", "._", "Proper", "tied", "Class_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Meta", "class", " ", "for", " ", "the", " ", "combin", "ed", " ", "Dj", "ang", "o", " ", "+", " ", "App", " ", "Engine", " ", "model", " ", "class", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Thi", "s", " ", "metaclass", " ", "inherits", " ", "from", " ", "db", ".", "Proper", "tied", "Class", " ", "in", " ", "the", " ", "appengine", " ", "librar", "y", ".", "\\", "10", ";", " ", " ", "Thi", "s", " ", "metaclass", " ", "has", " ", "two", " ", "addition", "al", " ", "purpose", "s", ":", "\\", "10", ";", " ", " ", "1", ")", " ", "Register", " ", "each", " ", "model", " ", "class", " ", "created", " ", "with", " ", "Dj", "ang", "o", " ", "(", "the", " ", "parent", " ", "class", " ", "will", " ", "take", "\\", "10", ";", " ", "care", " ", "of", " ", "register", "ing", " ", "it", " ", "with", " ", "the", " ", "appengine", " ", "librar", "ies", ").", "\\", "10", ";", " ", " ", "2", ")", " ", "Add", " ", "the", " ", "(", "minim", "um", " ", "number", ")", " ", "of", " ", "attribute", "s", " ", "and", " ", "method", "s", " ", "to", " ", "make", " ", "Dj", "ang", "o", " ", "beli", "eve", "\\", "10", ";", " ", "the", " ", "class", " ", "is", " ", "a", " ", "normal", " ", "Dj", "ang", "o", " ", "model", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "The", " ", "result", "ing", " ", "classe", "s", " ", "are", " ", "still", " ", "not", " ", "genera", "ll", "y", " ", "usef", "ul", " ", "as", " ", "Dj", "ang", "o", " ", "classe", "s", " ", "and", "\\", "10", ";", " ", " ", "are", " ", "inten", "ded", " ", "to", " ", "be", " ", "used", " ", "by", " ", "Dj", "ang", "o", " ", "only", " ", "in", " ", "limited", " ", "situation", "s", " ", "suc", "h", " ", "as", " ", "load", "ing", "\\", "10", ";", " ", " ", "and", " ", "dump", "ing", " ", "fixture", "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_", "[SEP]_", "class_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", "(_", "db_", "._", "Proper", "tied", "Class_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "name_", ",_", "bases_", ",_", "attrs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "es", " ", "a", " ", "combin", "ed", " ", "appengine", " ", "and", " ", "Dj", "ang", "o", " ", "model", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "result", "ing", " ", "model", " ", "will", " ", "be", " ", "know", "n", " ", "to", " ", "bot", "h", " ", "the", " ", "appengine", " ", "librar", "ies", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "Dj", "ang", "o", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "name_", "==_", "'", "Base", "Model", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "metaclass", " ", "only", " ", "acts", " ", "on", " ", "subclasses", " ", "of", " ", "Base", "Model", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", ",_", "cls_", ")_", "._", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "bases_", ",_", "attrs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "class_", "=_", "super_", "(_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", ",_", "cls_", ")_", "._", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "bases_", ",_", "attrs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "class_", "._", "\\u", "meta_", "=_", "Model", "Options_", "(_", "new", "\\u", "class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "class_", "._", "objects_", "=_", "Model", "Manager_", "(_", "new", "\\u", "class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "class_", "._", "\\u", "default", "\\u", "manager_", "=_", "new", "\\u", "class_", "._", "objects_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "class_", "._", "Do", "es", "Not", "Exist_", "=_", "types_", "._", "Class", "Type_", "(_", "'", "Do", "es", "Not", "Exist", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "Object", "Do", "es", "Not", "Exist_", ",_", ")_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "=_", "get", "\\u", "model_", "(_", "new", "\\u", "class_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "name_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "m_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "register", "\\u", "models_", "(_", "new", "\\u", "class_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "new", "\\u", "class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "get", "\\u", "model_", "(_", "new", "\\u", "class_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "name_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", "(_", "db_", "._", "Proper", "tied", "Class_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "cls_", ",_", "name_", ",_", "bases_", ",_", "attrs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Initialise", "s", " ", "the", " ", "list", " ", "of", " ", "Dj", "ang", "o", " ", "proper", "ties", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "take", "s", " ", "care", " ", "of", " ", "wrapp", "ing", " ", "the", " ", "proper", "ties", " ", "created", " ", "by", " ", "the", " ", "superclass", "\\", "10", ";", " ", " ", " ", " ", "so", " ", "tha", "t", " ", "the", "y", " ", "look", " ", "like", " ", "Dj", "ang", "o", " ", "proper", "ties", " ", "and", " ", "install", "ing", " ", "them", " ", "int", "o", " ", "the", "\\", "10", ";", " ", " ", " ", " ", ".\\u", "meta", " ", "object", " ", "of", " ", "the", " ", "class", " ", "so", " ", "tha", "t", " ", "Dj", "ang", "o", " ", "can", " ", "find", " ", "them", " ", "at", " ", "the", " ", "appropr", "iate", "\\", "10", ";", " ", " ", " ", " ", "time", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", ",_", "cls_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "name_", ",_", "bases_", ",_", "attrs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "name_", "==_", "'", "Base", "Model", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "metaclass", " ", "only", " ", "acts", " ", "on", " ", "subclasses", " ", "of", " ", "Base", "Model", "._", "\\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_", "fields_", "=_", "[_", "Proper", "ty", "Wrapper_", "(_", "p_", ")_", "for_", "p_", "in_", "cls_", "._", "\\u", "properties_", "._", "values_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "\\u", "meta_", "._", "local", "\\u", "fields_", "=_", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Base", "Model_", "(_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Combine", "d", " ", "appengine", " ", "and", " ", "Dj", "ang", "o", " ", "model", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "All", " ", "model", "s", " ", "used", " ", "in", " ", "the", " ", "applica", "tion", " ", "shou", "ld", " ", "derive", " ", "from", " ", "this", " ", "class", ".", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "metaclass\\u\\u_", "=_", "Proper", "tied", "Class", "With", "Dj", "ang", "o_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Model_", "(_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "other_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u", "get", "\\u", "pk", "\\u", "val_", "(_", ")_", "==_", "other_", "._", "\\u", "get", "\\u", "pk", "\\u", "val_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Model_", "(_", "db_", "._", "Model_", ")_", ":_", "\\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_", "._", "\\u\\u", "eq\\u\\u_", "(_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Model_", "(_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "pk", "\\u", "val_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "the", " ", "string", " ", "represent", "ation", " ", "of", " ", "the", " ", "model", "'", "s", " ", "key", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "unicode_", "(_", "self_", "._", "key_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Model_", "(_", "db_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "string", " ", "tha", "t", " ", "can", " ", "be", " ", "used", " ", "to", " ", "construct", " ", "an", " ", "equivalent", " ", "object", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "e", ".", "g", ".", " ", "eval", "(", "repr", "(", "obj", "))", " ", "==", " ", "obj", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fi", "rst", ",", " ", "create", "s", " ", "a", " ", "dictionar", "y", " ", "of", " ", "property", " ", "names", " ", "and", " ", "values", ".", " ", "Not", "e", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "property", " ", "values", ",", " ", "not", " ", "property", " ", "object", "s", ",", " ", "has", " ", "to", " ", "be", " ", "pass", "ed", " ", "in", " ", "to", " ", "construct", "or", "._", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "Make", "Repr", "Tuple_", "(_", "prop", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prop_", "=_", "getattr_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", ",_", "prop", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "prop", "\\u", "name_", ",_", "prop_", "._", "get", "\\u", "value", "\\u", "for", "\\u", "datastore_", "(_", "self_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d_", "=_", "dict_", "(_", "[_", "\\u", "Make", "Repr", "Tuple_", "(_", "prop", "\\u", "name_", ")_", "for_", "prop", "\\u", "name_", "in_", "self_", "._", "properties_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"%", "s", "(*", "*", "%", "s", ")\"_", "%_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "repr_", "(_", "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_", "class_", "Registration", "Test", "Model_", "(_", "Base", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Us", "ed", " ", "to", " ", "check", " ", "registration", " ", "with", " ", "Dj", "ang", "o", " ", "is", " ", "working", " ", "correct", "ly", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Dj", "ang", "o", " ", "0.96", " ", "only", " ", "recog", "nis", "es", " ", "model", "s", " ", "defin", "ed", " ", "within", " ", "an", " ", "applica", "tion", "s", " ", "model", "s", "\\", "10", ";", " ", " ", "module", " ", "whe", "n", " ", "get", "\\u", "model", "s", "()", " ", "is", " ", "call", "ed", " ", "so", " ", "this", " ", "definit", "ion", " ", "must", " ", "be", " ", "here", " ", "rat", "her", "\\", "10", ";", " ", " ", "than", " ", "within", " ", "the", " ", "associate", "d", " ", "test", " ", "(", "tests", "/", "model", "\\u", "test", ".", "py", ").", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
Dav1dde/glad/glad/lang/c/generator.py
[ { "content": "import os\nimport sys\n\nfrom glad.lang.common.generator import Generator\nfrom glad.lang.common.util import makefiledir\n\n\nKHRPLATFORM = 'https://www.khronos.org/registry/egl/api/KHR/khrplatform.h'\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class CGenerator(Generator):\n NAME = 'c'\n NAME_LONG = 'C/C++'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.CGenerator", "header": "['module', '___EOS___']", "index": 10 }, { "content": " def open(self):\n suffix = ''\n if not self.spec.NAME == 'gl':\n suffix = '_{}'.format(self.spec.NAME)\n\n self.h_include = '<glad/glad{}.h>'.format(suffix)\n self._f_c = open(make_path(self.path, 'src',\n 'glad{}.c'.format(suffix)), 'w')\n self._f_h = open(make_path(self.path, 'include',\n 'glad', 'glad{}.h'.format(suffix)), 'w')\n\n khr_url = KHRPLATFORM\n if os.path.exists('khrplatform.h'):\n khr_url = 'file://' + os.path.abspath('khrplatform.h')\n\n khr = os.path.join(self.path, 'include', 'KHR')\n khrplatform = os.path.join(khr, 'khrplatform.h')\n if not os.path.exists(khrplatform):\n if not os.path.exists(khr):\n os.makedirs(khr)\n self.opener.urlretrieve(khr_url, khrplatform)\n\n return self", "metadata": "root.CGenerator.open", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 14 }, { "content": " def close(self):\n self._f_c.close()\n self._f_h.close()", "metadata": "root.CGenerator.close", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 38 }, { "content": " def generate_header(self):\n self._f_h.write('/*\\n')\n self._f_h.write(self.header)\n self._f_h.write('*/\\n\\n')\n\n self._f_c.write('/*\\n')\n self._f_c.write(self.header)\n self._f_c.write('*/\\n\\n')", "metadata": "root.CGenerator.generate_header", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 42 }, { "content": " def generate_loader(self, features, extensions):\n f = self._f_c\n\n if self.spec.NAME in ('egl', 'wgl'):\n features = {'egl': [], 'wgl': []}\n\n written = set()\n for api, version in self.api.items():\n for feature in features[api]:\n f.write('static void load_{}(GLADloadproc load) {{\\n'\n .format(feature.name))\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n f.write('\\tif(!GLAD_{}) return;\\n'.format(feature.name))\n for func in feature.functions:\n f.write('\\tglad_{0} = (PFN{1}PROC)load(\"{0}\");\\n'\n .format(func.proto.name, func.proto.name.upper()))\n f.write('}\\n')\n\n for ext in extensions[api]:\n if len(list(ext.functions)) == 0 or ext.name in written:\n continue\n\n f.write('static void load_{}(GLADloadproc load) {{\\n'\n .format(ext.name))\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n f.write('\\tif(!GLAD_{}) return;\\n'.format(ext.name))\n if ext.name == 'GLX_SGIX_video_source': f.write('#ifdef _VL_H_\\n')\n if ext.name == 'GLX_SGIX_dmbuffer': f.write('#ifdef _DM_BUFFER_H_\\n')\n for func in ext.functions:\n # even if they were in written we need to load it\n f.write('\\tglad_{0} = (PFN{1}PROC)load(\"{0}\");\\n'\n .format(func.proto.name, func.proto.name.upper()))\n if ext.name in ('GLX_SGIX_video_source', 'GLX_SGIX_dmbuffer'):\n f.write('#else\\n')\n f.write('\\t(void)load;\\n')\n f.write('#endif\\n')\n f.write('}\\n')\n\n written.add(ext.name)\n\n f.write('static int find_extensions{}(void) {{\\n'.format(api.upper()))\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n f.write('\\tif (!get_exts()) return 0;\\n')\n for ext in extensions[api]:\n f.write('\\tGLAD_{0} = has_ext(\"{0}\");\\n'.format(ext.name))\n f.write('\\tfree_exts();\\n')\n f.write('\\treturn 1;\\n')\n f.write('}\\n\\n')\n\n if api == 'glx':\n f.write('static void find_core{}(Display *dpy, int screen) {{\\n'.format(api.upper()))\n elif api == 'wgl':\n f.write('static void find_core{}(HDC hdc) {{\\n'.format(api.upper()))\n else:\n f.write('static void find_core{}(void) {{\\n'.format(api.upper()))\n\n self.loader.write_find_core(f)\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n for feature in features[api]:\n f.write('\\tGLAD_{} = (major == {num[0]} && minor >= {num[1]}) ||'\n ' major > {num[0]};\\n'.format(feature.name, num=feature.number))\n if self.spec.NAME == 'gl':\n f.write('\\tif (GLVersion.major > {0} || (GLVersion.major >= {0} && GLVersion.minor >= {1})) {{\\n'.format(version[0], version[1]))\n f.write('\\t\\tmax_loaded_major = {0};\\n'.format(version[0]))\n f.write('\\t\\tmax_loaded_minor = {0};\\n'.format(version[1]))\n f.write('\\t}\\n')\n f.write('}\\n\\n')\n\n if api == 'glx':\n f.write('int gladLoad{}Loader(GLADloadproc load, Display *dpy, int screen) {{\\n'.format(api.upper()))\n elif api == 'wgl':\n f.write('int gladLoad{}Loader(GLADloadproc load, HDC hdc) {{\\n'.format(api.upper()))\n else:\n f.write('int gladLoad{}Loader(GLADloadproc load) {{\\n'.format(api.upper()))\n\n self.loader.write_begin_load(f)\n\n if api == 'glx':\n f.write('\\tfind_core{}(dpy, screen);\\n'.format(api.upper()))\n elif api == 'wgl':\n f.write('\\tfind_core{}(hdc);\\n'.format(api.upper()))\n else:\n f.write('\\tfind_core{}();\\n'.format(api.upper()))\n\n for feature in features[api]:\n f.write('\\tload_{}(load);\\n'.format(feature.name))\n f.write('\\n\\tif (!find_extensions{}()) return 0;\\n'.format(api.upper()))\n for ext in extensions[api]:\n if len(list(ext.functions)) == 0:\n continue\n f.write('\\tload_{}(load);\\n'.format(ext.name))\n\n self.loader.write_end_load(f)\n f.write('}\\n\\n')\n\n self.loader.write_header_end(self._f_h)", "metadata": "root.CGenerator.generate_loader", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 51 }, { "content": " def generate_types(self, types):\n f = self._f_h\n\n self.loader.write_header(f)\n self.write_api_header(f)\n\n for type in types:\n if not self.spec.NAME in ('egl',) and 'khronos' in type.raw:\n continue\n f.write((type.raw + '\\n').lstrip().replace(' ', ' '))", "metadata": "root.CGenerator.generate_types", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 148 }, { "content": " def generate_features(self, features):\n f = self._f_h\n write = set()\n if self.spec.NAME in ('wgl',):\n # These are already defined in windows.h\n pass\n elif self.spec.NAME in ('egl',):\n self.write_enums(f, set(), features)\n\n for feature in features:\n for func in feature.functions:\n self.write_function_def(f, func)\n else:\n self.write_functions(f, write, set(), features)\n\n f = self._f_c\n self.write_code_head(f)\n self.loader.write(f)\n self.loader.write_has_ext(f)\n\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n for feature in features:\n f.write('int GLAD_{};\\n'.format(feature.name))\n\n for func in write:\n self.write_function(f, func)", "metadata": "root.CGenerator.generate_features", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 159 }, { "content": " def generate_extensions(self, extensions, enums, functions):\n write = set()\n written = set(enum.name for enum in enums) | \\\n set(function.proto.name for function in functions)\n\n f = self._f_h\n self.write_functions(f, write, written, extensions)\n\n f = self._f_c\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n for ext in set(ext.name for ext in extensions):\n f.write('int GLAD_{};\\n'.format(ext))\n\n written = set()\n for ext in extensions:\n if ext.name == 'GLX_SGIX_video_source': f.write('#ifdef _VL_H_\\n')\n if ext.name == 'GLX_SGIX_dmbuffer': f.write('#ifdef _DM_BUFFER_H_\\n')\n for func in ext.functions:\n if func in write and func not in written:\n self.write_function(f, func)\n written.add(func)\n if ext.name in ('GLX_SGIX_video_source', 'GLX_SGIX_dmbuffer'): f.write('#endif\\n')", "metadata": "root.CGenerator.generate_extensions", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 186 }, { "content": " def write_functions(self, f, write, written, extensions):\n self.write_enums(f, written, extensions)\n\n for ext in extensions:\n f.write('#ifndef {0}\\n#define {0} 1\\n'.format(ext.name))\n if self.spec.NAME in ('gl', 'glx', 'wgl'):\n f.write('GLAPI int GLAD_{};\\n'.format(ext.name))\n if ext.name == 'GLX_SGIX_video_source': f.write('#ifdef _VL_H_\\n')\n if ext.name == 'GLX_SGIX_dmbuffer': f.write('#ifdef _DM_BUFFER_H_\\n')\n for func in ext.functions:\n if not func.proto.name in written:\n self.write_function_prototype(f, func)\n write.add(func)\n written.add(func.proto.name)\n if ext.name in ('GLX_SGIX_video_source', 'GLX_SGIX_dmbuffer'): f.write('#endif\\n')\n f.write('#endif\\n')", "metadata": "root.CGenerator.write_functions", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 209 }, { "content": " def write_enums(self, f, written, extensions):\n for ext in extensions:\n for enum in ext.enums:\n if not enum.name in written:\n f.write('#define {} {}\\n'.format(enum.name, enum.value))\n written.add(enum.name)", "metadata": "root.CGenerator.write_enums", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 226 }, { "content": " def write_api_header(self, f):\n for api in self.api:\n if api == 'glx':\n f.write('GLAPI int gladLoad{}Loader(GLADloadproc, Display *dpy, int screen);\\n\\n'.format(api.upper()))\n elif api == 'wgl':\n f.write('GLAPI int gladLoad{}Loader(GLADloadproc, HDC hdc);\\n\\n'.format(api.upper()))\n else:\n f.write('GLAPI int gladLoad{}Loader(GLADloadproc);\\n\\n'.format(api.upper()))", "metadata": "root.CGenerator.write_api_header", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 233 }, { "content": " def write_code_head(self, f):\n f.write('#include <stdio.h>\\n#include <stdlib.h>\\n#include <string.h>\\n#include {}\\n'.format(self.h_include))", "metadata": "root.CGenerator.write_code_head", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 242 }, { "content": " def write_extern(self, fobj):\n fobj.write('#ifdef __cplusplus\\nextern \"C\" {\\n#endif\\n')", "metadata": "root.CGenerator.write_extern", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 245 }, { "content": " def write_extern_end(self, fobj):\n fobj.write('#ifdef __cplusplus\\n}\\n#endif\\n')", "metadata": "root.CGenerator.write_extern_end", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 248 }, { "content": " def write_function_def(self, fobj, func):\n # write a function definition instead of a prototype.\n # e.g. egl uses that, since the main functions get linked in and not loaded through a function.\n fobj.write('{} {}('.format(func.proto.ret.to_c(), func.proto.name))\n fobj.write(', '.join('{} {}'.format(param.type.to_c(), param.name) for param in func.params))\n fobj.write(');\\n')", "metadata": "root.CGenerator.write_function_def", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 251 }, { "content": " def write_function_prototype(self, fobj, func):\n fobj.write('typedef {} (APIENTRYP PFN{}PROC)({});\\n'.format(\n func.proto.ret.to_c(), func.proto.name.upper(),\n ', '.join('{} {}'.format(param.type.to_c(), param.name) for param in func.params))\n )\n fobj.write('GLAPI PFN{}PROC glad_{};\\n'.format(func.proto.name.upper(),\n func.proto.name))\n fobj.write('#define {0} glad_{0}\\n'.format(func.proto.name))", "metadata": "root.CGenerator.write_function_prototype", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 258 }, { "content": " def write_function(self, fobj, func):\n fobj.write('PFN{}PROC glad_{};\\n'.format(func.proto.name.upper(),\n func.proto.name))", "metadata": "root.CGenerator.write_function", "header": "['class', 'CGenerator', '(', 'Generator', ')', ':', '___EOS___']", "index": 267 }, { "content": "def make_path(path, *args):\n path = os.path.join(path, *args)\n makefiledir(path)\n return path", "metadata": "root.make_path", "header": "['module', '___EOS___']", "index": 272 } ]
[ { "span": "import sys", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "gla", "d_", "._", "lang_", "._", "common_", "._", "generator_", "import_", "Generator_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gla", "d_", "._", "lang_", "._", "common_", "._", "util_", "import_", "makefile", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "KHR", "PLATFORM_", "=_", "'", "https", "://", "www", ".", "kh", "ron", "os", ".", "org", "/", "registr", "y", "/", "eg", "l", "/", "api", "/", "KHR", "/", "kh", "rpl", "at", "form", ".", "h", "'_", "\\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_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "c", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NAME", "\\u", "LONG_", "=_", "'", "C", "/", "C", "++'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "open_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "suffix_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "spec_", "._", "NAME_", "==_", "'", "gl", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "suffix_", "=_", "'\\u", "{}'_", "._", "format_", "(_", "self_", "._", "spec_", "._", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "h", "\\u", "include_", "=_", "'<", "gla", "d", "/", "gla", "d", "{}.", "h", ">'_", "._", "format_", "(_", "suffix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "c_", "=_", "open_", "(_", "make", "\\u", "path_", "(_", "self_", "._", "path_", ",_", "'", "src", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "gla", "d", "{}.", "c", "'_", "._", "format_", "(_", "suffix_", ")_", ")_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "h_", "=_", "open_", "(_", "make", "\\u", "path_", "(_", "self_", "._", "path_", ",_", "'", "include", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "gla", "d", "'_", ",_", "'", "gla", "d", "{}.", "h", "'_", "._", "format_", "(_", "suffix_", ")_", ")_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kh", "r", "\\u", "url_", "=_", "KHR", "PLATFORM_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "'", "kh", "rpl", "at", "form", ".", "h", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kh", "r", "\\u", "url_", "=_", "'", "file", "://'_", "+_", "os_", "._", "path_", "._", "abspath_", "(_", "'", "kh", "rpl", "at", "form", ".", "h", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kh", "r_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "path_", ",_", "'", "include", "'_", ",_", "'", "KHR", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kh", "rpl", "at", "form_", "=_", "os_", "._", "path_", "._", "join_", "(_", "kh", "r_", ",_", "'", "kh", "rpl", "at", "form", ".", "h", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "kh", "rpl", "at", "form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "kh", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "kh", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "opener_", "._", "urlretrieve_", "(_", "kh", "r", "\\u", "url_", ",_", "kh", "rpl", "at", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\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 ", " _", "self_", "._", "\\u", "f", "\\u", "c_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "h_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e\\u", "header_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "f", "\\u", "h_", "._", "write_", "(_", "'/*", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "h_", "._", "write_", "(_", "self_", "._", "header_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "h_", "._", "write_", "(_", "'*/", "\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "c_", "._", "write_", "(_", "'/*", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "c_", "._", "write_", "(_", "self_", "._", "header_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "f", "\\u", "c_", "._", "write_", "(_", "'*/", "\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e\\u", "loader_", "(_", "self_", ",_", "features_", ",_", "extensions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "self_", "._", "\\u", "f", "\\u", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "eg", "l", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "features_", "=_", "{_", "'", "eg", "l", "'_", ":_", "[_", "]_", ",_", "'", "wg", "l", "'_", ":_", "[_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "written_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "api_", ",_", "version_", "in_", "self_", "._", "api_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "feature_", "in_", "features_", "[_", "api_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "static", " ", "voi", "d", " ", "load", "\\u{}", "(", "GL", "AD", "load", "proc", " ", "load", ")", " ", "{{", "\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "._", "format_", "(_", "feature_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'\\\\", "tif", "(!", "GL", "AD", "\\u{}", ")", " ", "return", ";\\\\", "n", "'_", "._", "format_", "(_", "feature_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "func_", "in_", "feature_", "._", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'\\\\", "tg", "lad", "\\u{", "0", "}", " ", "=", " ", "(", "PF", "N", "{", "1", "}", "PROC", ")", "load", "(\"", "{", "0", "}\"", ");", "\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "._", "format_", "(_", "func_", "._", "proto_", "._", "name_", ",_", "func_", "._", "proto_", "._", "name_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'}", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "ext_", "in_", "extensions_", "[_", "api_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "list_", "(_", "ext_", "._", "functions_", ")_", ")_", "==_", "0_", "or_", "ext_", "._", "name_", "in_", "written_", ":_", "\\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_", "f_", "._", "write_", "(_", "'", "static", " ", "voi", "d", " ", "load", "\\u{}", "(", "GL", "AD", "load", "proc", " ", "load", ")", " ", "{{", "\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "._", "format_", "(_", "ext_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'\\\\", "tif", "(!", "GL", "AD", "\\u{}", ")", " ", "return", ";\\\\", "n", "'_", "._", "format_", "(_", "ext_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ext_", "._", "name_", "==_", "'", "GLX", "\\u", "SGI", "X", "\\u", "video", "\\u", "source", "'_", ":_", "f_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u", "VL", "\\u", "H", "\\u\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ext_", "._", "name_", "==_", "'", "GLX", "\\u", "SGI", "X", "\\u", "dm", "buffer", "'_", ":_", "f_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u", "DM", "\\u", "BUFF", "ER", "\\u", "H", "\\u\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "func_", "in_", "ext_", "._", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "even", " ", "if", " ", "the", "y", " ", "wer", "e", " ", "in", " ", "writt", "en", " ", "we", " ", "need", " ", "to", " ", "load", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'\\\\", "tg", "lad", "\\u{", "0", "}", " ", "=", " ", "(", "PF", "N", "{", "1", "}", "PROC", ")", "load", "(\"", "{", "0", "}\"", ");", "\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "._", "format_", "(_", "func_", "._", "proto_", "._", "name_", ",_", "func_", "._", "proto_", "._", "name_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ext_", "._", "name_", "in_", "(_", "'", "GLX", "\\u", "SGI", "X", "\\u", "video", "\\u", "source", "'_", ",_", "'", "GLX", "\\u", "SGI", "X", "\\u", "dm", "buffer", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'#", "else", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "t", "(", "voi", "d", ")", "load", ";\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'#", "endi", "f", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'}", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "written_", "._", "add_", "(_", "ext_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'", "static", " ", "int", " ", "find", "\\u", "extensi", "ons", "{}", "(", "voi", "d", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'\\\\", "tif", " ", "(!", "get", "\\u", "ext", "s", "())", " ", "return", " ", "0", ";\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ext_", "in_", "extensions_", "[_", "api_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'\\\\", "t", "GL", "AD", "\\u{", "0", "}", " ", "=", " ", "has", "\\u", "ext", "(\"", "{", "0", "}\"", ");", "\\\\", "n", "'_", "._", "format_", "(_", "ext_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "tfre", "e\\u", "ext", "s", "();", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "tre", "turn", " ", "1", ";\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'}", "\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "api_", "==_", "'", "gl", "x", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "static", " ", "voi", "d", " ", "find", "\\u", "core", "{}", "(", "Display", " ", "*", "dp", "y", ",", " ", "int", " ", "screen", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "api_", "==_", "'", "wg", "l", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "static", " ", "voi", "d", " ", "find", "\\u", "core", "{}", "(", "HD", "C", " ", "hd", "c", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "static", " ", "voi", "d", " ", "find", "\\u", "core", "{}", "(", "voi", "d", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "loader_", "._", "write", "\\u", "find", "\\u", "core_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "feature_", "in_", "features_", "[_", "api_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'\\\\", "t", "GL", "AD", "\\u{}", " ", "=", " ", "(", "major", " ", "==", " ", "{", "num", "[", "0", "]}", " ", "&&", " ", "mino", "r", " ", ">=", " ", "{", "num", "[", "1", "]}", ")", " ", "||", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", "major", " ", ">", " ", "{", "num", "[", "0", "]}", ";\\\\", "n", "'_", "._", "format_", "(_", "feature_", "._", "name_", ",_", "num_", "=_", "feature_", "._", "number_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "==_", "'", "gl", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'\\\\", "tif", " ", "(", "GL", "Version", ".", "major", " ", ">", " ", "{", "0", "}", " ", "||", " ", "(", "GL", "Version", ".", "major", " ", ">=", " ", "{", "0", "}", " ", "&&", " ", "GL", "Version", ".", "mino", "r", " ", ">=", " ", "{", "1", "}))", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "version_", "[_", "0_", "]_", ",_", "version_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "t", "\\\\", "tma", "x", "\\u", "load", "ed", "\\u", "major", " ", "=", " ", "{", "0", "};", "\\\\", "n", "'_", "._", "format_", "(_", "version_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "t", "\\\\", "tma", "x", "\\u", "load", "ed", "\\u", "mino", "r", " ", "=", " ", "{", "0", "};", "\\\\", "n", "'_", "._", "format_", "(_", "version_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "t", "}\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'}", "\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "api_", "==_", "'", "gl", "x", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "int", " ", "gla", "d", "Load", "{}", "Load", "er", "(", "GL", "AD", "load", "proc", " ", "load", ",", " ", "Display", " ", "*", "dp", "y", ",", " ", "int", " ", "screen", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "api_", "==_", "'", "wg", "l", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "int", " ", "gla", "d", "Load", "{}", "Load", "er", "(", "GL", "AD", "load", "proc", " ", "load", ",", " ", "HD", "C", " ", "hd", "c", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "int", " ", "gla", "d", "Load", "{}", "Load", "er", "(", "GL", "AD", "load", "proc", " ", "load", ")", " ", "{{", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "loader_", "._", "write", "\\u", "begin", "\\u", "load_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "api_", "==_", "'", "gl", "x", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'\\\\", "tfi", "nd", "\\u", "core", "{}", "(", "dp", "y", ",", " ", "screen", ");", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "api_", "==_", "'", "wg", "l", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'\\\\", "tfi", "nd", "\\u", "core", "{}", "(", "hd", "c", ");", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'\\\\", "tfi", "nd", "\\u", "core", "{}", "();", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "feature_", "in_", "features_", "[_", "api_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'\\\\", "tlo", "ad", "\\u{}", "(", "load", ");", "\\\\", "n", "'_", "._", "format_", "(_", "feature_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "n", "\\\\", "tif", " ", "(!", "find", "\\u", "extensi", "ons", "{}", "())", " ", "return", " ", "0", ";\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ext_", "in_", "extensions_", "[_", "api_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "list_", "(_", "ext_", "._", "functions_", ")_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "tlo", "ad", "\\u{}", "(", "load", ");", "\\\\", "n", "'_", "._", "format_", "(_", "ext_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "loader_", "._", "write", "\\u", "end", "\\u", "load_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'}", "\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "loader_", "._", "write", "\\u", "header", "\\u", "end_", "(_", "self_", "._", "\\u", "f", "\\u", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e\\u", "types_", "(_", "self_", ",_", "types_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "self_", "._", "\\u", "f", "\\u", "h_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "loader_", "._", "write", "\\u", "header_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "\\u", "api", "\\u", "header_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "type_", "in_", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "eg", "l", "'_", ",_", ")_", "and_", "'", "kh", "ron", "os", "'_", "in_", "type_", "._", "raw_", ":_", "\\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_", "f_", "._", "write_", "(_", "(_", "type_", "._", "raw_", "+_", "'\\\\", "n", "'_", ")_", "._", "lstrip_", "(_", ")_", "._", "replace_", "(_", "'", " ", " ", " ", " ", "'_", ",_", "'", " ", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\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_", "generat", "e\\u", "features_", "(_", "self_", ",_", "features_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "self_", "._", "\\u", "f", "\\u", "h_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "write_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "wg", "l", "'_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", "se", " ", "are", " ", "alr", "ead", "y", " ", "defin", "ed", " ", "in", " ", "windows", ".", "h_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "eg", "l", "'_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "write", "\\u", "enums_", "(_", "f_", ",_", "set_", "(_", ")_", ",_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "feature_", "in_", "features_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "func_", "in_", "feature_", "._", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "write", "\\u", "function", "\\u", "def_", "(_", "f_", ",_", "func_", ")_", "\\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_", "._", "write", "\\u", "functions_", "(_", "f_", ",_", "write_", ",_", "set_", "(_", ")_", ",_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "=_", "self_", "._", "\\u", "f", "\\u", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "\\u", "code", "\\u", "head_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "loader_", "._", "write_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "loader_", "._", "write", "\\u", "has", "\\u", "ext_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "feature_", "in_", "features_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "int", " ", "GL", "AD", "\\u{}", ";\\\\", "n", "'_", "._", "format_", "(_", "feature_", "._", "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_", "for_", "func_", "in_", "write_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "write", "\\u", "function_", "(_", "f_", ",_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\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_", "generat", "e\\u", "extensions_", "(_", "self_", ",_", "extensions_", ",_", "enums_", ",_", "functions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "write_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "written_", "=_", "set_", "(_", "enum_", "._", "name_", "for_", "enum_", "in_", "enums_", ")_", "|_", "set_", "(_", "function_", "._", "proto_", "._", "name_", "for_", "function_", "in_", "functions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "self_", "._", "\\u", "f", "\\u", "h_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "\\u", "functions_", "(_", "f_", ",_", "write_", ",_", "written_", ",_", "extensions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "self_", "._", "\\u", "f", "\\u", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ext_", "in_", "set_", "(_", "ext_", "._", "name_", "for_", "ext_", "in_", "extensions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "int", " ", "GL", "AD", "\\u{}", ";\\\\", "n", "'_", "._", "format_", "(_", "ext_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "written_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ext_", "in_", "extensions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ext_", "._", "name_", "==_", "'", "GLX", "\\u", "SGI", "X", "\\u", "video", "\\u", "source", "'_", ":_", "f_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u", "VL", "\\u", "H", "\\u\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ext_", "._", "name_", "==_", "'", "GLX", "\\u", "SGI", "X", "\\u", "dm", "buffer", "'_", ":_", "f_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u", "DM", "\\u", "BUFF", "ER", "\\u", "H", "\\u\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "func_", "in_", "ext_", "._", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "func_", "in_", "write_", "and_", "func_", "not_", "in_", "written_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "write", "\\u", "function_", "(_", "f_", ",_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "written_", "._", "add_", "(_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ext_", "._", "name_", "in_", "(_", "'", "GLX", "\\u", "SGI", "X", "\\u", "video", "\\u", "source", "'_", ",_", "'", "GLX", "\\u", "SGI", "X", "\\u", "dm", "buffer", "'_", ")_", ":_", "f_", "._", "write_", "(_", "'#", "endi", "f", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\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_", "write", "\\u", "functions_", "(_", "self_", ",_", "f_", ",_", "write_", ",_", "written_", ",_", "extensions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "write", "\\u", "enums_", "(_", "f_", ",_", "written_", ",_", "extensions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "ext_", "in_", "extensions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'#", "ifn", "def", " ", "{", "0", "}\\\\", "n", "#", "defin", "e", " ", "{", "0", "}", " ", "1", "\\\\", "n", "'_", "._", "format_", "(_", "ext_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "spec_", "._", "NAME_", "in_", "(_", "'", "gl", "'_", ",_", "'", "gl", "x", "'_", ",_", "'", "wg", "l", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "GL", "API", " ", "int", " ", "GL", "AD", "\\u{}", ";\\\\", "n", "'_", "._", "format_", "(_", "ext_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ext_", "._", "name_", "==_", "'", "GLX", "\\u", "SGI", "X", "\\u", "video", "\\u", "source", "'_", ":_", "f_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u", "VL", "\\u", "H", "\\u\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ext_", "._", "name_", "==_", "'", "GLX", "\\u", "SGI", "X", "\\u", "dm", "buffer", "'_", ":_", "f_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u", "DM", "\\u", "BUFF", "ER", "\\u", "H", "\\u\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "func_", "in_", "ext_", "._", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "func_", "._", "proto_", "._", "name_", "in_", "written_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "write", "\\u", "function", "\\u", "prototype_", "(_", "f_", ",_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "write_", "._", "add_", "(_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "written_", "._", "add_", "(_", "func_", "._", "proto_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ext_", "._", "name_", "in_", "(_", "'", "GLX", "\\u", "SGI", "X", "\\u", "video", "\\u", "source", "'_", ",_", "'", "GLX", "\\u", "SGI", "X", "\\u", "dm", "buffer", "'_", ")_", ":_", "f_", "._", "write_", "(_", "'#", "endi", "f", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "'#", "endi", "f", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\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_", "write", "\\u", "enums_", "(_", "self_", ",_", "f_", ",_", "written_", ",_", "extensions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ext_", "in_", "extensions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "enum_", "in_", "ext_", "._", "enums_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "enum_", "._", "name_", "in_", "written_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "'#", "defin", "e", " ", "{}", " ", "{}", "\\\\", "n", "'_", "._", "format_", "(_", "enum_", "._", "name_", ",_", "enum_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "written_", "._", "add_", "(_", "enum_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\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_", "write", "\\u", "api", "\\u", "header_", "(_", "self_", ",_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "api_", "in_", "self_", "._", "api_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "api_", "==_", "'", "gl", "x", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "GL", "API", " ", "int", " ", "gla", "d", "Load", "{}", "Load", "er", "(", "GL", "AD", "load", "proc", ",", " ", "Display", " ", "*", "dp", "y", ",", " ", "int", " ", "screen", ");", "\\\\", "n", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "api_", "==_", "'", "wg", "l", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "GL", "API", " ", "int", " ", "gla", "d", "Load", "{}", "Load", "er", "(", "GL", "AD", "load", "proc", ",", " ", "HD", "C", " ", "hd", "c", ");", "\\\\", "n", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'", "GL", "API", " ", "int", " ", "gla", "d", "Load", "{}", "Load", "er", "(", "GL", "AD", "load", "proc", ");", "\\\\", "n", "\\\\", "n", "'_", "._", "format_", "(_", "api_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\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_", "write", "\\u", "code", "\\u", "head_", "(_", "self_", ",_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "'#", "include", " ", "<", "std", "io", ".", "h", ">\\\\", "n", "#", "include", " ", "<", "stdlib", ".", "h", ">\\\\", "n", "#", "include", " ", "<", "string", ".", "h", ">\\\\", "n", "#", "include", " ", "{}", "\\\\", "n", "'_", "._", "format_", "(_", "self_", "._", "h", "\\u", "include_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "\\u", "extern", "_", "(_", "self_", ",_", "fobj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fobj_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u\\u", "cpl", "usp", "lus", "\\\\", "next", "ern", " ", "\"", "C", "\"", " ", "{\\\\", "n", "#", "endi", "f", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "\\u", "extern", "\\u", "end_", "(_", "self_", ",_", "fobj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fobj_", "._", "write_", "(_", "'#", "ifdef", " ", "\\u\\u", "cpl", "usp", "lus", "\\\\", "n", "}\\\\", "n", "#", "endi", "f", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "\\u", "function", "\\u", "def_", "(_", "self_", ",_", "fobj_", ",_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "write", " ", "a", " ", "function", " ", "definit", "ion", " ", "inst", "ead", " ", "of", " ", "a", " ", "protot", "ype", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "e", ".", "g", ".", " ", "eg", "l", " ", "use", "s", " ", "tha", "t", ",", " ", "sinc", "e", " ", "the", " ", "main", " ", "function", "s", " ", "get", " ", "linked", " ", "in", " ", "and", " ", "not", " ", "load", "ed", " ", "through", " ", "a", " ", "function", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fobj_", "._", "write_", "(_", "'{}", " ", "{}", "('_", "._", "format_", "(_", "func_", "._", "proto_", "._", "ret_", "._", "to", "\\u", "c_", "(_", ")_", ",_", "func_", "._", "proto_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fobj_", "._", "write_", "(_", "',", " ", "'_", "._", "join_", "(_", "'{}", " ", "{}'_", "._", "format_", "(_", "param_", "._", "type_", "._", "to", "\\u", "c_", "(_", ")_", ",_", "param_", "._", "name_", ")_", "for_", "param_", "in_", "func_", "._", "params_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fobj_", "._", "write_", "(_", "');", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "\\u", "function", "\\u", "prototype_", "(_", "self_", ",_", "fobj_", ",_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fobj_", "._", "write_", "(_", "'", "typedef", " ", "{}", " ", "(", "API", "ENTR", "YP", " ", "PF", "N", "{}", "PROC", ")(", "{})", ";\\\\", "n", "'_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "func_", "._", "proto_", "._", "ret_", "._", "to", "\\u", "c_", "(_", ")_", ",_", "func_", "._", "proto_", "._", "name_", "._", "upper_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "',", " ", "'_", "._", "join_", "(_", "'{}", " ", "{}'_", "._", "format_", "(_", "param_", "._", "type_", "._", "to", "\\u", "c_", "(_", ")_", ",_", "param_", "._", "name_", ")_", "for_", "param_", "in_", "func_", "._", "params_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fobj_", "._", "write_", "(_", "'", "GL", "API", " ", "PF", "N", "{}", "PROC", " ", "gla", "d\\u", "{};", "\\\\", "n", "'_", "._", "format_", "(_", "func_", "._", "proto_", "._", "name_", "._", "upper_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "func_", "._", "proto_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fobj_", "._", "write_", "(_", "'#", "defin", "e", " ", "{", "0", "}", " ", "gla", "d\\u", "{", "0", "}\\\\", "n", "'_", "._", "format_", "(_", "func_", "._", "proto_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CG", "enera", "tor_", "(_", "Generator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "\\u", "function_", "(_", "self_", ",_", "fobj_", ",_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fobj_", "._", "write_", "(_", "'", "PF", "N", "{}", "PROC", " ", "gla", "d\\u", "{};", "\\\\", "n", "'_", "._", "format_", "(_", "func_", "._", "proto_", "._", "name_", "._", "upper_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "func_", "._", "proto_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "path_", "(_", "path_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "path_", ",_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "makefile", "dir_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "path_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Imprecise assert
inpho/vsm/unit_tests/tests_beagleviewer.py
[ { "content": " def test_BeagleViewer(self):\n \n sww = self.venv.dist_word_word('1') \n sww1 = self.vord.dist_word_word('0')\n self.assertTrue(type(sww) == LabeledColumn)\n self.assertTrue(type(sww1) == LabeledColumn)\n \n smw = self.vcom.dismat_word(['1'])\n smw1 = self.vctx.dismat_word(['1'])\n self.assertTrue(type(smw) == IndexedSymmArray)\n self.assertTrue(type(smw1) == IndexedSymmArray)", "metadata": "root.TestBeagleViewer.test_BeagleViewer", "header": "['class', 'TestBeagleViewer', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 37 } ]
[ { "span": "self.assertTrue(type(sww) == LabeledColumn)", "start_line": 41, "start_column": 8, "end_line": 41, "end_column": 51 }, { "span": "self.assertTrue(type(sww1) == LabeledColumn)", "start_line": 42, "start_column": 8, "end_line": 42, "end_column": 52 }, { "span": "self.assertTrue(type(smw) == IndexedSymmArray)", "start_line": 46, "start_column": 8, "end_line": 46, "end_column": 54 }, { "span": "self.assertTrue(type(smw1) == IndexedSymmArray)", "start_line": 47, "start_column": 8, "end_line": 47, "end_column": 55 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Bea", "gle", "Viewer_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Bea", "gle", "Viewer_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sw", "w_", "=_", "self_", "._", "venv_", "._", "dist", "\\u", "word", "\\u", "word_", "(_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sw", "w1_", "=_", "self_", "._", "vor", "d_", "._", "dist", "\\u", "word", "\\u", "word_", "(_", "'", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "sw", "w_", ")_", "==_", "Label", "ed", "Column_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "sw", "w1_", ")_", "==_", "Label", "ed", "Column_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sm", "w_", "=_", "self_", "._", "vco", "m_", "._", "dis", "mat", "\\u", "word_", "(_", "[_", "'", "1", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sm", "w1_", "=_", "self_", "._", "vc", "tx_", "._", "dis", "mat", "\\u", "word_", "(_", "[_", "'", "1", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "sm", "w_", ")_", "==_", "Indexe", "d", "Sym", "m", "Array_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "sm", "w1_", ")_", "==_", "Indexe", "d", "Sym", "m", "Array_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Except block handles 'BaseException'
openeventdata/petrarch2/petrarch2/PETRtree.py
[ { "content": " def get_head(self):\n \"\"\"\n Method for finding the head of a phrase. The head of a phrase is the rightmost\n word-level constituent such that the path from root to head consists only of similarly-labeled\n phrases.\n \n Parameters\n -----------\n self: Phrase object that called the method\n \n Returns\n -------\n possibilities[-1]: tuple (string,NounPhrase)\n (The text of the head of the phrase, the NounPhrase object whose rightmost child is the\n head).\n \n \n \"\"\"\n self.get_head = self.return_head\n try:\n if self.label == 'S':\n self.head, self.head_phrase = map(lambda b: b.get_head(),filter(lambda a : a.label == 'VP', self.children))[0]\n return (self.head,self.head_phrase)\n elif self.label == 'ADVP':\n return self.children[0].text,self\n if (not self.label[1] == 'P'):\n return (self.text,self.parent)\n \n head_children = filter(lambda child : child.label.startswith(self.label[0]) and not child.label[1] == 'P', self.children)\n if head_children:\n possibilities = filter(None, map(lambda a: a.get_head(),head_children))\n else:\n other_children= filter(lambda child : child.label.startswith(self.label[0]), self.children)\n possibilities = filter(None, map(lambda a: a.get_head(),other_children))\n \n self.head_phrase = possibilities[-1][1]\n self.head = possibilities[-1][0] # return the last, English usually compounds words to the front\n return possibilities[-1]\n \n except:\n return (None,None)", "metadata": "root.Phrase.get_head", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 212 }, { "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 str_to_tree(self,str):\n \"\"\"\n Take the Stanford CoreNLP parse and convert it to an object/pointer tree.\n \n Parameters\n -----------\n str: string \n Pre-processed CoreNLP parse, needs to be formated by utilities.format_parsed_str\n before being passed.\n \n Returns\n -------\n root: Phrase object\n Top level of the tree that represents the sentence\n \"\"\"\n segs = str.split()\n root = Phrase(segs[0][1:],self.date, self )\n level_stack = [root]\n existentials = []\n \n for element in segs[1:]:\n if element.startswith(\"(\"):\n lab = element[1:]\n if lab == \"NP\":\n new = NounPhrase(lab, self.date, self)\n elif lab == \"VP\":\n new = VerbPhrase(lab,self.date, self)\n self.verbs.append(new)\n elif lab == \"PP\":\n new = PrepPhrase(lab, self.date, self)\n else:\n new = Phrase(lab, self.date, self)\n if lab == \"EX\":\n existentials.append(new)\n \n new.parent = level_stack[-1]\n new.index = len(level_stack[-1].children)\n level_stack[-1].children.append(new)\n level_stack.append(new)\n elif element.endswith(\")\"):\n try:\n level_stack.pop()\n except:\n break\n else:\n level_stack[-1].text = element\n self.txt += \" \" +element\n \n for element in existentials:\n try:\n element.parent.convert_existential()\n except:\n pass\n return root", "metadata": "root.Sentence.str_to_tree", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1398 } ]
[ { "span": "except:", "start_line": 251, "start_column": 8, "end_line": 251, "end_column": 15 }, { "span": "except:", "start_line": 1060, "start_column": 20, "end_line": 1060, "end_column": 27 }, { "span": "except:", "start_line": 1077, "start_column": 20, "end_line": 1077, "end_column": 27 }, { "span": "except:", "start_line": 1440, "start_column": 16, "end_line": 1440, "end_column": 23 }, { "span": "except:", "start_line": 1449, "start_column": 12, "end_line": 1449, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "head_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Meth", "od", " ", "for", " ", "finding", " ", "the", " ", "head", " ", "of", " ", "a", " ", "phrase", ".", " ", "The", " ", "head", " ", "of", " ", "a", " ", "phrase", " ", "is", " ", "the", " ", "right", "most", "\\", "10", ";", " ", " ", " ", " ", "word", "-", "level", " ", "constitu", "ent", " ", "suc", "h", " ", "tha", "t", " ", "the", " ", "path", " ", "from", " ", "root", " ", "to", " ", "head", " ", "consi", "sts", " ", "only", " ", "of", " ", "similar", "ly", "-", "label", "ed", "\\", "10", ";", " ", " ", " ", " ", "phrase", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "possibilit", "ies", "[-", "1", "]:", " ", "tuple", " ", "(", "string", ",", "Nou", "n", "Phrase", ")", "\\", "10", ";", " ", " ", " ", " ", "(", "The", " ", "text", " ", "of", " ", "the", " ", "head", " ", "of", " ", "the", " ", "phrase", ",", " ", "the", " ", "Nou", "n", "Phrase", " ", "object", " ", "who", "se", " ", "right", "most", " ", "child", " ", "is", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "head", ").", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "head_", "=_", "self_", "._", "return", "\\u", "head_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "label_", "==_", "'", "S", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "head_", ",_", "self_", "._", "head", "\\u", "phrase_", "=_", "map_", "(_", "lambda_", "b_", ":_", "b_", "._", "get", "\\u", "head_", "(_", ")_", ",_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "._", "label_", "==_", "'", "VP", "'_", ",_", "self_", "._", "children_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "self_", "._", "head_", ",_", "self_", "._", "head", "\\u", "phrase_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "label_", "==_", "'", "ADV", "P", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "children_", "[_", "0_", "]_", "._", "text_", ",_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "self_", "._", "label_", "[_", "1_", "]_", "==_", "'", "P", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "self_", "._", "text_", ",_", "self_", "._", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "head", "\\u", "children_", "=_", "filter_", "(_", "lambda_", "child_", ":_", "child_", "._", "label_", "._", "startswith_", "(_", "self_", "._", "label_", "[_", "0_", "]_", ")_", "and_", "not_", "child_", "._", "label_", "[_", "1_", "]_", "==_", "'", "P", "'_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "head", "\\u", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "possibilit", "ies_", "=_", "filter_", "(_", "None_", ",_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "head_", "(_", ")_", ",_", "head", "\\u", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "other", "\\u", "children_", "=_", "filter_", "(_", "lambda_", "child_", ":_", "child_", "._", "label_", "._", "startswith_", "(_", "self_", "._", "label_", "[_", "0_", "]_", ")_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "possibilit", "ies_", "=_", "filter_", "(_", "None_", ",_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "head_", "(_", ")_", ",_", "other", "\\u", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "head", "\\u", "phrase_", "=_", "possibilit", "ies_", "[_", "-_", "1_", "]_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "head_", "=_", "possibilit", "ies_", "[_", "-_", "1_", "]_", "[_", "0_", "]_", "#", " ", "return", " ", "the", " ", "last", ",", " ", "Eng", "lish", " ", "usual", "ly", " ", "compounds", " ", "words", " ", "to", " ", "the", " ", "front_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "possibilit", "ies_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "None_", ",_", "None_", ")_", "\\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_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "str", "\\u", "to", "\\u", "tree_", "(_", "self_", ",_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Tak", "e", " ", "the", " ", "Stan", "for", "d", " ", "Core", "NL", "P", " ", "parse", " ", "and", " ", "convert", " ", "it", " ", "to", " ", "an", " ", "object", "/", "point", "er", " ", "tree", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "str", ":", " ", "string", " ", "\\", "10", ";", " ", " ", " ", " ", " ", "Pre", "-", "process", "ed", " ", "Core", "NL", "P", " ", "parse", ",", " ", "need", "s", " ", "to", " ", "be", " ", "formate", "d", " ", "by", " ", "util", "iti", "es", ".", "format\\u", "parsed", "\\u", "str", "\\", "10", ";", " ", " ", " ", " ", " ", "bef", "ore", " ", "bei", "ng", " ", "pass", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "root", ":", " ", "Phrase", " ", "object", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "Top", " ", "level", " ", "of", " ", "the", " ", "tree", " ", "tha", "t", " ", "represent", "s", " ", "the", " ", "sentence", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "segs_", "=_", "str_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "=_", "Phrase", "_", "(_", "segs_", "[_", "0_", "]_", "[_", "1_", ":_", "]_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level", "\\u", "stack_", "=_", "[_", "root_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "existen", "tial", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "element_", "in_", "segs_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "element_", "._", "startswith_", "(_", "\"(\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lab_", "=_", "element_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "lab_", "==_", "\"", "NP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Nou", "n", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "lab_", "==_", "\"", "VP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Verb", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verbs", "_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "lab_", "==_", "\"", "PP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Prep", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "lab_", "==_", "\"", "EX", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "existen", "tial", "s_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new_", "._", "parent_", "=_", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new_", "._", "index_", "=_", "len_", "(_", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "._", "children_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level", "\\u", "stack_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "element_", "._", "endswith_", "(_", "\")\"_", ")_", ":_", "\\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 ", " ", "_", "level", "\\u", "stack_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "._", "text_", "=_", "element_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "txt_", "+=_", "\"", " ", "\"_", "+_", "element_", "\\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_", "element_", "in_", "existen", "tial", "s_", ":_", "\\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 ", " _", "element_", "._", "parent_", "._", "convert", "\\u", "existen", "tial", "_", "(_", ")_", "\\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_", "root_", "\\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,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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, 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, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
nickoala/telepot/test/test3_inline.py
[ { "content": "# coding=utf8\n\nimport time\nimport threading\nimport pprint\nimport sys\nimport traceback\nimport random\nimport telepot\nfrom telepot.namedtuple import InlineQuery, ChosenInlineResult, InlineQueryResultArticle, InlineQueryResultPhoto, InputTextMessageContent\n\n\n\n\n\n\n\n\n\nTOKEN = sys.argv[1]\nUSER_ID = int(sys.argv[2])\n\nbot = telepot.Bot(TOKEN)\nanswerer = telepot.helper.Answerer(bot)\n\nbot.sendMessage(USER_ID, 'Please give me an inline query.')\n\nbot.message_loop({'inline_query': on_inline_query,\n 'chosen_inline_result': on_chosen_inline_result}, run_forever=True)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def equivalent(data, nt):\n if type(data) is dict:\n keys = data.keys()\n\n # number of dictionary keys == number of non-None values in namedtuple?\n if len(keys) != len([f for f in nt._fields if getattr(nt, f) is not None]):\n return False\n\n # map `from` to `from_`\n fields = list(map(lambda k: k+'_' if k in ['from'] else k, keys))\n\n return all(map(equivalent, [data[k] for k in keys], [getattr(nt, f) for f in fields]))\n elif type(data) is list:\n return all(map(equivalent, data, nt))\n else:\n return data==nt", "metadata": "root.equivalent", "header": "['module', '___EOS___']", "index": 11 }, { "content": "def examine(result, type):\n try:\n print('Examining %s ......' % type)\n\n nt = type(**result)\n assert equivalent(result, nt), 'Not equivalent:::::::::::::::\\n%s\\n::::::::::::::::\\n%s' % (result, nt)\n\n pprint.pprint(result)\n pprint.pprint(nt)\n print()\n except AssertionError:\n traceback.print_exc()\n answer = raw_input('Do you want to continue? [y] ')\n if answer != 'y':\n exit(1)", "metadata": "root.examine", "header": "['module', '___EOS___']", "index": 28 }, { "content": "def on_inline_query(msg):\n def compute():\n articles = [InlineQueryResultArticle(\n id='abc', title='HK', input_message_content=InputTextMessageContent(message_text='Hong Kong'), url='https://www.google.com', hide_url=True),\n {'type': 'article',\n 'id': 'def', 'title': 'SZ', 'input_message_content': {'message_text': 'Shenzhen'}, 'url': 'https://www.yahoo.com'}]\n\n photos = [InlineQueryResultPhoto(\n id='123', photo_url='https://core.telegram.org/file/811140934/1/tbDSLHSaijc/fdcc7b6d5fb3354adf', thumb_url='https://core.telegram.org/file/811140934/1/tbDSLHSaijc/fdcc7b6d5fb3354adf'),\n {'type': 'photo',\n 'id': '345', 'photo_url': 'https://core.telegram.org/file/811140184/1/5YJxx-rostA/ad3f74094485fb97bd', 'thumb_url': 'https://core.telegram.org/file/811140184/1/5YJxx-rostA/ad3f74094485fb97bd', 'caption': 'Caption', 'title': 'Title', 'input_message_content': {'message_text': 'Shenzhen'}}]\n\n results = random.choice([articles, photos])\n return results\n\n query_id, from_id, query = telepot.glance(msg, flavor='inline_query')\n\n if from_id != USER_ID:\n print('Unauthorized user:', from_id)\n return\n\n examine(msg, InlineQuery)\n answerer.answer(msg, compute)", "metadata": "root.on_inline_query", "header": "['module', '___EOS___']", "index": 44 }, { "content": "def on_chosen_inline_result(msg):\n result_id, from_id, query = telepot.glance(msg, flavor='chosen_inline_result')\n\n if from_id != USER_ID:\n print('Unauthorized user:', from_id)\n return\n\n examine(msg, ChosenInlineResult)\n\n print('Chosen inline query:')\n pprint.pprint(msg)", "metadata": "root.on_chosen_inline_result", "header": "['module', '___EOS___']", "index": 69 }, { "content": "def compute(inline_query):\n articles = [InlineQueryResultArticle(\n id='abc', title='HK', message_text='Hong Kong', url='https://www.google.com', hide_url=True),\n {'type': 'article',\n 'id': 'def', 'title': 'SZ', 'message_text': 'Shenzhen', 'url': 'https://www.yahoo.com'}]\n\n photos = [InlineQueryResultPhoto(\n id='123', photo_url='https://core.telegram.org/file/811140934/1/tbDSLHSaijc/fdcc7b6d5fb3354adf', thumb_url='https://core.telegram.org/file/811140934/1/tbDSLHSaijc/fdcc7b6d5fb3354adf'),\n {'type': 'photo',\n 'id': '345', 'photo_url': 'https://core.telegram.org/file/811140184/1/5YJxx-rostA/ad3f74094485fb97bd', 'thumb_url': 'https://core.telegram.org/file/811140184/1/5YJxx-rostA/ad3f74094485fb97bd', 'caption': 'Caption', 'title': 'Title', 'message_text': 'Message Text'}]\n\n results = random.choice([articles, photos])\n return results", "metadata": "root.compute", "header": "['module', '___EOS___']", "index": 82 } ]
[ { "span": "import time", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 11 }, { "span": "import threading", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 16 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "codi", "ng", "=", "utf8_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "telep", "ot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "telep", "ot_", "._", "namedtuple_", "import_", "In", "line", "Query_", ",_", "Cho", "sen", "In", "line", "Result_", ",_", "In", "line", "Query", "Result", "Article_", ",_", "In", "line", "Query", "Result", "Photo_", ",_", "Inp", "ut", "Text", "Messag", "e", "Content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "TOKEN_", "=_", "sys_", "._", "argv_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "USER", "\\u", "ID_", "=_", "int_", "(_", "sys_", "._", "argv_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bot_", "=_", "telep", "ot_", "._", "Bot_", "(_", "TOKEN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "answer", "er_", "=_", "telep", "ot_", "._", "helper_", "._", "Answer", "er_", "(_", "bot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bot_", "._", "send", "Message_", "(_", "USER", "\\u", "ID_", ",_", "'", "Ple", "ase", " ", "give", " ", "me", " ", "an", " ", "inline", " ", "query", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bot_", "._", "message", "\\u", "loop_", "(_", "{_", "'", "inline", "\\u", "query", "'_", ":_", "on", "\\u", "inline", "\\u", "query_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "chosen", "\\u", "inline", "\\u", "result", "'_", ":_", "on", "\\u", "chosen", "\\u", "inline", "\\u", "result_", "}_", ",_", "run", "\\u", "forever_", "=_", "True_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "equivalent", "_", "(_", "data_", ",_", "nt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "data_", ")_", "is_", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "keys_", "=_", "data_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "number", " ", "of", " ", "dictionar", "y", " ", "keys", " ", "==", " ", "number", " ", "of", " ", "non", "-", "Non", "e", " ", "values", " ", "in", " ", "namedtupl", "e", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "keys_", ")_", "!=_", "len_", "(_", "[_", "f_", "for_", "f_", "in_", "nt_", "._", "\\u", "fields_", "if_", "getattr_", "(_", "nt_", ",_", "f_", ")_", "is_", "not_", "None_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "map", " ", "`", "from", "`", " ", "to", " ", "`", "from", "\\u`", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fields_", "=_", "list_", "(_", "map_", "(_", "lambda_", "k_", ":_", "k_", "+_", "'\\u'_", "if_", "k_", "in_", "[_", "'", "from", "'_", "]_", "else_", "k_", ",_", "keys_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "all_", "(_", "map_", "(_", "equivalent", "_", ",_", "[_", "data_", "[_", "k_", "]_", "for_", "k_", "in_", "keys_", "]_", ",_", "[_", "getattr_", "(_", "nt_", ",_", "f_", ")_", "for_", "f_", "in_", "fields_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "type_", "(_", "data_", ")_", "is_", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "all_", "(_", "map_", "(_", "equivalent", "_", ",_", "data_", ",_", "nt_", ")_", ")_", "\\u\\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_", "data_", "==_", "nt_", "\\u\\u\\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_", "examine", "_", "(_", "result_", ",_", "type_", ")_", ":_", "\\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 ", " _", "print_", "(_", "'", "Exam", "inin", "g", " ", "%", "s", " ", "......", "'_", "%_", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nt_", "=_", "type_", "(_", "**_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "equivalent", "_", "(_", "result_", ",_", "nt_", ")_", ",_", "'", "Not", " ", "equivalent", "::::::", "::::::", ":::", "\\\\", "n", "%", "s", "\\\\", "n", "::::::", "::::::", ":::", ":\\\\", "n", "%", "s", "'_", "%_", "(_", "result_", ",_", "nt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pprint_", "._", "pprint_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pprint_", "._", "pprint_", "(_", "nt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", ")_", "\\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 ", " _", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "answer_", "=_", "raw", "\\u", "input_", "(_", "'", "Do", " ", "you", " ", "want", " ", "to", " ", "continue", "?", " ", "[", "y", "]", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "answer_", "!=_", "'", "y", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "\\u", "inline", "\\u", "query_", "(_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "compute_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "articles_", "=_", "[_", "In", "line", "Query", "Result", "Article_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "abc", "'_", ",_", "title_", "=_", "'", "HK", "'_", ",_", "input", "\\u", "message", "\\u", "content_", "=_", "Inp", "ut", "Text", "Messag", "e", "Content_", "(_", "message", "\\u", "text_", "=_", "'", "Hon", "g", " ", "Kon", "g", "'_", ")_", ",_", "url_", "=_", "'", "https", "://", "www", ".", "google", ".", "com", "'_", ",_", "hide", "\\u", "url_", "=_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "type", "'_", ":_", "'", "article", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "'", "def", "'_", ",_", "'", "title", "'_", ":_", "'", "SZ", "'_", ",_", "'", "input", "\\u", "message", "\\u", "content", "'_", ":_", "{_", "'", "message", "\\u", "text", "'_", ":_", "'", "Shen", "zhe", "n", "'_", "}_", ",_", "'", "url", "'_", ":_", "'", "https", "://", "www", ".", "ya", "hoo", ".", "com", "'_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "photos_", "=_", "[_", "In", "line", "Query", "Result", "Photo_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "123", "'_", ",_", "photo", "\\u", "url_", "=_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "934", "/", "1", "/", "tb", "DSL", "HS", "ai", "jc", "/", "fd", "cc", "7b", "6d", "5f", "b3", "354", "adf", "'_", ",_", "thumb", "\\u", "url_", "=_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "934", "/", "1", "/", "tb", "DSL", "HS", "ai", "jc", "/", "fd", "cc", "7b", "6d", "5f", "b3", "354", "adf", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "type", "'_", ":_", "'", "photo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "'", "345", "'_", ",_", "'", "photo", "\\u", "url", "'_", ":_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "184", "/", "1", "/", "5", "YJ", "xx", "-", "ros", "t", "A", "/", "ad", "3f", "740", "944", "85", "fb", "9", "7b", "d", "'_", ",_", "'", "thumb", "\\u", "url", "'_", ":_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "184", "/", "1", "/", "5", "YJ", "xx", "-", "ros", "t", "A", "/", "ad", "3f", "740", "944", "85", "fb", "9", "7b", "d", "'_", ",_", "'", "caption", "'_", ":_", "'", "Caption", "'_", ",_", "'", "title", "'_", ":_", "'", "Tit", "le", "'_", ",_", "'", "input", "\\u", "message", "\\u", "content", "'_", ":_", "{_", "'", "message", "\\u", "text", "'_", ":_", "'", "Shen", "zhe", "n", "'_", "}_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "results_", "=_", "random_", "._", "choice_", "(_", "[_", "articles_", ",_", "photos_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query", "\\u", "id_", ",_", "from", "\\u", "id_", ",_", "query_", "=_", "telep", "ot_", "._", "glance_", "(_", "msg_", ",_", "flavor_", "=_", "'", "inline", "\\u", "query", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "from", "\\u", "id_", "!=_", "USER", "\\u", "ID_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Una", "uthor", "ize", "d", " ", "user", ":'_", ",_", "from", "\\u", "id_", ")_", "\\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_", "examine", "_", "(_", "msg_", ",_", "In", "line", "Query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "answer", "er_", "._", "answer_", "(_", "msg_", ",_", "compute_", ")_", "\\u\\u\\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_", "on", "\\u", "chosen", "\\u", "inline", "\\u", "result_", "(_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result", "\\u", "id_", ",_", "from", "\\u", "id_", ",_", "query_", "=_", "telep", "ot_", "._", "glance_", "(_", "msg_", ",_", "flavor_", "=_", "'", "chosen", "\\u", "inline", "\\u", "result", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "from", "\\u", "id_", "!=_", "USER", "\\u", "ID_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Una", "uthor", "ize", "d", " ", "user", ":'_", ",_", "from", "\\u", "id_", ")_", "\\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_", "examine", "_", "(_", "msg_", ",_", "Cho", "sen", "In", "line", "Result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Cho", "sen", " ", "inline", " ", "query", ":'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pprint_", "._", "pprint_", "(_", "msg_", ")_", "\\u\\u\\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_", "(_", "inline", "\\u", "query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "articles_", "=_", "[_", "In", "line", "Query", "Result", "Article_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "abc", "'_", ",_", "title_", "=_", "'", "HK", "'_", ",_", "message", "\\u", "text_", "=_", "'", "Hon", "g", " ", "Kon", "g", "'_", ",_", "url_", "=_", "'", "https", "://", "www", ".", "google", ".", "com", "'_", ",_", "hide", "\\u", "url_", "=_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "type", "'_", ":_", "'", "article", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "'", "def", "'_", ",_", "'", "title", "'_", ":_", "'", "SZ", "'_", ",_", "'", "message", "\\u", "text", "'_", ":_", "'", "Shen", "zhe", "n", "'_", ",_", "'", "url", "'_", ":_", "'", "https", "://", "www", ".", "ya", "hoo", ".", "com", "'_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "photos_", "=_", "[_", "In", "line", "Query", "Result", "Photo_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "123", "'_", ",_", "photo", "\\u", "url_", "=_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "934", "/", "1", "/", "tb", "DSL", "HS", "ai", "jc", "/", "fd", "cc", "7b", "6d", "5f", "b3", "354", "adf", "'_", ",_", "thumb", "\\u", "url_", "=_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "934", "/", "1", "/", "tb", "DSL", "HS", "ai", "jc", "/", "fd", "cc", "7b", "6d", "5f", "b3", "354", "adf", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "type", "'_", ":_", "'", "photo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "'", "345", "'_", ",_", "'", "photo", "\\u", "url", "'_", ":_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "184", "/", "1", "/", "5", "YJ", "xx", "-", "ros", "t", "A", "/", "ad", "3f", "740", "944", "85", "fb", "9", "7b", "d", "'_", ",_", "'", "thumb", "\\u", "url", "'_", ":_", "'", "https", "://", "core", ".", "tele", "gram", ".", "org", "/", "file", "/", "811", "140", "184", "/", "1", "/", "5", "YJ", "xx", "-", "ros", "t", "A", "/", "ad", "3f", "740", "944", "85", "fb", "9", "7b", "d", "'_", ",_", "'", "caption", "'_", ":_", "'", "Caption", "'_", ",_", "'", "title", "'_", ":_", "'", "Tit", "le", "'_", ",_", "'", "message", "\\u", "text", "'_", ":_", "'", "Messag", "e", " ", "Text", "'_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "results_", "=_", "random_", "._", "choice_", "(_", "[_", "articles_", ",_", "photos_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary pass
HenryHu/pybbs/xmppserver.py
[ { "content": " def steal_msg(self):\n Log.debug(\"stealing msg for %s\" % self._userid)\n msgbox = MsgBox.MsgBox(self._userid)\n msg_count = msgbox.GetMsgCount(all = False)\n msg_unread = msgbox.GetUnreadCount()\n read_count = msg_count - msg_unread\n my_pid = os.getpid()\n term_read = self.rosters.get_term_read(self.get_uid())\n term_stealed = self.rosters.get_term_stealed(self.get_uid())\n\n all_xmpp = True\n new_unread = {}\n # these are unread msgs!\n for i in range(read_count - 1, msg_count):\n if i < 0: # read_count == 0...\n continue\n\n msghead = msgbox.LoadMsgHead(i, all = False)\n if i >= read_count and all_xmpp:\n if msghead.topid == my_pid:\n # still xmpp\n # RACE!\n msgbox.GetUnreadMsg()\n else:\n # not xmpp\n all_xmpp = False\n\n if msghead.topid == my_pid:\n # xmpp msg, don't care\n continue\n\n if i < read_count: # read_count - 1\n session = self.rosters.find_session(self.authJID.bare, msghead.topid)\n if session is None or session.get_mode() != modes.MSG:\n continue\n Log.debug(\"considered msg %d as unread\" % i)\n\n # unread msg!\n if msghead.topid not in new_unread:\n Log.debug(\"for pid %d, first unread at %d\" % (msghead.topid, i))\n new_unread[msghead.topid] = i\n\n final_unread = {}\n to_steal = {}\n to_steal_begin = msg_count\n\n for pid in term_read:\n if pid in new_unread:\n if new_unread[pid] == term_read[pid][0]:\n # still unread\n final_unread[pid] = (term_read[pid][0], term_read[pid][1] + 1)\n Log.debug(\".. still unread: %d for %d, %d times\" % (new_unread[pid], pid, term_read[pid][1]+1))\n if final_unread[pid][1] > STEAL_AFTER_SEEN:\n to_steal[pid] = final_unread[pid]\n Log.debug(\".. let's steal! %d+ from %d\" % (to_steal[pid][0], pid))\n if pid in term_stealed:\n steal_begin = max(final_unread[pid][0], term_stealed[pid] + 1)\n else:\n steal_begin = final_unread[pid][0]\n if steal_begin < to_steal_begin:\n to_steal_begin = steal_begin\n else:\n # moved forward\n final_unread[pid] = (new_unread[pid], 1)\n Log.debug(\".. moved: %d->%d for %d\" % (term_read[pid][0], new_unread[pid], pid))\n else:\n # disappeared? consider as read\n Log.debug(\".. disappeared: %d\" % pid)\n pass\n for pid in new_unread:\n if pid not in term_read:\n # new session\n Log.debug(\".. new unread: %d for %d\" % (new_unread[pid], pid))\n final_unread[pid] = (new_unread[pid], 1)\n\n if to_steal:\n Log.debug(\"steal starting from %d\" % to_steal_begin)\n for i in range(to_steal_begin, msg_count):\n msghead = msgbox.LoadMsgHead(i, all = False)\n if msghead.topid == my_pid:\n Log.debug(\"skip xmpp %d for %d\" % (i, msghead.topid))\n msgbox.GetUnreadMsg()\n elif msghead.topid in to_steal:\n if msghead.topid not in term_stealed or i > term_stealed[msghead.topid]:\n Log.debug(\"steal! %d from %d\" % (i, msghead.topid))\n # not stealed...\n msgtext = msgbox.LoadMsgText(msghead)\n self.recv_msg(self.make_jid(msghead.id), msgtext)\n term_stealed[msghead.topid] = i\n else:\n Log.debug(\"already stealed: %d from %d\" % (i, msghead.topid))\n\n self.rosters.set_term_read(self.get_uid(), final_unread)", "metadata": "root.XMPPServer.steal_msg", "header": "['class', 'XMPPServer', '(', 'xmpp', '.', 'Plugin', ')', ':', '___EOS___']", "index": 221 } ]
[ { "span": "pass", "start_line": 289, "start_column": 16, "end_line": 289, "end_column": 20 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "class_", "XMPP", "Server_", "(_", "xmpp_", "._", "Plugin_", ")_", ":_", "\\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_", "stea", "l\\u", "msg_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Log_", "._", "debug_", "(_", "\"", "stea", "ling", " ", "msg", " ", "for", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u", "userid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msgb", "ox_", "=_", "Msg", "Box_", "._", "Msg", "Box_", "(_", "self_", "._", "\\u", "userid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "\\u", "count_", "=_", "msgb", "ox_", "._", "Get", "Msg", "Count_", "(_", "all_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "\\u", "unread", "_", "=_", "msgb", "ox_", "._", "Get", "Unrea", "d", "Count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read", "\\u", "count_", "=_", "msg", "\\u", "count_", "-_", "msg", "\\u", "unread", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "my", "\\u", "pid_", "=_", "os_", "._", "getpid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "term", "\\u", "read_", "=_", "self_", "._", "roster", "s_", "._", "get", "\\u", "term", "\\u", "read_", "(_", "self_", "._", "get", "\\u", "uid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "term", "\\u", "stea", "led_", "=_", "self_", "._", "roster", "s_", "._", "get", "\\u", "term", "\\u", "stea", "led_", "(_", "self_", "._", "get", "\\u", "uid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "all", "\\u", "xmpp_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "unread", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "these", " ", "are", " ", "unread", " ", "msgs", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "read", "\\u", "count_", "-_", "1_", ",_", "msg", "\\u", "count_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "<_", "0_", ":_", "#", " ", "read", "\\u", "count", " ", "==", " ", "0.", "..", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "msg", "head_", "=_", "msgb", "ox_", "._", "Load", "Msg", "Head_", "(_", "i_", ",_", "all_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i_", ">=_", "read", "\\u", "count_", "and_", "all", "\\u", "xmpp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "msg", "head_", "._", "top", "id_", "==_", "my", "\\u", "pid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "still", " ", "xmpp_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "RACE", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "msgb", "ox_", "._", "Get", "Unrea", "d", "Msg_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "not", " ", "xmpp_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "all", "\\u", "xmpp_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "msg", "head_", "._", "top", "id_", "==_", "my", "\\u", "pid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "xmpp", " ", "msg", ",", " ", "don", "'", "t", " ", "care", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i_", "<_", "read", "\\u", "count_", ":_", "#", " ", "read", "\\u", "count", " ", "-", " ", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "=_", "self_", "._", "roster", "s_", "._", "find", "\\u", "session_", "(_", "self_", "._", "auth", "JID", "_", "._", "bare", "_", ",_", "msg", "head_", "._", "top", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "session_", "is_", "None_", "or_", "session_", "._", "get", "\\u", "mode_", "(_", ")_", "!=_", "modes_", "._", "MSG_", ":_", "\\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_", "Log_", "._", "debug_", "(_", "\"", "consider", "ed", " ", "msg", " ", "%", "d", " ", "as", " ", "unread", "\"_", "%_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "unread", " ", "msg", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "msg", "head_", "._", "top", "id_", "not_", "in_", "new", "\\u", "unread", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Log_", "._", "debug_", "(_", "\"", "for", " ", "pid", " ", "%", "d", ",", " ", "first", " ", "unread", " ", "at", " ", "%", "d", "\"_", "%_", "(_", "msg", "head_", "._", "top", "id_", ",_", "i_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "unread", "_", "[_", "msg", "head_", "._", "top", "id_", "]_", "=_", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "final", "\\u", "unread", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "to", "\\u", "stea", "l_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "to", "\\u", "stea", "l\\u", "begin_", "=_", "msg", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "pid_", "in_", "term", "\\u", "read_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pid_", "in_", "new", "\\u", "unread", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "new", "\\u", "unread", "_", "[_", "pid_", "]_", "==_", "term", "\\u", "read_", "[_", "pid_", "]_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "still", " ", "unread", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "=_", "(_", "term", "\\u", "read_", "[_", "pid_", "]_", "[_", "0_", "]_", ",_", "term", "\\u", "read_", "[_", "pid_", "]_", "[_", "1_", "]_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Log_", "._", "debug_", "(_", "\"..", " ", "still", " ", "unread", ":", " ", "%", "d", " ", "for", " ", "%", "d", ",", " ", "%", "d", " ", "times", "\"_", "%_", "(_", "new", "\\u", "unread", "_", "[_", "pid_", "]_", ",_", "pid_", ",_", "term", "\\u", "read_", "[_", "pid_", "]_", "[_", "1_", "]_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "[_", "1_", "]_", ">_", "STE", "AL", "\\u", "AFTER", "\\u", "SEE", "N_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "to", "\\u", "stea", "l_", "[_", "pid_", "]_", "=_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Log_", "._", "debug_", "(_", "\"..", " ", "let", "'", "s", " ", "stea", "l", "!", " ", "%", "d", "+", " ", "from", " ", "%", "d", "\"_", "%_", "(_", "to", "\\u", "stea", "l_", "[_", "pid_", "]_", "[_", "0_", "]_", ",_", "pid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "pid_", "in_", "term", "\\u", "stea", "led_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "stea", "l\\u", "begin_", "=_", "max_", "(_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "[_", "0_", "]_", ",_", "term", "\\u", "stea", "led_", "[_", "pid_", "]_", "+_", "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 ", " ", " _", "stea", "l\\u", "begin_", "=_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "stea", "l\\u", "begin_", "<_", "to", "\\u", "stea", "l\\u", "begin_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "to", "\\u", "stea", "l\\u", "begin_", "=_", "stea", "l\\u", "begin_", "\\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_", "#", " ", "moved", " ", "forward_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "=_", "(_", "new", "\\u", "unread", "_", "[_", "pid_", "]_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Log_", "._", "debug_", "(_", "\"..", " ", "moved", ":", " ", "%", "d", "->", "%", "d", " ", "for", " ", "%", "d", "\"_", "%_", "(_", "term", "\\u", "read_", "[_", "pid_", "]_", "[_", "0_", "]_", ",_", "new", "\\u", "unread", "_", "[_", "pid_", "]_", ",_", "pid_", ")_", ")_", "\\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_", "#", " ", "disapp", "ear", "ed", "?", " ", "consider", " ", "as", " ", "read_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Log_", "._", "debug_", "(_", "\"..", " ", "disapp", "ear", "ed", ":", " ", "%", "d", "\"_", "%_", "pid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "pid_", "in_", "new", "\\u", "unread", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pid_", "not_", "in_", "term", "\\u", "read_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "new", " ", "session_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Log_", "._", "debug_", "(_", "\"..", " ", "new", " ", "unread", ":", " ", "%", "d", " ", "for", " ", "%", "d", "\"_", "%_", "(_", "new", "\\u", "unread", "_", "[_", "pid_", "]_", ",_", "pid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "final", "\\u", "unread", "_", "[_", "pid_", "]_", "=_", "(_", "new", "\\u", "unread", "_", "[_", "pid_", "]_", ",_", "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_", "to", "\\u", "stea", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Log_", "._", "debug_", "(_", "\"", "stea", "l", " ", "startin", "g", " ", "from", " ", "%", "d", "\"_", "%_", "to", "\\u", "stea", "l\\u", "begin_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "to", "\\u", "stea", "l\\u", "begin_", ",_", "msg", "\\u", "count_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg", "head_", "=_", "msgb", "ox_", "._", "Load", "Msg", "Head_", "(_", "i_", ",_", "all_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg", "head_", "._", "top", "id_", "==_", "my", "\\u", "pid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "Log_", "._", "debug_", "(_", "\"", "skip", " ", "xmpp", " ", "%", "d", " ", "for", " ", "%", "d", "\"_", "%_", "(_", "i_", ",_", "msg", "head_", "._", "top", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msgb", "ox_", "._", "Get", "Unrea", "d", "Msg_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "msg", "head_", "._", "top", "id_", "in_", "to", "\\u", "stea", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "msg", "head_", "._", "top", "id_", "not_", "in_", "term", "\\u", "stea", "led_", "or_", "i_", ">_", "term", "\\u", "stea", "led_", "[_", "msg", "head_", "._", "top", "id_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "Log_", "._", "debug_", "(_", "\"", "stea", "l", "!", " ", "%", "d", " ", "from", " ", "%", "d", "\"_", "%_", "(_", "i_", ",_", "msg", "head_", "._", "top", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "not", " ", "stea", "led", "..._", "\\u\\u\\uNL\\u\\u\\u_", "msgt", "ext_", "=_", "msgb", "ox_", "._", "Load", "Msg", "Text_", "(_", "msg", "head_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "recv", "\\u", "msg_", "(_", "self_", "._", "make", "\\u", "jid_", "(_", "msg", "head_", "._", "id_", ")_", ",_", "msgt", "ext_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "term", "\\u", "stea", "led_", "[_", "msg", "head_", "._", "top", "id_", "]_", "=_", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "Log_", "._", "debug_", "(_", "\"", "alr", "ead", "y", " ", "stea", "led", ":", " ", "%", "d", " ", "from", " ", "%", "d", "\"_", "%_", "(_", "i_", ",_", "msg", "head_", "._", "top", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "roster", "s_", "._", "set\\u", "term", "\\u", "read_", "(_", "self_", "._", "get", "\\u", "uid_", "(_", ")_", ",_", "final", "\\u", "unread", "_", ")_", "\\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 ]
Except block handles 'BaseException'
zorna/zorna/zorna/communities/templatetags/communities_tags.py
[ { "content": " def render(self, context):\n path = \"%s/%s\" % (get_upload_path(), self.message)\n try:\n context[self.var_name] = [f for f in os.listdir(path)]\n except:\n context[self.var_name] = []\n return ''", "metadata": "root.attachments_message.render", "header": "['class', 'attachments_message', '(', 'template', '.', 'Node', ')', ':', '___EOS___']", "index": 119 }, { "content": " def render(self, context):\n request = context['request']\n community = self.community.resolve(context)\n messages = get_all_messages(request, community.pk if community else 0)\n messages = messages.order_by('-time_updated')\n\n context[self.var_name] = []\n nbfiles = self.number\n for msg in messages:\n if nbfiles == 0:\n break\n path = \"%s/%s\" % (get_upload_communities(), msg.pk)\n try:\n files = []\n for f in os.listdir(path):\n files.append(f)\n nbfiles -= 1\n if nbfiles == 0:\n break\n context[self.var_name].append({'message': msg, 'files': files})\n except:\n pass\n return ''", "metadata": "root.last_communities_attachments.render", "header": "['class', 'last_communities_attachments', '(', 'template', '.', 'Node', ')', ':', '___EOS___']", "index": 148 } ]
[ { "span": "except:", "start_line": 123, "start_column": 8, "end_line": 123, "end_column": 15 }, { "span": "except:", "start_line": 168, "start_column": 12, "end_line": 168, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "attach", "ment", "s", "\\u", "message_", "(_", "template_", "._", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "render_", "(_", "self_", ",_", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "\"%", "s", "/", "%", "s", "\"_", "%_", "(_", "get", "\\u", "upload", "\\u", "path_", "(_", ")_", ",_", "self_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "[_", "self_", "._", "var", "\\u", "name_", "]_", "=_", "[_", "f_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "path_", ")_", "]_", "\\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 ", " _", "context_", "[_", "self_", "._", "var", "\\u", "name_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "last", "\\u", "communi", "ties", "\\u", "attachments_", "(_", "template_", "._", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "render_", "(_", "self_", ",_", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request_", "=_", "context_", "[_", "'", "request", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "community_", "=_", "self_", "._", "community_", "._", "resolve_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "=_", "get", "\\u", "all", "\\u", "messages_", "(_", "request_", ",_", "community_", "._", "pk_", "if_", "community_", "else_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "=_", "messages_", "._", "order", "\\u", "by_", "(_", "'-", "time", "\\u", "update", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "[_", "self_", "._", "var", "\\u", "name_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nb", "files_", "=_", "self_", "._", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "msg_", "in_", "messages_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "nb", "files_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "\"%", "s", "/", "%", "s", "\"_", "%_", "(_", "get", "\\u", "upload", "\\u", "communi", "ties_", "(_", ")_", ",_", "msg_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "files_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "files_", "._", "append_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nb", "files_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "nb", "files_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "[_", "self_", "._", "var", "\\u", "name_", "]_", "._", "append_", "(_", "{_", "'", "message", "'_", ":_", "msg_", ",_", "'", "files", "'_", ":_", "files_", "}_", ")_", "\\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, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
Piratenfraktion-Berlin/OwnTube/videoportal/BitTornadoABC/BitTornado/ConfigDir.py
[ { "content": "#written by John Hoffman\n\nfrom inifile import ini_write, ini_read\nfrom bencode import bencode, bdecode\nfrom types import IntType, LongType, StringType, FloatType\nfrom CreateIcons import GetIcons, CreateIcon\nfrom parseargs import defaultargs\nfrom __init__ import product_name, version_short\nimport sys, os\nfrom time import time, strftime\n\nfrom binascii import b2a_hex as tohex, a2b_hex as unhex\n\ntry:\n True\nexcept:\n True = 1\n False = 0\n\ntry:\n realpath = os.path.realpath\nexcept:\n realpath = lambda x: x\nOLDICONPATH = os.path.abspath(os.path.dirname(realpath(sys.argv[0])))\n\nDIRNAME = '.'+product_name\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def copyfile(oldpath, newpath): # simple file copy, all in RAM\n try:\n f = open(oldpath, 'rb')\n r = f.read()\n success = True\n except:\n success = False\n try:\n f.close()\n except:\n pass\n if not success:\n return False\n try:\n f = open(newpath, 'wb')\n f.write(r)\n except:\n success = False\n try:\n f.close()\n except:\n pass\n return success", "metadata": "root.copyfile", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def loadConfig(self):\n try:\n r = ini_read(self.configfile)['']\n except:\n return self.config\n l = self.config.keys()\n for k, v in r.items():\n if self.config.has_key(k):\n t = type(self.config[k])\n try:\n if t == StringType:\n self.config[k] = v\n elif t == IntType or t == LongType:\n self.config[k] = long(v)\n elif t == FloatType:\n self.config[k] = float(v)\n l.remove(k)\n except:\n pass\n if l: # new default values since last save\n self.saveConfig()\n return self.config", "metadata": "root.ConfigDir.loadConfig", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 123 }, { "content": " def saveConfig(self, new_config = None):\n if new_config:\n for k, v in new_config.items():\n if self.config.has_key(k):\n self.config[k] = v\n try:\n ini_write(self.configfile, self.config, \n 'Generated by '+product_name+'/'+version_short+'\\n'\n + strftime('%x %X'))\n return True\n except:\n return False", "metadata": "root.ConfigDir.saveConfig", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 146 }, { "content": " def getState(self):\n try:\n f = open(self.statefile, 'rb')\n r = f.read()\n except:\n r = None\n try:\n f.close()\n except:\n pass\n try:\n r = bdecode(r)\n except:\n r = None\n return r ", "metadata": "root.ConfigDir.getState", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 165 }, { "content": " def saveState(self, state):\n try:\n f = open(self.statefile, 'wb')\n f.write(bencode(state))\n success = True\n except:\n success = False\n try:\n f.close()\n except:\n pass\n return success", "metadata": "root.ConfigDir.saveState", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 181 }, { "content": " def getTorrents(self):\n d = {}\n for f in os.listdir(self.dir_torrentcache):\n f = os.path.basename(f)\n try:\n f, garbage = f.split('.')\n except:\n pass\n d[unhex(f)] = 1\n return d.keys()", "metadata": "root.ConfigDir.getTorrents", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 197 }, { "content": " def getTorrentVariations(self, t):\n t = tohex(t)\n d = []\n for f in os.listdir(self.dir_torrentcache):\n f = os.path.basename(f)\n if f[:len(t)] == t:\n try:\n garbage, ver = f.split('.')\n except:\n ver = '0'\n d.append(int(ver))\n d.sort()\n return d", "metadata": "root.ConfigDir.getTorrentVariations", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 208 }, { "content": " def getTorrent(self, t, v = -1):\n t = tohex(t)\n if v == -1:\n v = max(self.getTorrentVariations(t)) # potential exception\n if v:\n t += '.'+str(v)\n try:\n f = open(os.path.join(self.dir_torrentcache, t), 'rb')\n r = bdecode(f.read())\n except:\n r = None\n try:\n f.close()\n except:\n pass\n return r", "metadata": "root.ConfigDir.getTorrent", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 222 }, { "content": " def writeTorrent(self, data, t, v = -1):\n t = tohex(t)\n if v == -1:\n try:\n v = max(self.getTorrentVariations(t))+1\n except:\n v = 0\n if v:\n t += '.'+str(v)\n try:\n f = open(os.path.join(self.dir_torrentcache, t), 'wb')\n f.write(bencode(data))\n except:\n v = None\n try:\n f.close()\n except:\n pass\n return v", "metadata": "root.ConfigDir.writeTorrent", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 239 }, { "content": " def getTorrentData(self, t):\n if self.TorrentDataBuffer.has_key(t):\n return self.TorrentDataBuffer[t]\n t = os.path.join(self.dir_datacache, tohex(t))\n if not os.path.exists(t):\n return None\n try:\n f = open(t, 'rb')\n r = bdecode(f.read())\n except:\n r = None\n try:\n f.close()\n except:\n pass\n self.TorrentDataBuffer[t] = r\n return r", "metadata": "root.ConfigDir.getTorrentData", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 262 }, { "content": " def writeTorrentData(self, t, data):\n self.TorrentDataBuffer[t] = data\n try:\n f = open(os.path.join(self.dir_datacache, tohex(t)), 'wb')\n f.write(bencode(data))\n success = True\n except:\n success = False\n try:\n f.close()\n except:\n pass\n if not success:\n self.deleteTorrentData(t)\n return success", "metadata": "root.ConfigDir.writeTorrentData", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 280 }, { "content": " def deleteTorrentData(self, t):\n try:\n os.remove(os.path.join(self.dir_datacache, tohex(t)))\n except:\n pass", "metadata": "root.ConfigDir.deleteTorrentData", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 296 }, { "content": " def deleteOldCacheData(self, days, still_active = [], delete_torrents = False):\n if not days:\n return\n exptime = time() - (days*24*3600)\n names = {}\n times = {}\n\n for f in os.listdir(self.dir_torrentcache):\n p = os.path.join(self.dir_torrentcache, f)\n f = os.path.basename(f)\n try:\n f, garbage = f.split('.')\n except:\n pass\n try:\n f = unhex(f)\n assert len(f) == 20\n except:\n continue\n if delete_torrents:\n names.setdefault(f, []).append(p)\n try:\n t = os.path.getmtime(p)\n except:\n t = time()\n times.setdefault(f, []).append(t)\n \n for f in os.listdir(self.dir_datacache):\n p = os.path.join(self.dir_datacache, f)\n try:\n f = unhex(os.path.basename(f))\n assert len(f) == 20\n except:\n continue\n names.setdefault(f, []).append(p)\n try:\n t = os.path.getmtime(p)\n except:\n t = time()\n times.setdefault(f, []).append(t)\n\n for f in os.listdir(self.dir_piececache):\n p = os.path.join(self.dir_piececache, f)\n try:\n f = unhex(os.path.basename(f))\n assert len(f) == 20\n except:\n continue\n for f2 in os.listdir(p):\n p2 = os.path.join(p, f2)\n names.setdefault(f, []).append(p2)\n try:\n t = os.path.getmtime(p2)\n except:\n t = time()\n times.setdefault(f, []).append(t)\n names.setdefault(f, []).append(p)\n\n for k, v in times.items():\n if max(v) < exptime and not k in still_active:\n for f in names[k]:\n try:\n os.remove(f)\n except:\n try:\n os.removedirs(f)\n except:\n pass", "metadata": "root.ConfigDir.deleteOldCacheData", "header": "['class', 'ConfigDir', ':', '___NEWLINE___', '___NL___', '###### INITIALIZATION TASKS ######', '___NL___', '___EOS___']", "index": 308 } ]
[ { "span": "except:", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 7 }, { "span": "except:", "start_line": 33, "start_column": 4, "end_line": 33, "end_column": 11 }, { "span": "except:", "start_line": 37, "start_column": 4, "end_line": 37, "end_column": 11 }, { "span": "except:", "start_line": 44, "start_column": 4, "end_line": 44, "end_column": 11 }, { "span": "except:", "start_line": 48, "start_column": 4, "end_line": 48, "end_column": 11 }, { "span": "except:", "start_line": 126, "start_column": 8, "end_line": 126, "end_column": 15 }, { "span": "except:", "start_line": 140, "start_column": 16, "end_line": 140, "end_column": 23 }, { "span": "except:", "start_line": 156, "start_column": 8, "end_line": 156, "end_column": 15 }, { "span": "except:", "start_line": 169, "start_column": 8, "end_line": 169, "end_column": 15 }, { "span": "except:", "start_line": 173, "start_column": 8, "end_line": 173, "end_column": 15 }, { "span": "except:", "start_line": 177, "start_column": 8, "end_line": 177, "end_column": 15 }, { "span": "except:", "start_line": 186, "start_column": 8, "end_line": 186, "end_column": 15 }, { "span": "except:", "start_line": 190, "start_column": 8, "end_line": 190, "end_column": 15 }, { "span": "except:", "start_line": 203, "start_column": 12, "end_line": 203, "end_column": 19 }, { "span": "except:", "start_line": 216, "start_column": 16, "end_line": 216, "end_column": 23 }, { "span": "except:", "start_line": 231, "start_column": 8, "end_line": 231, "end_column": 15 }, { "span": "except:", "start_line": 235, "start_column": 8, "end_line": 235, "end_column": 15 }, { "span": "except:", "start_line": 244, "start_column": 12, "end_line": 244, "end_column": 19 }, { "span": "except:", "start_line": 251, "start_column": 8, "end_line": 251, "end_column": 15 }, { "span": "except:", "start_line": 255, "start_column": 8, "end_line": 255, "end_column": 15 }, { "span": "except:", "start_line": 271, "start_column": 8, "end_line": 271, "end_column": 15 }, { "span": "except:", "start_line": 275, "start_column": 8, "end_line": 275, "end_column": 15 }, { "span": "except:", "start_line": 286, "start_column": 8, "end_line": 286, "end_column": 15 }, { "span": "except:", "start_line": 290, "start_column": 8, "end_line": 290, "end_column": 15 }, { "span": "except:", "start_line": 299, "start_column": 8, "end_line": 299, "end_column": 15 }, { "span": "except:", "start_line": 320, "start_column": 12, "end_line": 320, "end_column": 19 }, { "span": "except:", "start_line": 325, "start_column": 12, "end_line": 325, "end_column": 19 }, { "span": "except:", "start_line": 331, "start_column": 12, "end_line": 331, "end_column": 19 }, { "span": "except:", "start_line": 340, "start_column": 12, "end_line": 340, "end_column": 19 }, { "span": "except:", "start_line": 345, "start_column": 12, "end_line": 345, "end_column": 19 }, { "span": "except:", "start_line": 354, "start_column": 12, "end_line": 354, "end_column": 19 }, { "span": "except:", "start_line": 361, "start_column": 16, "end_line": 361, "end_column": 23 }, { "span": "except:", "start_line": 371, "start_column": 20, "end_line": 371, "end_column": 27 }, { "span": "except:", "start_line": 374, "start_column": 24, "end_line": 374, "end_column": 31 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "writt", "en", " ", "by", " ", "Joh", "n", " ", "Ho", "ff", "man_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ini", "file_", "import_", "ini", "\\u", "write_", ",_", "ini", "\\u", "read_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ben", "code_", "import_", "ben", "code_", ",_", "bde", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "types_", "import_", "Int", "Type_", ",_", "Long", "Type_", ",_", "String", "Type_", ",_", "Float", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Creat", "e", "Icons", "_", "import_", "Get", "Icons", "_", ",_", "Creat", "e", "Icon_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "parse", "args_", "import_", "default", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "init\\u\\u_", "import_", "product", "\\u", "name_", ",_", "version", "\\u", "short_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", ",_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "time_", "import_", "time_", ",_", "strftime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "binascii_", "import_", "b2", "a", "\\u", "hex_", "as_", "to", "hex_", ",_", "a2", "b", "\\u", "hex_", "as_", "unh", "ex_", "\\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 ", " _", "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 ", " _", "True_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "False_", "=_", "0_", "\\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 ", " _", "realpath_", "=_", "os_", "._", "path_", "._", "realpath_", "\\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 ", " _", "realpath_", "=_", "lambda_", "x_", ":_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "OLD", "ICON", "PATH_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "realpath_", "(_", "sys_", "._", "argv_", "[_", "0_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DIR", "NAME_", "=_", "'.'_", "+_", "product", "\\u", "name_", "\\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_", "copyfile_", "(_", "oldp", "ath_", ",_", "newpath_", ")_", ":_", "#", " ", "simple", " ", "file", " ", "copy", ",", " ", "all", " ", "in", " ", "RAM", "_", "\\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 ", " _", "f_", "=_", "open_", "(_", "oldp", "ath_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "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 ", " _", "success_", "=_", "False_", "\\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 ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "success_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "open_", "(_", "newpath_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "r_", ")_", "\\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 ", " _", "success_", "=_", "False_", "\\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 ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "success_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "load", "Config_", "(_", "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 ", " _", "r_", "=_", "ini", "\\u", "read_", "(_", "self_", "._", "configfile_", ")_", "[_", "''_", "]_", "\\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_", "self_", "._", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "=_", "self_", "._", "config_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "r_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "config_", "._", "has", "\\u", "key_", "(_", "k_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "type_", "(_", "self_", "._", "config_", "[_", "k_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "t_", "==_", "String", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "config_", "[_", "k_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "t_", "==_", "Int", "Type_", "or_", "t_", "==_", "Long", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "config_", "[_", "k_", "]_", "=_", "long_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "t_", "==_", "Float", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "config_", "[_", "k_", "]_", "=_", "float_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "._", "remove_", "(_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "l_", ":_", "#", " ", "new", " ", "default", " ", "values", " ", "sinc", "e", " ", "last", " ", "save_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "save", "Config_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save", "Config_", "(_", "self_", ",_", "new", "\\u", "config_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "new", "\\u", "config_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "k_", ",_", "v_", "in_", "new", "\\u", "config_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "config_", "._", "has", "\\u", "key_", "(_", "k_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "config_", "[_", "k_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\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 ", " _", "ini", "\\u", "write_", "(_", "self_", "._", "configfile_", ",_", "self_", "._", "config_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Generate", "d", " ", "by", " ", "'_", "+_", "product", "\\u", "name_", "+_", "'/'_", "+_", "version", "\\u", "short_", "+_", "'\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "strftime_", "(_", "'%", "x", " ", "%", "X", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "State_", "(_", "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 ", " _", "f_", "=_", "open_", "(_", "self_", "._", "state", "file_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "f_", "._", "read_", "(_", ")_", "\\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 ", " _", "r_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "bde", "code_", "(_", "r_", ")_", "\\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 ", " _", "r_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save", "State_", "(_", "self_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "open_", "(_", "self_", "._", "state", "file_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "ben", "code_", "(_", "state_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "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 ", " _", "success_", "=_", "False_", "\\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 ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "success_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Torrent", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "self_", "._", "dir\\u", "torr", "ent", "cache_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", ",_", "gar", "bage", "_", "=_", "f_", "._", "split_", "(_", "'.'_", ")_", "\\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_", "d_", "[_", "unh", "ex_", "(_", "f_", ")_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "d_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Torrent", "Variation", "s_", "(_", "self_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "to", "hex_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "self_", "._", "dir\\u", "torr", "ent", "cache_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "f_", "[_", ":_", "len_", "(_", "t_", ")_", "]_", "==_", "t_", ":_", "\\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 ", " ", "_", "gar", "bage", "_", ",_", "ver_", "=_", "f_", "._", "split_", "(_", "'.'_", ")_", "\\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 ", " ", "_", "ver_", "=_", "'", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d_", "._", "append_", "(_", "int_", "(_", "ver_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d_", "._", "sort_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Torrent", "_", "(_", "self_", ",_", "t_", ",_", "v_", "=_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "to", "hex_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "v_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "max_", "(_", "self_", "._", "get", "Torrent", "Variation", "s_", "(_", "t_", ")_", ")_", "#", " ", "potenti", "al", " ", "exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "+=_", "'.'_", "+_", "str_", "(_", "v_", ")_", "\\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 ", " _", "f_", "=_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "torr", "ent", "cache_", ",_", "t_", ")_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "bde", "code_", "(_", "f_", "._", "read_", "(_", ")_", ")_", "\\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 ", " _", "r_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "Torrent", "_", "(_", "self_", ",_", "data_", ",_", "t_", ",_", "v_", "=_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "to", "hex_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "v_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "max_", "(_", "self_", "._", "get", "Torrent", "Variation", "s_", "(_", "t_", ")_", ")_", "+_", "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 ", " _", "v_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "+=_", "'.'_", "+_", "str_", "(_", "v_", ")_", "\\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 ", " _", "f_", "=_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "torr", "ent", "cache_", ",_", "t_", ")_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "ben", "code_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Torrent", "Data_", "(_", "self_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "Torrent", "Data", "Buffer_", "._", "has", "\\u", "key_", "(_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "Torrent", "Data", "Buffer_", "[_", "t_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "datac", "ache_", ",_", "to", "hex_", "(_", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "t_", ")_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "open_", "(_", "t_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "bde", "code_", "(_", "f_", "._", "read_", "(_", ")_", ")_", "\\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 ", " _", "r_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "Torrent", "Data", "Buffer_", "[_", "t_", "]_", "=_", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "Torrent", "Data_", "(_", "self_", ",_", "t_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "Torrent", "Data", "Buffer_", "[_", "t_", "]_", "=_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "datac", "ache_", ",_", "to", "hex_", "(_", "t_", ")_", ")_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "ben", "code_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "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 ", " _", "success_", "=_", "False_", "\\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 ", " _", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "delete", "Torrent", "Data_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "success_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "Torrent", "Data_", "(_", "self_", ",_", "t_", ")_", ":_", "\\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 ", " _", "os_", "._", "remove_", "(_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "datac", "ache_", ",_", "to", "hex_", "(_", "t_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", " ", "INITIAL", "IZA", "TIO", "N", " ", "TASK", "S", " ", "######", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "Old", "Cache", "Data_", "(_", "self_", ",_", "days_", ",_", "still", "\\u", "active_", "=_", "[_", "]_", ",_", "delete", "\\u", "torrents", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "days_", ":_", "\\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_", "expt", "ime_", "=_", "time_", "(_", ")_", "-_", "(_", "days_", "*_", "24_", "*_", "3600_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "names_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "self_", "._", "dir\\u", "torr", "ent", "cache_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "torr", "ent", "cache_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", ",_", "gar", "bage", "_", "=_", "f_", "._", "split_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "unh", "ex_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "f_", ")_", "==_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "delete", "\\u", "torrents", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "names_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "os_", "._", "path_", "._", "getmtime_", "(_", "p_", ")_", "\\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_", "=_", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "self_", "._", "dir\\u", "datac", "ache_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "datac", "ache_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "unh", "ex_", "(_", "os_", "._", "path_", "._", "basename_", "(_", "f_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "f_", ")_", "==_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "names_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "os_", "._", "path_", "._", "getmtime_", "(_", "p_", ")_", "\\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_", "=_", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "self_", "._", "dir\\u", "piece", "cache_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "dir\\u", "piece", "cache_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "unh", "ex_", "(_", "os_", "._", "path_", "._", "basename_", "(_", "f_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "f_", ")_", "==_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "f2_", "in_", "os_", "._", "listdir_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p2_", "=_", "os_", "._", "path_", "._", "join_", "(_", "p_", ",_", "f2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "names_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "p2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "t_", "=_", "os_", "._", "path_", "._", "getmtime_", "(_", "p2_", ")_", "\\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_", "=_", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "names_", "._", "setdefault_", "(_", "f_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "times_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "max_", "(_", "v_", ")_", "<_", "expt", "ime_", "and_", "not_", "k_", "in_", "still", "\\u", "active_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "f_", "in_", "names_", "[_", "k_", "]_", ":_", "\\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 ", " ", " _", "os_", "._", "remove_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "remove", "dirs_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4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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, 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, 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, 0, 1, 1, 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 ]
Testing equality to None
wylieswanson/AgileCLU/bin/agilepostmp.py
[ { "content": "def progress_callback(param, current, total):\n\tglobal pbar\n\tif (pbar==None):\n\t\twidgets = [ unicode(fname, errors='ignore').encode('utf-8'), ' ', progressbar.FileTransferSpeed(), ' [', progressbar.Bar(), '] ', progressbar.Percentage(), ' ', progressbar.ETA() ]\n\t\tpbar = progressbar.ProgressBar(widgets=widgets, maxval=total).start()\n\ttry:\n\t\tpbar.update(current)\n\texcept AssertionError, e:\n\t\tprint e", "metadata": "root.progress_callback", "header": "['module', '___EOS___']", "index": 56 } ]
[ { "span": "pbar==None)", "start_line": 58, "start_column": 5, "end_line": 58, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "progress", "\\u", "callback_", "(_", "param_", ",_", "current_", ",_", "total_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "pbar_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "pbar_", "==_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "widgets_", "=_", "[_", "unicode_", "(_", "fname_", ",_", "errors_", "=_", "'", "ignore", "'_", ")_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", ",_", "'", " ", "'_", ",_", "progressbar_", "._", "File", "Transfer", "Speed_", "(_", ")_", ",_", "'", " ", "['_", ",_", "progressbar_", "._", "Bar_", "(_", ")_", ",_", "']", " ", "'_", ",_", "progressbar_", "._", "Percentage_", "(_", ")_", ",_", "'", " ", "'_", ",_", "progressbar_", "._", "ETA", "_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pbar_", "=_", "progressbar_", "._", "Progres", "s", "Bar_", "(_", "widgets_", "=_", "widgets_", ",_", "maxval_", "=_", "total_", ")_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "pbar_", "._", "update_", "(_", "current_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "print_", "e_", "\\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, 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 ]
Unused import
cztomczak/cefpython/cefpython/cef3/mac/binaries_32bit/wxpython.py
[ { "content": "# An example of embedding CEF browser in wxPython on Mac.\n# Tested with wxPython3.0-osx-3.0.2.0-cocoa-py2.7.dmg which\n# was downloaded from the wxpython.org website.\n\n# IMPORTANT - importing CEF Python\n# --------------------------------------------------------------\n# The cefpython library must be the very first library imported.\n# This is because CEF was compiled with the tcmalloc memory\n# allocator which hooks globally and replaces the default\n# malloc allocator. If memory was allocated using malloc and\n# then freed using tcmalloc then this would result in random\n# segmentation faults in an application. See Issue 155 which\n# is to provide CEF builds on Mac with tcmalloc disabled:\n# https://code.google.com/p/cefpython/issues/detail?id=155\n\nimport ctypes, os, sys\nlibcef_so = os.path.join(os.path.dirname(os.path.abspath(__file__)),\\\n 'libcef.dylib')\nif os.path.exists(libcef_so):\n # Import a local module\n ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL)\n if 0x02070000 <= sys.hexversion < 0x03000000:\n import cefpython_py27 as cefpython\n else:\n raise Exception(\"Unsupported python version: %s\" % sys.version)\nelse:\n # Import an installed package\n from cefpython3 import cefpython\n\nimport wx\nimport time\nimport re\nimport uuid\nimport platform\nimport inspect\nimport struct\n\ng_applicationSettings = None\ng_browserSettings = None\ng_switches = None\ng_countWindows = 0\n\n# Which method to use for message loop processing.\n# EVT_IDLE - wx application has priority (default)\n# EVT_TIMER - cef browser has priority\n# It seems that Flash content behaves better when using a timer.\n# IMPORTANT! On Linux EVT_IDLE does not work, the events seems to\n# be propagated only when you move your mouse, which is not the\n# expected behavior, it is recommended to use EVT_TIMER on Linux,\n# so set this value to False.\nUSE_EVT_IDLE = False\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n print('[wxpython.py] architecture=%s-bit' % (8 * struct.calcsize(\"P\")))\n print('[wxpython.py] wx.version=%s' % wx.version())\n\n # Intercept python exceptions. Exit app immediately when exception\n # happens on any of the threads.\n sys.excepthook = ExceptHook\n\n # Application settings\n g_applicationSettings = {\n # Disk cache\n # \"cache_path\": \"webcache/\",\n\n # CEF Python debug messages in console and in log_file\n \"debug\": True,\n # Set it to LOGSEVERITY_VERBOSE for more details\n \"log_severity\": cefpython.LOGSEVERITY_INFO,\n # Set to \"\" to disable logging to a file\n \"log_file\": GetApplicationPath(\"debug.log\"),\n # This should be enabled only when debugging\n \"release_dcheck_enabled\": True,\n\n # \"resources_dir_path\" must be set on Mac, \"locales_dir_path\" not.\n # You must also set \"locale_pak\" using command line switch.\n \"resources_dir_path\": cefpython.GetModuleDirectory()+\"/Resources\",\n # The \"subprocess\" executable that launches the Renderer\n # and GPU processes among others. You may rename that\n # executable if you like.\n \"browser_subprocess_path\": \"%s/%s\" % (\n cefpython.GetModuleDirectory(), \"subprocess\"),\n\n # This option is required for the GetCookieManager callback\n # to work. It affects renderer processes, when this option\n # is set to True. It will force a separate renderer process\n # for each browser created using CreateBrowserSync.\n \"unique_request_context_per_browser\": True,\n\n # Downloads are handled automatically. A default SaveAs file\n # dialog provided by OS will be displayed.\n \"downloads_enabled\": True,\n\n # Remote debugging port, required for Developer Tools support.\n # A value of 0 will generate a random port. To disable devtools\n # support set it to -1.\n \"remote_debugging_port\": 0,\n\n # Mouse context menu\n \"context_menu\": {\n \"enabled\": True,\n \"navigation\": True, # Back, Forward, Reload\n \"print\": True,\n \"view_source\": True,\n \"external_browser\": True, # Open in external browser\n \"devtools\": True, # Developer Tools\n },\n\n # See also OnCertificateError which allows you to ignore\n # certificate errors for specific websites.\n \"ignore_certificate_errors\": False,\n }\n\n # Browser settings. You may have different settings for each\n # browser, see the call to CreateBrowserSync.\n g_browserSettings = {\n # \"plugins_disabled\": True,\n # \"file_access_from_file_urls_allowed\": True,\n # \"universal_access_from_file_urls_allowed\": True,\n }\n\n # Command line switches set programmatically\n g_switches = {\n # On Mac it is required to provide path to a specific\n # locale.pak file. On Win/Linux you only specify the\n # ApplicationSettings.locales_dir_path option.\n \"locale_pak\": cefpython.GetModuleDirectory()\n +\"/Resources/en.lproj/locale.pak\",\n\n # \"proxy-server\": \"socks5://127.0.0.1:8888\",\n # \"no-proxy-server\": \"\",\n # \"enable-media-stream\": \"\",\n # \"remote-debugging-port\": \"12345\",\n # \"disable-gpu\": \"\",\n # \"--invalid-switch\": \"\" -> Invalid switch name\n }\n\n cefpython.Initialize(g_applicationSettings, g_switches)\n\n app = MyApp(False)\n app.MainLoop()\n\n # Let wx.App destructor do the cleanup before calling\n # cefpython.Shutdown(). This is to ensure reliable CEF shutdown.\n del app\n\n # On Mac cefpython.Shutdown() is called in MainFrame.OnClose,\n # followed by wx.GetApp.Exit().\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def GetApplicationPath(file=None):\n import re, os, platform\n # On Windows after downloading file and calling Browser.GoForward(),\n # current working directory is set to %UserProfile%.\n # Calling os.path.dirname(os.path.realpath(__file__))\n # returns for eg. \"C:\\Users\\user\\Downloads\". A solution\n # is to cache path on first call.\n if not hasattr(GetApplicationPath, \"dir\"):\n if hasattr(sys, \"frozen\"):\n dir = os.path.dirname(sys.executable)\n elif \"__file__\" in globals():\n dir = os.path.dirname(os.path.realpath(__file__))\n else:\n dir = os.getcwd()\n GetApplicationPath.dir = dir\n # If file is None return current directory without trailing slash.\n if file is None:\n file = \"\"\n # Only when relative path.\n if not file.startswith(\"/\") and not file.startswith(\"\\\\\") and (\n not re.search(r\"^[\\w-]+:\", file)):\n path = GetApplicationPath.dir + os.sep + file\n if platform.system() == \"Windows\":\n path = re.sub(r\"[/\\\\]+\", re.escape(os.sep), path)\n path = re.sub(r\"[/\\\\]+$\", \"\", path)\n return path\n return str(file)", "metadata": "root.GetApplicationPath", "header": "['module', '___EOS___']", "index": 52 }, { "content": "def ExceptHook(excType, excValue, traceObject):\n import traceback, os, time, codecs\n # This hook does the following: in case of exception write it to\n # the \"error.log\" file, display it to the console, shutdown CEF\n # and exit application immediately by ignoring \"finally\" (os._exit()).\n errorMsg = \"\\n\".join(traceback.format_exception(excType, excValue,\n traceObject))\n errorFile = GetApplicationPath(\"error.log\")\n try:\n appEncoding = cefpython.g_applicationSettings[\"string_encoding\"]\n except:\n appEncoding = \"utf-8\"\n if type(errorMsg) == bytes:\n errorMsg = errorMsg.decode(encoding=appEncoding, errors=\"replace\")\n try:\n with codecs.open(errorFile, mode=\"a\", encoding=appEncoding) as fp:\n fp.write(\"\\n[%s] %s\\n\" % (\n time.strftime(\"%Y-%m-%d %H:%M:%S\"), errorMsg))\n except:\n print(\"[wxpython.py] WARNING: failed writing to error file: %s\" % (\n errorFile))\n # Convert error message to ascii before printing, otherwise\n # you may get error like this:\n # | UnicodeEncodeError: 'charmap' codec can't encode characters\n errorMsg = errorMsg.encode(\"ascii\", errors=\"replace\")\n errorMsg = errorMsg.decode(\"ascii\", errors=\"replace\")\n print(\"\\n\"+errorMsg+\"\\n\")\n cefpython.QuitMessageLoop()\n cefpython.Shutdown()\n os._exit(1)", "metadata": "root.ExceptHook", "header": "['module', '___EOS___']", "index": 80 }, { "content": "class MainFrame(wx.Frame):\n browser = None\n mainPanel = None\n clientHandler = None\n javascriptExternal = None\n\n\n\n", "metadata": "root.MainFrame", "header": "['module', '___EOS___']", "index": 111 }, { "content": " def __init__(self, url=None):\n wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,\n title='wxPython CEF 3 example', size=(800,600))\n\n global g_countWindows\n g_countWindows += 1\n\n if not url:\n url = \"file://\"+GetApplicationPath(\"wxpython.html\")\n # Test hash in url.\n # url += \"#test-hash\"\n\n self.CreateMenu()\n\n # Cannot attach browser to the main frame as this will cause\n # the menu not to work.\n # --\n # You also have to set the wx.WANTS_CHARS style for\n # all parent panels/controls, if it's deeply embedded.\n self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)\n\n # Global client callbacks must be set before browser is created.\n self.clientHandler = ClientHandler()\n cefpython.SetGlobalClientCallback(\"OnCertificateError\",\n self.clientHandler._OnCertificateError)\n cefpython.SetGlobalClientCallback(\"OnBeforePluginLoad\",\n self.clientHandler._OnBeforePluginLoad)\n cefpython.SetGlobalClientCallback(\"OnAfterCreated\",\n self.clientHandler._OnAfterCreated)\n\n windowInfo = cefpython.WindowInfo()\n (width, height) = self.mainPanel.GetClientSizeTuple()\n windowInfo.SetAsChild(self.mainPanel.GetHandle(),\n [0, 0, width, height])\n # Linux requires adding \"file://\" for local files,\n # otherwise /home/some will be replaced as http://home/some\n self.browser = cefpython.CreateBrowserSync(\n windowInfo,\n # If there are problems with Flash you can disable it here,\n # by disabling all plugins.\n browserSettings=g_browserSettings,\n navigateUrl=url)\n\n self.clientHandler.mainBrowser = self.browser\n self.browser.SetClientHandler(self.clientHandler)\n\n jsBindings = cefpython.JavascriptBindings(\n bindToFrames=False, bindToPopups=True)\n jsBindings.SetFunction(\"PyPrint\", PyPrint)\n jsBindings.SetProperty(\"pyProperty\", \"This was set in Python\")\n jsBindings.SetProperty(\"pyConfig\", [\"This was set in Python\",\n {\"name\": \"Nested dictionary\", \"isNested\": True},\n [1,\"2\", None]])\n self.javascriptExternal = JavascriptExternal(self.browser)\n jsBindings.SetObject(\"external\", self.javascriptExternal)\n jsBindings.SetProperty(\"sources\", GetSources())\n self.browser.SetJavascriptBindings(jsBindings)\n\n self.Bind(wx.EVT_CLOSE, self.OnClose)\n if USE_EVT_IDLE:\n # Bind EVT_IDLE only for the main application frame.\n self.Bind(wx.EVT_IDLE, self.OnIdle)", "metadata": "root.MainFrame.__init__", "header": "['class', 'MainFrame', '(', 'wx', '.', 'Frame', ')', ':', '___EOS___']", "index": 117 }, { "content": " def CreateMenu(self):\n filemenu = wx.Menu()\n filemenu.Append(1, \"Open\")\n exit = filemenu.Append(2, \"Exit\")\n self.Bind(wx.EVT_MENU, self.OnClose, exit)\n aboutmenu = wx.Menu()\n aboutmenu.Append(1, \"CEF Python\")\n menubar = wx.MenuBar()\n menubar.Append(filemenu,\"&File\")\n menubar.Append(aboutmenu, \"&About\")\n self.SetMenuBar(menubar)", "metadata": "root.MainFrame.CreateMenu", "header": "['class', 'MainFrame', '(', 'wx', '.', 'Frame', ')', ':', '___EOS___']", "index": 180 }, { "content": " def OnClose(self, event):\n # Remove all CEF browser references so that browser is closed\n # cleanly. Otherwise there may be issues for example with cookies\n # not being flushed to disk when closing app immediately\n # (Issue 158).\n del self.javascriptExternal.mainBrowser\n del self.clientHandler.mainBrowser\n del self.browser\n\n # Destroy wx frame, this will complete the destruction of CEF browser\n self.Destroy()\n\n # In wx.chromectrl calling browser.CloseBrowser and/or self.Destroy\n # may cause crashes when embedding multiple browsers in tab\n # (Issue 107). In such case instead of calling CloseBrowser/Destroy\n # try this code:\n # | self.browser.ParentWindowWillClose()\n # | event.Skip()\n\n global g_countWindows\n g_countWindows -= 1\n if g_countWindows == 0:\n # On Win/Linux the call to cefpython.Shutdown() is after\n # app.MainLoop() returns, but on Mac it needs to be here.\n cefpython.Shutdown()\n print(\"[wxpython.py] OnClose: Exiting\")\n wx.GetApp().Exit()", "metadata": "root.MainFrame.OnClose", "header": "['class', 'MainFrame', '(', 'wx', '.', 'Frame', ')', ':', '___EOS___']", "index": 192 }, { "content": " def OnIdle(self, event):\n cefpython.MessageLoopWork()", "metadata": "root.MainFrame.OnIdle", "header": "['class', 'MainFrame', '(', 'wx', '.', 'Frame', ')', ':', '___EOS___']", "index": 220 }, { "content": "def PyPrint(message):\n print(\"[wxpython.py] PyPrint: \"+message)", "metadata": "root.PyPrint", "header": "['module', '___EOS___']", "index": 223 }, { "content": "class JavascriptExternal:\n mainBrowser = None\n stringVisitor = None\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n # -------------------------------------------------------------------------\n # Cookies\n # -------------------------------------------------------------------------\n cookieVisitor = None\n\n\n\n", "metadata": "root.JavascriptExternal", "header": "['module', '___EOS___']", "index": 226 }, { "content": " def __init__(self, mainBrowser):\n self.mainBrowser = mainBrowser", "metadata": "root.JavascriptExternal.__init__", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 230 }, { "content": " def GoBack(self):\n self.mainBrowser.GoBack()", "metadata": "root.JavascriptExternal.GoBack", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 233 }, { "content": " def GoForward(self):\n self.mainBrowser.GoForward()", "metadata": "root.JavascriptExternal.GoForward", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 236 }, { "content": " def CreateAnotherBrowser(self, url=None):\n \"\"\"\n TODO: There are errors in the console when closing the window:\n >> Check failed: window\n >> Gdk: _gdk_window_destroy_hierarchy: assertion `GDK_IS_WINDOW\\\n >> (window)' failed\n >> GLib-GObject: g_object_unref: assertion `G_IS_OBJECT (object)' failed\n \"\"\"\n frame = MainFrame(url=url)\n frame.Show()", "metadata": "root.JavascriptExternal.CreateAnotherBrowser", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 239 }, { "content": " def Print(self, message):\n print(\"[wxpython.py] Print: \"+message)", "metadata": "root.JavascriptExternal.Print", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 250 }, { "content": " def TestAllTypes(self, *args):\n print(\"[wxpython.py] TestAllTypes: \"+str(args))", "metadata": "root.JavascriptExternal.TestAllTypes", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 253 }, { "content": " def ExecuteFunction(self, *args):\n self.mainBrowser.GetMainFrame().ExecuteFunction(*args)", "metadata": "root.JavascriptExternal.ExecuteFunction", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 256 }, { "content": " def TestJSCallback(self, jsCallback):\n print(\"[wxpython.py] jsCallback.GetFunctionName() = %s\"\\\n % jsCallback.GetFunctionName())\n print(\"[wxpython.py] jsCallback.GetFrame().GetIdentifier() = %s\" % \\\n jsCallback.GetFrame().GetIdentifier())\n jsCallback.Call(\"This message was sent from python using js callback\")", "metadata": "root.JavascriptExternal.TestJSCallback", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 259 }, { "content": " def TestJSCallbackComplexArguments(self, jsObject):\n jsCallback = jsObject[\"myCallback\"];\n jsCallback.Call(1, None, 2.14, \"string\", [\"list\", [\"nested list\", \\\n {\"nested object\":None}]], \\\n {\"nested list next\":[{\"deeply nested object\":1}]})", "metadata": "root.JavascriptExternal.TestJSCallbackComplexArguments", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 266 }, { "content": " def TestPythonCallback(self, jsCallback):\n jsCallback.Call(self.PyCallback)", "metadata": "root.JavascriptExternal.TestPythonCallback", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 272 }, { "content": " def PyCallback(self, *args):\n message = \"PyCallback() was executed successfully! \"\\\n \"Arguments: %s\" % str(args)\n print(\"[wxpython.py] \"+message)\n self.mainBrowser.GetMainFrame().ExecuteJavascript(\n \"window.alert(\\\"%s\\\")\" % message)", "metadata": "root.JavascriptExternal.PyCallback", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 275 }, { "content": " def GetSource(self):\n # Must keep a strong reference to the StringVisitor object\n # during the visit.\n self.stringVisitor = StringVisitor()\n self.mainBrowser.GetMainFrame().GetSource(self.stringVisitor)", "metadata": "root.JavascriptExternal.GetSource", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 282 }, { "content": " def GetText(self):\n # Must keep a strong reference to the StringVisitor object\n # during the visit.\n self.stringVisitor = StringVisitor()\n self.mainBrowser.GetMainFrame().GetText(self.stringVisitor)", "metadata": "root.JavascriptExternal.GetText", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 288 }, { "content": " def ShowDevTools(self):\n print(\"[wxpython.py] external.ShowDevTools called\")\n self.mainBrowser.ShowDevTools()", "metadata": "root.JavascriptExternal.ShowDevTools", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 294 }, { "content": " def VisitAllCookies(self):\n # Need to keep the reference alive.\n self.cookieVisitor = CookieVisitor()\n cookieManager = self.mainBrowser.GetUserData(\"cookieManager\")\n if not cookieManager:\n print(\"\\n[wxpython.py] Cookie manager not yet created! Visit\"\\\n \" the cookietester website first and create some cookies\")\n return\n cookieManager.VisitAllCookies(self.cookieVisitor)", "metadata": "root.JavascriptExternal.VisitAllCookies", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 303 }, { "content": " def VisitUrlCookies(self):\n # Need to keep the reference alive.\n self.cookieVisitor = CookieVisitor()\n cookieManager = self.mainBrowser.GetUserData(\"cookieManager\")\n if not cookieManager:\n print(\"\\n[wxpython.py] Cookie manager not yet created! Visit\"\\\n \" the cookietester website first and create some cookies\")\n return\n cookieManager.VisitUrlCookies(\n \"http://www.html-kit.com/tools/cookietester/\",\n False, self.cookieVisitor)\n # .www.html-kit.com", "metadata": "root.JavascriptExternal.VisitUrlCookies", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 313 }, { "content": " def SetCookie(self):\n cookieManager = self.mainBrowser.GetUserData(\"cookieManager\")\n if not cookieManager:\n print(\"\\n[wxpython.py] Cookie manager not yet created! Visit\"\\\n \"the cookietester website first and create some cookies\")\n return\n cookie = cefpython.Cookie()\n cookie.SetName(\"Created_Via_Python\")\n cookie.SetValue(\"yeah really\")\n cookieManager.SetCookie(\"http://www.html-kit.com/tools/cookietester/\",\n cookie)\n print(\"\\n[wxpython.py] Cookie created! Visit html-kit cookietester to\"\\\n \" see it\")", "metadata": "root.JavascriptExternal.SetCookie", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 326 }, { "content": " def DeleteCookies(self):\n cookieManager = self.mainBrowser.GetUserData(\"cookieManager\")\n if not cookieManager:\n print(\"\\n[wxpython.py] Cookie manager not yet created! Visit\"\\\n \" the cookietester website first and create some cookies\")\n return\n cookieManager.DeleteCookies(\n \"http://www.html-kit.com/tools/cookietester/\",\n \"Created_Via_Python\")\n print(\"\\n[wxpython.py] Cookie deleted! Visit html-kit cookietester \"\\\n \"to see the result\")", "metadata": "root.JavascriptExternal.DeleteCookies", "header": "['class', 'JavascriptExternal', ':', '___EOS___']", "index": 340 }, { "content": "class StringVisitor:", "metadata": "root.StringVisitor", "header": "['module', '___EOS___']", "index": 352 }, { "content": " def Visit(self, string):\n print(\"\\n[wxpython.py] StringVisitor.Visit(): string:\")\n print(\"--------------------------------\")\n print(string)\n print(\"--------------------------------\")", "metadata": "root.StringVisitor.Visit", "header": "['class', 'StringVisitor', ':', '___EOS___']", "index": 353 }, { "content": "class CookieVisitor:", "metadata": "root.CookieVisitor", "header": "['module', '___EOS___']", "index": 359 }, { "content": " def Visit(self, cookie, count, total, deleteCookie):\n if count == 0:\n print(\"\\n[wxpython.py] CookieVisitor.Visit(): total cookies: %s\"\\\n % total)\n print(\"\\n[wxpython.py] CookieVisitor.Visit(): cookie:\")\n print(\" \"+str(cookie.Get()))\n # True to continue visiting cookies\n return True", "metadata": "root.CookieVisitor.Visit", "header": "['class', 'CookieVisitor', ':', '___EOS___']", "index": 360 }, { "content": "class ClientHandler:\n mainBrowser = None # May be None for global client callbacks.\n\n\n # -------------------------------------------------------------------------\n # DisplayHandler\n # -------------------------------------------------------------------------\n\n\n\n\n statusMessageCount = 0\n\n\n # -------------------------------------------------------------------------\n # KeyboardHandler\n # -------------------------------------------------------------------------\n\n\n\n # -------------------------------------------------------------------------\n # RequestHandler\n # -------------------------------------------------------------------------\n\n\n\n\n\n\n\n\n\n\n\n\n # -------------------------------------------------------------------------\n # LoadHandler\n # -------------------------------------------------------------------------\n\n\n\n\n\n\n # -------------------------------------------------------------------------\n # LifespanHandler\n # -------------------------------------------------------------------------\n\n # ** This callback is executed on the IO thread **\n # Empty place-holders: popupFeatures, client.\n\n\n\n\n\n # -------------------------------------------------------------------------\n # JavascriptDialogHandler\n # -------------------------------------------------------------------------\n\n\n\n", "metadata": "root.ClientHandler", "header": "['module', '___EOS___']", "index": 369 }, { "content": " def __init__(self):\n pass", "metadata": "root.ClientHandler.__init__", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 372 }, { "content": " def OnAddressChange(self, browser, frame, url):\n print(\"[wxpython.py] DisplayHandler::OnAddressChange()\")\n print(\" url = %s\" % url)", "metadata": "root.ClientHandler.OnAddressChange", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 379 }, { "content": " def OnTitleChange(self, browser, title):\n print(\"[wxpython.py] DisplayHandler::OnTitleChange()\")\n print(\" title = %s\" % title)", "metadata": "root.ClientHandler.OnTitleChange", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 383 }, { "content": " def OnTooltip(self, browser, textOut):\n # OnTooltip not yet implemented (both Linux and Windows),\n # will be fixed in next CEF release, see Issue 783:\n # https://code.google.com/p/chromiumembedded/issues/detail?id=783\n print(\"[wxpython.py] DisplayHandler::OnTooltip()\")\n print(\" text = %s\" % textOut[0])", "metadata": "root.ClientHandler.OnTooltip", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 387 }, { "content": " def OnStatusMessage(self, browser, value):\n if not value:\n # Do not notify in the console about empty statuses.\n return\n self.statusMessageCount += 1\n if self.statusMessageCount > 3:\n # Do not spam too much.\n return\n print(\"[wxpython.py] DisplayHandler::OnStatusMessage()\")\n print(\" value = %s\" % value)", "metadata": "root.ClientHandler.OnStatusMessage", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 395 }, { "content": " def OnConsoleMessage(self, browser, message, source, line):\n print(\"[wxpython.py] DisplayHandler::OnConsoleMessage()\")\n print(\" message = %s\" % message)\n print(\" source = %s\" % source)\n print(\" line = %s\" % line)", "metadata": "root.ClientHandler.OnConsoleMessage", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 406 }, { "content": " def OnPreKeyEvent(self, browser, event, eventHandle,\n isKeyboardShortcutOut):\n print(\"[wxpython.py] KeyboardHandler::OnPreKeyEvent()\")", "metadata": "root.ClientHandler.OnPreKeyEvent", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 416 }, { "content": " def OnKeyEvent(self, browser, event, eventHandle):\n if event[\"type\"] == cefpython.KEYEVENT_KEYUP:\n # OnKeyEvent is called twice for F5/Esc keys, with event\n # type KEYEVENT_RAWKEYDOWN and KEYEVENT_KEYUP.\n # Normal characters a-z should have KEYEVENT_CHAR.\n return False\n print(\"[wxpython.py] KeyboardHandler::OnKeyEvent()\")\n print(\" type=%s\" % event[\"type\"])\n print(\" modifiers=%s\" % event[\"modifiers\"])\n print(\" windows_key_code=%s\" % event[\"windows_key_code\"])\n print(\" native_key_code=%s\" % event[\"native_key_code\"])\n print(\" is_system_key=%s\" % event[\"is_system_key\"])\n print(\" character=%s\" % event[\"character\"])\n print(\" unmodified_character=%s\" % event[\"unmodified_character\"])\n print(\" focus_on_editable_field=%s\"\\\n % event[\"focus_on_editable_field\"])\n if platform.system() == \"Linux\":\n # F5\n if event[\"native_key_code\"] == 71:\n print(\"[wxpython.py] F5 pressed, calling\"\\\n \" browser.ReloadIgnoreCache()\")\n browser.ReloadIgnoreCache()\n return True\n # Escape\n if event[\"native_key_code\"] == 9:\n print(\"[wxpython.py] Esc pressed, calling browser.StopLoad()\")\n browser.StopLoad()\n return True\n # F12\n if event[\"native_key_code\"] == 96:\n print(\"[wxpython.py] F12 pressed, calling\"\\\n \" browser.ShowDevTools()\")\n browser.ShowDevTools()\n return True\n elif platform.system() == \"Windows\":\n # F5 todo\n # Escape todo\n pass\n elif platform.system() == \"Darwin\":\n # Cmd+Opt+I\n if event[\"modifiers\"] == 136 and event[\"character\"] == 94:\n browser.ShowDevTools()\n return True\n # F5\n if event[\"modifiers\"] == 0 and event[\"character\"] == 63240:\n browser.ReloadIgnoreCache()\n return True\n # Esc\n if event[\"modifiers\"] == 0 and event[\"character\"] == 27:\n browser.StopLoad()\n return True\n return False", "metadata": "root.ClientHandler.OnKeyEvent", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 420 }, { "content": " def OnBeforeBrowse(self, browser, frame, request, isRedirect):\n print(\"[wxpython.py] RequestHandler::OnBeforeBrowse()\")\n print(\" url = %s\" % request.GetUrl()[:100])\n return False", "metadata": "root.ClientHandler.OnBeforeBrowse", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 477 }, { "content": " def OnBeforeResourceLoad(self, browser, frame, request):\n print(\"[wxpython.py] RequestHandler::OnBeforeResourceLoad()\")\n print(\" url = %s\" % request.GetUrl()[:100])\n return False", "metadata": "root.ClientHandler.OnBeforeResourceLoad", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 482 }, { "content": " def OnResourceRedirect(self, browser, frame, oldUrl, newUrlOut):\n print(\"[wxpython.py] RequestHandler::OnResourceRedirect()\")\n print(\" old url = %s\" % oldUrl[:100])\n print(\" new url = %s\" % newUrlOut[0][:100])", "metadata": "root.ClientHandler.OnResourceRedirect", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 487 }, { "content": " def GetAuthCredentials(self, browser, frame, isProxy, host, port, realm,\n scheme, callback):\n # This callback is called on the IO thread, thus print messages\n # may not be visible.\n print(\"[wxpython.py] RequestHandler::GetAuthCredentials()\")\n print(\" host = %s\" % host)\n print(\" realm = %s\" % realm)\n callback.Continue(username=\"test\", password=\"test\")\n return True", "metadata": "root.ClientHandler.GetAuthCredentials", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 492 }, { "content": " def OnQuotaRequest(self, browser, originUrl, newSize, callback):\n print(\"[wxpython.py] RequestHandler::OnQuotaRequest()\")\n print(\" origin url = %s\" % originUrl)\n print(\" new size = %s\" % newSize)\n callback.Continue(True)\n return True", "metadata": "root.ClientHandler.OnQuotaRequest", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 502 }, { "content": " def GetCookieManager(self, browser, mainUrl):\n # Create unique cookie manager for each browser.\n # You must set the \"unique_request_context_per_browser\"\n # application setting to True for the cookie manager\n # to work.\n # Return None to have one global cookie manager for\n # all CEF browsers.\n if not browser:\n # The browser param may be empty in some exceptional\n # case, see docs.\n return None\n cookieManager = browser.GetUserData(\"cookieManager\")\n if cookieManager:\n return cookieManager\n else:\n print(\"[wxpython.py] RequestHandler::GetCookieManager():\"\\\n \" created cookie manager\")\n cookieManager = cefpython.CookieManager.CreateManager(\"\")\n if \"cache_path\" in g_applicationSettings:\n path = g_applicationSettings[\"cache_path\"]\n # path = os.path.join(path, \"cookies_browser_{}\".format(\n # browser.GetIdentifier()))\n cookieManager.SetStoragePath(path)\n browser.SetUserData(\"cookieManager\", cookieManager)\n return cookieManager", "metadata": "root.ClientHandler.GetCookieManager", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 509 }, { "content": " def OnProtocolExecution(self, browser, url, allowExecutionOut):\n # There's no default implementation for OnProtocolExecution on Linux,\n # you have to make OS system call on your own. You probably also need\n # to use LoadHandler::OnLoadError() when implementing this on Linux.\n print(\"[wxpython.py] RequestHandler::OnProtocolExecution()\")\n print(\" url = %s\" % url)\n if url.startswith(\"magnet:\"):\n print(\"[wxpython.py] Magnet link allowed!\")\n allowExecutionOut[0] = True", "metadata": "root.ClientHandler.OnProtocolExecution", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 535 }, { "content": " def _OnBeforePluginLoad(self, browser, url, policyUrl, info):\n # This is a global callback set using SetGlobalClientCallback().\n # Plugins are loaded on demand, only when website requires it,\n # the same plugin may be called multiple times.\n # This callback is called on the IO thread, thus print messages\n # may not be visible.\n print(\"[wxpython.py] RequestHandler::_OnBeforePluginLoad()\")\n print(\" url = %s\" % url)\n print(\" policy url = %s\" % policyUrl)\n print(\" info.GetName() = %s\" % info.GetName())\n print(\" info.GetPath() = %s\" % info.GetPath())\n print(\" info.GetVersion() = %s\" % info.GetVersion())\n print(\" info.GetDescription() = %s\" % info.GetDescription())\n # False to allow, True to block plugin.\n return False", "metadata": "root.ClientHandler._OnBeforePluginLoad", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 545 }, { "content": " def _OnCertificateError(self, certError, requestUrl, callback):\n # This is a global callback set using SetGlobalClientCallback().\n print(\"[wxpython.py] RequestHandler::_OnCertificateError()\")\n print(\" certError = %s\" % certError)\n print(\" requestUrl = %s\" % requestUrl)\n if requestUrl.startswith(\n \"https://tv.eurosport.com/do-not-allow\"):\n print(\" Not allowed!\")\n return False\n if requestUrl.startswith(\n \"https://tv.eurosport.com/\"):\n print(\" Allowed!\")\n callback.Continue(True)\n return True\n return False", "metadata": "root.ClientHandler._OnCertificateError", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 561 }, { "content": " def OnRendererProcessTerminated(self, browser, status):\n print(\"[wxpython.py] RequestHandler::OnRendererProcessTerminated()\")\n statuses = {\n cefpython.TS_ABNORMAL_TERMINATION: \"TS_ABNORMAL_TERMINATION\",\n cefpython.TS_PROCESS_WAS_KILLED: \"TS_PROCESS_WAS_KILLED\",\n cefpython.TS_PROCESS_CRASHED: \"TS_PROCESS_CRASHED\"\n }\n statusName = \"Unknown\"\n if status in statuses:\n statusName = statuses[status]\n print(\" status = %s\" % statusName)", "metadata": "root.ClientHandler.OnRendererProcessTerminated", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 577 }, { "content": " def OnPluginCrashed(self, browser, pluginPath):\n print(\"[wxpython.py] RequestHandler::OnPluginCrashed()\")\n print(\" plugin path = %s\" % pluginPath)", "metadata": "root.ClientHandler.OnPluginCrashed", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 589 }, { "content": " def OnLoadingStateChange(self, browser, isLoading, canGoBack,\n canGoForward):\n print(\"[wxpython.py] LoadHandler::OnLoadingStateChange()\")\n print(\" isLoading = %s, canGoBack = %s, canGoForward = %s\" \\\n % (isLoading, canGoBack, canGoForward))", "metadata": "root.ClientHandler.OnLoadingStateChange", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 597 }, { "content": " def OnLoadStart(self, browser, frame):\n print(\"[wxpython.py] LoadHandler::OnLoadStart()\")\n print(\" frame url = %s\" % frame.GetUrl()[:100])", "metadata": "root.ClientHandler.OnLoadStart", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 603 }, { "content": " def OnLoadEnd(self, browser, frame, httpStatusCode):\n print(\"[wxpython.py] LoadHandler::OnLoadEnd()\")\n print(\" frame url = %s\" % frame.GetUrl()[:100])\n # For file:// urls the status code = 0\n print(\" http status code = %s\" % httpStatusCode)\n # Tests for the Browser object methods\n self._Browser_LoadUrl(browser)", "metadata": "root.ClientHandler.OnLoadEnd", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 607 }, { "content": " def _Browser_LoadUrl(self, browser):\n if browser.GetUrl() == \"data:text/html,Test#Browser.LoadUrl\":\n browser.LoadUrl(\"file://\"+GetApplicationPath(\"wxpython.html\"))", "metadata": "root.ClientHandler._Browser_LoadUrl", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 615 }, { "content": " def OnLoadError(self, browser, frame, errorCode, errorTextList, failedUrl):\n print(\"[wxpython.py] LoadHandler::OnLoadError()\")\n print(\" frame url = %s\" % frame.GetUrl()[:100])\n print(\" error code = %s\" % errorCode)\n print(\" error text = %s\" % errorTextList[0])\n print(\" failed url = %s\" % failedUrl)\n # Handle ERR_ABORTED error code, to handle the following cases:\n # 1. Esc key was pressed which calls browser.StopLoad() in OnKeyEvent\n # 2. Download of a file was aborted\n if errorCode == cefpython.ERR_ABORTED:\n print(\"[wxpython.py] LoadHandler::OnLoadError(): Ignoring load\"\\\n \" error: Esc was pressed or file download was aborted\")\n return;\n customErrorMessage = \"My custom error message!\"\n frame.LoadUrl(\"data:text/html,%s\" % customErrorMessage)", "metadata": "root.ClientHandler.OnLoadError", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 619 }, { "content": " def OnBeforePopup(self, browser, frame, targetUrl, targetFrameName,\\\n popupFeatures, windowInfo, client, browserSettings,\\\n noJavascriptAccess):\n print(\"[wxpython.py] LifespanHandler::OnBeforePopup()\")\n print(\" targetUrl = %s\" % targetUrl)\n # Custom browser settings for popups:\n # > browserSettings[0] = {\"plugins_disabled\": True}\n # Set WindowInfo object:\n # > windowInfo[0] = cefpython.WindowInfo()\n allowPopups = True\n return not allowPopups", "metadata": "root.ClientHandler.OnBeforePopup", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 641 }, { "content": " def _OnAfterCreated(self, browser):\n # This is a global callback set using SetGlobalClientCallback().\n print(\"[wxpython.py] LifespanHandler::_OnAfterCreated()\")\n print(\" browserId=%s\" % browser.GetIdentifier())", "metadata": "root.ClientHandler._OnAfterCreated", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 653 }, { "content": " def RunModal(self, browser):\n print(\"[wxpython.py] LifespanHandler::RunModal()\")\n print(\" browserId=%s\" % browser.GetIdentifier())", "metadata": "root.ClientHandler.RunModal", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 658 }, { "content": " def DoClose(self, browser):\n print(\"[wxpython.py] LifespanHandler::DoClose()\")\n print(\" browserId=%s\" % browser.GetIdentifier())", "metadata": "root.ClientHandler.DoClose", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 662 }, { "content": " def OnBeforeClose(self, browser):\n print(\"[wxpython.py] LifespanHandler::OnBeforeClose\")\n print(\" browserId=%s\" % browser.GetIdentifier())", "metadata": "root.ClientHandler.OnBeforeClose", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 666 }, { "content": " def OnJavascriptDialog(self, browser, originUrl, acceptLang, dialogType,\n messageText, defaultPromptText, callback,\n suppressMessage):\n print(\"[wxpython.py] JavascriptDialogHandler::OnJavascriptDialog()\")\n print(\" originUrl=\"+originUrl)\n print(\" acceptLang=\"+acceptLang)\n print(\" dialogType=\"+str(dialogType))\n print(\" messageText=\"+messageText)\n print(\" defaultPromptText=\"+defaultPromptText)\n # If you want to suppress the javascript dialog:\n # suppressMessage[0] = True\n return False", "metadata": "root.ClientHandler.OnJavascriptDialog", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 674 }, { "content": " def OnBeforeUnloadJavascriptDialog(self, browser, messageText, isReload,\n callback):\n print(\"[wxpython.py] OnBeforeUnloadJavascriptDialog()\")\n print(\" messageText=\"+messageText)\n print(\" isReload=\"+str(isReload))\n # Return True if the application will use a custom dialog:\n # callback.Continue(allow=True, userInput=\"\")\n # return True\n return False", "metadata": "root.ClientHandler.OnBeforeUnloadJavascriptDialog", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 687 }, { "content": " def OnResetJavascriptDialogState(self, browser):\n print(\"[wxpython.py] OnResetDialogState()\")", "metadata": "root.ClientHandler.OnResetJavascriptDialogState", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 697 }, { "content": " def OnJavascriptDialogClosed(self, browser):\n print(\"[wxpython.py] OnDialogClosed()\")", "metadata": "root.ClientHandler.OnJavascriptDialogClosed", "header": "['class', 'ClientHandler', ':', '___EOS___']", "index": 700 }, { "content": "class MyApp(wx.App):\n timer = None\n timerID = 1\n timerCount = 0\n\n\n\n", "metadata": "root.MyApp", "header": "['module', '___EOS___']", "index": 704 }, { "content": " def OnInit(self):\n if not USE_EVT_IDLE:\n self.CreateTimer()\n frame = MainFrame()\n self.SetTopWindow(frame)\n frame.Show()\n return True", "metadata": "root.MyApp.OnInit", "header": "['class', 'MyApp', '(', 'wx', '.', 'App', ')', ':', '___EOS___']", "index": 709 }, { "content": " def CreateTimer(self):\n # See \"Making a render loop\":\n # http://wiki.wxwidgets.org/Making_a_render_loop\n # Another approach is to use EVT_IDLE in MainFrame,\n # see which one fits you better.\n self.timer = wx.Timer(self, self.timerID)\n self.timer.Start(10) # 10ms\n wx.EVT_TIMER(self, self.timerID, self.OnTimer)", "metadata": "root.MyApp.CreateTimer", "header": "['class', 'MyApp', '(', 'wx', '.', 'App', ')', ':', '___EOS___']", "index": 717 }, { "content": " def OnTimer(self, event):\n self.timerCount += 1\n # print(\"[wxpython.py] OnTimer() %d\" % self.timerCount)\n cefpython.MessageLoopWork()", "metadata": "root.MyApp.OnTimer", "header": "['class', 'MyApp', '(', 'wx', '.', 'App', ')', ':', '___EOS___']", "index": 726 }, { "content": " def OnExit(self):\n # When app.MainLoop() returns, MessageLoopWork() should\n # not be called anymore.\n if not USE_EVT_IDLE:\n self.timer.Stop()", "metadata": "root.MyApp.OnExit", "header": "['class', 'MyApp', '(', 'wx', '.', 'App', ')', ':', '___EOS___']", "index": 731 }, { "content": "def GetSources():\n # Get sources of all python functions and methods from this file.\n # This is to provide sources preview to wxpython.html.\n # The dictionary of functions is binded to \"window.sources\".\n thisModule = sys.modules[__name__]\n functions = inspect.getmembers(thisModule, inspect.isfunction)\n classes = inspect.getmembers(thisModule, inspect.isclass)\n sources = {}\n for funcTuple in functions:\n sources[funcTuple[0]] = inspect.getsource(funcTuple[1])\n for classTuple in classes:\n className = classTuple[0]\n classObject = classTuple[1]\n methods = inspect.getmembers(classObject)\n for methodTuple in methods:\n try:\n sources[methodTuple[0]] = inspect.getsource(\\\n methodTuple[1])\n except:\n pass\n return sources", "metadata": "root.GetSources", "header": "['module', '___EOS___']", "index": 737 } ]
[ { "span": "import time", "start_line": 30, "start_column": 0, "end_line": 30, "end_column": 11 }, { "span": "import re", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 9 }, { "span": "import uuid", "start_line": 32, "start_column": 0, "end_line": 32, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "An", " ", "example", " ", "of", " ", "embed", "ding", " ", "CE", "F", " ", "browse", "r", " ", "in", " ", "wx", "Pyth", "on", " ", "on", " ", "Mac", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", "ed", " ", "with", " ", "wx", "Pyth", "on", "3.0", "-", "os", "x", "-", "3.0", ".2", ".0", "-", "coco", "a", "-", "py2", ".7", ".", "dmg", " ", "which_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "was", " ", "download", "ed", " ", "from", " ", "the", " ", "wx", "python", ".", "org", " ", "webs", "ite", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IMPORT", "ANT", " ", "-", " ", "import", "ing", " ", "CE", "F", " ", "Python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "cef", "python", " ", "librar", "y", " ", "must", " ", "be", " ", "the", " ", "very", " ", "first", " ", "librar", "y", " ", "import", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "bec", "aus", "e", " ", "CE", "F", " ", "was", " ", "compile", "d", " ", "with", " ", "the", " ", "tc", "malloc", " ", "memory_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "allocat", "or", " ", "whi", "ch", " ", "hook", "s", " ", "global", "ly", " ", "and", " ", "replace", "s", " ", "the", " ", "default_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "malloc", " ", "allocat", "or", ".", " ", "If", " ", "memory", " ", "was", " ", "allocated", " ", "usi", "ng", " ", "malloc", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "then", " ", "freed", " ", "usi", "ng", " ", "tc", "malloc", " ", "then", " ", "this", " ", "wou", "ld", " ", "result", " ", "in", " ", "random_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "segmentation", " ", "faults", " ", "in", " ", "an", " ", "applica", "tion", ".", " ", "See", " ", "Issue", " ", "155", " ", "which_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "to", " ", "provide", " ", "CE", "F", " ", "builds", " ", "on", " ", "Mac", " ", "with", " ", "tc", "malloc", " ", "disable", "d", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "code", ".", "google", ".", "com", "/", "p", "/", "cef", "python", "/", "issue", "s", "/", "deta", "il", "?", "id", "=", "155_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "ctypes_", ",_", "os_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "libc", "ef", "\\u", "so_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ",_", "'", "libc", "ef", ".", "dylib", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "libc", "ef", "\\u", "so_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Import", " ", "a", " ", "local", " ", "module_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ctypes_", "._", "CD", "LL_", "(_", "libc", "ef", "\\u", "so_", ",_", "ctypes_", "._", "RTL", "D", "\\u", "GLOBAL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "0x02", "0700", "00_", "<=_", "sys_", "._", "hex", "version_", "<_", "0x03", "000000_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "cef", "python", "\\u", "py2", "7_", "as_", "cef", "python_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"", "Unsu", "ppo", "rted", " ", "python", " ", "version", ":", " ", "%", "s", "\"_", "%_", "sys_", "._", "version_", ")_", "\\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_", "#", " ", "Import", " ", "an", " ", "install", "ed", " ", "package_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "cef", "python", "3_", "import_", "cef", "python_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "wx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "platform_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "inspect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "struct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "g", "\\u", "applica", "tion", "Settings_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "browse", "r", "Settings_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "switches_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "count", "Windows_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Whi", "ch", " ", "method", " ", "to", " ", "use", " ", "for", " ", "message", " ", "loop", " ", "process", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "EV", "T", "\\u", "IDLE", " ", "-", " ", "wx", " ", "applica", "tion", " ", "has", " ", "priorit", "y", " ", "(", "default", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "EV", "T", "\\u", "TIMER", " ", "-", " ", "cef", " ", "browse", "r", " ", "has", " ", "priority_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "It", " ", "see", "ms", " ", "tha", "t", " ", "Fla", "sh", " ", "content", " ", "behave", "s", " ", "bett", "er", " ", "whe", "n", " ", "usi", "ng", " ", "a", " ", "timer", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IMPORT", "ANT", "!", " ", "On", " ", "Lin", "ux", " ", "EV", "T", "\\u", "IDLE", " ", "doe", "s", " ", "not", " ", "work", ",", " ", "the", " ", "events", " ", "see", "ms", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "be", " ", "propagate", "d", " ", "only", " ", "whe", "n", " ", "you", " ", "move", " ", "your", " ", "mouse", ",", " ", "whi", "ch", " ", "is", " ", "not", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "expected", " ", "behavior", ",", " ", "it", " ", "is", " ", "recommende", "d", " ", "to", " ", "use", " ", "EV", "T", "\\u", "TIMER", " ", "on", " ", "Lin", "ux", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "so", " ", "set", " ", "this", " ", "value", " ", "to", " ", "Fal", "se", "._", "\\u\\u\\uNL\\u\\u\\u_", "USE", "\\u", "EV", "T", "\\u", "IDLE", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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\\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_", "(_", "'[", "wx", "python", ".", "py", "]", " ", "architecture", "=", "%", "s", "-", "bit", "'_", "%_", "(_", "8_", "*_", "struct_", "._", "calcsize_", "(_", "\"", "P", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'[", "wx", "python", ".", "py", "]", " ", "wx", ".", "version", "=", "%", "s", "'_", "%_", "wx_", "._", "version_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Interc", "ept", " ", "python", " ", "exception", "s", ".", " ", "Exi", "t", " ", "app", " ", "immediate", "ly", " ", "whe", "n", " ", "exception_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "happ", "ens", " ", "on", " ", "any", " ", "of", " ", "the", " ", "thread", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "except", "hook_", "=_", "Except", "Hook_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Applica", "tion", " ", "settings_", "\\u\\u\\uNL\\u\\u\\u_", "g", "\\u", "applica", "tion", "Settings_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Disk", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "cache", "\\u", "path", "\":", " ", "\"", "webca", "che", "/\"", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CE", "F", " ", "Pyth", "on", " ", "debug", " ", "message", "s", " ", "in", " ", "console", " ", "and", " ", "in", " ", "log", "\\u", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "debug", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "it", " ", "to", " ", "LOG", "SEV", "ERIT", "Y", "\\u", "VERBOS", "E", " ", "for", " ", "more", " ", "details_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "log", "\\u", "sever", "it", "y", "\"_", ":_", "cef", "python_", "._", "LOG", "SEV", "ERIT", "Y", "\\u", "INFO_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "to", " ", "\"\"", " ", "to", " ", "disable", " ", "logg", "ing", " ", "to", " ", "a", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "log", "\\u", "file", "\"_", ":_", "Get", "Applica", "tion", "Path_", "(_", "\"", "debug", ".", "log", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "be", " ", "enable", "d", " ", "only", " ", "whe", "n", " ", "debugg", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "release", "\\u", "dch", "eck", "\\u", "enable", "d", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "resource", "s", "\\u", "dir\\u", "path", "\"", " ", "must", " ", "be", " ", "set", " ", "on", " ", "Mac", ",", " ", "\"", "locale", "s", "\\u", "dir\\u", "path", "\"", " ", "not", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "must", " ", "als", "o", " ", "set", " ", "\"", "locale", "\\u", "pak", "\"", " ", "usi", "ng", " ", "command", " ", "line", " ", "switch", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "resource", "s", "\\u", "dir\\u", "path", "\"_", ":_", "cef", "python_", "._", "Get", "Modul", "e", "Directory_", "(_", ")_", "+_", "\"/", "Reso", "urc", "es", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "\"", "subproc", "ess", "\"", " ", "executable", " ", "tha", "t", " ", "launch", "es", " ", "the", " ", "Renderer_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "GPU", " ", "process", "es", " ", "amo", "ng", " ", "other", "s", ".", " ", "You", " ", "may", " ", "rename", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "executable", " ", "if", " ", "you", " ", "like", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "browse", "r", "\\u", "subproc", "ess", "\\u", "path", "\"_", ":_", "\"%", "s", "/", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "cef", "python_", "._", "Get", "Modul", "e", "Directory_", "(_", ")_", ",_", "\"", "subproc", "ess", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "option", " ", "is", " ", "require", "d", " ", "for", " ", "the", " ", "Get", "Cooki", "e", "Manager", " ", "callback_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "work", ".", " ", "It", " ", "affect", "s", " ", "render", "er", " ", "process", "es", ",", " ", "whe", "n", " ", "this", " ", "option_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "set", " ", "to", " ", "Tru", "e", ".", " ", "It", " ", "will", " ", "force", " ", "a", " ", "separate", " ", "render", "er", " ", "process_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "each", " ", "browse", "r", " ", "created", " ", "usi", "ng", " ", "Creat", "e", "Brows", "er", "Sync", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "unique", "\\u", "request", "\\u", "context", "\\u", "per", "\\u", "browse", "r", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Down", "load", "s", " ", "are", " ", "handle", "d", " ", "automati", "call", "y", ".", " ", "A", " ", "default", " ", "Save", "As", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dialog", " ", "provided", " ", "by", " ", "OS", " ", "will", " ", "be", " ", "displaye", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "download", "s", "\\u", "enable", "d", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Remo", "te", " ", "debugg", "ing", " ", "port", ",", " ", "require", "d", " ", "for", " ", "Dev", "elope", "r", " ", "Tool", "s", " ", "support", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "A", " ", "value", " ", "of", " ", "0", " ", "will", " ", "generat", "e", " ", "a", " ", "random", " ", "port", ".", " ", "To", " ", "disable", " ", "devt", "ools_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "support", " ", "set", " ", "it", " ", "to", " ", "-1", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "remote", "\\u", "debugg", "ing", "\\u", "port", "\"_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mouse", " ", "context", " ", "menu_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "context", "\\u", "menu", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "enable", "d", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "navigation", "\"_", ":_", "True_", ",_", "#", " ", "Back", ",", " ", "Forward", ",", " ", "Relo", "ad_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "print", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "view", "\\u", "source", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "external", "\\u", "browse", "r", "\"_", ":_", "True_", ",_", "#", " ", "Open", " ", "in", " ", "external", " ", "browser_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "devt", "ool", "s", "\"_", ":_", "True_", ",_", "#", " ", "Dev", "elope", "r", " ", "Tools_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "als", "o", " ", "On", "Certificat", "e", "Error", " ", "whi", "ch", " ", "allow", "s", " ", "you", " ", "to", " ", "ignore_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "certifica", "te", " ", "error", "s", " ", "for", " ", "specific", " ", "webs", "ites", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "ignore", "\\u", "certifica", "te", "\\u", "error", "s", "\"_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Brows", "er", " ", "settings", ".", " ", "You", " ", "may", " ", "have", " ", "different", " ", "settings", " ", "for", " ", "each_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "browse", "r", ",", " ", "see", " ", "the", " ", "call", " ", "to", " ", "Creat", "e", "Brows", "er", "Sync", "._", "\\u\\u\\uNL\\u\\u\\u_", "g", "\\u", "browse", "r", "Settings_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "plugin", "s", "\\u", "disable", "d", "\":", " ", "Tru", "e", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "file", "\\u", "access", "\\u", "from", "\\u", "file", "\\u", "urls", "\\u", "allow", "ed", "\":", " ", "Tru", "e", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "universal", "\\u", "access", "\\u", "from", "\\u", "file", "\\u", "urls", "\\u", "allow", "ed", "\":", " ", "Tru", "e", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Command", " ", "line", " ", "switche", "s", " ", "set", " ", "program", "matical", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "g", "\\u", "switches_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "On", " ", "Mac", " ", "it", " ", "is", " ", "require", "d", " ", "to", " ", "provide", " ", "path", " ", "to", " ", "a", " ", "specific_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "locale", ".", "pak", " ", "file", ".", " ", "On", " ", "Win", "/", "Lin", "ux", " ", "you", " ", "only", " ", "speci", "fy", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Applica", "tion", "Sett", "ings", ".", "locale", "s", "\\u", "dir\\u", "path", " ", "option", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"", "locale", "\\u", "pak", "\"_", ":_", "cef", "python_", "._", "Get", "Modul", "e", "Directory_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "\"/", "Reso", "urc", "es", "/", "en", ".", "lpr", "oj", "/", "locale", ".", "pak", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "proxy", "-", "server", "\":", " ", "\"", "socks", "5", "://", "127", ".0", ".0", ".1", ":", "8888", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "no", "-", "proxy", "-", "server", "\":", " ", "\"\"", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "enable", "-", "media", "-", "stream", "\":", " ", "\"\"", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "remote", "-", "debugg", "ing", "-", "port", "\":", " ", "\"", "12345", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "disable", "-", "gpu", "\":", " ", "\"\"", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"--", "invalid", "-", "switch", "\":", " ", "\"\"", " ", "->", " ", "Inva", "lid", " ", "switch", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cef", "python_", "._", "Initializ", "e_", "(_", "g", "\\u", "applica", "tion", "Settings_", ",_", "g", "\\u", "switches_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "My", "App_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "Main", "Loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Let", " ", "wx", ".", "App", " ", "destruct", "or", " ", "do", " ", "the", " ", "clean", "up", " ", "bef", "ore", " ", "calling", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cef", "python", ".", "Shut", "down", "()", ".", " ", "Thi", "s", " ", "is", " ", "to", " ", "ensure", " ", "reliab", "le", " ", "CE", "F", " ", "shut", "down", "._", "\\u\\u\\uNL\\u\\u\\u_", "del_", "app_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "On", " ", "Mac", " ", "cef", "python", ".", "Shut", "down", "()", " ", "is", " ", "call", "ed", " ", "in", " ", "Main", "Frame", ".", "On", "Clos", "e", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "followe", "d", " ", "by", " ", "wx", ".", "Get", "App", ".", "Exi", "t", "()", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "Get", "Applica", "tion", "Path_", "(_", "file_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "re_", ",_", "os_", ",_", "platform_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", " ", "Window", "s", " ", "after", " ", "download", "ing", " ", "file", " ", "and", " ", "calling", " ", "Brows", "er", ".", "Go", "Forward", "()", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "current", " ", "working", " ", "director", "y", " ", "is", " ", "set", " ", "to", " ", "%", "User", "Profil", "e", "%", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Call", "ing", " ", "os", ".", "path", ".", "dir", "name", "(", "os", ".", "path", ".", "real", "path", "(\\u", "\\u", "file", "\\u\\u)", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "return", "s", " ", "for", " ", "eg", ".", " ", "\"", "C", ":\\\\", "User", "s", "\\\\", "user", "\\\\", "Down", "load", "s", "\".", " ", "A", " ", "solution_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "to", " ", "cache", " ", "path", " ", "on", " ", "first", " ", "call", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "Get", "Applica", "tion", "Path_", ",_", "\"", "dir", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "sys_", ",_", "\"", "frozen", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "sys_", "._", "executable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "\"\\u\\u", "file", "\\u\\u\"_", "in_", "globals_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "realpath_", "(_", "\\u\\u", "file\\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 ", " _", "dir_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Get", "Applica", "tion", "Path_", "._", "dir_", "=_", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "file", " ", "is", " ", "Non", "e", " ", "return", " ", "current", " ", "director", "y", " ", "with", "out", " ", "trail", "ing", " ", "slash", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "file_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", "ly", " ", "whe", "n", " ", "relative", " ", "path", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "file_", "._", "startswith_", "(_", "\"/\"_", ")_", "and_", "not_", "file_", "._", "startswith_", "(_", "\"\\\\\\\\\"_", ")_", "and_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "re_", "._", "search_", "(_", "r", "\"", "^", "[\\\\", "w", "-]+", ":\"_", ",_", "file_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "Get", "Applica", "tion", "Path_", "._", "dir_", "+_", "os_", "._", "sep_", "+_", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "platform_", "._", "system_", "(_", ")_", "==_", "\"", "Window", "s", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "re_", "._", "sub_", "(_", "r", "\"[", "/\\\\\\\\", "]+\"", "_", ",_", "re_", "._", "escape_", "(_", "os_", "._", "sep_", ")_", ",_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "re_", "._", "sub_", "(_", "r", "\"[", "/\\\\\\\\", "]+$", "\"_", ",_", "\"\"_", ",_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "str_", "(_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Except", "Hook_", "(_", "exc", "Type_", ",_", "exc", "Value_", ",_", "trace", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "traceback_", ",_", "os_", ",_", "time_", ",_", "codecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "hook", " ", "doe", "s", " ", "the", " ", "follow", "ing", ":", " ", "in", " ", "case", " ", "of", " ", "exception", " ", "write", " ", "it", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "\"", "error", ".", "log", "\"", " ", "file", ",", " ", "display", " ", "it", " ", "to", " ", "the", " ", "console", ",", " ", "shut", "down", " ", "CE", "F_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "exit", " ", "applica", "tion", " ", "immediate", "ly", " ", "by", " ", "ign", "orin", "g", " ", "\"", "final", "ly", "\"", " ", "(", "os", ".\\u", "exit", "())", "._", "\\u\\u\\uNL\\u\\u\\u_", "error", "Msg_", "=_", "\"\\\\", "n", "\"_", "._", "join_", "(_", "traceback_", "._", "format\\u", "exception_", "(_", "exc", "Type_", ",_", "exc", "Value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "trace", "Object_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error", "File_", "=_", "Get", "Applica", "tion", "Path_", "(_", "\"", "error", ".", "log", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "app", "Encoding_", "=_", "cef", "python_", "._", "g", "\\u", "applica", "tion", "Settings_", "[_", "\"", "string", "\\u", "encoding", "\"_", "]_", "\\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 ", " _", "app", "Encoding_", "=_", "\"", "utf", "-", "8", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "type_", "(_", "error", "Msg_", ")_", "==_", "bytes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error", "Msg_", "=_", "error", "Msg_", "._", "decode_", "(_", "encoding_", "=_", "app", "Encoding_", ",_", "errors_", "=_", "\"", "replace", "\"_", ")_", "\\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 ", " _", "with_", "codecs_", "._", "open_", "(_", "error", "File_", ",_", "mode_", "=_", "\"", "a", "\"_", ",_", "encoding_", "=_", "app", "Encoding_", ")_", "as_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fp_", "._", "write_", "(_", "\"\\\\", "n", "[", "%", "s", "]", " ", "%", "s", "\\\\", "n", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "._", "strftime_", "(_", "\"%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "\"_", ")_", ",_", "error", "Msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "WARN", "ING", ":", " ", "fail", "ed", " ", "writ", "ing", " ", "to", " ", "error", " ", "file", ":", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "error", "File_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Convert", " ", "error", " ", "message", " ", "to", " ", "ascii", " ", "bef", "ore", " ", "printin", "g", ",", " ", "other", "wise_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "you", " ", "may", " ", "get", " ", "error", " ", "like", " ", "this", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", " ", "Unic", "ode", "Encode", "Error", ":", " ", "'", "charm", "ap", "'", " ", "codec", " ", "can", "'", "t", " ", "encode", " ", "characters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "error", "Msg_", "=_", "error", "Msg_", "._", "encode_", "(_", "\"", "ascii", "\"_", ",_", "errors_", "=_", "\"", "replace", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error", "Msg_", "=_", "error", "Msg_", "._", "decode_", "(_", "\"", "ascii", "\"_", ",_", "errors_", "=_", "\"", "replace", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"\\\\", "n", "\"_", "+_", "error", "Msg_", "+_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cef", "python_", "._", "Qui", "t", "Messag", "e", "Loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cef", "python_", "._", "Shut", "down_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "\\u", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Main", "Frame_", "(_", "wx_", "._", "Frame_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "browser_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "main", "Panel_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "Handler_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "javascript", "Exter", "nal_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Main", "Frame_", "(_", "wx_", "._", "Frame_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "url_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wx_", "._", "Frame_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", "=_", "None_", ",_", "id_", "=_", "wx_", "._", "ID", "\\u", "ANY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "'", "wx", "Pyth", "on", " ", "CE", "F", " ", "3", " ", "example", "'_", ",_", "size_", "=_", "(_", "800_", ",_", "600_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "global_", "g", "\\u", "count", "Windows_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "count", "Windows_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "\"", "file", "://\"_", "+_", "Get", "Applica", "tion", "Path_", "(_", "\"", "wx", "python", ".", "html", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "hash", " ", "in", " ", "url", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "url", " ", "+=", " ", "\"#", "test", "-", "hash", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "Creat", "e", "Menu_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Cann", "ot", " ", "attach", " ", "browse", "r", " ", "to", " ", "the", " ", "main", " ", "frame", " ", "as", " ", "this", " ", "will", " ", "cause_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "menu", " ", "not", " ", "to", " ", "work", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "als", "o", " ", "have", " ", "to", " ", "set", " ", "the", " ", "wx", ".", "WAN", "TS", "\\u", "CHARS", " ", "style", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "parent", " ", "panel", "s", "/", "controls", ",", " ", "if", " ", "it", "'", "s", " ", "deep", "ly", " ", "embedde", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "main", "Panel_", "=_", "wx_", "._", "Panel_", "(_", "self_", ",_", "style_", "=_", "wx_", "._", "WAN", "TS", "\\u", "CHARS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Global", " ", "client", " ", "callback", "s", " ", "must", " ", "be", " ", "set", " ", "bef", "ore", " ", "browse", "r", " ", "is", " ", "created", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client", "Handler_", "=_", "Client", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cef", "python_", "._", "Set", "Global", "Client", "Callback_", "(_", "\"", "On", "Certificat", "e", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client", "Handler_", "._", "\\u", "On", "Certificat", "e", "Error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cef", "python_", "._", "Set", "Global", "Client", "Callback_", "(_", "\"", "On", "Be", "fore", "Plug", "in", "Load", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client", "Handler_", "._", "\\u", "On", "Be", "fore", "Plug", "in", "Load_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cef", "python_", "._", "Set", "Global", "Client", "Callback_", "(_", "\"", "On", "Af", "ter", "Creat", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client", "Handler_", "._", "\\u", "On", "Af", "ter", "Created_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "window", "Info_", "=_", "cef", "python_", "._", "Window", "Info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "width_", ",_", "height_", ")_", "=_", "self_", "._", "main", "Panel_", "._", "Get", "Client", "Size", "Tuple_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "window", "Info_", "._", "Set", "As", "Child_", "(_", "self_", "._", "main", "Panel_", "._", "Get", "Handle_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "0_", ",_", "0_", ",_", "width_", ",_", "height_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Lin", "ux", " ", "require", "s", " ", "addin", "g", " ", "\"", "file", "://", "\"", " ", "for", " ", "local", " ", "files", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "other", "wis", "e", " ", "/", "home", "/", "some", " ", "will", " ", "be", " ", "replaced", " ", "as", " ", "http", "://", "home", "/", "some", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "browser_", "=_", "cef", "python_", "._", "Creat", "e", "Brows", "er", "Sync_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "window", "Info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "there", " ", "are", " ", "problem", "s", " ", "with", " ", "Fla", "sh", " ", "you", " ", "can", " ", "disable", " ", "it", " ", "here", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "by", " ", "disa", "blin", "g", " ", "all", " ", "plugin", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "browse", "r", "Settings_", "=_", "g", "\\u", "browse", "r", "Settings_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "navigate", "Url_", "=_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client", "Handler_", "._", "main", "Browser_", "=_", "self_", "._", "browser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "browser_", "._", "Set", "Client", "Handler_", "(_", "self_", "._", "client", "Handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "js", "Bindings", "_", "=_", "cef", "python_", "._", "Javascript", "Bindings", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "bind", "To", "Frames_", "=_", "False_", ",_", "bind", "To", "Pop", "ups_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Bindings", "_", "._", "Set", "Function_", "(_", "\"", "Py", "Print", "\"_", ",_", "Py", "Print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Bindings", "_", "._", "Set", "Property_", "(_", "\"", "py", "Proper", "ty", "\"_", ",_", "\"", "Thi", "s", " ", "was", " ", "set", " ", "in", " ", "Pyth", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Bindings", "_", "._", "Set", "Property_", "(_", "\"", "py", "Config", "\"_", ",_", "[_", "\"", "Thi", "s", " ", "was", " ", "set", " ", "in", " ", "Pyth", "on", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\"", "name", "\"_", ":_", "\"", "Nest", "ed", " ", "dictionar", "y", "\"_", ",_", "\"", "is", "Nest", "ed", "\"_", ":_", "True_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "1_", ",_", "\"", "2", "\"_", ",_", "None_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "javascript", "Exter", "nal_", "=_", "Javascript", "Exter", "nal_", "(_", "self_", "._", "browser_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Bindings", "_", "._", "Set", "Object_", "(_", "\"", "external", "\"_", ",_", "self_", "._", "javascript", "Exter", "nal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Bindings", "_", "._", "Set", "Property_", "(_", "\"", "source", "s", "\"_", ",_", "Get", "Sources_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "browser_", "._", "Set", "Javascript", "Bindings", "_", "(_", "js", "Bindings", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "Bind_", "(_", "wx_", "._", "EV", "T", "\\u", "CLOSE_", ",_", "self_", "._", "On", "Close_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "USE", "\\u", "EV", "T", "\\u", "IDLE", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Bind", " ", "EV", "T", "\\u", "IDLE", " ", "only", " ", "for", " ", "the", " ", "main", " ", "applica", "tion", " ", "frame", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "Bind_", "(_", "wx_", "._", "EV", "T", "\\u", "IDLE", "_", ",_", "self_", "._", "On", "Id", "le_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Frame_", "(_", "wx_", "._", "Frame_", ")_", ":_", "\\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_", "Creat", "e", "Menu_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filem", "enu_", "=_", "wx_", "._", "Menu_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filem", "enu_", "._", "Append_", "(_", "1_", ",_", "\"", "Open", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exit_", "=_", "filem", "enu_", "._", "Append_", "(_", "2_", ",_", "\"", "Exi", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Bind_", "(_", "wx_", "._", "EV", "T", "\\u", "MENU_", ",_", "self_", "._", "On", "Close_", ",_", "exit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "abo", "utm", "enu_", "=_", "wx_", "._", "Menu_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "abo", "utm", "enu_", "._", "Append_", "(_", "1_", ",_", "\"", "CE", "F", " ", "Pyth", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "menubar_", "=_", "wx_", "._", "Menu", "Bar_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "menubar_", "._", "Append_", "(_", "filem", "enu_", ",_", "\"&", "File", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "menubar_", "._", "Append_", "(_", "abo", "utm", "enu_", ",_", "\"&", "Abo", "ut", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Set", "Menu", "Bar_", "(_", "menubar_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Frame_", "(_", "wx_", "._", "Frame_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Close_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remove", " ", "all", " ", "CE", "F", " ", "browse", "r", " ", "reference", "s", " ", "so", " ", "tha", "t", " ", "browse", "r", " ", "is", " ", "closed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "clean", "ly", ".", " ", "Ot", "her", "wis", "e", " ", "there", " ", "may", " ", "be", " ", "issue", "s", " ", "for", " ", "example", " ", "with", " ", "cookies_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "not", " ", "bei", "ng", " ", "flush", "ed", " ", "to", " ", "disk", " ", "whe", "n", " ", "clos", "ing", " ", "app", " ", "immediate", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "Issue", " ", "158", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "javascript", "Exter", "nal_", "._", "main", "Browser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "client", "Handler_", "._", "main", "Browser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "browser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Destr", "oy", " ", "wx", " ", "frame", ",", " ", "this", " ", "will", " ", "complete", " ", "the", " ", "destruct", "ion", " ", "of", " ", "CE", "F", " ", "browser_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "Destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "In", " ", "wx", ".", "chrome", "ctrl", " ", "calling", " ", "browse", "r", ".", "Clos", "e", "Brows", "er", " ", "and", "/", "or", " ", "self", ".", "Destroy_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "may", " ", "caus", "e", " ", "crashes", " ", "whe", "n", " ", "embed", "ding", " ", "multiple", " ", "browsers", " ", "in", " ", "tab_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "Issue", " ", "107", ").", " ", "In", " ", "suc", "h", " ", "case", " ", "inst", "ead", " ", "of", " ", "calling", " ", "Clos", "e", "Brows", "er", "/", "Destroy_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "this", " ", "code", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", " ", "self", ".", "browse", "r", ".", "Parent", "Window", "Wil", "l", "Clos", "e", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", " ", "event", ".", "Ski", "p", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "global_", "g", "\\u", "count", "Windows_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "count", "Windows_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "g", "\\u", "count", "Windows_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", " ", "Win", "/", "Lin", "ux", " ", "the", " ", "call", " ", "to", " ", "cef", "python", ".", "Shut", "down", "()", " ", "is", " ", "after_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "app", ".", "Main", "Loop", "()", " ", "return", "s", ",", " ", "but", " ", "on", " ", "Mac", " ", "it", " ", "need", "s", " ", "to", " ", "be", " ", "here", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cef", "python_", "._", "Shut", "down_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "On", "Clos", "e", ":", " ", "Exi", "ting", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Get", "App_", "(_", ")_", "._", "Exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Frame_", "(_", "wx_", "._", "Frame_", ")_", ":_", "\\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_", "On", "Id", "le_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cef", "python_", "._", "Messag", "e", "Loop", "Work", "_", "(_", ")_", "\\u\\u\\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_", "Py", "Print_", "(_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Py", "Print", ":", " ", "\"_", "+_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main", "Browser_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "Visitor_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "Cooki", "es_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cookie", "Visitor_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "main", "Browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "main", "Browser_", "=_", "main", "Browser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Go", "Back_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "main", "Browser_", "._", "Go", "Back_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Go", "Forward_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "main", "Browser_", "._", "Go", "Forward_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Creat", "e", "Ano", "ther", "Browser_", "(_", "self_", ",_", "url_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "TOD", "O", ":", " ", "There", " ", "are", " ", "error", "s", " ", "in", " ", "the", " ", "console", " ", "whe", "n", " ", "clos", "ing", " ", "the", " ", "window", ":", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", "Check", " ", "fail", "ed", ":", " ", "window", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", "Gd", "k", ":", " ", "\\u", "gd", "k", "\\u", "window", "\\u", "destroy", "\\u", "hier", "arch", "y", ":", " ", "assertion", " ", "`", "GD", "K", "\\u", "IS", "\\u", "WIND", "OW", "\\\\", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", " ", "(", "window", ")'", " ", "fail", "ed", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", "GL", "ib", "-", "GO", "bject", ":", " ", "g", "\\u", "object\\u", "unre", "f", ":", " ", "assertion", " ", "`", "G", "\\u", "IS", "\\u", "OBJ", "ECT", " ", "(", "object", ")'", " ", "fail", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frame_", "=_", "Main", "Frame_", "(_", "url_", "=_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frame_", "._", "Show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Print_", "(_", "self_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Print", ":", " ", "\"_", "+_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Test", "All", "Types_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Test", "All", "Type", "s", ":", " ", "\"_", "+_", "str_", "(_", "args_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Execut", "e", "Function_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "main", "Browser_", "._", "Get", "Main", "Frame_", "(_", ")_", "._", "Execut", "e", "Function_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Test", "JS", "Callback_", "(_", "self_", ",_", "js", "Callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "js", "Call", "back", ".", "Get", "Function", "Name", "()", " ", "=", " ", "%", "s", "\"_", "%_", "js", "Callback_", "._", "Get", "Function", "Name_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "js", "Call", "back", ".", "Get", "Frame", "()", ".", "Get", "Identifie", "r", "()", " ", "=", " ", "%", "s", "\"_", "%_", "js", "Callback_", "._", "Get", "Frame_", "(_", ")_", "._", "Get", "Identifier_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Callback_", "._", "Call_", "(_", "\"", "Thi", "s", " ", "message", " ", "was", " ", "sent", " ", "from", " ", "python", " ", "usi", "ng", " ", "js", " ", "callback", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Test", "JS", "Call", "back", "Comple", "x", "Arguments_", "(_", "self_", ",_", "js", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "Callback_", "=_", "js", "Object_", "[_", "\"", "my", "Call", "back", "\"_", "]_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "js", "Callback_", "._", "Call_", "(_", "1_", ",_", "None_", ",_", "2.1", "4_", ",_", "\"", "string", "\"_", ",_", "[_", "\"", "list", "\"_", ",_", "[_", "\"", "nest", "ed", " ", "list", "\"_", ",_", "{_", "\"", "nest", "ed", " ", "object", "\"_", ":_", "None_", "}_", "]_", "]_", ",_", "{_", "\"", "nest", "ed", " ", "list", " ", "next", "\"_", ":_", "[_", "{_", "\"", "deep", "ly", " ", "nest", "ed", " ", "object", "\"_", ":_", "1_", "}_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Test", "Pyth", "on", "Callback_", "(_", "self_", ",_", "js", "Callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "Callback_", "._", "Call_", "(_", "self_", "._", "Py", "Callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Py", "Callback_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "\"", "Py", "Call", "back", "()", " ", "was", " ", "executed", " ", "success", "full", "y", "!", " ", "\"_", "\"", "Arg", "ument", "s", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "\"_", "+_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "main", "Browser_", "._", "Get", "Main", "Frame_", "(_", ")_", "._", "Execut", "e", "Javascript", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "window", ".", "alert", "(\\\\\"", "%", "s", "\\\\\")", "\"_", "%_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Get", "Source_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Mus", "t", " ", "keep", " ", "a", " ", "strong", " ", "reference", " ", "to", " ", "the", " ", "String", "Visit", "or", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dur", "ing", " ", "the", " ", "visit", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "string", "Visitor_", "=_", "String", "Visitor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "main", "Browser_", "._", "Get", "Main", "Frame_", "(_", ")_", "._", "Get", "Source_", "(_", "self_", "._", "string", "Visitor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Get", "Text_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Mus", "t", " ", "keep", " ", "a", " ", "strong", " ", "reference", " ", "to", " ", "the", " ", "String", "Visit", "or", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dur", "ing", " ", "the", " ", "visit", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "string", "Visitor_", "=_", "String", "Visitor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "main", "Browser_", "._", "Get", "Main", "Frame_", "(_", ")_", "._", "Get", "Text_", "(_", "self_", "._", "string", "Visitor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Show", "Dev", "Tools_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "external", ".", "Show", "Dev", "Tool", "s", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "main", "Browser_", "._", "Show", "Dev", "Tools_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "Visit", "All", "Cooki", "es_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ne", "ed", " ", "to", " ", "keep", " ", "the", " ", "reference", " ", "alive", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "cookie", "Visitor_", "=_", "Cooki", "e", "Visitor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cookie", "Manager_", "=_", "self_", "._", "main", "Browser_", "._", "Get", "User", "Data_", "(_", "\"", "cookie", "Manager", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cookie", "Manager_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", " ", "manage", "r", " ", "not", " ", "ye", "t", " ", "created", "!", " ", "Visit", "\"_", "\"", " ", "the", " ", "cookie", "teste", "r", " ", "webs", "ite", " ", "first", " ", "and", " ", "create", " ", "some", " ", "cookie", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cookie", "Manager_", "._", "Visit", "All", "Cooki", "es_", "(_", "self_", "._", "cookie", "Visitor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Visit", "Ur", "l", "Cooki", "es_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ne", "ed", " ", "to", " ", "keep", " ", "the", " ", "reference", " ", "alive", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "cookie", "Visitor_", "=_", "Cooki", "e", "Visitor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cookie", "Manager_", "=_", "self_", "._", "main", "Browser_", "._", "Get", "User", "Data_", "(_", "\"", "cookie", "Manager", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cookie", "Manager_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", " ", "manage", "r", " ", "not", " ", "ye", "t", " ", "created", "!", " ", "Visit", "\"_", "\"", " ", "the", " ", "cookie", "teste", "r", " ", "webs", "ite", " ", "first", " ", "and", " ", "create", " ", "some", " ", "cookie", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cookie", "Manager_", "._", "Visit", "Ur", "l", "Cooki", "es_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "http", "://", "www", ".", "html", "-", "kit", ".", "com", "/", "tool", "s", "/", "cookie", "teste", "r", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ",_", "self_", "._", "cookie", "Visitor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", ".", "www", ".", "html", "-", "kit", ".", "com_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Set", "Cookie_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cookie", "Manager_", "=_", "self_", "._", "main", "Browser_", "._", "Get", "User", "Data_", "(_", "\"", "cookie", "Manager", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cookie", "Manager_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", " ", "manage", "r", " ", "not", " ", "ye", "t", " ", "created", "!", " ", "Visit", "\"_", "\"", "the", " ", "cookie", "teste", "r", " ", "webs", "ite", " ", "first", " ", "and", " ", "create", " ", "some", " ", "cookie", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cookie_", "=_", "cef", "python_", "._", "Cookie_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cookie_", "._", "Set", "Name_", "(_", "\"", "Creat", "ed", "\\u", "Via", "\\u", "Pyth", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cookie_", "._", "Set", "Value_", "(_", "\"", "ye", "ah", " ", "reall", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cookie", "Manager_", "._", "Set", "Cookie_", "(_", "\"", "http", "://", "www", ".", "html", "-", "kit", ".", "com", "/", "tool", "s", "/", "cookie", "teste", "r", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cookie_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", " ", "created", "!", " ", "Visit", " ", "html", "-", "kit", " ", "cookie", "teste", "r", " ", "to", "\"_", "\"", " ", "see", " ", "it", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Javascript", "Exter", "nal_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Delete", "Cooki", "es_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cookie", "Manager_", "=_", "self_", "._", "main", "Browser_", "._", "Get", "User", "Data_", "(_", "\"", "cookie", "Manager", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cookie", "Manager_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", " ", "manage", "r", " ", "not", " ", "ye", "t", " ", "created", "!", " ", "Visit", "\"_", "\"", " ", "the", " ", "cookie", "teste", "r", " ", "webs", "ite", " ", "first", " ", "and", " ", "create", " ", "some", " ", "cookie", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cookie", "Manager_", "._", "Delete", "Cooki", "es_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "http", "://", "www", ".", "html", "-", "kit", ".", "com", "/", "tool", "s", "/", "cookie", "teste", "r", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Creat", "ed", "\\u", "Via", "\\u", "Pyth", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", " ", "delete", "d", "!", " ", "Visit", " ", "html", "-", "kit", " ", "cookie", "teste", "r", " ", "\"_", "\"", "to", " ", "see", " ", "the", " ", "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_", "String", "Visitor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "String", "Visitor_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "Visit", "_", "(_", "self_", ",_", "string_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "String", "Visit", "or", ".", "Visit", "():", " ", "string", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"-------", "--------------", "-----------", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"-------", "--------------", "-----------", "\"_", ")_", "\\u\\u\\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_", "Cooki", "e", "Visitor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cooki", "e", "Visitor_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "Visit", "_", "(_", "self_", ",_", "cookie_", ",_", "count_", ",_", "total_", ",_", "delete", "Cookie_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "count_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", "Visit", "or", ".", "Visit", "():", " ", "total", " ", "cookie", "s", ":", " ", "%", "s", "\"_", "%_", "total_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"\\\\", "n", "[", "wx", "python", ".", "py", "]", " ", "Cooki", "e", "Visit", "or", ".", "Visit", "():", " ", "cookie", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "\"_", "+_", "str_", "(_", "cookie_", "._", "Get_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tru", "e", " ", "to", " ", "continue", " ", "visit", "ing", " ", "cookies_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main", "Browser_", "=_", "None_", "#", " ", "Ma", "y", " ", "be", " ", "Non", "e", " ", "for", " ", "global", " ", "client", " ", "callback", "s", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Display", "Handler_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status", "Messag", "e", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Key", "board", "Handler_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Request", "Handler_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "Load", "Handler_", "\\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\\uNL\\u\\u\\u_", "#", " ", "Life", "span", "Handler_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "**", " ", "Thi", "s", " ", "callback", " ", "is", " ", "executed", " ", "on", " ", "the", " ", "IO", " ", "thread", " ", "**_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Emp", "ty", " ", "place", "-", "holder", "s", ":", " ", "popu", "p", "Feature", "s", ",", " ", "client", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "Javascript", "Dialog", "Handler_", "\\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_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\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_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Address", "Change_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Display", "Handle", "r", "::", "On", "Address", "Change", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Tit", "le", "Change_", "(_", "self_", ",_", "browser_", ",_", "title_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Display", "Handle", "r", "::", "On", "Tit", "le", "Change", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "title", " ", "=", " ", "%", "s", "\"_", "%_", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Tooltip", "_", "(_", "self_", ",_", "browser_", ",_", "text", "Out_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", "Tooltip", " ", "not", " ", "ye", "t", " ", "implemented", " ", "(", "bot", "h", " ", "Lin", "ux", " ", "and", " ", "Window", "s", "),", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "will", " ", "be", " ", "fixed", " ", "in", " ", "next", " ", "CE", "F", " ", "release", ",", " ", "see", " ", "Issue", " ", "783", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "code", ".", "google", ".", "com", "/", "p", "/", "chrom", "ium", "embedde", "d", "/", "issue", "s", "/", "deta", "il", "?", "id", "=", "783", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Display", "Handle", "r", "::", "On", "Tooltip", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "text", " ", "=", " ", "%", "s", "\"_", "%_", "text", "Out_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "On", "Status", "Message_", "(_", "self_", ",_", "browser_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Do", " ", "not", " ", "notif", "y", " ", "in", " ", "the", " ", "console", " ", "abo", "ut", " ", "empty", " ", "status", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "status", "Messag", "e", "Count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "status", "Messag", "e", "Count_", ">_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Do", " ", "not", " ", "spam", " ", "too", " ", "muc", "h", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Display", "Handle", "r", "::", "On", "Status", "Messag", "e", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "value", " ", "=", " ", "%", "s", "\"_", "%_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Cons", "ole", "Message_", "(_", "self_", ",_", "browser_", ",_", "message_", ",_", "source_", ",_", "line_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Display", "Handle", "r", "::", "On", "Cons", "ole", "Messag", "e", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "message", " ", "=", " ", "%", "s", "\"_", "%_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "source", " ", "=", " ", "%", "s", "\"_", "%_", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "line", " ", "=", " ", "%", "s", "\"_", "%_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Pre", "Key", "Event_", "(_", "self_", ",_", "browser_", ",_", "event_", ",_", "event", "Handle_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "Key", "board", "Short", "cut", "Out_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Key", "board", "Handle", "r", "::", "On", "Pre", "Key", "Event", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Key", "Event_", "(_", "self_", ",_", "browser_", ",_", "event_", ",_", "event", "Handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "event_", "[_", "\"", "type", "\"_", "]_", "==_", "cef", "python_", "._", "KEY", "EVENT", "\\u", "KEY", "UP_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "On", "Key", "Event", " ", "is", " ", "call", "ed", " ", "twi", "ce", " ", "for", " ", "F5", "/", "Esc", " ", "keys", ",", " ", "with", " ", "event_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "type", " ", "KEY", "EVENT", "\\u", "RA", "WK", "EY", "DOWN", " ", "and", " ", "KEY", "EVENT", "\\u", "KEY", "UP", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Normal", " ", "character", "s", " ", "a", "-", "z", " ", "shou", "ld", " ", "have", " ", "KEY", "EVENT", "\\u", "CHAR", "._", "\\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_", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Key", "board", "Handle", "r", "::", "On", "Key", "Event", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "type", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "type", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "modifiers", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "modifiers", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "windows", "\\u", "key", "\\u", "code", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "windows", "\\u", "key", "\\u", "code", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "nativ", "e\\u", "key", "\\u", "code", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "nativ", "e\\u", "key", "\\u", "code", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "is", "\\u", "system", "\\u", "key", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "is", "\\u", "system", "\\u", "key", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "character", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "character", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "unmo", "difi", "ed", "\\u", "character", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "unmo", "difi", "ed", "\\u", "character", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "foc", "us", "\\u", "on", "\\u", "edita", "ble", "\\u", "field", "=", "%", "s", "\"_", "%_", "event_", "[_", "\"", "foc", "us", "\\u", "on", "\\u", "edita", "ble", "\\u", "field", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "platform_", "._", "system_", "(_", ")_", "==_", "\"", "Lin", "ux", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "F5", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "event_", "[_", "\"", "nativ", "e\\u", "key", "\\u", "code", "\"_", "]_", "==_", "71_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "F5", " ", "presse", "d", ",", " ", "calling", "\"_", "\"", " ", "browse", "r", ".", "Relo", "ad", "Ignor", "e", "Cache", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "browser_", "._", "Relo", "ad", "Ignor", "e", "Cache_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Escape_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "event_", "[_", "\"", "nativ", "e\\u", "key", "\\u", "code", "\"_", "]_", "==_", "9_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Esc", " ", "presse", "d", ",", " ", "calling", " ", "browse", "r", ".", "Sto", "p", "Load", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "browser_", "._", "Sto", "p", "Load_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "F1", "2_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "event_", "[_", "\"", "nativ", "e\\u", "key", "\\u", "code", "\"_", "]_", "==_", "96_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "F1", "2", " ", "presse", "d", ",", " ", "calling", "\"_", "\"", " ", "browse", "r", ".", "Show", "Dev", "Tool", "s", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "browser_", "._", "Show", "Dev", "Tools_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "platform_", "._", "system_", "(_", ")_", "==_", "\"", "Window", "s", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "F5", " ", "todo_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Esc", "ape", " ", "todo_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "platform_", "._", "system_", "(_", ")_", "==_", "\"", "Dar", "win", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Cmd", "+", "Opt", "+", "I_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "event_", "[_", "\"", "modifiers", "\"_", "]_", "==_", "136_", "and_", "event_", "[_", "\"", "character", "\"_", "]_", "==_", "94_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "browser_", "._", "Show", "Dev", "Tools_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "F5", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "event_", "[_", "\"", "modifiers", "\"_", "]_", "==_", "0_", "and_", "event_", "[_", "\"", "character", "\"_", "]_", "==_", "632", "40_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "browser_", "._", "Relo", "ad", "Ignor", "e", "Cache_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Esc", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "event_", "[_", "\"", "modifiers", "\"_", "]_", "==_", "0_", "and_", "event_", "[_", "\"", "character", "\"_", "]_", "==_", "27_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "browser_", "._", "Sto", "p", "Load_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Be", "fore", "Brows", "e_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "request_", ",_", "is", "Redirect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Be", "fore", "Brows", "e", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "request_", "._", "Get", "Url_", "(_", ")_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Be", "fore", "Reso", "urc", "e", "Load_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Be", "fore", "Reso", "urc", "e", "Load", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "request_", "._", "Get", "Url_", "(_", ")_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Reso", "urc", "e", "Redirect_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "old", "Url_", ",_", "new", "Ur", "l", "Out_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Reso", "urc", "e", "Redirect", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "old", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "old", "Url_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "new", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "new", "Ur", "l", "Out_", "[_", "0_", "]_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Get", "Auth", "Credentials_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "is", "Proxy_", ",_", "host_", ",_", "port_", ",_", "realm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scheme_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "callback", " ", "is", " ", "call", "ed", " ", "on", " ", "the", " ", "IO", " ", "thread", ",", " ", "thu", "s", " ", "print", " ", "messages_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "may", " ", "not", " ", "be", " ", "visi", "ble", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "Get", "Auth", "Cred", "ential", "s", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "host", " ", "=", " ", "%", "s", "\"_", "%_", "host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "real", "m", " ", "=", " ", "%", "s", "\"_", "%_", "realm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callback_", "._", "Continu", "e_", "(_", "username_", "=_", "\"", "test", "\"_", ",_", "password_", "=_", "\"", "test", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Quota", "Request_", "(_", "self_", ",_", "browser_", ",_", "orig", "in", "Url_", ",_", "new", "Size_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Quota", "Request", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "orig", "in", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "orig", "in", "Url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "new", " ", "size", " ", "=", " ", "%", "s", "\"_", "%_", "new", "Size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callback_", "._", "Continu", "e_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Get", "Cooki", "e", "Manager_", "(_", "self_", ",_", "browser_", ",_", "main", "Url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "unique", " ", "cookie", " ", "manage", "r", " ", "for", " ", "each", " ", "browse", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "must", " ", "set", " ", "the", " ", "\"", "unique", "\\u", "request", "\\u", "context", "\\u", "per", "\\u", "browse", "r", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "applica", "tion", " ", "setti", "ng", " ", "to", " ", "Tru", "e", " ", "for", " ", "the", " ", "cookie", " ", "manager_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "work", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Return", " ", "Non", "e", " ", "to", " ", "have", " ", "one", " ", "global", " ", "cookie", " ", "manage", "r", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "CE", "F", " ", "browsers", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "browser_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "browse", "r", " ", "param", " ", "may", " ", "be", " ", "empty", " ", "in", " ", "some", " ", "exception", "al_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "case", ",", " ", "see", " ", "docs", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cookie", "Manager_", "=_", "browser_", "._", "Get", "User", "Data_", "(_", "\"", "cookie", "Manager", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cookie", "Manager_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cookie", "Manager_", "\\u\\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_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "Get", "Cooki", "e", "Manager", "():", "\"_", "\"", " ", "created", " ", "cookie", " ", "manage", "r", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cookie", "Manager_", "=_", "cef", "python_", "._", "Cooki", "e", "Manager_", "._", "Creat", "e", "Manager_", "(_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\"", "cache", "\\u", "path", "\"_", "in_", "g", "\\u", "applica", "tion", "Settings_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "g", "\\u", "applica", "tion", "Settings_", "[_", "\"", "cache", "\\u", "path", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "path", " ", "=", " ", "os", ".", "path", ".", "join", "(", "path", ",", " ", "\"", "cookie", "s", "\\u", "browse", "r", "\\u{}", "\".", "format", "(_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "browse", "r", ".", "Get", "Identifie", "r", "())", ")_", "\\u\\u\\uNL\\u\\u\\u_", "cookie", "Manager_", "._", "Set", "Stor", "age", "Path_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "browser_", "._", "Set", "User", "Data_", "(_", "\"", "cookie", "Manager", "\"_", ",_", "cookie", "Manager_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cookie", "Manager_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "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_", "On", "Proto", "col", "Execution_", "(_", "self_", ",_", "browser_", ",_", "url_", ",_", "allow", "Execut", "ion", "Out_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "There", "'", "s", " ", "no", " ", "default", " ", "implementation", " ", "for", " ", "On", "Proto", "col", "Execut", "ion", " ", "on", " ", "Lin", "ux", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "you", " ", "have", " ", "to", " ", "make", " ", "OS", " ", "system", " ", "call", " ", "on", " ", "your", " ", "own", ".", " ", "You", " ", "probab", "ly", " ", "als", "o", " ", "need", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "use", " ", "Load", "Handle", "r", "::", "On", "Load", "Error", "()", " ", "whe", "n", " ", "implement", "ing", " ", "this", " ", "on", " ", "Lin", "ux", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Proto", "col", "Execut", "ion", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "url_", "._", "startswith_", "(_", "\"", "magnet", ":\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Magnet", " ", "link", " ", "allow", "ed", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "Execut", "ion", "Out_", "[_", "0_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "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_", "\\u", "On", "Be", "fore", "Plug", "in", "Load_", "(_", "self_", ",_", "browser_", ",_", "url_", ",_", "policy", "Url_", ",_", "info_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "global", " ", "callback", " ", "set", " ", "usi", "ng", " ", "Set", "Global", "Client", "Call", "back", "()", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plug", "ins", " ", "are", " ", "load", "ed", " ", "on", " ", "demand", ",", " ", "only", " ", "whe", "n", " ", "webs", "ite", " ", "require", "s", " ", "it", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "same", " ", "plugin", " ", "may", " ", "be", " ", "call", "ed", " ", "multiple", " ", "times", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "callback", " ", "is", " ", "call", "ed", " ", "on", " ", "the", " ", "IO", " ", "thread", ",", " ", "thu", "s", " ", "print", " ", "messages_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "may", " ", "not", " ", "be", " ", "visi", "ble", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "\\u", "On", "Be", "fore", "Plug", "in", "Load", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "policy", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "policy", "Url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "info", ".", "Get", "Name", "()", " ", "=", " ", "%", "s", "\"_", "%_", "info_", "._", "Get", "Name_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "info", ".", "Get", "Path", "()", " ", "=", " ", "%", "s", "\"_", "%_", "info_", "._", "Get", "Path_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "info", ".", "Get", "Version", "()", " ", "=", " ", "%", "s", "\"_", "%_", "info_", "._", "Get", "Version_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "info", ".", "Get", "Descripti", "on", "()", " ", "=", " ", "%", "s", "\"_", "%_", "info_", "._", "Get", "Description_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fal", "se", " ", "to", " ", "allow", ",", " ", "Tru", "e", " ", "to", " ", "block", " ", "plugin", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "On", "Certificat", "e", "Error_", "(_", "self_", ",_", "cert", "Error_", ",_", "request", "Url_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "global", " ", "callback", " ", "set", " ", "usi", "ng", " ", "Set", "Global", "Client", "Call", "back", "()", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "\\u", "On", "Certificat", "e", "Error", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "cert", "Error", " ", "=", " ", "%", "s", "\"_", "%_", "cert", "Error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "request", "Ur", "l", " ", "=", " ", "%", "s", "\"_", "%_", "request", "Url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request", "Url_", "._", "startswith_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "https", "://", "tv", ".", "euro", "sport", ".", "com", "/", "do", "-", "not", "-", "allow", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", " ", " ", " ", "Not", " ", "allow", "ed", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request", "Url_", "._", "startswith_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "https", "://", "tv", ".", "euro", "sport", ".", "com", "/\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", " ", " ", " ", "All", "owe", "d", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callback_", "._", "Continu", "e_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\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_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Render", "er", "Process", "Terminate", "d_", "(_", "self_", ",_", "browser_", ",_", "status_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Render", "er", "Process", "Terminate", "d", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statuses_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "cef", "python_", "._", "TS", "\\u", "AB", "NORMA", "L", "\\u", "TERMINAT", "ION_", ":_", "\"", "TS", "\\u", "AB", "NORMA", "L", "\\u", "TERMINAT", "ION", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cef", "python_", "._", "TS", "\\u", "PROCESS", "\\u", "WA", "S", "\\u", "KILL", "ED_", ":_", "\"", "TS", "\\u", "PROCESS", "\\u", "WA", "S", "\\u", "KILL", "ED", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cef", "python_", "._", "TS", "\\u", "PROCESS", "\\u", "CRA", "SHE", "D_", ":_", "\"", "TS", "\\u", "PROCESS", "\\u", "CRA", "SHE", "D", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status", "Name_", "=_", "\"", "Un", "know", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "status_", "in_", "statuses_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status", "Name_", "=_", "statuses_", "[_", "status_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "status", " ", "=", " ", "%", "s", "\"_", "%_", "status", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Plug", "in", "Cra", "shed", "_", "(_", "self_", ",_", "browser_", ",_", "plugin", "Path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Request", "Handle", "r", "::", "On", "Plug", "in", "Cra", "shed", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "plugin", " ", "path", " ", "=", " ", "%", "s", "\"_", "%_", "plugin", "Path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Load", "ing", "State", "Change_", "(_", "self_", ",_", "browser_", ",_", "is", "Load", "ing_", ",_", "can", "Go", "Back_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "can", "Go", "Forward_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Load", "Handle", "r", "::", "On", "Load", "ing", "State", "Change", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "is", "Load", "ing", " ", "=", " ", "%", "s", ",", " ", "can", "Go", "Back", " ", "=", " ", "%", "s", ",", " ", "can", "Go", "Forward", " ", "=", " ", "%", "s", "\"_", "%_", "(_", "is", "Load", "ing_", ",_", "can", "Go", "Back_", ",_", "can", "Go", "Forward_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Load", "Start_", "(_", "self_", ",_", "browser_", ",_", "frame_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Load", "Handle", "r", "::", "On", "Load", "Start", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "frame", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "frame_", "._", "Get", "Url_", "(_", ")_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Load", "End_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "http", "Status", "Code_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Load", "Handle", "r", "::", "On", "Load", "End", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "frame", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "frame_", "._", "Get", "Url_", "(_", ")_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "For", " ", "file", "://", " ", "urls", " ", "the", " ", "status", " ", "code", " ", "=", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "http", " ", "status", " ", "code", " ", "=", " ", "%", "s", "\"_", "%_", "http", "Status", "Code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", "s", " ", "for", " ", "the", " ", "Brows", "er", " ", "object", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "Brows", "er", "\\u", "Load", "Url_", "(_", "browser_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "Brows", "er", "\\u", "Load", "Url_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "browser_", "._", "Get", "Url_", "(_", ")_", "==_", "\"", "data", ":", "text", "/", "html", ",", "Test", "#", "Brows", "er", ".", "Load", "Ur", "l", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "browser_", "._", "Load", "Url_", "(_", "\"", "file", "://\"_", "+_", "Get", "Applica", "tion", "Path_", "(_", "\"", "wx", "python", ".", "html", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "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_", "On", "Load", "Error_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "error", "Code_", ",_", "error", "Text", "List_", ",_", "fail", "ed", "Url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Load", "Handle", "r", "::", "On", "Load", "Error", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "frame", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "frame_", "._", "Get", "Url_", "(_", ")_", "[_", ":_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "error", " ", "code", " ", "=", " ", "%", "s", "\"_", "%_", "error", "Code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "error", " ", "text", " ", "=", " ", "%", "s", "\"_", "%_", "error", "Text", "List_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "fail", "ed", " ", "url", " ", "=", " ", "%", "s", "\"_", "%_", "fail", "ed", "Url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Handle", " ", "ERR", "\\u", "ABORT", "ED", " ", "error", " ", "code", ",", " ", "to", " ", "handle", " ", "the", " ", "follow", "ing", " ", "case", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ".", " ", "Esc", " ", "key", " ", "was", " ", "presse", "d", " ", "whi", "ch", " ", "calls", " ", "browse", "r", ".", "Sto", "p", "Load", "()", " ", "in", " ", "On", "Key", "Event_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", ".", " ", "Down", "load", " ", "of", " ", "a", " ", "file", " ", "was", " ", "abort", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "error", "Code_", "==_", "cef", "python_", "._", "ERR", "\\u", "ABORT", "ED_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Load", "Handle", "r", "::", "On", "Load", "Error", "():", " ", "Ignor", "ing", " ", "load", "\"_", "\"", " ", "error", ":", " ", "Esc", " ", "was", " ", "presse", "d", " ", "or", " ", "file", " ", "download", " ", "was", " ", "abort", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "custom", "Error", "Message_", "=_", "\"", "My", " ", "custom", " ", "error", " ", "message", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frame_", "._", "Load", "Url_", "(_", "\"", "data", ":", "text", "/", "html", ",%", "s", "\"_", "%_", "custom", "Error", "Message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Be", "fore", "Popup_", "(_", "self_", ",_", "browser_", ",_", "frame_", ",_", "target", "Url_", ",_", "target", "Frame", "Name_", ",_", "popu", "p", "Features_", ",_", "window", "Info_", ",_", "client_", ",_", "browse", "r", "Settings_", ",_", "no", "Javascript", "Access_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Life", "span", "Handle", "r", "::", "On", "Be", "fore", "Pop", "up", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "target", "Ur", "l", " ", "=", " ", "%", "s", "\"_", "%_", "target", "Url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Custom", " ", "browse", "r", " ", "settings", " ", "for", " ", "popu", "ps", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", ">", " ", "browse", "r", "Sett", "ings", "[", "0", "]", " ", "=", " ", "{", "\"", "plugin", "s", "\\u", "disable", "d", "\":", " ", "Tru", "e", "}_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "Window", "Info", " ", "object", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", ">", " ", "window", "Info", "[", "0", "]", " ", "=", " ", "cef", "python", ".", "Window", "Info", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "allow", "Pop", "ups_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "not_", "allow", "Pop", "ups_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "On", "Af", "ter", "Created_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "global", " ", "callback", " ", "set", " ", "usi", "ng", " ", "Set", "Global", "Client", "Call", "back", "()", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Life", "span", "Handle", "r", "::", "\\u", "On", "Af", "ter", "Creat", "ed", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "browse", "r", "Id", "=", "%", "s", "\"_", "%_", "browser_", "._", "Get", "Identifier_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Run", "Modal_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Life", "span", "Handle", "r", "::", "Run", "Modal", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "browse", "r", "Id", "=", "%", "s", "\"_", "%_", "browser_", "._", "Get", "Identifier_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Do", "Close_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Life", "span", "Handle", "r", "::", "Do", "Clos", "e", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "browse", "r", "Id", "=", "%", "s", "\"_", "%_", "browser_", "._", "Get", "Identifier_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Be", "fore", "Close_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Life", "span", "Handle", "r", "::", "On", "Be", "fore", "Clos", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "browse", "r", "Id", "=", "%", "s", "\"_", "%_", "browser_", "._", "Get", "Identifier_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Javascript", "Dialog_", "(_", "self_", ",_", "browser_", ",_", "orig", "in", "Url_", ",_", "accept", "Lang_", ",_", "dialog", "Type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message", "Text_", ",_", "default", "Prom", "pt", "Text_", ",_", "callback_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "suppress", "Message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "Javascript", "Dialog", "Handle", "r", "::", "On", "Javascript", "Dialog", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "orig", "in", "Ur", "l", "=\"_", "+_", "orig", "in", "Url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "accept", "Lang", "=\"_", "+_", "accept", "Lang_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "dialog", "Type", "=\"_", "+_", "str_", "(_", "dialog", "Type_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "message", "Text", "=\"_", "+_", "message", "Text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "default", "Prom", "pt", "Text", "=\"_", "+_", "default", "Prom", "pt", "Text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "you", " ", "want", " ", "to", " ", "suppress", " ", "the", " ", "javascript", " ", "dialog", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "suppress", "Messag", "e", "[", "0", "]", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Be", "fore", "Unlo", "ad", "Javascript", "Dialog_", "(_", "self_", ",_", "browser_", ",_", "message", "Text_", ",_", "is", "Relo", "ad_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "On", "Be", "fore", "Unlo", "ad", "Javascript", "Dialog", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "message", "Text", "=\"_", "+_", "message", "Text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "is", "Relo", "ad", "=\"_", "+_", "str_", "(_", "is", "Relo", "ad_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Return", " ", "Tru", "e", " ", "if", " ", "the", " ", "applica", "tion", " ", "will", " ", "use", " ", "a", " ", "custom", " ", "dialog", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "callback", ".", "Continu", "e", "(", "allow", "=", "Tru", "e", ",", " ", "user", "Inp", "ut", "=\"\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "return", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Reset", "Javascript", "Dialog", "State_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "On", "Reset", "Dialog", "State", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Client", "Handler_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Javascript", "Dialog", "Closed_", "(_", "self_", ",_", "browser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"[", "wx", "python", ".", "py", "]", " ", "On", "Dialog", "Clos", "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_", "class_", "My", "App_", "(_", "wx_", "._", "App_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timer_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timer", "ID_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timer", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "My", "App_", "(_", "wx_", "._", "App_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "On", "Init_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "USE", "\\u", "EV", "T", "\\u", "IDLE", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "Creat", "e", "Timer_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "frame_", "=_", "Main", "Frame_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Set", "Top", "Window_", "(_", "frame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frame_", "._", "Show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "My", "App_", "(_", "wx_", "._", "App_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Creat", "e", "Timer_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "See", " ", "\"", "Maki", "ng", " ", "a", " ", "render", " ", "loop", "\":", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "wiki", ".", "wx", "widget", "s", ".", "org", "/", "Maki", "ng", "\\u", "a", "\\u", "render", "\\u", "loop_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ano", "ther", " ", "appro", "ach", " ", "is", " ", "to", " ", "use", " ", "EV", "T", "\\u", "IDLE", " ", "in", " ", "Main", "Frame", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "see", " ", "whi", "ch", " ", "one", " ", "fits", " ", "you", " ", "bett", "er", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "=_", "wx_", "._", "Timer_", "(_", "self_", ",_", "self_", "._", "timer", "ID_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "._", "Start_", "(_", "10_", ")_", "#", " ", "10", "ms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "EV", "T", "\\u", "TIMER", "_", "(_", "self_", ",_", "self_", "._", "timer", "ID_", ",_", "self_", "._", "On", "Timer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "My", "App_", "(_", "wx_", "._", "App_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Timer_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer", "Count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", "(\"", "[", "wx", "python", ".", "py", "]", " ", "On", "Time", "r", "()", " ", "%", "d", "\"", " ", "%", " ", "self", ".", "timer", "Count", ")_", "\\u\\u\\uNL\\u\\u\\u_", "cef", "python_", "._", "Messag", "e", "Loop", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "My", "App_", "(_", "wx_", "._", "App_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Exit_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Whe", "n", " ", "app", ".", "Main", "Loop", "()", " ", "return", "s", ",", " ", "Messag", "e", "Loop", "Work", "()", " ", "should_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "not", " ", "be", " ", "call", "ed", " ", "any", "more", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "USE", "\\u", "EV", "T", "\\u", "IDLE", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "._", "Stop_", "(_", ")_", "\\u\\u\\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_", "Get", "Sources_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "source", "s", " ", "of", " ", "all", " ", "python", " ", "function", "s", " ", "and", " ", "method", "s", " ", "from", " ", "this", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "to", " ", "provide", " ", "source", "s", " ", "previe", "w", " ", "to", " ", "wx", "python", ".", "html", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "dictionar", "y", " ", "of", " ", "function", "s", " ", "is", " ", "binde", "d", " ", "to", " ", "\"", "window", ".", "source", "s", "\".", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "this", "Module_", "=_", "sys_", "._", "modules_", "[_", "\\u\\u", "name\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "functions_", "=_", "inspect_", "._", "getmember", "s_", "(_", "this", "Module_", ",_", "inspect_", "._", "isf", "unction_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "classes_", "=_", "inspect_", "._", "getmember", "s_", "(_", "this", "Module_", ",_", "inspect_", "._", "iscl", "ass_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sources_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "func", "Tuple_", "in_", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sources_", "[_", "func", "Tuple_", "[_", "0_", "]_", "]_", "=_", "inspect_", "._", "gets", "ource_", "(_", "func", "Tuple_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "class", "Tuple_", "in_", "classes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class", "Name_", "=_", "class", "Tuple_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class", "Object_", "=_", "class", "Tuple_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "methods_", "=_", "inspect_", "._", "getmember", "s_", "(_", "class", "Object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "method", "Tuple_", "in_", "methods_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sources_", "[_", "method", "Tuple_", "[_", "0_", "]_", "]_", "=_", "inspect_", "._", "gets", "ource_", "(_", "method", "Tuple_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLIN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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
sahana/eden/modules/templates/OCHAROCCA/config.py
[ { "content": "# -*- coding: utf-8 -*-\n\ntry:\n # Python 2.7\n from collections import OrderedDict\nexcept:\n # Python 2.6\n from gluon.contrib.simplejson.ordered_dict import OrderedDict\n\nfrom gluon import current\nfrom gluon.html import *\nfrom gluon.storage import Storage\n\n\n# END =========================================================================", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pyth", "on", " ", "2.7", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "collections_", "import_", "Order", "ed", "Dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pyth", "on", " ", "2.6", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gluon_", "._", "contrib_", "._", "simplejson_", "._", "order", "ed", "\\u", "dict_", "import_", "Order", "ed", "Dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "gluon_", "import_", "current_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "html_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "storage_", "import_", "Storage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "END", " ", "==============", "==============", "==============", "==============", "==============", "===", "_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 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, 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 ]
Variable defined multiple times
enthought/traitsui/traitsui/wx/table_editor.py
[ { "content": " def init ( self, parent ):\n \"\"\" Finishes initializing the editor by creating the underlying toolkit\n widget.\n \"\"\"\n\n factory = self.factory\n self.filter = factory.filter\n self.auto_add = (factory.auto_add and (factory.row_factory is not None))\n\n columns = factory.columns[:]\n if (len( columns ) == 0) and (len( self.value ) > 0):\n columns = [ ObjectColumn( name = name )\n for name in self.value[0].editable_traits() ]\n self.columns = columns\n\n self.model = model = TableModel(\n editor = self,\n reverse = factory.reverse )\n model.on_trait_change( self._model_sorted, 'sorted', dispatch = 'ui' )\n mode = factory.selection_mode\n row_mode = mode in ( 'row', 'rows' )\n selected = None\n items = model.get_filtered_items()\n if factory.editable and (len( items ) > 0):\n selected = items[0]\n if (factory.edit_view == ' ') or (not row_mode):\n self.control = panel = TraitsUIPanel( parent, -1 )\n sizer = wx.BoxSizer( wx.VERTICAL )\n self._create_toolbar( panel, sizer )\n\n # Create the table (i.e. grid) control:\n hsizer = wx.BoxSizer( wx.HORIZONTAL )\n self._create_grid( panel, hsizer )\n sizer.Add( hsizer, 1, wx.EXPAND )\n else:\n item = self.item\n name = item.get_label( self.ui )\n theme = factory.dock_theme or item.container.dock_theme\n self.control = dw = DockWindow( parent, theme = theme ).control\n panel = TraitsUIPanel( dw, -1, size = ( 300, 300 ) )\n sizer = wx.BoxSizer( wx.VERTICAL )\n dc = DockControl( name = name + ' Table',\n id = 'table',\n control = panel,\n style = 'fixed' )\n contents = [ DockRegion( contents = [ dc ] ) ]\n self._create_toolbar( panel, sizer )\n selected = None\n items = model.get_filtered_items()\n if factory.editable and (len( items ) > 0):\n selected = items[0]\n\n # Create the table (i.e. grid) control:\n hsizer = wx.BoxSizer( wx.HORIZONTAL )\n self._create_grid( panel, hsizer )\n sizer.Add( hsizer, 1, wx.EXPAND )\n\n # Assign the initial object here, so a valid editor will be built\n # when the 'edit_traits' call is made:\n self.selected_row = selected\n self._ui = ui = self.edit_traits(\n parent = dw,\n kind = 'subpanel',\n view = View( [ Item( 'selected_row',\n style = 'custom',\n editor = InstanceEditor(\n view = factory.edit_view,\n kind = 'subpanel' ),\n resizable = True,\n width = factory.edit_view_width,\n height = factory.edit_view_height ),\n '|<>' ],\n resizable = True,\n handler = factory.edit_view_handler ) )\n\n # Set the parent UI of the new UI to our own UI:\n ui.parent = self.ui\n\n # Reset the object so that the sub-sub-view will pick up the\n # correct history also:\n self.selected_row = None\n self.selected_row = selected\n\n dc.style = item.dock\n contents.append( DockRegion( contents = [\n DockControl( name = name + ' Editor',\n id = 'editor',\n control = ui.control,\n style = item.dock ) ] ) )\n\n # Finish setting up the DockWindow:\n dw.SetSizer( DockSizer( contents = DockSection(\n contents = contents,\n is_row = (factory.orientation == 'horizontal') ) ) )\n\n # Set up the required externally synchronized traits (if any):\n sv = self.sync_value\n is_list = (mode[-1] == 's')\n sv( factory.click, 'click', 'to' )\n sv( factory.dclick, 'dclick', 'to' )\n sv( factory.filter_name, 'filter', 'from' )\n sv( factory.columns_name, 'columns', is_list = True )\n sv( factory.filtered_indices, 'filtered_indices', 'to' )\n sv( factory.selected, 'selected_%s' % mode, is_list = is_list )\n if is_list:\n sv( factory.selected_indices, 'selected_%s_indices' % mode[:-1],\n is_list = True )\n else:\n sv( factory.selected_indices, 'selected_%s_index' % mode )\n\n # Listen for the selection changing on the grid:\n self.grid.on_trait_change(\n getattr( self, '_selection_%s_updated' % mode ),\n 'selection_changed', dispatch = 'ui' )\n\n # Make sure the selection is initialized:\n if row_mode:\n self.set_selection( items[0:1] )\n else:\n self.set_selection()\n\n\n # Set the min height of the grid panel to 0, this will provide\n # a scrollbar if the window is resized such that only the first row\n # is visible\n panel.SetMinSize((-1, 0))\n\n # Finish the panel layout setup:\n panel.SetSizer( sizer )", "metadata": "root.TableEditor.init", "header": "['class', 'TableEditor', '(', 'Editor', ',', 'BaseTableEditor', ')', ':', '___EOS___']", "index": 168 } ]
[ { "span": "selected ", "start_line": 192, "start_column": 12, "end_line": 192, "end_column": 20 } ]
[ { "span": "selected ", "start_line": 215, "start_column": 12, "end_line": 215, "end_column": 20 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Table", "Editor_", "(_", "Editor_", ",_", "Base", "Table", "Editor_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "init_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Finish", "es", " ", "initiali", "zin", "g", " ", "the", " ", "editor", " ", "by", " ", "creati", "ng", " ", "the", " ", "underl", "ying", " ", "tool", "kit", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "factory_", "=_", "self_", "._", "factory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "filter_", "=_", "factory_", "._", "filter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "\\u", "add_", "=_", "(_", "factory_", "._", "auto", "\\u", "add_", "and_", "(_", "factory_", "._", "row", "\\u", "factory_", "is_", "not_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "columns_", "=_", "factory_", "._", "columns_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "len_", "(_", "columns_", ")_", "==_", "0_", ")_", "and_", "(_", "len_", "(_", "self_", "._", "value_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "columns_", "=_", "[_", "Object", "Column_", "(_", "name_", "=_", "name_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "name_", "in_", "self_", "._", "value_", "[_", "0_", "]_", "._", "edita", "ble", "\\u", "traits_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "columns_", "=_", "columns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "model_", "=_", "model_", "=_", "Table", "Model_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "editor_", "=_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reverse_", "=_", "factory_", "._", "reverse_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "on", "\\u", "tra", "it", "\\u", "change_", "(_", "self_", "._", "\\u", "model", "\\u", "sorted_", ",_", "'", "sorte", "d", "'_", ",_", "dispatch_", "=_", "'", "ui", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mode_", "=_", "factory_", "._", "selection", "\\u", "mode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row", "\\u", "mode_", "=_", "mode_", "in_", "(_", "'", "row", "'_", ",_", "'", "rows", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selected_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "=_", "model_", "._", "get", "\\u", "filter", "ed", "\\u", "items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "factory_", "._", "editable_", "and_", "(_", "len_", "(_", "items_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "selected_", "=_", "items_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "factory_", "._", "edit", "\\u", "view_", "==_", "'", " ", "'_", ")_", "or_", "(_", "not_", "row", "\\u", "mode_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "control_", "=_", "panel_", "=_", "Trait", "s", "UI", "Panel_", "(_", "parent_", ",_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizer_", "=_", "wx_", "._", "Box", "Sizer_", "(_", "wx_", "._", "VERTICAL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "create", "\\u", "toolbar_", "(_", "panel_", ",_", "sizer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "table", " ", "(", "i", ".", "e", ".", " ", "grid", ")", " ", "control", ":_", "\\u\\u\\uNL\\u\\u\\u_", "hsi", "zer_", "=_", "wx_", "._", "Box", "Sizer_", "(_", "wx_", "._", "HORIZONTAL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "create", "\\u", "grid_", "(_", "panel_", ",_", "hsi", "zer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizer_", "._", "Add_", "(_", "hsi", "zer_", ",_", "1_", ",_", "wx_", "._", "EXPAND_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item_", "=_", "self_", "._", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "item_", "._", "get", "\\u", "label_", "(_", "self_", "._", "ui_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theme_", "=_", "factory_", "._", "dock", "\\u", "theme_", "or_", "item_", "._", "container_", "._", "dock", "\\u", "theme_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "control_", "=_", "dw_", "=_", "Dock", "Window_", "(_", "parent_", ",_", "theme_", "=_", "theme_", ")_", "._", "control_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "=_", "Trait", "s", "UI", "Panel_", "(_", "dw_", ",_", "-_", "1_", ",_", "size_", "=_", "(_", "300_", ",_", "300_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizer_", "=_", "wx_", "._", "Box", "Sizer_", "(_", "wx_", "._", "VERTICAL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dc_", "=_", "Dock", "Control_", "(_", "name_", "=_", "name_", "+_", "'", " ", "Table", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "table", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "control_", "=_", "panel_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "style_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contents_", "=_", "[_", "Dock", "Region_", "(_", "contents_", "=_", "[_", "dc_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "create", "\\u", "toolbar_", "(_", "panel_", ",_", "sizer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selected_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "=_", "model_", "._", "get", "\\u", "filter", "ed", "\\u", "items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "factory_", "._", "editable_", "and_", "(_", "len_", "(_", "items_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "selected_", "=_", "items_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "table", " ", "(", "i", ".", "e", ".", " ", "grid", ")", " ", "control", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hsi", "zer_", "=_", "wx_", "._", "Box", "Sizer_", "(_", "wx_", "._", "HORIZONTAL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "create", "\\u", "grid_", "(_", "panel_", ",_", "hsi", "zer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizer_", "._", "Add_", "(_", "hsi", "zer_", ",_", "1_", ",_", "wx_", "._", "EXPAND_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Assign", " ", "the", " ", "initial", " ", "object", " ", "here", ",", " ", "so", " ", "a", " ", "valid", " ", "editor", " ", "will", " ", "be", " ", "built_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whe", "n", " ", "the", " ", "'", "edit", "\\u", "traits", "'", " ", "call", " ", "is", " ", "made", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "selecte", "d\\u", "row_", "=_", "selected_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ui_", "=_", "ui_", "=_", "self_", "._", "edit", "\\u", "traits_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "=_", "dw_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kind_", "=_", "'", "subpa", "nel", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view_", "=_", "View_", "(_", "[_", "Item_", "(_", "'", "selecte", "d\\u", "row", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "style_", "=_", "'", "custom", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "editor_", "=_", "Insta", "nce", "Editor_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "view_", "=_", "factory_", "._", "edit", "\\u", "view_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kind_", "=_", "'", "subpa", "nel", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "resizable", "_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "width_", "=_", "factory_", "._", "edit", "\\u", "view", "\\u", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "height_", "=_", "factory_", "._", "edit", "\\u", "view", "\\u", "height_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'|", "<>", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "resizable", "_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "handler_", "=_", "factory_", "._", "edit", "\\u", "view", "\\u", "handler_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "the", " ", "parent", " ", "UI", " ", "of", " ", "the", " ", "new", " ", "UI", " ", "to", " ", "our", " ", "own", " ", "UI", ":_", "\\u\\u\\uNL\\u\\u\\u_", "ui_", "._", "parent_", "=_", "self_", "._", "ui_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Reset", " ", "the", " ", "object", " ", "so", " ", "tha", "t", " ", "the", " ", "sub", "-", "sub", "-", "view", " ", "will", " ", "pick", " ", "up", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "correct", " ", "histo", "ry", " ", "als", "o", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "selecte", "d\\u", "row_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "selecte", "d\\u", "row_", "=_", "selected_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dc_", "._", "style_", "=_", "item_", "._", "dock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contents_", "._", "append_", "(_", "Dock", "Region_", "(_", "contents_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "Dock", "Control_", "(_", "name_", "=_", "name_", "+_", "'", " ", "Edit", "or", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "editor", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "control_", "=_", "ui_", "._", "control_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "style_", "=_", "item_", "._", "dock_", ")_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Finish", " ", "setti", "ng", " ", "up", " ", "the", " ", "Dock", "Window", ":_", "\\u\\u\\uNL\\u\\u\\u_", "dw_", "._", "Set", "Sizer_", "(_", "Dock", "Sizer_", "(_", "contents_", "=_", "Dock", "Section_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "contents_", "=_", "contents_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "row_", "=_", "(_", "factory_", "._", "orientation_", "==_", "'", "horizon", "tal", "'_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "up", " ", "the", " ", "require", "d", " ", "external", "ly", " ", "synchronized", " ", "traits", " ", "(", "if", " ", "any", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sv_", "=_", "self_", "._", "sync", "\\u", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "list_", "=_", "(_", "mode_", "[_", "-_", "1_", "]_", "==_", "'", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv_", "(_", "factory_", "._", "click_", ",_", "'", "click", "'_", ",_", "'", "to", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv_", "(_", "factory_", "._", "dcl", "ick", "_", ",_", "'", "dcl", "ick", "'_", ",_", "'", "to", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv_", "(_", "factory_", "._", "filter", "\\u", "name_", ",_", "'", "filter", "'_", ",_", "'", "from", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv_", "(_", "factory_", "._", "column", "s", "\\u", "name_", ",_", "'", "column", "s", "'_", ",_", "is", "\\u", "list_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv_", "(_", "factory_", "._", "filter", "ed", "\\u", "indices_", ",_", "'", "filter", "ed", "\\u", "indice", "s", "'_", ",_", "'", "to", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv_", "(_", "factory_", "._", "selected_", ",_", "'", "selecte", "d\\u", "%", "s", "'_", "%_", "mode_", ",_", "is", "\\u", "list_", "=_", "is", "\\u", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "is", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sv_", "(_", "factory_", "._", "selecte", "d\\u", "indices_", ",_", "'", "selecte", "d\\u", "%", "s", "\\u", "indice", "s", "'_", "%_", "mode_", "[_", ":_", "-_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "list_", "=_", "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 ", " _", "sv_", "(_", "factory_", "._", "selecte", "d\\u", "indices_", ",_", "'", "selecte", "d\\u", "%", "s", "\\u", "index", "'_", "%_", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Listen", " ", "for", " ", "the", " ", "selection", " ", "chang", "ing", " ", "on", " ", "the", " ", "grid", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "grid_", "._", "on", "\\u", "tra", "it", "\\u", "change_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "getattr_", "(_", "self_", ",_", "'\\u", "selection", "\\u", "%", "s", "\\u", "update", "d", "'_", "%_", "mode_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "selection", "\\u", "change", "d", "'_", ",_", "dispatch_", "=_", "'", "ui", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "selection", " ", "is", " ", "initialize", "d", ":_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "row", "\\u", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set\\u", "selection_", "(_", "items_", "[_", "0_", ":_", "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_", "._", "set\\u", "selection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "the", " ", "min", " ", "height", " ", "of", " ", "the", " ", "grid", " ", "panel", " ", "to", " ", "0", ",", " ", "this", " ", "will", " ", "provide", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "scrollbar", " ", "if", " ", "the", " ", "window", " ", "is", " ", "resized", " ", "suc", "h", " ", "tha", "t", " ", "only", " ", "the", " ", "first", " ", "row_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "visible_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "panel_", "._", "Set", "Min", "Size_", "(_", "(_", "-_", "1_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Finish", " ", "the", " ", "panel", " ", "layout", " ", "setup", ":_", "\\u\\u\\uNL\\u\\u\\u_", "panel_", "._", "Set", "Sizer_", "(_", "sizer_", ")_", "\\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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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 ]
Unreachable code
mne-tools/mne-python/mne/minimum_norm/inverse.py
[ { "content": "@verbose\ndef make_inverse_operator(info, forward, noise_cov, loose=0.2, depth=0.8,\n fixed=False, limit_depth_chs=True, rank=None,\n verbose=None):\n \"\"\"Assemble inverse operator\n\n Parameters\n ----------\n info : dict\n The measurement info to specify the channels to include.\n Bad channels in info['bads'] are not used.\n forward : dict\n Forward operator.\n noise_cov : instance of Covariance\n The noise covariance matrix.\n loose : None | float in [0, 1]\n Value that weights the source variances of the dipole components\n defining the tangent space of the cortical surfaces. Requires surface-\n based, free orientation forward solutions.\n depth : None | float in [0, 1]\n Depth weighting coefficients. If None, no depth weighting is performed.\n fixed : bool\n Use fixed source orientations normal to the cortical mantle. If True,\n the loose parameter is ignored.\n limit_depth_chs : bool\n If True, use only grad channels in depth weighting (equivalent to MNE\n C code). If grad chanels aren't present, only mag channels will be\n used (if no mag, then eeg). If False, use all channels.\n rank : None | int | dict\n Specified rank of the noise covariance matrix. If None, the rank is\n detected automatically. If int, the rank is specified for the MEG\n channels. A dictionary with entries 'eeg' and/or 'meg' can be used\n to specify the rank for each modality.\n verbose : bool, str, int, or None\n If not None, override default verbose level (see mne.verbose).\n\n Returns\n -------\n inv : instance of InverseOperator\n Inverse operator.\n\n Notes\n -----\n For different sets of options (**loose**, **depth**, **fixed**) to work,\n the forward operator must have been loaded using a certain configuration\n (i.e., with **force_fixed** and **surf_ori** set appropriately). For\n example, given the desired inverse type (with representative choices\n of **loose** = 0.2 and **depth** = 0.8 shown in the table in various\n places, as these are the defaults for those parameters):\n\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | Inverse desired | Forward parameters allowed |\n +=====================+===========+===========+===========+=================+==============+\n | | **loose** | **depth** | **fixed** | **force_fixed** | **surf_ori** |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | | Loose constraint, | 0.2 | 0.8 | False | False | True |\n | | Depth weighted | | | | | |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | | Loose constraint | 0.2 | None | False | False | True |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | | Free orientation, | None | 0.8 | False | False | True |\n | | Depth weighted | | | | | |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | | Free orientation | None | None | False | False | True | False |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | | Fixed constraint, | None | 0.8 | True | False | True |\n | | Depth weighted | | | | | |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n | | Fixed constraint | None | None | True | True | True |\n +---------------------+-----------+-----------+-----------+-----------------+--------------+\n\n Also note that, if the source space (as stored in the forward solution)\n has patch statistics computed, these are used to improve the depth\n weighting. Thus slightly different results are to be expected with\n and without this information.\n \"\"\" # noqa\n is_fixed_ori = is_fixed_orient(forward)\n\n if fixed and loose is not None:\n warn('When invoking make_inverse_operator with fixed=True, the loose '\n 'parameter is ignored.')\n loose = None\n\n if is_fixed_ori and not fixed:\n raise ValueError('Forward operator has fixed orientation and can only '\n 'be used to make a fixed-orientation inverse '\n 'operator.')\n if fixed:\n if depth is not None:\n if is_fixed_ori or not forward['surf_ori']:\n raise ValueError('For a fixed orientation inverse solution '\n 'with depth weighting, the forward solution '\n 'must be free-orientation and in surface '\n 'orientation')\n elif forward['surf_ori'] is False:\n raise ValueError('For a fixed orientation inverse solution '\n 'without depth weighting, the forward solution '\n 'must be in surface orientation')\n\n # depth=None can use fixed fwd, depth=0<x<1 must use free ori\n if depth is not None:\n if not (0 < depth <= 1):\n raise ValueError('depth should be a scalar between 0 and 1')\n if is_fixed_ori:\n raise ValueError('You need a free-orientation, surface-oriented '\n 'forward solution to do depth weighting even '\n 'when calculating a fixed-orientation inverse.')\n if not forward['surf_ori']:\n forward = convert_forward_solution(forward, surf_ori=True)\n assert forward['surf_ori']\n if loose is not None:\n if not (0 <= loose <= 1):\n raise ValueError('loose value should be smaller than 1 and bigger '\n 'than 0, or None for not loose orientations.')\n if loose < 1 and not forward['surf_ori']:\n raise ValueError('Forward operator is not oriented in surface '\n 'coordinates. A loose inverse operator requires '\n 'a surface-based, free orientation forward '\n 'operator.')\n\n #\n # 1. Read the bad channels\n # 2. Read the necessary data from the forward solution matrix file\n # 3. Load the projection data\n # 4. Load the sensor noise covariance matrix and attach it to the forward\n #\n\n gain_info, gain, noise_cov, whitener, n_nzero = \\\n _prepare_forward(forward, info, noise_cov, rank=rank)\n forward['info']._check_consistency()\n\n #\n # 5. Compose the depth-weighting matrix\n #\n\n if depth is not None:\n patch_areas = forward.get('patch_areas', None)\n depth_prior = compute_depth_prior(gain, gain_info, is_fixed_ori,\n exp=depth, patch_areas=patch_areas,\n limit_depth_chs=limit_depth_chs)\n else:\n depth_prior = np.ones(gain.shape[1], dtype=gain.dtype)\n\n # Deal with fixed orientation forward / inverse\n if fixed:\n if depth is not None:\n # Convert the depth prior into a fixed-orientation one\n logger.info(' Picked elements from a free-orientation '\n 'depth-weighting prior into the fixed-orientation one')\n if not is_fixed_ori:\n # Convert to the fixed orientation forward solution now\n depth_prior = depth_prior[2::3]\n forward = convert_forward_solution(\n forward, surf_ori=forward['surf_ori'], force_fixed=True)\n is_fixed_ori = is_fixed_orient(forward)\n gain_info, gain, noise_cov, whitener, n_nzero = \\\n _prepare_forward(forward, info, noise_cov, verbose=False)\n\n logger.info(\"Computing inverse operator with %d channels.\"\n % len(gain_info['ch_names']))\n\n #\n # 6. Compose the source covariance matrix\n #\n\n logger.info('Creating the source covariance matrix')\n source_cov = depth_prior.copy()\n depth_prior = dict(data=depth_prior, kind=FIFF.FIFFV_MNE_DEPTH_PRIOR_COV,\n bads=[], diag=True, names=[], eig=None,\n eigvec=None, dim=depth_prior.size, nfree=1,\n projs=[])\n\n # apply loose orientations\n if not is_fixed_ori:\n orient_prior = compute_orient_prior(forward, loose=loose)\n source_cov *= orient_prior\n orient_prior = dict(data=orient_prior,\n kind=FIFF.FIFFV_MNE_ORIENT_PRIOR_COV,\n bads=[], diag=True, names=[], eig=None,\n eigvec=None, dim=orient_prior.size, nfree=1,\n projs=[])\n else:\n orient_prior = None\n\n # 7. Apply fMRI weighting (not done)\n\n #\n # 8. Apply the linear projection to the forward solution\n # 9. Apply whitening to the forward computation matrix\n #\n logger.info('Whitening the forward solution.')\n gain = np.dot(whitener, gain)\n\n # 10. Exclude the source space points within the labels (not done)\n\n #\n # 11. Do appropriate source weighting to the forward computation matrix\n #\n\n # Adjusting Source Covariance matrix to make trace of G*R*G' equal\n # to number of sensors.\n logger.info('Adjusting source covariance matrix.')\n source_std = np.sqrt(source_cov)\n gain *= source_std[None, :]\n trace_GRGT = linalg.norm(gain, ord='fro') ** 2\n scaling_source_cov = n_nzero / trace_GRGT\n source_cov *= scaling_source_cov\n gain *= sqrt(scaling_source_cov)\n\n source_cov = dict(data=source_cov, dim=source_cov.size,\n kind=FIFF.FIFFV_MNE_SOURCE_COV, diag=True,\n names=[], projs=[], eig=None, eigvec=None,\n nfree=1, bads=[])\n\n # now np.trace(np.dot(gain, gain.T)) == n_nzero\n # logger.info(np.trace(np.dot(gain, gain.T)), n_nzero)\n\n #\n # 12. Decompose the combined matrix\n #\n\n logger.info('Computing SVD of whitened and weighted lead field '\n 'matrix.')\n eigen_fields, sing, eigen_leads = linalg.svd(gain, full_matrices=False)\n logger.info(' largest singular value = %g' % np.max(sing))\n logger.info(' scaling factor to adjust the trace = %g' % trace_GRGT)\n\n eigen_fields = dict(data=eigen_fields.T, col_names=gain_info['ch_names'],\n row_names=[], nrow=eigen_fields.shape[1],\n ncol=eigen_fields.shape[0])\n eigen_leads = dict(data=eigen_leads.T, nrow=eigen_leads.shape[1],\n ncol=eigen_leads.shape[0], row_names=[],\n col_names=[])\n nave = 1.0\n\n # Handle methods\n has_meg = False\n has_eeg = False\n ch_idx = [k for k, c in enumerate(info['chs'])\n if c['ch_name'] in gain_info['ch_names']]\n for idx in ch_idx:\n ch_type = channel_type(info, idx)\n if ch_type == 'eeg':\n has_eeg = True\n if (ch_type == 'mag') or (ch_type == 'grad'):\n has_meg = True\n if has_eeg and has_meg:\n methods = FIFF.FIFFV_MNE_MEG_EEG\n elif has_meg:\n methods = FIFF.FIFFV_MNE_MEG\n else:\n methods = FIFF.FIFFV_MNE_EEG\n\n # We set this for consistency with mne C code written inverses\n if depth is None:\n depth_prior = None\n inv_op = dict(eigen_fields=eigen_fields, eigen_leads=eigen_leads,\n sing=sing, nave=nave, depth_prior=depth_prior,\n source_cov=source_cov, noise_cov=noise_cov,\n orient_prior=orient_prior, projs=deepcopy(info['projs']),\n eigen_leads_weighted=False, source_ori=forward['source_ori'],\n mri_head_t=deepcopy(forward['mri_head_t']),\n methods=methods, nsource=forward['nsource'],\n coord_frame=forward['coord_frame'],\n source_nn=forward['source_nn'].copy(),\n src=deepcopy(forward['src']), fmri_prior=None)\n inv_info = deepcopy(forward['info'])\n inv_info['bads'] = [bad for bad in info['bads']\n if bad in inv_info['ch_names']]\n inv_info._check_consistency()\n inv_op['units'] = 'Am'\n inv_op['info'] = inv_info\n\n return InverseOperator(inv_op)", "metadata": "root.make_inverse_operator", "header": "['module', '___EOS___']", "index": 1162 } ]
[ { "span": "raise ValueError('You need a free-orientation, surface-oriented '\n 'forward solution to do depth weighting even '\n 'when calculating a fixed-orientation inverse.')", "start_line": 1266, "start_column": 12, "end_line": 1268, "end_column": 77 } ]
[]
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_", "@_", "verbose_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "make", "\\u", "inv", "erse", "\\u", "operator_", "(_", "info_", ",_", "forward_", ",_", "noise", "\\u", "cov_", ",_", "loose", "_", "=_", "0.2_", ",_", "depth_", "=_", "0.8_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fixed_", "=_", "False_", ",_", "limit", "\\u", "depth", "\\u", "chs", "_", "=_", "True_", ",_", "rank_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "verbose_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Assemble", " ", "inv", "erse", " ", "opera", "tor", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "info", " ", ":", " ", "dict", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "measure", "ment", " ", "info", " ", "to", " ", "speci", "fy", " ", "the", " ", "channel", "s", " ", "to", " ", "include", ".", "\\", "10", ";", " ", " ", " ", " ", "Ba", "d", " ", "channel", "s", " ", "in", " ", "info", "['", "bad", "s", "']", " ", "are", " ", "not", " ", "used", ".", "\\", "10", ";", " ", " ", " ", " ", "forward", " ", ":", " ", "dict", "\\", "10", ";", " ", " ", " ", " ", "Forward", " ", "opera", "tor", ".", "\\", "10", ";", " ", " ", " ", " ", "noise", "\\u", "cov", " ", ":", " ", "instance", " ", "of", " ", "Covar", "iance", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "noise", " ", "covariance", " ", "matrix", ".", "\\", "10", ";", " ", " ", " ", " ", "loose", " ", ":", " ", "Non", "e", " ", "|", " ", "float", " ", "in", " ", "[", "0", ",", " ", "1", "]", "\\", "10", ";", " ", " ", " ", " ", "Value", " ", "tha", "t", " ", "weight", "s", " ", "the", " ", "source", " ", "varian", "ces", " ", "of", " ", "the", " ", "dipole", " ", "component", "s", "\\", "10", ";", " ", " ", " ", " ", "defini", "ng", " ", "the", " ", "tangent", " ", "space", " ", "of", " ", "the", " ", "cort", "ical", " ", "surfaces", ".", " ", "Requ", "ires", " ", "surf", "ace", "-", "\\", "10", ";", " ", " ", " ", " ", "based", ",", " ", "free", " ", "orientation", " ", "forward", " ", "solut", "ion", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "depth", " ", ":", " ", "Non", "e", " ", "|", " ", "float", " ", "in", " ", "[", "0", ",", " ", "1", "]", "\\", "10", ";", " ", " ", " ", " ", "Dep", "th", " ", "weighting", " ", "coefficient", "s", ".", " ", "If", " ", "Non", "e", ",", " ", "no", " ", "depth", " ", "weighting", " ", "is", " ", "perform", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "fixed", " ", ":", " ", "bool", "\\", "10", ";", " ", " ", " ", " ", "Us", "e", " ", "fixed", " ", "source", " ", "orientation", "s", " ", "normal", " ", "to", " ", "the", " ", "cort", "ical", " ", "mant", "le", ".", " ", "If", " ", "Tru", "e", ",", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "loose", " ", "parameter", " ", "is", " ", "ignore", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "limit", "\\u", "depth", "\\u", "chs", " ", ":", " ", "bool", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "Tru", "e", ",", " ", "use", " ", "only", " ", "grad", " ", "channel", "s", " ", "in", " ", "depth", " ", "weighting", " ", "(", "equivalent", " ", "to", " ", "MN", "E", "\\", "10", ";", " ", " ", " ", " ", "C", " ", "code", ").", " ", "If", " ", "grad", " ", "chan", "el", "s", " ", "are", "n", "'", "t", " ", "presen", "t", ",", " ", "only", " ", "mag", " ", "channel", "s", " ", "will", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "used", " ", "(", "if", " ", "no", " ", "mag", ",", " ", "then", " ", "ee", "g", ").", " ", "If", " ", "Fal", "se", ",", " ", "use", " ", "all", " ", "channel", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "rank", " ", ":", " ", "Non", "e", " ", "|", " ", "int", " ", "|", " ", "dict", "\\", "10", ";", " ", " ", " ", " ", "Specifie", "d", " ", "rank", " ", "of", " ", "the", " ", "noise", " ", "covariance", " ", "matrix", ".", " ", "If", " ", "Non", "e", ",", " ", "the", " ", "rank", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "detect", "ed", " ", "automati", "call", "y", ".", " ", "If", " ", "int", ",", " ", "the", " ", "rank", " ", "is", " ", "specified", " ", "for", " ", "the", " ", "ME", "G", "\\", "10", ";", " ", " ", " ", " ", "channel", "s", ".", " ", "A", " ", "dictionar", "y", " ", "with", " ", "entri", "es", " ", "'", "ee", "g", "'", " ", "and", "/", "or", " ", "'", "me", "g", "'", " ", "can", " ", "be", " ", "used", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "speci", "fy", " ", "the", " ", "rank", " ", "for", " ", "each", " ", "modalit", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "verbo", "se", " ", ":", " ", "bool", ",", " ", "str", ",", " ", "int", ",", " ", "or", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "not", " ", "Non", "e", ",", " ", "override", " ", "default", " ", "verbo", "se", " ", "level", " ", "(", "see", " ", "mne", ".", "verbo", "se", ").", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "inv", " ", ":", " ", "instance", " ", "of", " ", "Inv", "erse", "Opera", "tor", "\\", "10", ";", " ", " ", " ", " ", "Inv", "erse", " ", "opera", "tor", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "es", "\\", "10", ";", " ", " ", " ", " ", "-----", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "different", " ", "sets", " ", "of", " ", "options", " ", "(*", "*", "loose", "**", ",", " ", "**", "depth", "**", ",", " ", "**", "fixed", "**", ")", " ", "to", " ", "work", ",", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "forward", " ", "opera", "tor", " ", "must", " ", "have", " ", "bee", "n", " ", "load", "ed", " ", "usi", "ng", " ", "a", " ", "cert", "ain", " ", "configura", "tion", "\\", "10", ";", " ", " ", " ", " ", "(", "i", ".", "e", ".,", " ", "with", " ", "**", "force", "\\u", "fixed", "**", " ", "and", " ", "**", "surf", "\\u", "ori", "**", " ", "set", " ", "appropr", "iate", "ly", ").", " ", "For", "\\", "10", ";", " ", " ", " ", " ", "example", ",", " ", "give", "n", " ", "the", " ", "desi", "red", " ", "inv", "erse", " ", "type", " ", "(", "with", " ", "representative", " ", "choice", "s", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "**", "loose", "**", " ", "=", " ", "0.", "2", " ", "and", " ", "**", "depth", "**", " ", "=", " ", "0.", "8", " ", "shown", " ", "in", " ", "the", " ", "table", " ", "in", " ", "vari", "ous", "\\", "10", ";", " ", " ", " ", " ", "place", "s", ",", " ", "as", " ", "these", " ", "are", " ", "the", " ", "default", "s", " ", "for", " ", "tho", "se", " ", "parameter", "s", "):", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "Inv", "erse", " ", "desi", "red", " ", " ", " ", "|", " ", "Forward", " ", "parameter", "s", " ", "allow", "ed", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+===", "==============", "====", "+===", "=======", "=+", "=========", "==", "+===", "=======", "=+", "==============", "===", "+===", "=========", "==", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", " ", " ", "|", " ", "**", "loose", "**", " ", "|", " ", "**", "depth", "**", " ", "|", " ", "**", "fixed", "**", " ", "|", " ", "**", "force", "\\u", "fixed", "**", " ", "|", " ", "**", "surf", "\\u", "ori", "**", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Lo", "ose", " ", "constraint", ",", " ", "|", " ", "0.", "2", " ", " ", " ", "|", " ", "0.", "8", " ", " ", " ", "|", " ", "Fal", "se", " ", "|", " ", "Fal", "se", " ", " ", " ", "|", " ", "Tru", "e", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Dep", "th", " ", "weight", "ed", " ", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", " ", " ", "|", " ", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Lo", "ose", " ", "constraint", " ", " ", "|", " ", "0.", "2", " ", " ", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "Fal", "se", " ", "|", " ", "Fal", "se", " ", " ", " ", "|", " ", "Tru", "e", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Free", " ", "orientation", ",", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "0.", "8", " ", " ", " ", "|", " ", "Fal", "se", " ", "|", " ", "Fal", "se", " ", " ", " ", "|", " ", "Tru", "e", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Dep", "th", " ", "weight", "ed", " ", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", " ", " ", "|", " ", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Free", " ", "orientation", " ", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "Fal", "se", " ", "|", " ", "Fal", "se", " ", " ", " ", "|", " ", "Tru", "e", " ", "|", " ", "Fal", "se", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Fix", "ed", " ", "constraint", ",", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "0.", "8", " ", " ", " ", "|", " ", "Tru", "e", " ", " ", "|", " ", "Fal", "se", " ", " ", " ", "|", " ", "Tru", "e", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Dep", "th", " ", "weight", "ed", " ", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", "|", " ", " ", " ", " ", " ", "|", " ", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "|", " ", "Fix", "ed", " ", "constraint", " ", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "Non", "e", " ", " ", "|", " ", "Tru", "e", " ", " ", "|", " ", "Tru", "e", " ", " ", " ", " ", "|", " ", "Tru", "e", " ", " ", " ", " ", " ", "|", "\\", "10", ";", " ", " ", " ", " ", "+----------", "-----------", "+----------", "-+-----", "------+", "-----------", "+----------", "-------", "+----------", "----", "+", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Al", "so", " ", "note", " ", "tha", "t", ",", " ", "if", " ", "the", " ", "source", " ", "space", " ", "(", "as", " ", "store", "d", " ", "in", " ", "the", " ", "forward", " ", "solut", "ion", ")", "\\", "10", ";", " ", " ", " ", " ", "has", " ", "patch", " ", "statistic", "s", " ", "compute", "d", ",", " ", "these", " ", "are", " ", "used", " ", "to", " ", "improve", " ", "the", " ", "depth", "\\", "10", ";", " ", " ", " ", " ", "weighting", ".", " ", "Thu", "s", " ", "slight", "ly", " ", "different", " ", "results", " ", "are", " ", "to", " ", "be", " ", "expected", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "with", "out", " ", "this", " ", "informati", "on", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "#", " ", "no", "qa_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "fixed", "\\u", "ori_", "=_", "is", "\\u", "fixed", "\\u", "orient_", "(_", "forward_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "fixed_", "and_", "loose", "_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warn_", "(_", "'", "Whe", "n", " ", "inv", "oki", "ng", " ", "make", "\\u", "inv", "erse", "\\u", "opera", "tor", " ", "with", " ", "fixed", "=", "Tru", "e", ",", " ", "the", " ", "loose", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parameter", " ", "is", " ", "ignore", "d", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loose", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "is", "\\u", "fixed", "\\u", "ori_", "and_", "not_", "fixed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Forward", " ", "opera", "tor", " ", "has", " ", "fixed", " ", "orientation", " ", "and", " ", "can", " ", "only", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "be", " ", "used", " ", "to", " ", "make", " ", "a", " ", "fixed", "-", "orientation", " ", "inv", "erse", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "opera", "tor", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fixed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "depth_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "is", "\\u", "fixed", "\\u", "ori_", "or_", "not_", "forward_", "[_", "'", "surf", "\\u", "ori", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "For", " ", "a", " ", "fixed", " ", "orientation", " ", "inv", "erse", " ", "solut", "ion", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "with", " ", "depth", " ", "weighting", ",", " ", "the", " ", "forward", " ", "solut", "ion", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "must", " ", "be", " ", "free", "-", "orientation", " ", "and", " ", "in", " ", "surf", "ace", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "orientation", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "forward_", "[_", "'", "surf", "\\u", "ori", "'_", "]_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "For", " ", "a", " ", "fixed", " ", "orientation", " ", "inv", "erse", " ", "solut", "ion", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "with", "out", " ", "depth", " ", "weighting", ",", " ", "the", " ", "forward", " ", "solut", "ion", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "must", " ", "be", " ", "in", " ", "surf", "ace", " ", "orientation", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "depth", "=", "Non", "e", " ", "can", " ", "use", " ", "fixed", " ", "fw", "d", ",", " ", "depth", "=", "0", "<", "x", "<", "1", " ", "must", " ", "use", " ", "free", " ", "ori_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "depth_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "(_", "0_", "<_", "depth_", "<=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "depth", " ", "shou", "ld", " ", "be", " ", "a", " ", "scala", "r", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "is", "\\u", "fixed", "\\u", "ori_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "You", " ", "need", " ", "a", " ", "free", "-", "orientation", ",", " ", "surf", "ace", "-", "orient", "ed", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "forward", " ", "solut", "ion", " ", "to", " ", "do", " ", "depth", " ", "weighting", " ", "even", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "whe", "n", " ", "calculati", "ng", " ", "a", " ", "fixed", "-", "orientation", " ", "inv", "erse", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "forward_", "[_", "'", "surf", "\\u", "ori", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "forward_", "=_", "convert", "\\u", "forward", "\\u", "solution_", "(_", "forward_", ",_", "surf", "\\u", "ori_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "forward_", "[_", "'", "surf", "\\u", "ori", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "loose", "_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "(_", "0_", "<=_", "loose", "_", "<=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "loose", " ", "value", " ", "shou", "ld", " ", "be", " ", "small", "er", " ", "than", " ", "1", " ", "and", " ", "bigger", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "than", " ", "0", ",", " ", "or", " ", "Non", "e", " ", "for", " ", "not", " ", "loose", " ", "orientation", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "loose", "_", "<_", "1_", "and_", "not_", "forward_", "[_", "'", "surf", "\\u", "ori", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Forward", " ", "opera", "tor", " ", "is", " ", "not", " ", "orient", "ed", " ", "in", " ", "surf", "ace", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "coordinate", "s", ".", " ", "A", " ", "loose", " ", "inv", "erse", " ", "opera", "tor", " ", "require", "s", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "a", " ", "surf", "ace", "-", "based", ",", " ", "free", " ", "orientation", " ", "forward", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "opera", "tor", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ".", " ", "Read", " ", "the", " ", "bad", " ", "channels_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", ".", " ", "Read", " ", "the", " ", "necessar", "y", " ", "data", " ", "from", " ", "the", " ", "forward", " ", "solut", "ion", " ", "matrix", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "3", ".", " ", "Load", " ", "the", " ", "projecti", "on", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "4", ".", " ", "Load", " ", "the", " ", "sensor", " ", "noise", " ", "covariance", " ", "matrix", " ", "and", " ", "attach", " ", "it", " ", "to", " ", "the", " ", "forward_", "\\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_", "gain", "\\u", "info_", ",_", "gain_", ",_", "noise", "\\u", "cov_", ",_", "whiten", "er_", ",_", "n", "\\u", "nze", "ro_", "=_", "\\u", "prepar", "e\\u", "forward_", "(_", "forward_", ",_", "info_", ",_", "noise", "\\u", "cov_", ",_", "rank_", "=_", "rank_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "forward_", "[_", "'", "info", "'_", "]_", "._", "\\u", "check", "\\u", "consiste", "ncy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "5", ".", " ", "Compose", " ", "the", " ", "depth", "-", "weighting", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "depth_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "patch", "\\u", "areas_", "=_", "forward_", "._", "get_", "(_", "'", "patch", "\\u", "area", "s", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "depth", "\\u", "prior_", "=_", "compute", "\\u", "depth", "\\u", "prior_", "(_", "gain_", ",_", "gain", "\\u", "info_", ",_", "is", "\\u", "fixed", "\\u", "ori_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "depth_", ",_", "patch", "\\u", "areas_", "=_", "patch", "\\u", "areas_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "limit", "\\u", "depth", "\\u", "chs", "_", "=_", "limit", "\\u", "depth", "\\u", "chs", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "depth", "\\u", "prior_", "=_", "np_", "._", "ones_", "(_", "gain_", "._", "shape_", "[_", "1_", "]_", ",_", "dtype_", "=_", "gain_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Deal", " ", "with", " ", "fixed", " ", "orientation", " ", "forward", " ", "/", " ", "inverse_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fixed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "depth_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Convert", " ", "the", " ", "depth", " ", "prior", " ", "int", "o", " ", "a", " ", "fixed", "-", "orientation", " ", "one_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", " ", " ", "Picke", "d", " ", "element", "s", " ", "from", " ", "a", " ", "free", "-", "orientation", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "depth", "-", "weighting", " ", "prior", " ", "int", "o", " ", "the", " ", "fixed", "-", "orientation", " ", "one", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "is", "\\u", "fixed", "\\u", "ori_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Convert", " ", "to", " ", "the", " ", "fixed", " ", "orientation", " ", "forward", " ", "solut", "ion", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "depth", "\\u", "prior_", "=_", "depth", "\\u", "prior_", "[_", "2_", ":_", ":_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "forward_", "=_", "convert", "\\u", "forward", "\\u", "solution_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "forward_", ",_", "surf", "\\u", "ori_", "=_", "forward_", "[_", "'", "surf", "\\u", "ori", "'_", "]_", ",_", "force", "\\u", "fixed_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "fixed", "\\u", "ori_", "=_", "is", "\\u", "fixed", "\\u", "orient_", "(_", "forward_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gain", "\\u", "info_", ",_", "gain_", ",_", "noise", "\\u", "cov_", ",_", "whiten", "er_", ",_", "n", "\\u", "nze", "ro_", "=_", "\\u", "prepar", "e\\u", "forward_", "(_", "forward_", ",_", "info_", ",_", "noise", "\\u", "cov_", ",_", "verbose_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "Comp", "uti", "ng", " ", "inv", "erse", " ", "opera", "tor", " ", "with", " ", "%", "d", " ", "channel", "s", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "len_", "(_", "gain", "\\u", "info_", "[_", "'", "ch", "\\u", "names", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "6", ".", " ", "Compose", " ", "the", " ", "source", " ", "covariance", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "info_", "(_", "'", "Creat", "ing", " ", "the", " ", "source", " ", "covariance", " ", "matrix", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "\\u", "cov_", "=_", "depth", "\\u", "prior_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "depth", "\\u", "prior_", "=_", "dict_", "(_", "data_", "=_", "depth", "\\u", "prior_", ",_", "kind_", "=_", "FI", "FF_", "._", "FI", "FF", "V", "\\u", "MN", "E", "\\u", "DEPTH", "\\u", "PRI", "OR", "\\u", "CO", "V_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "bad", "s_", "=_", "[_", "]_", ",_", "diag_", "=_", "True_", ",_", "names_", "=_", "[_", "]_", ",_", "eig_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "eigv", "ec_", "=_", "None_", ",_", "dim_", "=_", "depth", "\\u", "prior_", "._", "size_", ",_", "nfr", "ee_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "proj", "s_", "=_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "appl", "y", " ", "loose", " ", "orientation", "s_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "is", "\\u", "fixed", "\\u", "ori_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "orient", "\\u", "prior_", "=_", "compute", "\\u", "orient", "\\u", "prior_", "(_", "forward_", ",_", "loose", "_", "=_", "loose", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "\\u", "cov_", "*=_", "orient", "\\u", "prior_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orient", "\\u", "prior_", "=_", "dict_", "(_", "data_", "=_", "orient", "\\u", "prior_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kind_", "=_", "FI", "FF_", "._", "FI", "FF", "V", "\\u", "MN", "E", "\\u", "ORIE", "NT", "\\u", "PRI", "OR", "\\u", "CO", "V_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "bad", "s_", "=_", "[_", "]_", ",_", "diag_", "=_", "True_", ",_", "names_", "=_", "[_", "]_", ",_", "eig_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "eigv", "ec_", "=_", "None_", ",_", "dim_", "=_", "orient", "\\u", "prior_", "._", "size_", ",_", "nfr", "ee_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "proj", "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 ", " _", "orient", "\\u", "prior_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "7", ".", " ", "Apply", " ", "f", "MR", "I", " ", "weighting", " ", "(", "not", " ", "don", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "8", ".", " ", "Apply", " ", "the", " ", "linear", " ", "projecti", "on", " ", "to", " ", "the", " ", "forward", " ", "solution_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "9", ".", " ", "Apply", " ", "whiten", "ing", " ", "to", " ", "the", " ", "forward", " ", "computation", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "info_", "(_", "'", "White", "ning", " ", "the", " ", "forward", " ", "solut", "ion", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gain_", "=_", "np_", "._", "dot_", "(_", "whiten", "er_", ",_", "gain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "10.", " ", "Exclude", " ", "the", " ", "source", " ", "space", " ", "points", " ", "within", " ", "the", " ", "labels", " ", "(", "not", " ", "don", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "11.", " ", "Do", " ", "appropr", "iate", " ", "source", " ", "weighting", " ", "to", " ", "the", " ", "forward", " ", "computation", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Adjust", "ing", " ", "Sou", "rce", " ", "Covar", "iance", " ", "matrix", " ", "to", " ", "make", " ", "trace", " ", "of", " ", "G", "*", "R", "*", "G", "'", " ", "equal_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "number", " ", "of", " ", "sensor", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "info_", "(_", "'", "Adjust", "ing", " ", "source", " ", "covariance", " ", "matrix", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "\\u", "std_", "=_", "np_", "._", "sqrt_", "(_", "source", "\\u", "cov_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gain_", "*=_", "source", "\\u", "std_", "[_", "None_", ",_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trace", "\\u", "GR", "GT", "_", "=_", "linalg_", "._", "norm_", "(_", "gain_", ",_", "ord_", "=_", "'", "fro", "'_", ")_", "**_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scal", "ing", "\\u", "source", "\\u", "cov_", "=_", "n", "\\u", "nze", "ro_", "/_", "trace", "\\u", "GR", "GT", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "\\u", "cov_", "*=_", "scal", "ing", "\\u", "source", "\\u", "cov_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gain_", "*=_", "sqrt_", "(_", "scal", "ing", "\\u", "source", "\\u", "cov_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "cov_", "=_", "dict_", "(_", "data_", "=_", "source", "\\u", "cov_", ",_", "dim_", "=_", "source", "\\u", "cov_", "._", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "kind_", "=_", "FI", "FF_", "._", "FI", "FF", "V", "\\u", "MN", "E", "\\u", "SOU", "RC", "E", "\\u", "CO", "V_", ",_", "diag_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "names_", "=_", "[_", "]_", ",_", "proj", "s_", "=_", "[_", "]_", ",_", "eig_", "=_", "None_", ",_", "eigv", "ec_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nfr", "ee_", "=_", "1_", ",_", "bad", "s_", "=_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "np", ".", "trace", "(", "np", ".", "dot", "(", "gain", ",", " ", "gain", ".", "T", "))", " ", "==", " ", "n", "\\u", "nze", "ro_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "logg", "er", ".", "info", "(", "np", ".", "trace", "(", "np", ".", "dot", "(", "gain", ",", " ", "gain", ".", "T", "))", ",", " ", "n", "\\u", "nze", "ro", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "12.", " ", "Decomp", "ose", " ", "the", " ", "combin", "ed", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "info_", "(_", "'", "Comp", "uti", "ng", " ", "SV", "D", " ", "of", " ", "whiten", "ed", " ", "and", " ", "weight", "ed", " ", "lead", " ", "field", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "matrix", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eigen", "\\u", "fields_", ",_", "sing", "_", ",_", "eigen", "\\u", "leads", "_", "=_", "linalg_", "._", "svd_", "(_", "gain_", ",_", "full", "\\u", "matrices_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "'", " ", " ", " ", " ", "large", "st", " ", "singular", " ", "value", " ", "=", " ", "%", "g", "'_", "%_", "np_", "._", "max_", "(_", "sing", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "'", " ", " ", " ", " ", "scal", "ing", " ", "factor", " ", "to", " ", "adjust", " ", "the", " ", "trace", " ", "=", " ", "%", "g", "'_", "%_", "trace", "\\u", "GR", "GT", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "eigen", "\\u", "fields_", "=_", "dict_", "(_", "data_", "=_", "eigen", "\\u", "fields_", "._", "T_", ",_", "col", "\\u", "names_", "=_", "gain", "\\u", "info_", "[_", "'", "ch", "\\u", "names", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "row", "\\u", "names_", "=_", "[_", "]_", ",_", "nrow_", "=_", "eigen", "\\u", "fields_", "._", "shape_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ncol_", "=_", "eigen", "\\u", "fields_", "._", "shape_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eigen", "\\u", "leads", "_", "=_", "dict_", "(_", "data_", "=_", "eigen", "\\u", "leads", "_", "._", "T_", ",_", "nrow_", "=_", "eigen", "\\u", "leads", "_", "._", "shape_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ncol_", "=_", "eigen", "\\u", "leads", "_", "._", "shape_", "[_", "0_", "]_", ",_", "row", "\\u", "names_", "=_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "col", "\\u", "names_", "=_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nav", "e_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Handle", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "has", "\\u", "me", "g_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "has", "\\u", "ee", "g_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ch", "\\u", "idx_", "=_", "[_", "k_", "for_", "k_", ",_", "c_", "in_", "enumerate_", "(_", "info_", "[_", "'", "chs", "'_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c_", "[_", "'", "ch", "\\u", "name", "'_", "]_", "in_", "gain", "\\u", "info_", "[_", "'", "ch", "\\u", "names", "'_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "idx_", "in_", "ch", "\\u", "idx_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ch", "\\u", "type_", "=_", "channel", "\\u", "type_", "(_", "info_", ",_", "idx_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ch", "\\u", "type_", "==_", "'", "ee", "g", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "has", "\\u", "ee", "g_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "ch", "\\u", "type_", "==_", "'", "mag", "'_", ")_", "or_", "(_", "ch", "\\u", "type_", "==_", "'", "grad", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "has", "\\u", "me", "g_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "has", "\\u", "ee", "g_", "and_", "has", "\\u", "me", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "methods_", "=_", "FI", "FF_", "._", "FI", "FF", "V", "\\u", "MN", "E", "\\u", "ME", "G", "\\u", "EE", "G_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "has", "\\u", "me", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "methods_", "=_", "FI", "FF_", "._", "FI", "FF", "V", "\\u", "MN", "E", "\\u", "ME", "G_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "methods_", "=_", "FI", "FF_", "._", "FI", "FF", "V", "\\u", "MN", "E", "\\u", "EE", "G_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "set", " ", "this", " ", "for", " ", "consiste", "nc", "y", " ", "with", " ", "mne", " ", "C", " ", "code", " ", "writt", "en", " ", "inv", "erse", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "depth_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "depth", "\\u", "prior_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inv", "\\u", "op_", "=_", "dict_", "(_", "eigen", "\\u", "fields_", "=_", "eigen", "\\u", "fields_", ",_", "eigen", "\\u", "leads", "_", "=_", "eigen", "\\u", "leads", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sing", "_", "=_", "sing", "_", ",_", "nav", "e_", "=_", "nav", "e_", ",_", "depth", "\\u", "prior_", "=_", "depth", "\\u", "prior_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "cov_", "=_", "source", "\\u", "cov_", ",_", "noise", "\\u", "cov_", "=_", "noise", "\\u", "cov_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "orient", "\\u", "prior_", "=_", "orient", "\\u", "prior_", ",_", "proj", "s_", "=_", "deepcopy_", "(_", "info_", "[_", "'", "proj", "s", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "eigen", "\\u", "leads", "\\u", "weighted_", "=_", "False_", ",_", "source", "\\u", "ori_", "=_", "forward_", "[_", "'", "source", "\\u", "ori", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mri", "\\u", "head", "\\u", "t_", "=_", "deepcopy_", "(_", "forward_", "[_", "'", "mri", "\\u", "head", "\\u", "t", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "methods_", "=_", "methods_", ",_", "nso", "urc", "e_", "=_", "forward_", "[_", "'", "nso", "urc", "e", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "coord", "\\u", "frame_", "=_", "forward_", "[_", "'", "coord", "\\u", "frame", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "nn_", "=_", "forward_", "[_", "'", "source", "\\u", "nn", "'_", "]_", "._", "copy_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "src_", "=_", "deepcopy_", "(_", "forward_", "[_", "'", "src", "'_", "]_", ")_", ",_", "fm", "ri", "\\u", "prior_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inv", "\\u", "info_", "=_", "deepcopy_", "(_", "forward_", "[_", "'", "info", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inv", "\\u", "info_", "[_", "'", "bad", "s", "'_", "]_", "=_", "[_", "bad_", "for_", "bad_", "in_", "info_", "[_", "'", "bad", "s", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "bad_", "in_", "inv", "\\u", "info_", "[_", "'", "ch", "\\u", "names", "'_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inv", "\\u", "info_", "._", "\\u", "check", "\\u", "consiste", "ncy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inv", "\\u", "op_", "[_", "'", "unit", "s", "'_", "]_", "=_", "'", "Am", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inv", "\\u", "op_", "[_", "'", "info", "'_", "]_", "=_", "inv", "\\u", "info_", "\\u\\u\\uNEWLINE\\u\\u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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
kvh/ramp/ramp/folds.py
[ { "content": " def __iter__(self):\n n = len(self.data)\n index = self.data.index\n indices = range(n)\n foldsize = n / self.num_folds\n folds = []\n if self.seed is not None:\n np.random.seed(self.seed)\n for i in range(self.repeat):\n np.random.shuffle(indices)\n for i in range(self.num_folds):\n test = index[indices[i*foldsize:(i + 1)*foldsize]]\n train = index - test\n assert not (train & test)\n fold = (pd.Index(train), pd.Index(test))\n yield fold", "metadata": "root.BasicFolds.__iter__", "header": "['class', 'BasicFolds', '(', 'object', ')', ':', '___EOS___']", "index": 18 }, { "content": " def __iter__(self):\n n = len(self.data)\n index = self.data.index\n indices = range(n)\n foldsize = n / self.num_folds\n folds = []\n\n if self.seed is not None:\n np.random.seed(self.seed)\n\n for i in range(self.repeat):\n watertight_bins = self.data.groupby(self.leakage_column)[self.data.columns[0]].count()\n watertight_bins = watertight_bins.reindex(np.random.permutation(watertight_bins.index))\n watertight_bins_cum = watertight_bins.cumsum()\n for i in range(self.num_folds):\n test_bins = watertight_bins_cum[(watertight_bins_cum > i * foldsize) &\n (watertight_bins_cum <= (i+1) * foldsize)]\n test =index[self.data[self.leakage_column].isin(test_bins.index)]\n train = index - test\n\n # Sanity checks\n assert not (train & test)\n if np.abs(len(test) - foldsize) > 0.05*foldsize:\n # Folds will not be exact in size, but a warning will be\n # emitted if they are far from the expected value.\n logging.warn(\"Fold deviated from expected size. Target: {target} Actual: {actual}\".format(target=foldsize, actual=len(test)))\n fold = (pd.Index(train), pd.Index(test))\n yield fold", "metadata": "root.WatertightFolds.__iter__", "header": "['class', 'WatertightFolds', '(', 'BasicFolds', ')', ':', '___EOS___']", "index": 48 } ]
[ { "span": "folds ", "start_line": 23, "start_column": 8, "end_line": 23, "end_column": 13 }, { "span": "indices ", "start_line": 51, "start_column": 8, "end_line": 51, "end_column": 15 }, { "span": "folds ", "start_line": 53, "start_column": 8, "end_line": 53, "end_column": 13 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Basic", "Fold", "s_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "len_", "(_", "self_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "=_", "self_", "._", "data_", "._", "index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "indices_", "=_", "range_", "(_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fold", "size_", "=_", "n_", "/_", "self_", "._", "num", "\\u", "folds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "folds_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "seed_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "np_", "._", "random_", "._", "seed_", "(_", "self_", "._", "seed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "repeat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "np_", "._", "random_", "._", "shuffle_", "(_", "indices_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "num", "\\u", "folds_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test_", "=_", "index_", "[_", "indices_", "[_", "i_", "*_", "fold", "size_", ":_", "(_", "i_", "+_", "1_", ")_", "*_", "fold", "size_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train_", "=_", "index_", "-_", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "(_", "train_", "&_", "test_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fold_", "=_", "(_", "pd_", "._", "Index_", "(_", "train_", ")_", ",_", "pd_", "._", "Index_", "(_", "test_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "fold_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Water", "tig", "ht", "Fold", "s_", "(_", "Basic", "Fold", "s_", ")_", ":_", "\\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 ", " _", "n_", "=_", "len_", "(_", "self_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "=_", "self_", "._", "data_", "._", "index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "indices_", "=_", "range_", "(_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fold", "size_", "=_", "n_", "/_", "self_", "._", "num", "\\u", "folds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "folds_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "seed_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "np_", "._", "random_", "._", "seed_", "(_", "self_", "._", "seed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "repeat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "water", "tig", "ht", "\\u", "bins_", "=_", "self_", "._", "data_", "._", "groupby_", "(_", "self_", "._", "leak", "age", "\\u", "column_", ")_", "[_", "self_", "._", "data_", "._", "columns_", "[_", "0_", "]_", "]_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "water", "tig", "ht", "\\u", "bins_", "=_", "water", "tig", "ht", "\\u", "bins_", "._", "reindex", "_", "(_", "np_", "._", "random_", "._", "permutation_", "(_", "water", "tig", "ht", "\\u", "bins_", "._", "index_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "water", "tig", "ht", "\\u", "bins", "\\u", "cum", "_", "=_", "water", "tig", "ht", "\\u", "bins_", "._", "cumsum_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "num", "\\u", "folds_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "bins_", "=_", "water", "tig", "ht", "\\u", "bins", "\\u", "cum", "_", "[_", "(_", "water", "tig", "ht", "\\u", "bins", "\\u", "cum", "_", ">_", "i_", "*_", "fold", "size_", ")_", "&_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "water", "tig", "ht", "\\u", "bins", "\\u", "cum", "_", "<=_", "(_", "i_", "+_", "1_", ")_", "*_", "fold", "size_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "=_", "index_", "[_", "self_", "._", "data_", "[_", "self_", "._", "leak", "age", "\\u", "column_", "]_", "._", "isin_", "(_", "test\\u", "bins_", "._", "index_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train_", "=_", "index_", "-_", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "checks_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "not_", "(_", "train_", "&_", "test_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "np_", "._", "abs_", "(_", "len_", "(_", "test_", ")_", "-_", "fold", "size_", ")_", ">_", "0.05_", "*_", "fold", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fold", "s", " ", "will", " ", "not", " ", "be", " ", "exact", " ", "in", " ", "size", ",", " ", "but", " ", "a", " ", "warn", "ing", " ", "will", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "emitte", "d", " ", "if", " ", "the", "y", " ", "are", " ", "far", " ", "from", " ", "the", " ", "expected", " ", "value", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logging_", "._", "warn_", "(_", "\"", "Fold", " ", "devi", "ated", " ", "from", " ", "expected", " ", "size", ".", " ", "Target", ":", " ", "{", "target", "}", " ", "Actual", ":", " ", "{", "actual", "}\"_", "._", "format_", "(_", "target_", "=_", "fold", "size_", ",_", "actual_", "=_", "len_", "(_", "test_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fold_", "=_", "(_", "pd_", "._", "Index_", "(_", "train_", ")_", ",_", "pd_", "._", "Index_", "(_", "test_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "fold_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
grantbrown/laspy/laspy/glviewer.py
[ { "content": "import laspy\nimport numpy as np\nimport random\nimport sys\n\n# OpenGL library doesn't support absolute import for gl, glu, glut, or arrays\nimport OpenGL.GL as gl \nimport OpenGL.GLU as glu \nimport OpenGL.GLUT as glut \nfrom OpenGL.arrays import vbo\n\n\n\n# Skip debugging for speedup\n#OpenGL.ERROR_CHECKING = False\n\n# Skip logging for speedup \n#OpenGL.ERROR_LOGGING = False\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def run_glviewer(file_object, mode, dim):\n glviewer = pcl_image(file_object, mode, dim)\n return(0)", "metadata": "root.run_glviewer", "header": "['module', '___EOS___']", "index": 20 }, { "content": "class VBO_Provider():\n\n\n\n\n\n \n", "metadata": "root.VBO_Provider", "header": "['module', '___EOS___']", "index": 24 }, { "content": " def __init__(self, file_object, vbsize, means, mode, dim, scaled = True):\n self.vbos = []\n self.allcolor = False\n start_idx = 0\n self.file_object = file_object\n end_idx = vbsize\n i = 1\n\n while(start_idx < len((file_object))):\n i += 1\n try:\n end_idx = min(len(file_object), start_idx + vbsize) \n print(\"Buffering points \" + str(start_idx) + \" to \" + str((end_idx)))\n dat = self.slice_file(start_idx, end_idx, means, scaled)\n self.set_color_mode(mode,dim, start_idx, end_idx, dat)\n _vbo = vbo.VBO(data = np.array(dat, dtype = np.float32),\n usage = gl.GL_DYNAMIC_DRAW, target = gl.GL_ARRAY_BUFFER)\n self.vbos.append((_vbo, end_idx -start_idx))\n start_idx += vbsize\n except Exception, err:\n print(\"Error initializing VBO:\")\n print(err)", "metadata": "root.VBO_Provider.__init__", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 25 }, { "content": " def slice_file(self,start_idx, end_idx, means, scaled):\n if scaled:\n return(np.array(np.vstack((self.file_object.x[start_idx:end_idx], self.file_object.y[start_idx:end_idx], self.file_object.z[start_idx:end_idx], \n np.zeros(end_idx - start_idx),np.zeros(end_idx - start_idx),np.zeros(end_idx - start_idx))).T) - means)\n else:\n scale = np.array(self.file_object.header.scale + [0,0,0], dtype = np.float64)\n dat = (np.array(np.vstack((self.file_object.X[start_idx:end_idx], self.file_object.Y[start_idx:end_idx], self.file_object.Z[start_idx:end_idx], \n np.zeros(end_idx - start_idx),np.zeros(end_idx - start_idx),np.zeros(end_idx - start_idx))).T) - means)\n dat *= (scale*100)\n return(dat)", "metadata": "root.VBO_Provider.slice_file", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 49 }, { "content": " def bind(self):\n for _vbo in self.vbos:\n _vbo[0].bind()", "metadata": "root.VBO_Provider.bind", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 61 }, { "content": " def unbind(self):\n for _vbo in self.vbos:\n _vbo[0].unbind()", "metadata": "root.VBO_Provider.unbind", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 65 }, { "content": " def draw(self):\n\n for _vbo in self.vbos:\n _vbo[0].bind()\n gl.glVertexPointer(3, gl.GL_FLOAT, 24,_vbo[0])\n gl.glColorPointer(3, gl.GL_FLOAT, 24, _vbo[0] + 12)\n gl.glDrawArrays(gl.GL_POINTS, 0, _vbo[1]) \n _vbo[0].unbind()\n #gl.glMultiDrawArrays(gl.GL_POINTS, 0,100000, len(self.vbos))", "metadata": "root.VBO_Provider.draw", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 68 }, { "content": " def set_color_mode(self, mode, dim,start_idx, end_idx, data): \n if (mode == \"default\"):\n if (all([x in self.file_object.point_format.lookup for x in (\"red\", \"green\", \"blue\")])):\n if ((all(self.file_object.red[0:len(self.file_object):(len(self.file_object)/1000)] == 0)) and\n (all(self.file_object.green[0:len(self.file_object):(len(self.file_object)/1000)] == 0)) and\n (all(self.file_object.blue[0:len(self.file_object):(len(self.file_object)/1000)] == 0))):\n print(\"Warning: Color data appears empty, using intensity mode. Specify -mode=rgb to override\")\n mode = \"intensity\"\n else:\n mode=\"rgb\"\n else:\n mode = \"intensity\" \n if mode == \"rgb\" and not \"red\" in self.file_object.point_format.lookup:\n print(\"Color data not found in file, using intensity\")\n mode = \"intensity\"\n if mode in [\"grey\", \"greyscale\", \"intensity\"]:\n if type(self.allcolor) == bool:\n self.allcolor = self.file_object.reader.get_dimension(dim)/float(np.max(self.file_object.reader.get_dimension(dim)))\n scaled = self.allcolor[start_idx:end_idx] + 0.1\n col = np.array((np.vstack((scaled, scaled, scaled)).T), dtype = np.float32)\n data[:,3:6] += col\n return(data)\n elif (mode == \"elevation\" or (mode == \"heatmap\" and dim == \"z\")):\n if type(self.allcolor) == bool:\n self.allcolor = self.heatmap(self.file_object.z)\n col = self.allcolor[start_idx:end_idx]\n data[:,3:6] += col\n return(data)\n elif (mode == \"heatmap\" and dim != \"z\"):\n if type(self.allcolor) == bool:\n self.allcolor = self.heatmap(self.file_object.reader.get_dimension(dim))\n col = self.allcolor[start_idx:end_idx]\n data[:,3:6] += col\n return(data)\n elif mode == \"rgb\":\n _max = max(np.max(self.file_object.red), np.max(self.file_object.green), np.max(self.file_object.blue))\n _min = min(np.min(self.file_object.red), np.min(self.file_object.green), np.min(self.file_object.blue))\n diff = _max - _min\n col = np.array(np.vstack((self.file_object.red[start_idx:end_idx], self.file_object.green[start_idx:end_idx], self.file_object.blue[start_idx:end_idx])).T, dtype = np.float32)\n col -= _min\n col /= diff\n data[:,3:6] += col\n return(data)", "metadata": "root.VBO_Provider.set_color_mode", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 78 }, { "content": " def heatmap(self, vec, mode = 1):\n _max = np.max(vec)\n _min = np.min(vec)\n diff = _max-_min\n red = (vec-_min)/float(diff) \n if mode == 1:\n col = np.array(np.vstack((red**4, np.sqrt(0.0625-(0.5-red)**4) , (1-red)**4)),dtype = np.float32).T \n else:\n col = np.array(np.vstack((red**4, np.zeros(self.N) , (1-red)**4)),dtype = np.float32).T \n return(col)", "metadata": "root.VBO_Provider.heatmap", "header": "['class', 'VBO_Provider', '(', ')', ':', '___EOS___']", "index": 122 }, { "content": "class pcl_image():\n\n \n\n \n\n \n\n \n \n \n\n\n\n\n\n \n\n\n\n\n\n", "metadata": "root.pcl_image", "header": "['module', '___EOS___']", "index": 133 }, { "content": " def __init__(self, file_object, mode, dim):\n self.file_object = file_object\n self.read_data(mode, dim)\n self.movement_granularity = 1.0\n self.look_granularity = 16.0\n self.main()", "metadata": "root.pcl_image.__init__", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 134 }, { "content": " def main(self): \n self.location = np.array([0.0,0.0,1500.0])\n self.focus = np.array([0.0,0.0,0.0])\n self.up = np.array([1.0,0.0,0.0])\n\n self.mousex = 0\n self.mousey = 0\n self.mouse_drag = gl.GL_FALSE\n\n # Wire up GL\n glut.glutInit(sys.argv)\n\n glut.glutInitDisplayMode(glut.GLUT_RGB | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)\n glut.glutInitWindowSize(500,500)\n glut.glutInitWindowPosition(10,10)\n glut.glutCreateWindow(\"Laspy+OpenGL Pointcloud\")\n glut.glutDisplayFunc(self.display)\n glut.glutReshapeFunc(self.reshape)\n glut.glutMouseFunc(self.mouse)\n glut.glutMotionFunc(self.mouse_motion)\n glut.glutKeyboardFunc(self.keyboard)\n gl.glClearColor(0.0,0.0,0.0,1.0)\n glut.glutTimerFunc(10,self.timerEvent,1)\n\n glut.glutMainLoop()\n return 0", "metadata": "root.pcl_image.main", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 141 }, { "content": " def read_data(self, mode, dim):\n if (np.max(self.file_object.x) - np.min(self.file_object.x)) < 1:\n means = np.array([np.mean(self.file_object.X, dtype = np.float64), \n np.mean(self.file_object.Y, dtype = np.float64), \n np.mean(self.file_object.Z, dtype = np.float64),\n 0,0,0])\n scaled = False\n else:\n means = np.array([np.mean(self.file_object.x, dtype = np.float64), \n np.mean(self.file_object.y, dtype = np.float64), \n np.mean(self.file_object.z, dtype = np.float64),\n 0,0,0])\n scaled = True\n \n self.N = len(self.file_object)\n self.data_buffer = VBO_Provider(self.file_object, 1000000, means, mode, dim, scaled) ", "metadata": "root.pcl_image.read_data", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 168 }, { "content": " def reshape(self, w, h):\n print(\"Reshape \" + str(w) + \", \" + str(h))\n ratio = w if h == 0 else float(w)/h\n gl.glMatrixMode(gl.GL_PROJECTION)\n gl.glLoadIdentity()\n gl.glViewport(0,0,w,h)\n gl.glLoadIdentity()\n glu.gluPerspective(90,float(ratio),0.001,3000);\n\n gl.glMatrixMode(gl.GL_MODELVIEW)", "metadata": "root.pcl_image.reshape", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 187 }, { "content": " def timerEvent(self, arg):\n # Do stuff\n glut.glutPostRedisplay()\n glut.glutTimerFunc(10,self.timerEvent,1)", "metadata": "root.pcl_image.timerEvent", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 198 }, { "content": " def draw_points(self, num):\n\n gl.glEnableClientState(gl.GL_VERTEX_ARRAY)\n gl.glEnableClientState(gl.GL_COLOR_ARRAY)\n self.data_buffer.draw()\n\n gl.glDisableClientState(gl.GL_COLOR_ARRAY)\n gl.glDisableClientState(gl.GL_VERTEX_ARRAY)", "metadata": "root.pcl_image.draw_points", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 203 }, { "content": " def rotate_vector(self, vec_rot, vec_about, theta):\n d = np.sqrt(vec_about.dot(vec_about))\n \n L = np.array((0,vec_about[2], -vec_about[1], \n -vec_about[2], 0, vec_about[0],\n vec_about[1], -vec_about[0], 0))\n L.shape = (3,3)\n\n \n try:\n R = (np.identity(3) + np.sin(theta)/d*L +\n (1-np.cos(theta))/(d*d)*(L.dot(L)))\n except:\n print(\"Error in rotation.\")\n return()\n return(vec_rot.dot(R))", "metadata": "root.pcl_image.rotate_vector", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 214 }, { "content": " def display(self):\n gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)\n gl.glLoadIdentity()\n glu.gluLookAt(self.location[0], self.location[1], self.location[2], \n self.focus[0],self.focus[1], self.focus[2] ,\n self.up[0], self.up[1], self.up[2])\n self.draw_points(self.N)\n glut.glutSwapBuffers()", "metadata": "root.pcl_image.display", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 231 }, { "content": " def camera_reset(self):\n self.location = np.array([0.0,0.0,1500.0])\n self.focus = np.array([0.0,0.0,0.0])\n self.up = np.array([1.0,0.0,0.0])", "metadata": "root.pcl_image.camera_reset", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 240 }, { "content": " def camera_move(self,ammount, axis = 1):\n if axis == 1:\n pointing = self.focus - self.location\n pnorm = np.sqrt(pointing.dot(pointing))\n pointing /= pnorm\n self.location = self.location + ammount*pointing\n self.focus = self.location + pnorm*pointing\n elif axis == 2:\n pointing = self.focus - self.location\n direction = np.cross(self.up, pointing)\n direction /= np.sqrt(direction.dot(direction))\n self.location = self.location + ammount * direction\n self.focus = self.location + pointing", "metadata": "root.pcl_image.camera_move", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 247 }, { "content": " def camera_yaw(self, theta):\n pointing = self.focus - self.location\n newpointing = self.rotate_vector(pointing, self.up, theta)\n self.focus = newpointing + self.location", "metadata": "root.pcl_image.camera_yaw", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 261 }, { "content": " def camera_roll(self, theta):\n self.up = self.rotate_vector(self.up, self.focus-self.location, theta)", "metadata": "root.pcl_image.camera_roll", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 266 }, { "content": " def camera_pitch(self,theta):\n pointing = self.focus - self.location\n axis = np.cross(self.up, pointing)\n newpointing = self.rotate_vector(pointing, axis, theta)\n self.focus = newpointing + self.location\n self.up = np.cross(newpointing, axis)\n self.up /= np.sqrt(self.up.dot(self.up))", "metadata": "root.pcl_image.camera_pitch", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 269 }, { "content": " def mouse(self, button, state, x, y):\n if button == glut.GLUT_LEFT_BUTTON:\n if state == glut.GLUT_DOWN:\n self.mouse_drag = gl.GL_TRUE\n self.mousex = x\n self.mousey = y\n elif state == glut.GLUT_UP and self.mouse_drag:\n self.mouse_drag = gl.GL_FALSE\n elif button == 3:\n #Scoll up\n pass\n elif button == 4:\n #Scroll down\n pass", "metadata": "root.pcl_image.mouse", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 277 }, { "content": " def mouse_motion(self,x,y):\n if self.mouse_drag:\n self.mousex = x\n self.mousey = y", "metadata": "root.pcl_image.mouse_motion", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 292 }, { "content": " def keyboard(self,key, x, y):\n ## Looking\n if key == \"a\":\n self.camera_yaw(np.pi/(self.look_granularity))\n elif key == \"d\":\n self.camera_yaw(-np.pi/self.look_granularity)\n elif key == \"w\":\n self.camera_pitch(-np.pi/self.look_granularity)\n elif key == \"s\":\n self.camera_pitch(np.pi/self.look_granularity)\n elif key == \"e\":\n self.camera_roll(np.pi/self.look_granularity)\n elif key == \"q\":\n self.camera_roll(-np.pi/self.look_granularity)\n ## Moving\n elif key == \"W\":\n self.camera_move(self.movement_granularity * 100.0)\n elif key == \"S\":\n self.camera_move(self.movement_granularity *-100.0)\n elif key == \"A\":\n self.camera_move(self.movement_granularity * 100.0, axis = 2)\n elif key == \"D\":\n self.camera_move(self.movement_granularity * -100.0, axis = 2)\n\n elif key in (\"R\", \"r\"):\n self.camera_reset()\n\n\n elif key == \"+\":\n self.movement_granularity *= 0.8\n self.look_granularity /= 0.8\n elif key == \"-\":\n self.movement_granularity /= 0.8\n self.look_granularity *= 0.8\n elif key in (\"x\", \"y\", \"z\"):\n self.set_up_axis(key)\n print(key)\n pass", "metadata": "root.pcl_image.keyboard", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 297 }, { "content": " def set_up_axis(self, key):\n if key == \"x\":\n self.up = np.array([1.0, 0.0001, 0.0001])\n self.focus[0] = self.location[0]\n elif key == \"y\":\n self.up = np.array([0.0001, 1.0, 0.0001])\n self.focus[1] = self.location[1]\n elif key == \"z\":\n self.up = np.array([0.0001, 0.0001, 1.0])\n self.focus[2] = self.location[2]\n if all(self.focus == self.location):\n self.focus[{\"x\":1, \"y\":2, \"z\":0}[key]] += 1500", "metadata": "root.pcl_image.set_up_axis", "header": "['class', 'pcl_image', '(', ')', ':', '___EOS___']", "index": 336 } ]
[ { "span": "import laspy", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 12 }, { "span": "import random", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "las", "py_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Open", "GL", " ", "librar", "y", " ", "doe", "sn", "'", "t", " ", "support", " ", "abs", "olute", " ", "import", " ", "for", " ", "gl", ",", " ", "glu", ",", " ", "glut", ",", " ", "or", " ", "arrays_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "Open", "GL_", "._", "GL_", "as_", "gl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Open", "GL_", "._", "GLU", "_", "as_", "glu", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Open", "GL_", "._", "GLU", "T_", "as_", "glut", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Open", "GL_", "._", "arrays_", "import_", "vb", "o_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ski", "p", " ", "debugg", "ing", " ", "for", " ", "speed", "up_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Open", "GL", ".", "ERROR", "\\u", "CHECKING", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ski", "p", " ", "logg", "ing", " ", "for", " ", "speed", "up", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "Open", "GL", ".", "ERROR", "\\u", "LOGGING", " ", "=", " ", "False_", "\\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_", "\\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_", "run", "\\u", "gl", "viewer_", "(_", "file", "\\u", "object_", ",_", "mode_", ",_", "dim_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gl", "viewer_", "=_", "pcl", "\\u", "image_", "(_", "file", "\\u", "object_", ",_", "mode_", ",_", "dim_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\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_", ",_", "file", "\\u", "object_", ",_", "vb", "size_", ",_", "means_", ",_", "mode_", ",_", "dim_", ",_", "scaled_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "vb", "os_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "allc", "olor_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "idx_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file", "\\u", "object_", "=_", "file", "\\u", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "\\u", "idx_", "=_", "vb", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "(_", "start", "\\u", "idx_", "<_", "len_", "(_", "(_", "file", "\\u", "object_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end", "\\u", "idx_", "=_", "min_", "(_", "len_", "(_", "file", "\\u", "object_", ")_", ",_", "start", "\\u", "idx_", "+_", "vb", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Buffer", "ing", " ", "points", " ", "\"_", "+_", "str_", "(_", "start", "\\u", "idx_", ")_", "+_", "\"", " ", "to", " ", "\"_", "+_", "str_", "(_", "(_", "end", "\\u", "idx_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dat_", "=_", "self_", "._", "slice", "\\u", "file_", "(_", "start", "\\u", "idx_", ",_", "end", "\\u", "idx_", ",_", "means_", ",_", "scaled_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set\\u", "color", "\\u", "mode_", "(_", "mode_", ",_", "dim_", ",_", "start", "\\u", "idx_", ",_", "end", "\\u", "idx_", ",_", "dat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "vb", "o_", "=_", "vb", "o_", "._", "VB", "O_", "(_", "data_", "=_", "np_", "._", "array_", "(_", "dat_", ",_", "dtype_", "=_", "np_", "._", "float32_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "usage_", "=_", "gl_", "._", "GL", "\\u", "DYNAMIC", "\\u", "DRAW", "_", ",_", "target_", "=_", "gl_", "._", "GL", "\\u", "ARR", "AY", "\\u", "BUFFER_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "vb", "os_", "._", "append_", "(_", "(_", "\\u", "vb", "o_", ",_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "idx_", "+=_", "vb", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Error", " ", "initiali", "zin", "g", " ", "VB", "O", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\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_", "slice", "\\u", "file_", "(_", "self_", ",_", "start", "\\u", "idx_", ",_", "end", "\\u", "idx_", ",_", "means_", ",_", "scaled_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "scaled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "np_", "._", "array_", "(_", "np_", "._", "vstack_", "(_", "(_", "self_", "._", "file", "\\u", "object_", "._", "x_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "self_", "._", "file", "\\u", "object_", "._", "y_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "self_", "._", "file", "\\u", "object_", "._", "z_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "np_", "._", "zeros_", "(_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ",_", "np_", "._", "zeros_", "(_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ",_", "np_", "._", "zeros_", "(_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ")_", ")_", "._", "T_", ")_", "-_", "means_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "scale_", "=_", "np_", "._", "array_", "(_", "self_", "._", "file", "\\u", "object_", "._", "header_", "._", "scale_", "+_", "[_", "0_", ",_", "0_", ",_", "0_", "]_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dat_", "=_", "(_", "np_", "._", "array_", "(_", "np_", "._", "vstack_", "(_", "(_", "self_", "._", "file", "\\u", "object_", "._", "X_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "self_", "._", "file", "\\u", "object_", "._", "Y_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "self_", "._", "file", "\\u", "object_", "._", "Z_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "np_", "._", "zeros_", "(_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ",_", "np_", "._", "zeros_", "(_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ",_", "np_", "._", "zeros_", "(_", "end", "\\u", "idx_", "-_", "start", "\\u", "idx_", ")_", ")_", ")_", "._", "T_", ")_", "-_", "means_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dat_", "*=_", "(_", "scale_", "*_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "dat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "bind_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "\\u", "vb", "o_", "in_", "self_", "._", "vb", "os_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "vb", "o_", "[_", "0_", "]_", "._", "bind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\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_", "unbind", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "\\u", "vb", "o_", "in_", "self_", "._", "vb", "os_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "vb", "o_", "[_", "0_", "]_", "._", "unbind", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "draw_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "\\u", "vb", "o_", "in_", "self_", "._", "vb", "os_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "vb", "o_", "[_", "0_", "]_", "._", "bind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Vertex", "Pointer_", "(_", "3_", ",_", "gl_", "._", "GL", "\\u", "FLOAT_", ",_", "24_", ",_", "\\u", "vb", "o_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Color", "Pointer_", "(_", "3_", ",_", "gl_", "._", "GL", "\\u", "FLOAT_", ",_", "24_", ",_", "\\u", "vb", "o_", "[_", "0_", "]_", "+_", "12_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Draw", "Arrays", "_", "(_", "gl_", "._", "GL", "\\u", "POINTS_", ",_", "0_", ",_", "\\u", "vb", "o_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "vb", "o_", "[_", "0_", "]_", "._", "unbind", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "gl", ".", "gl", "Multi", "Draw", "Arrays", "(", "gl", ".", "GL", "\\u", "POINT", "S", ",", " ", "0", ",", "100000", ",", " ", "len", "(", "self", ".", "vb", "os", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "color", "\\u", "mode_", "(_", "self_", ",_", "mode_", ",_", "dim_", ",_", "start", "\\u", "idx_", ",_", "end", "\\u", "idx_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "mode_", "==_", "\"", "default", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "all_", "(_", "[_", "x_", "in_", "self_", "._", "file", "\\u", "object_", "._", "point", "\\u", "format_", "._", "lookup_", "for_", "x_", "in_", "(_", "\"", "red", "\"_", ",_", "\"", "green", "\"_", ",_", "\"", "blue", "\"_", ")_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "(_", "all_", "(_", "self_", "._", "file", "\\u", "object_", "._", "red_", "[_", "0_", ":_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", ":_", "(_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", "/_", "1000_", ")_", "]_", "==_", "0_", ")_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "all_", "(_", "self_", "._", "file", "\\u", "object_", "._", "green_", "[_", "0_", ":_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", ":_", "(_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", "/_", "1000_", ")_", "]_", "==_", "0_", ")_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "all_", "(_", "self_", "._", "file", "\\u", "object_", "._", "blue_", "[_", "0_", ":_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", ":_", "(_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", "/_", "1000_", ")_", "]_", "==_", "0_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "\"", "Warn", "ing", ":", " ", "Color", " ", "data", " ", "appear", "s", " ", "empty", ",", " ", "usi", "ng", " ", "intensity", " ", "mode", ".", " ", "Speci", "fy", " ", "-", "mode", "=", "rgb", " ", "to", " ", "override", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mode_", "=_", "\"", "intensity", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "mode_", "=_", "\"", "rgb", "\"_", "\\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 ", " _", "mode_", "=_", "\"", "intensity", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "mode_", "==_", "\"", "rgb", "\"_", "and_", "not_", "\"", "red", "\"_", "in_", "self_", "._", "file", "\\u", "object_", "._", "point", "\\u", "format_", "._", "lookup_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Color", " ", "data", " ", "not", " ", "found", " ", "in", " ", "file", ",", " ", "usi", "ng", " ", "intensity", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mode_", "=_", "\"", "intensity", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "mode_", "in_", "[_", "\"", "grey", "\"_", ",_", "\"", "grey", "scale", "\"_", ",_", "\"", "intensity", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "self_", "._", "allc", "olor_", ")_", "==_", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "allc", "olor_", "=_", "self_", "._", "file", "\\u", "object_", "._", "reader_", "._", "get", "\\u", "dimension_", "(_", "dim_", ")_", "/_", "float_", "(_", "np_", "._", "max_", "(_", "self_", "._", "file", "\\u", "object_", "._", "reader_", "._", "get", "\\u", "dimension_", "(_", "dim_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "scaled_", "=_", "self_", "._", "allc", "olor_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", "+_", "0.1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "col_", "=_", "np_", "._", "array_", "(_", "(_", "np_", "._", "vstack_", "(_", "(_", "scaled_", ",_", "scaled_", ",_", "scaled_", ")_", ")_", "._", "T_", ")_", ",_", "dtype_", "=_", "np_", "._", "float32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", ":_", ",_", "3_", ":_", "6_", "]_", "+=_", "col_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "mode_", "==_", "\"", "elevat", "ion", "\"_", "or_", "(_", "mode_", "==_", "\"", "heatmap", "\"_", "and_", "dim_", "==_", "\"", "z", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "self_", "._", "allc", "olor_", ")_", "==_", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "allc", "olor_", "=_", "self_", "._", "heatmap", "_", "(_", "self_", "._", "file", "\\u", "object_", "._", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "col_", "=_", "self_", "._", "allc", "olor_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", ":_", ",_", "3_", ":_", "6_", "]_", "+=_", "col_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "mode_", "==_", "\"", "heatmap", "\"_", "and_", "dim_", "!=_", "\"", "z", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "self_", "._", "allc", "olor_", ")_", "==_", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "allc", "olor_", "=_", "self_", "._", "heatmap", "_", "(_", "self_", "._", "file", "\\u", "object_", "._", "reader_", "._", "get", "\\u", "dimension_", "(_", "dim_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "col_", "=_", "self_", "._", "allc", "olor_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", ":_", ",_", "3_", ":_", "6_", "]_", "+=_", "col_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "mode_", "==_", "\"", "rgb", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "max_", "=_", "max_", "(_", "np_", "._", "max_", "(_", "self_", "._", "file", "\\u", "object_", "._", "red_", ")_", ",_", "np_", "._", "max_", "(_", "self_", "._", "file", "\\u", "object_", "._", "green_", ")_", ",_", "np_", "._", "max_", "(_", "self_", "._", "file", "\\u", "object_", "._", "blue_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "min_", "=_", "min_", "(_", "np_", "._", "min_", "(_", "self_", "._", "file", "\\u", "object_", "._", "red_", ")_", ",_", "np_", "._", "min_", "(_", "self_", "._", "file", "\\u", "object_", "._", "green_", ")_", ",_", "np_", "._", "min_", "(_", "self_", "._", "file", "\\u", "object_", "._", "blue_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "diff_", "=_", "\\u", "max_", "-_", "\\u", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "col_", "=_", "np_", "._", "array_", "(_", "np_", "._", "vstack_", "(_", "(_", "self_", "._", "file", "\\u", "object_", "._", "red_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "self_", "._", "file", "\\u", "object_", "._", "green_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ",_", "self_", "._", "file", "\\u", "object_", "._", "blue_", "[_", "start", "\\u", "idx_", ":_", "end", "\\u", "idx_", "]_", ")_", ")_", "._", "T_", ",_", "dtype_", "=_", "np_", "._", "float32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "col_", "-=_", "\\u", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "col_", "/=_", "diff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", ":_", ",_", "3_", ":_", "6_", "]_", "+=_", "col_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VB", "O", "\\u", "Provider_", "(_", ")_", ":_", "\\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_", "heatmap", "_", "(_", "self_", ",_", "vec_", ",_", "mode_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "max_", "=_", "np_", "._", "max_", "(_", "vec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "min_", "=_", "np_", "._", "min_", "(_", "vec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "diff_", "=_", "\\u", "max_", "-_", "\\u", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "red_", "=_", "(_", "vec_", "-_", "\\u", "min_", ")_", "/_", "float_", "(_", "diff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "mode_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "col_", "=_", "np_", "._", "array_", "(_", "np_", "._", "vstack_", "(_", "(_", "red_", "**_", "4_", ",_", "np_", "._", "sqrt_", "(_", "0.06", "25_", "-_", "(_", "0.5_", "-_", "red_", ")_", "**_", "4_", ")_", ",_", "(_", "1_", "-_", "red_", ")_", "**_", "4_", ")_", ")_", ",_", "dtype_", "=_", "np_", "._", "float32_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "col_", "=_", "np_", "._", "array_", "(_", "np_", "._", "vstack_", "(_", "(_", "red_", "**_", "4_", ",_", "np_", "._", "zeros_", "(_", "self_", "._", "N_", ")_", ",_", "(_", "1_", "-_", "red_", ")_", "**_", "4_", ")_", ")_", ",_", "dtype_", "=_", "np_", "._", "float32_", ")_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "col_", ")_", "\\u\\u\\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_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\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_", ",_", "file", "\\u", "object_", ",_", "mode_", ",_", "dim_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file", "\\u", "object_", "=_", "file", "\\u", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "read", "\\u", "data_", "(_", "mode_", ",_", "dim_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "movement", "\\u", "granularity", "_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "look", "\\u", "granularity", "_", "=_", "16.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "main_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "location_", "=_", "np_", "._", "array_", "(_", "[_", "0.0_", ",_", "0.0_", ",_", "150", "0.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "=_", "np_", "._", "array_", "(_", "[_", "0.0_", ",_", "0.0_", ",_", "0.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "up_", "=_", "np_", "._", "array_", "(_", "[_", "1.0_", ",_", "0.0_", ",_", "0.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "mouse", "x_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mouse", "y_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mouse", "\\u", "drag", "_", "=_", "gl_", "._", "GL", "\\u", "FALSE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wire", " ", "up", " ", "GL_", "\\u\\u\\uNL\\u\\u\\u_", "glut", "_", "._", "glut", "Init_", "(_", "sys_", "._", "argv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "glut", "_", "._", "glut", "Ini", "t", "Display", "Mode_", "(_", "glut", "_", "._", "GLU", "T", "\\u", "RGB_", "|_", "glut", "_", "._", "GLU", "T", "\\u", "DOUBLE_", "|_", "glut", "_", "._", "GLU", "T", "\\u", "DEPTH", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Ini", "t", "Window", "Size_", "(_", "500_", ",_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Ini", "t", "Window", "Position_", "(_", "10_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Creat", "e", "Window_", "(_", "\"", "Las", "py", "+", "Open", "GL", " ", "Point", "cloud", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Display", "Func_", "(_", "self_", "._", "display_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Res", "hap", "e", "Func_", "(_", "self_", "._", "reshape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Mouse", "Func_", "(_", "self_", "._", "mouse_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Motion", "Func_", "(_", "self_", "._", "mouse", "\\u", "motion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Key", "board", "Func_", "(_", "self_", "._", "keyboard_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Clear", "Color_", "(_", "0.0_", ",_", "0.0_", ",_", "0.0_", ",_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Time", "r", "Func_", "(_", "10_", ",_", "self_", "._", "timer", "Event_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "glut", "_", "._", "glut", "Main", "Loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "\\u", "data_", "(_", "self_", ",_", "mode_", ",_", "dim_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "np_", "._", "max_", "(_", "self_", "._", "file", "\\u", "object_", "._", "x_", ")_", "-_", "np_", "._", "min_", "(_", "self_", "._", "file", "\\u", "object_", "._", "x_", ")_", ")_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "means_", "=_", "np_", "._", "array_", "(_", "[_", "np_", "._", "mean_", "(_", "self_", "._", "file", "\\u", "object_", "._", "X_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "np_", "._", "mean_", "(_", "self_", "._", "file", "\\u", "object_", "._", "Y_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "np_", "._", "mean_", "(_", "self_", "._", "file", "\\u", "object_", "._", "Z_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ",_", "0_", ",_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scaled_", "=_", "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 ", " _", "means_", "=_", "np_", "._", "array_", "(_", "[_", "np_", "._", "mean_", "(_", "self_", "._", "file", "\\u", "object_", "._", "x_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "np_", "._", "mean_", "(_", "self_", "._", "file", "\\u", "object_", "._", "y_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "np_", "._", "mean_", "(_", "self_", "._", "file", "\\u", "object_", "._", "z_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ",_", "0_", ",_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scaled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "N_", "=_", "len_", "(_", "self_", "._", "file", "\\u", "object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data\\u", "buffer_", "=_", "VB", "O", "\\u", "Provider_", "(_", "self_", "._", "file", "\\u", "object_", ",_", "1000000_", ",_", "means_", ",_", "mode_", ",_", "dim_", ",_", "scaled_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reshape_", "(_", "self_", ",_", "w_", ",_", "h_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Res", "hap", "e", " ", "\"_", "+_", "str_", "(_", "w_", ")_", "+_", "\",", " ", "\"_", "+_", "str_", "(_", "h_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ratio_", "=_", "w_", "if_", "h_", "==_", "0_", "else_", "float_", "(_", "w_", ")_", "/_", "h_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Matrix", "Mode_", "(_", "gl_", "._", "GL", "\\u", "PROJECT", "ION_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Load", "Identity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Viewport", "_", "(_", "0_", ",_", "0_", ",_", "w_", ",_", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Load", "Identity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glu", "_", "._", "glu", "Pers", "pect", "ive_", "(_", "90_", ",_", "float_", "(_", "ratio_", ")_", ",_", "0.001_", ",_", "3000_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gl_", "._", "gl", "Matrix", "Mode_", "(_", "gl_", "._", "GL", "\\u", "MODEL", "VIEW_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "timer", "Event_", "(_", "self_", ",_", "arg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Do", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "glut", "_", "._", "glut", "Post", "Red", "isp", "lay_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Time", "r", "Func_", "(_", "10_", ",_", "self_", "._", "timer", "Event_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "draw", "\\u", "points_", "(_", "self_", ",_", "num_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gl_", "._", "gl", "Enable", "Client", "State_", "(_", "gl_", "._", "GL", "\\u", "VERTEX", "\\u", "ARRAY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Enable", "Client", "State_", "(_", "gl_", "._", "GL", "\\u", "COLOR", "\\u", "ARRAY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data\\u", "buffer_", "._", "draw_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gl_", "._", "gl", "Disa", "ble", "Client", "State_", "(_", "gl_", "._", "GL", "\\u", "COLOR", "\\u", "ARRAY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Disa", "ble", "Client", "State_", "(_", "gl_", "._", "GL", "\\u", "VERTEX", "\\u", "ARRAY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rota", "te", "\\u", "vector_", "(_", "self_", ",_", "vec", "\\u", "rot_", ",_", "vec", "\\u", "about_", ",_", "theta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "np_", "._", "sqrt_", "(_", "vec", "\\u", "about_", "._", "dot_", "(_", "vec", "\\u", "about_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "L_", "=_", "np_", "._", "array_", "(_", "(_", "0_", ",_", "vec", "\\u", "about_", "[_", "2_", "]_", ",_", "-_", "vec", "\\u", "about_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "-_", "vec", "\\u", "about_", "[_", "2_", "]_", ",_", "0_", ",_", "vec", "\\u", "about_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vec", "\\u", "about_", "[_", "1_", "]_", ",_", "-_", "vec", "\\u", "about_", "[_", "0_", "]_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "L_", "._", "shape_", "=_", "(_", "3_", ",_", "3_", ")_", "\\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 ", " _", "R_", "=_", "(_", "np_", "._", "identity_", "(_", "3_", ")_", "+_", "np_", "._", "sin_", "(_", "theta_", ")_", "/_", "d_", "*_", "L_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "1_", "-_", "np_", "._", "cos_", "(_", "theta_", ")_", ")_", "/_", "(_", "d_", "*_", "d_", ")_", "*_", "(_", "L_", "._", "dot_", "(_", "L_", ")_", ")_", ")_", "\\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_", "(_", "\"", "Error", " ", "in", " ", "rotati", "on", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "vec", "\\u", "rot_", "._", "dot_", "(_", "R_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "display_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gl_", "._", "gl", "Clear_", "(_", "gl_", "._", "GL", "\\u", "COLOR", "\\u", "BUFF", "ER", "\\u", "BIT_", "|_", "gl_", "._", "GL", "\\u", "DEPTH", "\\u", "BUFF", "ER", "\\u", "BIT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gl_", "._", "gl", "Load", "Identity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glu", "_", "._", "glu", "Look", "At_", "(_", "self_", "._", "location_", "[_", "0_", "]_", ",_", "self_", "._", "location_", "[_", "1_", "]_", ",_", "self_", "._", "location_", "[_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "focus_", "[_", "0_", "]_", ",_", "self_", "._", "focus_", "[_", "1_", "]_", ",_", "self_", "._", "focus_", "[_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "up_", "[_", "0_", "]_", ",_", "self_", "._", "up_", "[_", "1_", "]_", ",_", "self_", "._", "up_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "draw", "\\u", "points_", "(_", "self_", "._", "N_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "glut", "_", "._", "glut", "Swa", "p", "Buffers", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "came", "ra", "\\u", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "location_", "=_", "np_", "._", "array_", "(_", "[_", "0.0_", ",_", "0.0_", ",_", "150", "0.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "=_", "np_", "._", "array_", "(_", "[_", "0.0_", ",_", "0.0_", ",_", "0.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "up_", "=_", "np_", "._", "array_", "(_", "[_", "1.0_", ",_", "0.0_", ",_", "0.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "came", "ra", "\\u", "move_", "(_", "self_", ",_", "ammo", "unt_", ",_", "axis_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "axis_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pointi", "ng_", "=_", "self_", "._", "focus_", "-_", "self_", "._", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pno", "rm_", "=_", "np_", "._", "sqrt_", "(_", "pointi", "ng_", "._", "dot_", "(_", "pointi", "ng_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pointi", "ng_", "/=_", "pno", "rm_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "location_", "=_", "self_", "._", "location_", "+_", "ammo", "unt_", "*_", "pointi", "ng_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "=_", "self_", "._", "location_", "+_", "pno", "rm_", "*_", "pointi", "ng_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "axis_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pointi", "ng_", "=_", "self_", "._", "focus_", "-_", "self_", "._", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "direction_", "=_", "np_", "._", "cross_", "(_", "self_", "._", "up_", ",_", "pointi", "ng_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "direction_", "/=_", "np_", "._", "sqrt_", "(_", "direction_", "._", "dot_", "(_", "direction_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "location_", "=_", "self_", "._", "location_", "+_", "ammo", "unt_", "*_", "direction_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "=_", "self_", "._", "location_", "+_", "pointi", "ng_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\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_", "came", "ra", "\\u", "yaw_", "(_", "self_", ",_", "theta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pointi", "ng_", "=_", "self_", "._", "focus_", "-_", "self_", "._", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newpo", "inti", "ng_", "=_", "self_", "._", "rota", "te", "\\u", "vector_", "(_", "pointi", "ng_", ",_", "self_", "._", "up_", ",_", "theta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "=_", "newpo", "inti", "ng_", "+_", "self_", "._", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "came", "ra", "\\u", "roll_", "(_", "self_", ",_", "theta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "up_", "=_", "self_", "._", "rota", "te", "\\u", "vector_", "(_", "self_", "._", "up_", ",_", "self_", "._", "focus_", "-_", "self_", "._", "location_", ",_", "theta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "came", "ra", "\\u", "pitch_", "(_", "self_", ",_", "theta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pointi", "ng_", "=_", "self_", "._", "focus_", "-_", "self_", "._", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "axis_", "=_", "np_", "._", "cross_", "(_", "self_", "._", "up_", ",_", "pointi", "ng_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newpo", "inti", "ng_", "=_", "self_", "._", "rota", "te", "\\u", "vector_", "(_", "pointi", "ng_", ",_", "axis_", ",_", "theta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "=_", "newpo", "inti", "ng_", "+_", "self_", "._", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "up_", "=_", "np_", "._", "cross_", "(_", "newpo", "inti", "ng_", ",_", "axis_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "up_", "/=_", "np_", "._", "sqrt_", "(_", "self_", "._", "up_", "._", "dot_", "(_", "self_", "._", "up_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse_", "(_", "self_", ",_", "button_", ",_", "state_", ",_", "x_", ",_", "y_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "button_", "==_", "glut", "_", "._", "GLU", "T", "\\u", "LEF", "T", "\\u", "BUTTON_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "state_", "==_", "glut", "_", "._", "GLU", "T", "\\u", "DOWN_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mouse", "\\u", "drag", "_", "=_", "gl_", "._", "GL", "\\u", "TRUE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mouse", "x_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mouse", "y_", "=_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "state_", "==_", "glut", "_", "._", "GLU", "T", "\\u", "UP_", "and_", "self_", "._", "mouse", "\\u", "drag", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mouse", "\\u", "drag", "_", "=_", "gl_", "._", "GL", "\\u", "FALSE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "button_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Sco", "ll", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "button_", "==_", "4_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Scroll", " ", "down_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\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_", "mouse", "\\u", "motion_", "(_", "self_", ",_", "x_", ",_", "y_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "mouse", "\\u", "drag", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mouse", "x_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mouse", "y_", "=_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\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_", "keyboard_", "(_", "self_", ",_", "key_", ",_", "x_", ",_", "y_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "Look", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "==_", "\"", "a", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "yaw_", "(_", "np_", "._", "pi_", "/_", "(_", "self_", "._", "look", "\\u", "granularity", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "d", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "yaw_", "(_", "-_", "np_", "._", "pi_", "/_", "self_", "._", "look", "\\u", "granularity", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "w", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "pitch_", "(_", "-_", "np_", "._", "pi_", "/_", "self_", "._", "look", "\\u", "granularity", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "s", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "pitch_", "(_", "np_", "._", "pi_", "/_", "self_", "._", "look", "\\u", "granularity", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "e", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "roll_", "(_", "np_", "._", "pi_", "/_", "self_", "._", "look", "\\u", "granularity", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "q", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "roll_", "(_", "-_", "np_", "._", "pi_", "/_", "self_", "._", "look", "\\u", "granularity", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "Movi", "ng_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "W", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "move_", "(_", "self_", "._", "movement", "\\u", "granularity", "_", "*_", "100.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "S", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "move_", "(_", "self_", "._", "movement", "\\u", "granularity", "_", "*_", "-_", "100.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "A", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "move_", "(_", "self_", "._", "movement", "\\u", "granularity", "_", "*_", "100.0_", ",_", "axis_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "D", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "move_", "(_", "self_", "._", "movement", "\\u", "granularity", "_", "*_", "-_", "100.0_", ",_", "axis_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "in_", "(_", "\"", "R", "\"_", ",_", "\"", "r", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "came", "ra", "\\u", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"+\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "movement", "\\u", "granularity", "_", "*=_", "0.8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "look", "\\u", "granularity", "_", "/=_", "0.8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"-\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "movement", "\\u", "granularity", "_", "/=_", "0.8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "look", "\\u", "granularity", "_", "*=_", "0.8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "in_", "(_", "\"", "x", "\"_", ",_", "\"", "y", "\"_", ",_", "\"", "z", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set\\u", "up", "\\u", "axis_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "pcl", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "up", "\\u", "axis_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "==_", "\"", "x", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "up_", "=_", "np_", "._", "array_", "(_", "[_", "1.0_", ",_", "0.0001_", ",_", "0.0001_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "[_", "0_", "]_", "=_", "self_", "._", "location_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "y", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "up_", "=_", "np_", "._", "array_", "(_", "[_", "0.0001_", ",_", "1.0_", ",_", "0.0001_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "[_", "1_", "]_", "=_", "self_", "._", "location_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "up_", "=_", "np_", "._", "array_", "(_", "[_", "0.0001_", ",_", "0.0001_", ",_", "1.0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "focus_", "[_", "2_", "]_", "=_", "self_", "._", "location_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "all_", "(_", "self_", "._", "focus_", "==_", "self_", "._", "location_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "focus_", "[_", "{_", "\"", "x", "\"_", ":_", "1_", ",_", "\"", "y", "\"_", ":_", "2_", ",_", "\"", "z", "\"_", ":_", "0_", "}_", "[_", "key_", "]_", "]_", "+=_", "1500_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 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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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 ]
`__init__` method calls overridden method
lektor/lektor/lektor/publisher.py
[ { "content": "class FtpConnection(object):\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.FtpConnection", "header": "['module', '___EOS___']", "index": 238 }, { "content": " def __init__(self, url, credentials=None):\n credentials = credentials or {}\n self.con = self.make_connection()\n self.url = url\n self.username = credentials.get('username') or url.username\n self.password = credentials.get('password') or url.password\n self.log_buffer = []\n self._known_folders = set()", "metadata": "root.FtpConnection.__init__", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 240 }, { "content": " def make_connection(self):\n from ftplib import FTP\n return FTP()", "metadata": "root.FtpConnection.make_connection", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 249 }, { "content": " def drain_log(self):\n log = self.log_buffer[:]\n del self.log_buffer[:]\n for chunk in log:\n for line in chunk.splitlines():\n if isinstance(line, str):\n line = line.decode('utf-8', 'replace')\n yield line.rstrip()", "metadata": "root.FtpConnection.drain_log", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 253 }, { "content": " def connect(self):\n options = self.url.decode_query()\n\n log = self.log_buffer\n log.append('000 Connecting to server ...')\n try:\n log.append(self.con.connect(self.url.ascii_host,\n self.url.port or 21))\n except Exception as e:\n log.append('000 Could not connect.')\n log.append(str(e))\n return False\n\n try:\n credentials = {}\n if self.username:\n credentials[\"user\"] = self.username.encode('utf-8')\n if self.password:\n credentials[\"passwd\"] = self.password.encode('utf-8')\n log.append(self.con.login(**credentials))\n\n except Exception as e:\n log.append('000 Could not authenticate.')\n log.append(str(e))\n return False\n\n passive = options.get('passive') in ('on', 'yes', 'true', '1', None)\n log.append('000 Using passive mode: %s' % (passive and 'yes' or 'no'))\n self.con.set_pasv(passive)\n\n try:\n log.append(self.con.cwd(self.url.path.encode('utf-8')))\n except Exception as e:\n log.append(str(e))\n return False\n\n log.append('000 Connected!')\n return True", "metadata": "root.FtpConnection.connect", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 262 }, { "content": " def mkdir(self, path, recursive=True):\n if isinstance(path, text_type):\n path = path.encode('utf-8')\n if path in self._known_folders:\n return\n dirname, basename = posixpath.split(path)\n if dirname and recursive:\n self.mkdir(dirname)\n try:\n self.con.mkd(path)\n except Exception as e:\n msg = str(e)\n if msg[:4] != '550 ':\n self.log_buffer.append(e)\n return\n self._known_folders.add(path)", "metadata": "root.FtpConnection.mkdir", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 301 }, { "content": " def append(self, filename, data):\n if isinstance(filename, text_type):\n filename = filename.encode('utf-8')\n input = StringIO(data)\n try:\n self.con.storbinary('APPE ' + filename, input)\n except Exception as e:\n self.log_buffer.append(str(e))\n return False\n return True", "metadata": "root.FtpConnection.append", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 318 }, { "content": " def get_file(self, filename, out=None):\n if isinstance(filename, text_type):\n filename = filename.encode('utf-8')\n getvalue = False\n if out is None:\n out = StringIO()\n getvalue = True\n try:\n self.con.retrbinary('RETR ' + filename, out.write)\n except Exception as e:\n msg = str(e)\n if msg[:4] != '550 ':\n self.log_buffer.append(e)\n return None\n if getvalue:\n return out.getvalue()\n return out", "metadata": "root.FtpConnection.get_file", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 329 }, { "content": " def upload_file(self, filename, src, mkdir=False):\n if isinstance(src, string_types):\n src = StringIO(src)\n if mkdir:\n directory = posixpath.dirname(filename)\n if directory:\n self.mkdir(directory, recursive=True)\n if isinstance(filename, text_type):\n filename = filename.encode('utf-8')\n try:\n self.con.storbinary('STOR ' + filename, src,\n blocksize=32768)\n except Exception as e:\n self.log_buffer.append(str(e))\n return False\n return True", "metadata": "root.FtpConnection.upload_file", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 347 }, { "content": " def rename_file(self, src, dst):\n try:\n self.con.rename(src, dst)\n except Exception as e:\n self.log_buffer.append(str(e))\n try:\n self.con.delete(dst)\n except Exception as e:\n self.log_buffer.append(str(e))\n try:\n self.con.rename(src, dst)\n except Exception as e:\n self.log_buffer.append(str(e))", "metadata": "root.FtpConnection.rename_file", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 364 }, { "content": " def delete_file(self, filename):\n if isinstance(filename, text_type):\n filename = filename.encode('utf-8')\n try:\n self.con.delete(filename)\n except Exception as e:\n self.log_buffer.append(str(e))", "metadata": "root.FtpConnection.delete_file", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 378 }, { "content": " def delete_folder(self, filename):\n if isinstance(filename, text_type):\n filename = filename.encode('utf-8')\n try:\n self.con.rmd(filename)\n except Exception as e:\n self.log_buffer.append(str(e))\n self._known_folders.discard(filename)", "metadata": "root.FtpConnection.delete_folder", "header": "['class', 'FtpConnection', '(', 'object', ')', ':', '___EOS___']", "index": 386 }, { "content": "class FtpTlsConnection(FtpConnection):\n\n", "metadata": "root.FtpTlsConnection", "header": "['module', '___EOS___']", "index": 396 }, { "content": " def make_connection(self):\n from ftplib import FTP_TLS\n return FTP_TLS()", "metadata": "root.FtpTlsConnection.make_connection", "header": "['class', 'FtpTlsConnection', '(', 'FtpConnection', ')', ':', '___EOS___']", "index": 398 }, { "content": " def connect(self):\n connected = super(FtpTlsConnection, self).connect()\n if connected:\n # Upgrade data connection to TLS.\n self.con.prot_p()\n return connected", "metadata": "root.FtpTlsConnection.connect", "header": "['class', 'FtpTlsConnection', '(', 'FtpConnection', ')', ':', '___EOS___']", "index": 402 } ]
[ { "span": "self.make_connection()", "start_line": 242, "start_column": 19, "end_line": 242, "end_column": 41 } ]
[ { "span": "def make_connection(self):", "start_line": 249, "start_column": 4, "end_line": 249, "end_column": 30 }, { "span": "def make_connection(self):", "start_line": 398, "start_column": 4, "end_line": 398, "end_column": 30 } ]
1
false
[ "[CLS]_", "`_", "\\u\\u", "init\\u\\u_", "`_", "method_", "calls_", "overrid", "den_", "method_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "url_", ",_", "credentials_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "credentials_", "=_", "credentials_", "or_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "con_", "=_", "self_", "._", "make", "\\u", "connection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "url_", "=_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "username_", "=_", "credentials_", "._", "get_", "(_", "'", "user", "name", "'_", ")_", "or_", "url_", "._", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "password_", "=_", "credentials_", "._", "get_", "(_", "'", "password", "'_", ")_", "or_", "url_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log", "\\u", "buffer_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "know", "n", "\\u", "folders_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "connection_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "ftp", "lib_", "import_", "FTP", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "FTP", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "drain", "\\u", "log_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "=_", "self_", "._", "log", "\\u", "buffer_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "log", "\\u", "buffer_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "chunk_", "in_", "log_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "chunk_", "._", "splitlines_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "line_", ",_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "line_", "=_", "line_", "._", "decode_", "(_", "'", "utf", "-", "8", "'_", ",_", "'", "replace", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "yield_", "line_", "._", "rstrip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connect_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "=_", "self_", "._", "url_", "._", "decode", "\\u", "query_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "=_", "self_", "._", "log", "\\u", "buffer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "append_", "(_", "'", "000", " ", "Connect", "ing", " ", "to", " ", "server", " ", "...'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "append_", "(_", "self_", "._", "con_", "._", "connect_", "(_", "self_", "._", "url_", "._", "ascii", "\\u", "host_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "url_", "._", "port_", "or_", "21_", ")_", ")_", "\\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 ", " _", "log_", "._", "append_", "(_", "'", "000", " ", "Cou", "ld", " ", "not", " ", "connect", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "credentials_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "username_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "credentials_", "[_", "\"", "user", "\"_", "]_", "=_", "self_", "._", "username_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "credentials_", "[_", "\"", "passw", "d", "\"_", "]_", "=_", "self_", "._", "password_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "append_", "(_", "self_", "._", "con_", "._", "login_", "(_", "**_", "credentials_", ")_", ")_", "\\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 ", " _", "log_", "._", "append_", "(_", "'", "000", " ", "Cou", "ld", " ", "not", " ", "authenticat", "e", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "passive", "_", "=_", "options_", "._", "get_", "(_", "'", "passive", "'_", ")_", "in_", "(_", "'", "on", "'_", ",_", "'", "ye", "s", "'_", ",_", "'", "true", "'_", ",_", "'", "1", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "append_", "(_", "'", "000", " ", "Us", "ing", " ", "passive", " ", "mode", ":", " ", "%", "s", "'_", "%_", "(_", "passive", "_", "and_", "'", "ye", "s", "'_", "or_", "'", "no", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "con_", "._", "set\\u", "pas", "v_", "(_", "passive", "_", ")_", "\\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 ", " _", "log_", "._", "append_", "(_", "self_", "._", "con_", "._", "cwd_", "(_", "self_", "._", "url_", "._", "path_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", ")_", "\\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 ", " _", "log_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "append_", "(_", "'", "000", " ", "Connect", "ed", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mkdir_", "(_", "self_", ",_", "path_", ",_", "recursive_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "path_", ",_", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "path_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "path_", "in_", "self_", "._", "\\u", "know", "n", "\\u", "folders_", ":_", "\\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_", "dirname_", ",_", "basename_", "=_", "posixpath_", "._", "split_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "dirname_", "and_", "recursive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mkdir_", "(_", "dirname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "mkd", "_", "(_", "path_", ")_", "\\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 ", " _", "msg_", "=_", "str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "[_", ":_", "4_", "]_", "!=_", "'", "550", " ", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "e_", ")_", "\\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_", "self_", "._", "\\u", "know", "n", "\\u", "folders_", "._", "add_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "append_", "(_", "self_", ",_", "filename_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "filename_", ",_", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "filename_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "input_", "=_", "String", "IO_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "stor", "binary_", "(_", "'", "APP", "E", " ", "'_", "+_", "filename_", ",_", "input_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "file_", "(_", "self_", ",_", "filename_", ",_", "out_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "filename_", ",_", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "filename_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "getvalue_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "out_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out_", "=_", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "getvalue_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "retr", "binary_", "(_", "'", "RET", "R", " ", "'_", "+_", "filename_", ",_", "out_", "._", "write_", ")_", "\\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 ", " _", "msg_", "=_", "str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "[_", ":_", "4_", "]_", "!=_", "'", "550", " ", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "getvalue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "out_", "._", "getvalue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "out_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "upload", "\\u", "file_", "(_", "self_", ",_", "filename_", ",_", "src_", ",_", "mkdir_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "src_", ",_", "string", "\\u", "types_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "src_", "=_", "String", "IO_", "(_", "src_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "mkdir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "directory_", "=_", "posixpath_", "._", "dirname_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "directory_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mkdir_", "(_", "directory_", ",_", "recursive_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "filename_", ",_", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "filename_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "stor", "binary_", "(_", "'", "STOR", " ", "'_", "+_", "filename_", ",_", "src_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blocksize_", "=_", "32768_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rename", "\\u", "file_", "(_", "self_", ",_", "src_", ",_", "dst_", ")_", ":_", "\\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_", "._", "con_", "._", "rename_", "(_", "src_", ",_", "dst_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "delete_", "(_", "dst_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "rename_", "(_", "src_", ",_", "dst_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "\\u", "file_", "(_", "self_", ",_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "filename_", ",_", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "filename_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "delete_", "(_", "filename_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Connection_", "(_", "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_", "delete", "\\u", "folder_", "(_", "self_", ",_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "filename_", ",_", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "filename_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "rmd", "_", "(_", "filename_", ")_", "\\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 ", " _", "self_", "._", "log", "\\u", "buffer_", "._", "append_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "know", "n", "\\u", "folders_", "._", "discard_", "(_", "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_", "Ft", "p", "Tl", "s", "Connection_", "(_", "Ft", "p", "Connection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Tl", "s", "Connection_", "(_", "Ft", "p", "Connection_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "make", "\\u", "connection_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "ftp", "lib_", "import_", "FTP", "\\u", "TLS", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "FTP", "\\u", "TLS", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ft", "p", "Tl", "s", "Connection_", "(_", "Ft", "p", "Connection_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connect_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "connected_", "=_", "super_", "(_", "Ft", "p", "Tl", "s", "Connection_", ",_", "self_", ")_", "._", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "connected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Upgrade", " ", "data", " ", "connecti", "on", " ", "to", " ", "TLS", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "con_", "._", "prot", "\\u", "p_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "connected_", "\\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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2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 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
jrk/llvm-py/test/testall.py
[ { "content": "def do_llvmexception():\n print \" Testing class LLVMException\"\n e = LLVMException()", "metadata": "root.do_llvmexception", "header": "['module', '___EOS___']", "index": 16 }, { "content": "def do_module():\n print \" Testing class Module\"\n m = Module.new('test')\n m.target = 'a'\n a = m.target\n m.data_layout = 'a'\n a = m.data_layout\n m.add_type_name('a', ti)\n m.delete_type_name('a')\n s = str(m)\n s = m == Module.new('a')\n m.add_global_variable(ti, 'b')\n m.get_global_variable_named('b')\n gvs = list(m.global_variables)\n ft = Type.function(ti, [ti])\n m.add_function(ft, \"func\")\n m.get_function_named(\"func\")\n m.get_or_insert_function(ft, \"func\")\n m.get_or_insert_function(Type.function(ti, []), \"func\")\n m.get_or_insert_function(ft, \"func2\")\n fns = list(m.functions)\n try:\n m.verify()\n except LLVMException:\n pass\n\n class strstream(object):\n def __init__(self):\n self.s = ''\n\n def write(self, data):\n self.s += data\n\n def read(self):\n return self.s\n\n ss = strstream()\n m2 = Module.new('test')\n m2.add_type_name('myint', ti)\n m2.to_bitcode(ss)\n m3 = Module.from_bitcode(ss)\n t = m2 == m3\n ss2 = strstream()\n ss2.write(str(m))\n m4 = Module.from_assembly(ss2)\n t = m4 == m\n t = m4.pointer_size\n mA = Module.new('ma')\n mB = Module.new('mb')\n mA.link_in(mB)", "metadata": "root.do_module", "header": "['module', '___EOS___']", "index": 50 }, { "content": "def do_type():\n print \" Testing class Type\"\n for i in range(1,100):\n Type.int(i)\n Type.float()\n Type.double()\n Type.x86_fp80()\n Type.fp128()\n Type.ppc_fp128()\n Type.function(ti, [ti]*100, True)\n Type.function(ti, [ti]*100, False)\n Type.struct([ti]*100)\n Type.packed_struct([ti]*100)\n Type.array(ti, 100)\n ptr = Type.pointer(ti, 4)\n pte = ptr.pointee\n Type.vector(ti, 100)\n Type.void()\n Type.label()\n Type.opaque()\n s = str(ti)\n s = ti == Type.float()\n Type.opaque().refine(Type.int())\n s = ti.width\n ft = Type.function(ti, [ti]*10)\n ft.return_type\n ft.vararg\n s = list(ft.args)\n ft.arg_count\n st = Type.struct([ti]*10)\n s = st.element_count\n s = list(st.elements)\n s = st.packed\n st = Type.packed_struct([ti]*10)\n s = st.element_count\n s = list(st.elements)\n s = st.packed\n at = Type.array(ti, 100)\n s = at.element\n s = at.count\n pt = Type.pointer(ti, 10)\n pt.address_space\n vt = Type.vector(ti, 100)\n s = vt.element\n s = vt.count\n Type.int(32) == Type.int(64)\n Type.int(32) != Type.int(64)\n Type.int(32) != Type.float()", "metadata": "root.do_type", "header": "['module', '___EOS___']", "index": 102 }, { "content": "def do_value():\n print \" Testing class Value\"\n k = Constant.int(ti, 42)\n k.name = 'a'\n s = k.name\n t = k.type\n s = str(k)\n s = k == Constant.int(ti, 43)\n i = k.value_id\n i = k.use_count\n i = k.uses", "metadata": "root.do_value", "header": "['module', '___EOS___']", "index": 159 }, { "content": "def do_constant():\n print \" Testing class Constant\"\n Constant.null(ti)\n Constant.all_ones(ti)\n Constant.undef(ti)\n Constant.int(ti, 10)\n Constant.int_signextend(ti, 10)\n Constant.real(Type.float(), \"10.0\")\n Constant.real(Type.float(), 3.14)\n Constant.string(\"test\")\n Constant.stringz(\"test2\")\n Constant.array(ti, [Constant.int(ti,42)]*10)\n Constant.struct([Constant.int(ti,42)]*10)\n Constant.packed_struct([Constant.int(ti,42)]*10)\n Constant.vector([Constant.int(ti,42)]*10)\n Constant.sizeof(ti)\n k = Constant.int(ti, 10)\n f = Constant.real(Type.float(), 3.1415)\n k.neg().not_().add(k).sub(k).mul(k).udiv(k).sdiv(k).urem(k)\n k.srem(k).and_(k).or_(k).xor(k).icmp(IPRED_ULT, k)\n f.fdiv(f).frem(f).fcmp(RPRED_ULT, f)\n f.fadd(f).fmul(f).fsub(f)\n vi = Constant.vector([Constant.int(ti,42)]*10)\n vf = Constant.vector([Constant.real(Type.float(), 3.14)]*10)\n k.shl(k).lshr(k).ashr(k)\n # TODO gep\n k.trunc(Type.int(1))\n k.sext(Type.int(64))\n k.zext(Type.int(64))\n Constant.real(Type.double(), 1.0).fptrunc(Type.float())\n Constant.real(Type.float(), 1.0).fpext(Type.double())\n k.uitofp(Type.float())\n k.sitofp(Type.float())\n f.fptoui(ti)\n f.fptosi(ti)\n p = Type.pointer(ti)\n # TODO ptrtoint\n k.inttoptr(p)\n f.bitcast(Type.int(32))\n k.trunc(Type.int(1)).select(k, k)\n vi.extract_element( Constant.int(ti,0) )\n vi.insert_element( k, k )\n vi.shuffle_vector( vi, vi )", "metadata": "root.do_constant", "header": "['module', '___EOS___']", "index": 187 }, { "content": "def do_global_value():\n print \" Testing class GlobalValue\"\n m = Module.new('a')\n gv = GlobalVariable.new(m, Type.int(), 'b')\n s = gv.is_declaration\n m = gv.module\n gv.linkage = LINKAGE_EXTERNAL\n s = gv.linkage\n gv.section = '.text'\n s = gv.section\n gv.visibility = VISIBILITY_HIDDEN\n s = gv.visibility\n gv.alignment = 8\n s = gv.alignment", "metadata": "root.do_global_value", "header": "['module', '___EOS___']", "index": 232 }, { "content": "def do_global_variable():\n print \" Testing class GlobalVariable\"\n m = Module.new('a')\n gv = GlobalVariable.new(m, Type.int(), 'b')\n gv = GlobalVariable.get(m, 'b')\n gv.delete()\n gv = GlobalVariable.new(m, Type.int(), 'c')\n gv.initializer = Constant.int( ti, 10 )\n s = gv.initializer\n gv.global_constant = True\n s = gv.global_constant", "metadata": "root.do_global_variable", "header": "['module', '___EOS___']", "index": 248 }, { "content": "def do_argument():\n print \" Testing class Argument\"\n m = Module.new('a')\n ft = Type.function(ti, [ti])\n f = Function.new(m, ft, 'func')\n a = f.args[0]\n a.add_attribute(ATTR_ZEXT)\n a.remove_attribute(ATTR_ZEXT)\n a.alignment = 16\n a1 = a.alignment", "metadata": "root.do_argument", "header": "['module', '___EOS___']", "index": 261 }, { "content": "def do_function():\n print \" Testing class Function\"\n ft = Type.function(ti, [ti]*20)\n zz = Function.new(Module.new('z'), ft, 'foobar')\n del zz\n Function.new(Module.new('zz'), ft, 'foobar')\n m = Module.new('a')\n f = Function.new(m, ft, 'func')\n f.delete()\n ft = Type.function(ti, [ti]*20)\n f = Function.new(m, ft, 'func2')\n has_nounwind = f.does_not_throw\n f.does_not_throw = True\n f2 = Function.intrinsic(m, INTR_COS, [ti])\n g = f.intrinsic_id\n f.calling_convenion = CC_FASTCALL\n g = f.calling_convenion\n f.collector = 'a'\n c = f.collector\n a = list(f.args)\n g = f.basic_block_count\n g = f.get_entry_basic_block()\n g = f.append_basic_block('a')\n g = f.get_entry_basic_block()\n g = list(f.basic_blocks)\n f.add_attribute(ATTR_NO_RETURN)\n f.add_attribute(ATTR_ALWAYS_INLINE)\n f.remove_attribute(ATTR_NO_RETURN)\n # LLVM misbehaves:\n #try:\n # f.verify()\n #except LLVMException:\n # pass", "metadata": "root.do_function", "header": "['module', '___EOS___']", "index": 273 }, { "content": "def do_instruction():\n print \" Testing class Instruction\"\n m = Module.new('a')\n ft = Type.function(ti, [ti]*20)\n f = Function.new(m, ft, 'func')\n b = f.append_basic_block('a')\n bb = Builder.new(b)\n i = bb.ret_void()\n bb2 = i.basic_block\n ops = i.operands\n opcount = i.operand_count", "metadata": "root.do_instruction", "header": "['module', '___EOS___']", "index": 308 }, { "content": "def do_callorinvokeinstruction():\n print \" Testing class CallOrInvokeInstruction\"\n m = Module.new('a')\n ft = Type.function(ti, [ti])\n f = Function.new(m, ft, 'func')\n b = f.append_basic_block('a')\n bb = Builder.new(b)\n i = bb.invoke(f, [Constant.int(ti, 10)], b, b)\n a = i.calling_convention\n i.calling_convention = CC_FASTCALL\n i.add_parameter_attribute(0, ATTR_SEXT)\n i.remove_parameter_attribute(0, ATTR_SEXT)\n i.set_parameter_alignment(0, 8)\n #tc = i.tail_call\n #i.tail_call = 1", "metadata": "root.do_callorinvokeinstruction", "header": "['module', '___EOS___']", "index": 321 }, { "content": "def do_phinode():\n print \" Testing class PhiNode\"\n m = Module.new('a')\n ft = Type.function(ti, [ti])\n f = Function.new(m, ft, 'func')\n b = f.append_basic_block('b')\n c = f.append_basic_block('c')\n d = f.append_basic_block('d')\n bb = Builder.new(d)\n p = bb.phi(ti)\n v = p.incoming_count\n p.add_incoming( Constant.int(ti, 10), b )\n p.add_incoming( Constant.int(ti, 10), c )\n p.get_incoming_value(0)\n p.get_incoming_block(0)", "metadata": "root.do_phinode", "header": "['module', '___EOS___']", "index": 338 }, { "content": "def do_basicblock():\n print \" Testing class BasicBlock\"\n m = Module.new('a')\n ft = Type.function(ti, [ti])\n f = Function.new(m, ft, 'func')\n b = f.append_basic_block('b')\n bb = Builder.new(b)\n s = bb.switch(f.args[0], b)\n s.add_case(Constant.int(ti, 10), b)\n s = list(b.instructions)\n b2 = b.insert_before('before')\n b2.delete()\n ff = b.function\n m2 = ff.module\n t = m == m2", "metadata": "root.do_basicblock", "header": "['module', '___EOS___']", "index": 366 }, { "content": "def do_builder():\n print \" Testing class Builder\"\n m = Module.new('a')\n ft = Type.function(ti, [ti])\n f = Function.new(m, ft, 'func')\n blk = f.append_basic_block('b')\n b = Builder.new(blk)\n b.ret(Constant.int(ti, 10))\n b.position_at_beginning(blk)\n b.position_at_end(blk)\n b.position_before(blk.instructions[0])\n blk2 = b.block\n b.ret_void()\n b.ret(Constant.int(ti, 10))\n _do_builder_mrv()\n #b.ret_many([Constant.int(ti, 10)]*10)\n b.branch(blk)\n b.cbranch(Constant.int(Type.int(1), 1), blk, blk)\n b.switch(f.args[0], blk)\n b.invoke(f, [Constant.int(ti,10)], blk, blk)\n b.unwind()\n b.unreachable()\n v = f.args[0]\n fv = Constant.real(Type.float(), \"1.0\")\n k = Constant.int(ti, 10)\n b.add(v, v)\n b.fadd(fv, fv)\n b.sub(v, v)\n b.fsub(fv, fv)\n b.mul(v, v)\n b.fmul(fv, fv)\n b.udiv(v, v)\n b.sdiv(v, v)\n b.fdiv(fv, fv)\n b.urem(v, v)\n b.srem(v, v)\n b.frem(fv, fv)\n b.shl(v, k)\n b.lshr(v, k)\n b.ashr(v, k)\n b.and_(v, v)\n b.or_(v, v)\n b.xor(v, v)\n b.neg(v)\n b.not_(v)\n p = b.malloc(Type.int())\n b.malloc_array(Type.int(), k)\n b.alloca(Type.int())\n b.alloca_array(Type.int(), k)\n b.free(p)\n b.load(p)\n b.store(k, p)\n # TODO gep\n b.trunc(v, Type.int(1))\n b.zext(v, Type.int(64))\n b.sext(v, Type.int(64))\n b.fptoui(fv, ti)\n b.fptosi(fv, ti)\n b.uitofp(k, Type.float())\n b.sitofp(k, Type.float())\n b.fptrunc(Constant.real(Type.double(), \"1.0\"), Type.float())\n b.fpext(Constant.real(Type.float(), \"1.0\"), Type.double())\n b.ptrtoint(p, ti)\n b.inttoptr(k, Type.pointer(Type.int()))\n b.bitcast(v, Type.float())\n b.icmp(IPRED_ULT, v, v)\n b.fcmp(RPRED_ULT, fv, fv)\n vi = Constant.vector([Constant.int(ti,42)]*10)\n vf = Constant.vector([Constant.real(Type.float(), 3.14)]*10)\n # TODO b.extract_value(v, 0)\n b.call(f, [v])\n b.select(Constant.int(Type.int(1), 1), blk, blk)\n b.vaarg(v, Type.int())\n b.extract_element(vi, v)\n b.insert_element(vi, v, v)\n b.shuffle_vector(vi, vi, vi)\n # NOTE: phi nodes without incoming values segfaults in LLVM during\n # destruction.\n i = b.phi(Type.int())\n i.add_incoming(v, blk)\n t = i.is_terminator == False\n t = i.is_binary_op == False\n t = i.is_shift == False\n t = i.is_cast == False\n t = i.is_logical_shift == False\n t = i.is_arithmetic_shift == False\n t = i.is_associative == False\n t = i.is_commutative == False\n t = i.is_volatile == False\n t = i.opcode\n t = i.opcode_name", "metadata": "root.do_builder", "header": "['module', '___EOS___']", "index": 396 }, { "content": "def do_targetdata():\n print \" Testing class TargetData\"\n t = TargetData.new('')\n v = str(t)\n v = t.byte_order\n v = t.pointer_size\n v = t.target_integer_type\n ty = Type.int()\n v = t.size(ty)\n v = t.store_size(ty)\n v = t.abi_size(ty)\n v = t.abi_alignment(ty)\n v = t.callframe_alignment(ty)\n v = t.preferred_alignment(ty)\n sty = Type.struct([ty, ty])\n v = t.element_at_offset(sty, 0)\n v = t.offset_of_element(sty, 0)\n m = Module.new('a')\n gv = m.add_global_variable(ty, 'gv')\n v = t.preferred_alignment(gv)", "metadata": "root.do_targetdata", "header": "['module', '___EOS___']", "index": 509 }, { "content": "def do_genericvalue():\n print \" Testing class GenericValue\"\n v = GenericValue.int(ti, 1)\n v = GenericValue.int_signed(ti, 1)\n v = GenericValue.real(Type.float(), 3.14)\n a = v.as_int()\n a = v.as_int_signed()\n a = v.as_real(Type.float())", "metadata": "root.do_genericvalue", "header": "['module', '___EOS___']", "index": 531 }, { "content": "def do_executionengine():\n print \" Testing class ExecutionEngine\"\n m = Module.new('a')\n ee = ExecutionEngine.new(m, True)\n ft = Type.function(ti, [])\n f = m.add_function(ft, 'func')\n bb = f.append_basic_block('entry')\n b = Builder.new(bb)\n b.ret(Constant.int(ti, 42))\n ee.run_static_ctors()\n gv = ee.run_function(f, [])\n is42 = gv.as_int() == 42\n ee.run_static_dtors()\n ee.free_machine_code_for(f)\n t = ee.target_data\n m2 = Module.new('b')\n ee.add_module(m2)\n m3 = Module.new('c')\n ee2 = ExecutionEngine.new(m3, False)\n m4 = Module.new('d')\n m5 = Module.new('e')\n ee3 = ExecutionEngine.new(m4, False)\n ee3.add_module(m5)\n x = ee3.remove_module(m5)\n check_is_module(x)", "metadata": "root.do_executionengine", "header": "['module', '___EOS___']", "index": 541 } ]
[ { "span": "e ", "start_line": 18, "start_column": 4, "end_line": 18, "end_column": 5 }, { "span": "a ", "start_line": 56, "start_column": 4, "end_line": 56, "end_column": 5 }, { "span": "s ", "start_line": 60, "start_column": 4, "end_line": 60, "end_column": 5 }, { "span": "gvs ", "start_line": 63, "start_column": 4, "end_line": 63, "end_column": 7 }, { "span": "fns ", "start_line": 70, "start_column": 4, "end_line": 70, "end_column": 7 }, { "span": "t ", "start_line": 96, "start_column": 4, "end_line": 96, "end_column": 5 }, { "span": "pte ", "start_line": 117, "start_column": 4, "end_line": 117, "end_column": 7 }, { "span": "s ", "start_line": 146, "start_column": 4, "end_line": 146, "end_column": 5 }, { "span": "t ", "start_line": 164, "start_column": 4, "end_line": 164, "end_column": 5 }, { "span": "s ", "start_line": 166, "start_column": 4, "end_line": 166, "end_column": 5 }, { "span": "i ", "start_line": 169, "start_column": 4, "end_line": 169, "end_column": 5 }, { "span": "vf ", "start_line": 210, "start_column": 4, "end_line": 210, "end_column": 6 }, { "span": "m ", "start_line": 237, "start_column": 4, "end_line": 237, "end_column": 5 }, { "span": "s ", "start_line": 245, "start_column": 4, "end_line": 245, "end_column": 5 }, { "span": "s ", "start_line": 258, "start_column": 4, "end_line": 258, "end_column": 5 }, { "span": "a1 ", "start_line": 270, "start_column": 4, "end_line": 270, "end_column": 6 }, { "span": "has_nounwind ", "start_line": 284, "start_column": 4, "end_line": 284, "end_column": 16 }, { "span": "f2 ", "start_line": 286, "start_column": 4, "end_line": 286, "end_column": 6 }, { "span": "c ", "start_line": 291, "start_column": 4, "end_line": 291, "end_column": 5 }, { "span": "a ", "start_line": 292, "start_column": 4, "end_line": 292, "end_column": 5 }, { "span": "g ", "start_line": 297, "start_column": 4, "end_line": 297, "end_column": 5 }, { "span": "bb2 ", "start_line": 316, "start_column": 4, "end_line": 316, "end_column": 7 }, { "span": "ops ", "start_line": 317, "start_column": 4, "end_line": 317, "end_column": 7 }, { "span": "opcount ", "start_line": 318, "start_column": 4, "end_line": 318, "end_column": 11 }, { "span": "a ", "start_line": 329, "start_column": 4, "end_line": 329, "end_column": 5 }, { "span": "v ", "start_line": 348, "start_column": 4, "end_line": 348, "end_column": 5 }, { "span": "s ", "start_line": 375, "start_column": 4, "end_line": 375, "end_column": 5 }, { "span": "t ", "start_line": 380, "start_column": 4, "end_line": 380, "end_column": 5 }, { "span": "blk2 ", "start_line": 407, "start_column": 4, "end_line": 407, "end_column": 8 }, { "span": "vf ", "start_line": 464, "start_column": 4, "end_line": 464, "end_column": 6 }, { "span": "t ", "start_line": 486, "start_column": 4, "end_line": 486, "end_column": 5 }, { "span": "v ", "start_line": 528, "start_column": 4, "end_line": 528, "end_column": 5 }, { "span": "a ", "start_line": 538, "start_column": 4, "end_line": 538, "end_column": 5 }, { "span": "is42 ", "start_line": 552, "start_column": 4, "end_line": 552, "end_column": 8 }, { "span": "t ", "start_line": 555, "start_column": 4, "end_line": 555, "end_column": 5 }, { "span": "ee2 ", "start_line": 559, "start_column": 4, "end_line": 559, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "do", "\\u", "llvm", "exception_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "LLVM", "Except", "ion", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "=_", "LLVM", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "module_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Modul", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "target_", "=_", "'", "a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "m_", "._", "target_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "data\\u", "layout_", "=_", "'", "a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "m_", "._", "data\\u", "layout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "add", "\\u", "type", "\\u", "name_", "(_", "'", "a", "'_", ",_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "delete", "\\u", "type", "\\u", "name_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "str_", "(_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "m_", "==_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "add", "\\u", "global", "\\u", "variable_", "(_", "ti_", ",_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "get", "\\u", "global", "\\u", "variab", "le", "\\u", "named_", "(_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv", "s_", "=_", "list_", "(_", "m_", "._", "global", "\\u", "variables_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "add", "\\u", "function_", "(_", "ft_", ",_", "\"", "func", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "get", "\\u", "function", "\\u", "named_", "(_", "\"", "func", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "get", "\\u", "or", "\\u", "insert", "\\u", "function_", "(_", "ft_", ",_", "\"", "func", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "get", "\\u", "or", "\\u", "insert", "\\u", "function_", "(_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "]_", ")_", ",_", "\"", "func", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "get", "\\u", "or", "\\u", "insert", "\\u", "function_", "(_", "ft_", ",_", "\"", "func", "2", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fns_", "=_", "list_", "(_", "m_", "._", "functions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "._", "verify_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "LLVM", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "strs", "tream_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "s_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "s_", "+=_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ss_", "=_", "strs", "tream_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m2_", "=_", "Module_", "._", "new_", "(_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m2_", "._", "add", "\\u", "type", "\\u", "name_", "(_", "'", "myi", "nt", "'_", ",_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m2_", "._", "to", "\\u", "bit", "code_", "(_", "ss_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m3_", "=_", "Module_", "._", "from", "\\u", "bit", "code_", "(_", "ss_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "m2_", "==_", "m3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ss", "2_", "=_", "strs", "tream_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ss", "2_", "._", "write_", "(_", "str_", "(_", "m_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m4", "_", "=_", "Module_", "._", "from", "\\u", "assembly_", "(_", "ss", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "m4", "_", "==_", "m_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "m4", "_", "._", "point", "er", "\\u", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m", "A_", "=_", "Module_", "._", "new_", "(_", "'", "ma", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m", "B_", "=_", "Module_", "._", "new_", "(_", "'", "mb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m", "A_", "._", "link", "\\u", "in_", "(_", "m", "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_", "do", "\\u", "type_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Type", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "1_", ",_", "100_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Type_", "._", "int_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Type_", "._", "float_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "double_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "x8", "6", "\\u", "fp", "80_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "fp", "128_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "pp", "c\\u", "fp", "128_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", "*_", "100_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", "*_", "100_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "struct_", "(_", "[_", "ti_", "]_", "*_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "pack", "ed", "\\u", "struct_", "(_", "[_", "ti_", "]_", "*_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "array_", "(_", "ti_", ",_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ptr_", "=_", "Type_", "._", "pointer_", "(_", "ti_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pte", "_", "=_", "ptr_", "._", "point", "ee_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "vector_", "(_", "ti_", ",_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "void_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "opaque", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "str_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "ti_", "==_", "Type_", "._", "float_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "opaque", "_", "(_", ")_", "._", "refine", "_", "(_", "Type_", "._", "int_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "ti_", "._", "width_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "._", "return", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "._", "vara", "rg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "list_", "(_", "ft_", "._", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "._", "arg", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "st_", "=_", "Type_", "._", "struct_", "(_", "[_", "ti_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "st_", "._", "element", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "list_", "(_", "st_", "._", "elements_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "st_", "._", "packed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "st_", "=_", "Type_", "._", "pack", "ed", "\\u", "struct_", "(_", "[_", "ti_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "st_", "._", "element", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "list_", "(_", "st_", "._", "elements_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "st_", "._", "packed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "at_", "=_", "Type_", "._", "array_", "(_", "ti_", ",_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "at_", "._", "element_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "at_", "._", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pt_", "=_", "Type_", "._", "pointer_", "(_", "ti_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pt_", "._", "address", "\\u", "space_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vt_", "=_", "Type_", "._", "vector_", "(_", "ti_", ",_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "vt_", "._", "element_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "vt_", "._", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "int_", "(_", "32_", ")_", "==_", "Type_", "._", "int_", "(_", "64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "int_", "(_", "32_", ")_", "!=_", "Type_", "._", "int_", "(_", "64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Type_", "._", "int_", "(_", "32_", ")_", "!=_", "Type_", "._", "float_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "value_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Value", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "name_", "=_", "'", "a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "k_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "k_", "._", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "str_", "(_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "k_", "==_", "Constant_", "._", "int_", "(_", "ti_", ",_", "43_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "k_", "._", "value", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "k_", "._", "use", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "k_", "._", "uses_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "constant_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Const", "ant", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "null_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "all", "\\u", "ones_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "undef", "_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "int\\u", "sign", "extend_", "(_", "ti_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "\"", "10.", "0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "3.14", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "string_", "(_", "\"", "test", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "string", "z_", "(_", "\"", "test", "2", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "array_", "(_", "ti_", ",_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "struct_", "(_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "pack", "ed", "\\u", "struct_", "(_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "vector_", "(_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "sizeof_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "3.14", "15_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "neg_", "(_", ")_", "._", "not", "\\u_", "(_", ")_", "._", "add_", "(_", "k_", ")_", "._", "sub_", "(_", "k_", ")_", "._", "mul_", "(_", "k_", ")_", "._", "udi", "v_", "(_", "k_", ")_", "._", "sdi", "v_", "(_", "k_", ")_", "._", "ure", "m_", "(_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "sre", "m_", "(_", "k_", ")_", "._", "and\\u_", "(_", "k_", ")_", "._", "or\\u_", "(_", "k_", ")_", "._", "xor_", "(_", "k_", ")_", "._", "icmp", "_", "(_", "IP", "RED", "\\u", "ULT", "_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "fdi", "v_", "(_", "f_", ")_", "._", "fre", "m_", "(_", "f_", ")_", "._", "fcm", "p_", "(_", "RP", "RED", "\\u", "ULT", "_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "fad", "d_", "(_", "f_", ")_", "._", "fm", "ul_", "(_", "f_", ")_", "._", "fsu", "b_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi_", "=_", "Constant_", "._", "vector_", "(_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vf_", "=_", "Constant_", "._", "vector_", "(_", "[_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "3.14", "_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "shl", "_", "(_", "k_", ")_", "._", "lsh", "r_", "(_", "k_", ")_", "._", "ash", "r_", "(_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "ge", "p_", "\\u\\u\\uNL\\u\\u\\u_", "k_", "._", "trunc", "_", "(_", "Type_", "._", "int_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "sex", "t_", "(_", "Type_", "._", "int_", "(_", "64_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "ze", "xt_", "(_", "Type_", "._", "int_", "(_", "64_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "real_", "(_", "Type_", "._", "double_", "(_", ")_", ",_", "1.0_", ")_", "._", "fp", "trunc", "_", "(_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "1.0_", ")_", "._", "fp", "ext_", "(_", "Type_", "._", "double_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "uit", "ofp", "_", "(_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "sit", "ofp", "_", "(_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "fp", "tou", "i_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "fp", "tos", "i_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "Type_", "._", "pointer_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "ptr", "toi", "nt_", "\\u\\u\\uNL\\u\\u\\u_", "k_", "._", "int", "top", "tr_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "bit", "cast_", "(_", "Type_", "._", "int_", "(_", "32_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "trunc", "_", "(_", "Type_", "._", "int_", "(_", "1_", ")_", ")_", "._", "select_", "(_", "k_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi_", "._", "extract", "\\u", "element_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi_", "._", "insert", "\\u", "element_", "(_", "k_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi_", "._", "shu", "ffle", "\\u", "vector_", "(_", "vi_", ",_", "vi_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "global", "\\u", "value_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Global", "Value", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "=_", "Global", "Variable_", "._", "new_", "(_", "m_", ",_", "Type_", "._", "int_", "(_", ")_", ",_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "is", "\\u", "declaration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "gv_", "._", "module_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "linkage", "_", "=_", "LINK", "AGE", "\\u", "EXTERNAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "linkage", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "section_", "=_", "'.", "text", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "section_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "visibility_", "=_", "VISI", "BILITY", "\\u", "HIDDEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "visibility_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "alignment_", "=_", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "alignment_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "global", "\\u", "variable_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Global", "Varia", "ble", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "=_", "Global", "Variable_", "._", "new_", "(_", "m_", ",_", "Type_", "._", "int_", "(_", ")_", ",_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "=_", "Global", "Variable_", "._", "get_", "(_", "m_", ",_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "=_", "Global", "Variable_", "._", "new_", "(_", "m_", ",_", "Type_", "._", "int_", "(_", ")_", ",_", "'", "c", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "initializer_", "=_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "initializer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "._", "global", "\\u", "constant_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "gv_", "._", "global", "\\u", "constant_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "argument_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Arg", "ument", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "f_", "._", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "add", "\\u", "attribute_", "(_", "ATT", "R", "\\u", "ZE", "XT", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "remove", "\\u", "attribute_", "(_", "ATT", "R", "\\u", "ZE", "XT", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "alignment_", "=_", "16_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "a_", "._", "alignment_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "function_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Function", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", "*_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zz_", "=_", "Function_", "._", "new_", "(_", "Module_", "._", "new_", "(_", "'", "z", "'_", ")_", ",_", "ft_", ",_", "'", "fooba", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "zz_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Function_", "._", "new_", "(_", "Module_", "._", "new_", "(_", "'", "zz", "'_", ")_", ",_", "ft_", ",_", "'", "fooba", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", "*_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "has", "\\u", "noun", "wind_", "=_", "f_", "._", "doe", "s", "\\u", "not", "\\u", "throw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "doe", "s", "\\u", "not", "\\u", "throw_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f2_", "=_", "Function_", "._", "intrinsic", "_", "(_", "m_", ",_", "INT", "R", "\\u", "COS", "_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "f_", "._", "intrinsic", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "calling", "\\u", "conve", "nio", "n_", "=_", "CC", "\\u", "FAST", "CALL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "f_", "._", "calling", "\\u", "conve", "nio", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "collector_", "=_", "'", "a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "f_", "._", "collector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "list_", "(_", "f_", "._", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "f_", "._", "basic", "\\u", "block", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "f_", "._", "get", "\\u", "entry", "\\u", "basic", "\\u", "block_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "f_", "._", "get", "\\u", "entry", "\\u", "basic", "\\u", "block_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "list_", "(_", "f_", "._", "basic", "\\u", "blocks_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "add", "\\u", "attribute_", "(_", "ATT", "R", "\\u", "NO", "\\u", "RETURN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "add", "\\u", "attribute_", "(_", "ATT", "R", "\\u", "ALWAYS", "\\u", "IN", "LINE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "remove", "\\u", "attribute_", "(_", "ATT", "R", "\\u", "NO", "\\u", "RETURN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "LLVM", " ", "mis", "behave", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "f", ".", "verify", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "except", " ", "LLVM", "Except", "ion", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "pass_", "\\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_", "do", "\\u", "instruction_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Instr", "ucti", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", "*_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb_", "=_", "Builder_", "._", "new_", "(_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "bb_", "._", "ret", "\\u", "void_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb", "2_", "=_", "i_", "._", "basic", "\\u", "block_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ops_", "=_", "i_", "._", "operands_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opc", "ount_", "=_", "i_", "._", "operand", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "call", "orin", "vo", "kei", "nstr", "ucti", "on_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Call", "Or", "Invok", "e", "Instr", "ucti", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb_", "=_", "Builder_", "._", "new_", "(_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "bb_", "._", "invoke_", "(_", "f_", ",_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", "]_", ",_", "b_", ",_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "i_", "._", "calling", "\\u", "convention", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "._", "calling", "\\u", "convention", "_", "=_", "CC", "\\u", "FAST", "CALL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "._", "add", "\\u", "parameter", "\\u", "attribute_", "(_", "0_", ",_", "ATT", "R", "\\u", "SE", "XT", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "._", "remove", "\\u", "parameter", "\\u", "attribute_", "(_", "0_", ",_", "ATT", "R", "\\u", "SE", "XT", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "._", "set\\u", "parameter", "\\u", "alignment_", "(_", "0_", ",_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "tc", " ", "=", " ", "i", ".", "tail", "\\u", "call_", "\\u\\u\\uNL\\u\\u\\u_", "#", "i", ".", "tail", "\\u", "call", " ", "=", " ", "1_", "\\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_", "do", "\\u", "phin", "ode_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Phi", "Node", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "c", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb_", "=_", "Builder_", "._", "new_", "(_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "bb_", "._", "phi_", "(_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "p_", "._", "inco", "ming", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "add", "\\u", "incoming_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", ",_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "add", "\\u", "incoming_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", ",_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "get", "\\u", "inco", "ming", "\\u", "value_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "get", "\\u", "inco", "ming", "\\u", "block_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "basic", "block_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Basic", "Block", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb_", "=_", "Builder_", "._", "new_", "(_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "bb_", "._", "switch_", "(_", "f_", "._", "args_", "[_", "0_", "]_", ",_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "\\u", "case_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", ",_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "list_", "(_", "b_", "._", "instructions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b2_", "=_", "b_", "._", "insert", "\\u", "before_", "(_", "'", "bef", "ore", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b2_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ff_", "=_", "b_", "._", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m2_", "=_", "ff_", "._", "module_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "m_", "==_", "m2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "builder_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Build", "er", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "ti_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Function_", "._", "new_", "(_", "m_", ",_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blk_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "Builder_", "._", "new_", "(_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ret_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "position", "\\u", "at", "\\u", "beginn", "ing_", "(_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "position", "\\u", "at", "\\u", "end_", "(_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "position", "\\u", "before_", "(_", "blk_", "._", "instructions_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blk", "2_", "=_", "b_", "._", "block_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ret", "\\u", "void_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ret_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "do", "\\u", "builde", "r", "\\u", "mr", "v_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "b", ".", "ret", "\\u", "many", "([", "Const", "ant", ".", "int", "(", "ti", ",", " ", "10", ")]", "*", "10", ")_", "\\u\\u\\uNL\\u\\u\\u_", "b_", "._", "branch_", "(_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "cb", "ranch", "_", "(_", "Constant_", "._", "int_", "(_", "Type_", "._", "int_", "(_", "1_", ")_", ",_", "1_", ")_", ",_", "blk_", ",_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "switch_", "(_", "f_", "._", "args_", "[_", "0_", "]_", ",_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "invoke_", "(_", "f_", ",_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", "]_", ",_", "blk_", ",_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "unw", "ind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "unreachable", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "f_", "._", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fv_", "=_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "\"", "1.0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "Constant_", "._", "int_", "(_", "ti_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "add_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fad", "d_", "(_", "fv_", ",_", "fv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "sub_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fsu", "b_", "(_", "fv_", ",_", "fv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "mul_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fm", "ul_", "(_", "fv_", ",_", "fv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "udi", "v_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "sdi", "v_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fdi", "v_", "(_", "fv_", ",_", "fv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ure", "m_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "sre", "m_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fre", "m_", "(_", "fv_", ",_", "fv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "shl", "_", "(_", "v_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "lsh", "r_", "(_", "v_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ash", "r_", "(_", "v_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "and\\u_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "or\\u_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "xor_", "(_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "neg_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "not", "\\u_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "b_", "._", "malloc", "_", "(_", "Type_", "._", "int_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "malloc", "\\u", "array_", "(_", "Type_", "._", "int_", "(_", ")_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "allo", "ca_", "(_", "Type_", "._", "int_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "allo", "ca", "\\u", "array_", "(_", "Type_", "._", "int_", "(_", ")_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "free_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "load_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "store_", "(_", "k_", ",_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "ge", "p_", "\\u\\u\\uNL\\u\\u\\u_", "b_", "._", "trunc", "_", "(_", "v_", ",_", "Type_", "._", "int_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ze", "xt_", "(_", "v_", ",_", "Type_", "._", "int_", "(_", "64_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "sex", "t_", "(_", "v_", ",_", "Type_", "._", "int_", "(_", "64_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fp", "tou", "i_", "(_", "fv_", ",_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fp", "tos", "i_", "(_", "fv_", ",_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "uit", "ofp", "_", "(_", "k_", ",_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "sit", "ofp", "_", "(_", "k_", ",_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fp", "trunc", "_", "(_", "Constant_", "._", "real_", "(_", "Type_", "._", "double_", "(_", ")_", ",_", "\"", "1.0", "\"_", ")_", ",_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fp", "ext_", "(_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "\"", "1.0", "\"_", ")_", ",_", "Type_", "._", "double_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ptr", "toi", "nt_", "(_", "p_", ",_", "ti_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "int", "top", "tr_", "(_", "k_", ",_", "Type_", "._", "pointer_", "(_", "Type_", "._", "int_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "bit", "cast_", "(_", "v_", ",_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "icmp", "_", "(_", "IP", "RED", "\\u", "ULT", "_", ",_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "fcm", "p_", "(_", "RP", "RED", "\\u", "ULT", "_", ",_", "fv_", ",_", "fv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi_", "=_", "Constant_", "._", "vector_", "(_", "[_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vf_", "=_", "Constant_", "._", "vector_", "(_", "[_", "Constant_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "3.14", "_", ")_", "]_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "b", ".", "extract", "\\u", "value", "(", "v", ",", " ", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "b_", "._", "call_", "(_", "f_", ",_", "[_", "v_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "select_", "(_", "Constant_", "._", "int_", "(_", "Type_", "._", "int_", "(_", "1_", ")_", ",_", "1_", ")_", ",_", "blk_", ",_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "va", "arg_", "(_", "v_", ",_", "Type_", "._", "int_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "extract", "\\u", "element_", "(_", "vi_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "insert", "\\u", "element_", "(_", "vi_", ",_", "v_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "shu", "ffle", "\\u", "vector_", "(_", "vi_", ",_", "vi_", ",_", "vi_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "NOTE", ":", " ", "phi", " ", "nodes", " ", "with", "out", " ", "inco", "ming", " ", "values", " ", "seg", "faults", " ", "in", " ", "LLVM", " ", "dur", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "destruct", "ion", "._", "\\u\\u\\uNL\\u\\u\\u_", "i_", "=_", "b_", "._", "phi_", "(_", "Type_", "._", "int_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "._", "add", "\\u", "incoming_", "(_", "v_", ",_", "blk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "terminator", "_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "binar", "y", "\\u", "op_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "shift_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "cast_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "logical", "\\u", "shift_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "arithmetic", "\\u", "shift_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "associ", "ative_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "commu", "tative", "_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "is", "\\u", "volatile", "_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "opcode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "i_", "._", "opcode", "\\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_", "do", "\\u", "target", "data_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Target", "Data", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "Target", "Data_", "._", "new_", "(_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "str_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "byte", "\\u", "order_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "point", "er", "\\u", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "target", "\\u", "integ", "er", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ty_", "=_", "Type_", "._", "int_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "size_", "(_", "ty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "store", "\\u", "size_", "(_", "ty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "abi", "\\u", "size_", "(_", "ty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "abi", "\\u", "alignment_", "(_", "ty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "call", "frame", "\\u", "alignment_", "(_", "ty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "prefer", "red", "\\u", "alignment_", "(_", "ty_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sty", "_", "=_", "Type_", "._", "struct_", "(_", "[_", "ty_", ",_", "ty_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "element", "\\u", "at", "\\u", "offset_", "(_", "sty", "_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "offset", "\\u", "of", "\\u", "element_", "(_", "sty", "_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "=_", "m_", "._", "add", "\\u", "global", "\\u", "variable_", "(_", "ty_", ",_", "'", "gv", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "t_", "._", "prefer", "red", "\\u", "alignment_", "(_", "gv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "gener", "ic", "value_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Gene", "ric", "Value", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "Gene", "ric", "Value_", "._", "int_", "(_", "ti_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "Gene", "ric", "Value_", "._", "int\\u", "signed_", "(_", "ti_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "Gene", "ric", "Value_", "._", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ",_", "3.14", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "v_", "._", "as", "\\u", "int_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "v_", "._", "as", "\\u", "int\\u", "signed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "v_", "._", "as", "\\u", "real_", "(_", "Type_", "._", "float_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "executi", "one", "ngin", "e_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "Test", "ing", " ", "class", " ", "Execut", "ion", "Engine", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Module_", "._", "new_", "(_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee_", "=_", "Execut", "ion", "Engine_", "._", "new_", "(_", "m_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "Type_", "._", "function_", "(_", "ti_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "m_", "._", "add", "\\u", "function_", "(_", "ft_", ",_", "'", "func", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb_", "=_", "f_", "._", "append", "\\u", "basic", "\\u", "block_", "(_", "'", "entry", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "Builder_", "._", "new_", "(_", "bb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "ret_", "(_", "Constant_", "._", "int_", "(_", "ti_", ",_", "42_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee_", "._", "run", "\\u", "static", "\\u", "ctor", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gv_", "=_", "ee_", "._", "run", "\\u", "function_", "(_", "f_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "42_", "=_", "gv_", "._", "as", "\\u", "int_", "(_", ")_", "==_", "42_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee_", "._", "run", "\\u", "static", "\\u", "dto", "rs_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee_", "._", "free", "\\u", "machine", "\\u", "code", "\\u", "for_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "ee_", "._", "target", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m2_", "=_", "Module_", "._", "new_", "(_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee_", "._", "add", "\\u", "module_", "(_", "m2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m3_", "=_", "Module_", "._", "new_", "(_", "'", "c", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee", "2_", "=_", "Execut", "ion", "Engine_", "._", "new_", "(_", "m3_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m4", "_", "=_", "Module_", "._", "new_", "(_", "'", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m", "5_", "=_", "Module_", "._", "new_", "(_", "'", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee", "3_", "=_", "Execut", "ion", "Engine_", "._", "new_", "(_", "m4", "_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee", "3_", "._", "add", "\\u", "module_", "(_", "m", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
kayhayen/Nuitka/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Tool/install.py
[ { "content": "def versionedLibVersion(dest, env):\n \"\"\"Check if dest is a version shared library name. Return version, libname, & install_dir if it is.\"\"\"\n Verbose = False\n platform = env.subst('$PLATFORM')\n if not (platform == 'posix' or platform == 'darwin'):\n return (None, None, None)\n\n libname = os.path.basename(dest)\n install_dir = os.path.dirname(dest)\n shlib_suffix = env.subst('$SHLIBSUFFIX')\n # See if the source name is a versioned shared library, get the version number\n result = False\n\n version_re = re.compile(\"[0-9]+\\\\.[0-9]+\\\\.[0-9a-zA-Z]+\")\n version_File = None\n if platform == 'posix':\n # handle unix names\n versioned_re = re.compile(re.escape(shlib_suffix + '.') + \"[0-9]+\\\\.[0-9]+\\\\.[0-9a-zA-Z]+\")\n result = versioned_re.findall(libname)\n if result:\n version_File = version_re.findall(versioned_re.findall(libname)[-1])[-1]\n elif platform == 'darwin':\n # handle OSX names\n versioned_re = re.compile(\"\\\\.[0-9]+\\\\.[0-9]+\\\\.[0-9a-zA-Z]+\" + re.escape(shlib_suffix) )\n result = versioned_re.findall(libname)\n if result:\n version_File = version_re.findall(versioned_re.findall(libname)[-1])[-1]\n\n if Verbose:\n print \"install: version_File \", version_File\n # result is False if we did not find a versioned shared library name, so return and empty list\n if not result:\n return (None, libname, install_dir)\n\n version = None\n # get version number from the environment\n try:\n version = env.subst('$SHLIBVERSION')\n except KeyError:\n version = None\n\n if version != version_File:\n #raise SCons.Errors.UserError(\"SHLIBVERSION '%s' does not match the version # '%s' in the filename\" % (version, version_File) )\n print \"SHLIBVERSION '%s' does not match the version # '%s' in the filename, proceeding based on file name\" % (version, version_File)\n version = version_File\n return (version, libname, install_dir)", "metadata": "root.versionedLibVersion", "header": "['module', '___EOS___']", "index": 147 }, { "content": "def versionedLibLinks(dest, source, env):\n \"\"\"If we are installing a versioned shared library create the required links.\"\"\"\n Verbose = False\n linknames = []\n version, libname, install_dir = versionedLibVersion(dest, env)\n\n if version != None:\n # libname includes the version number if one was given\n linknames = SCons.Tool.VersionShLibLinkNames(version,libname,env)\n if Verbose:\n print \"versionedLibLinks: linknames \",linknames\n # Here we just need the file name w/o path as the target of the link\n lib_ver = libname\n # make symlink of adjacent names in linknames\n for count in range(len(linknames)):\n linkname = linknames[count]\n fulllinkname = os.path.join(install_dir, linkname)\n if Verbose:\n print \"full link name \",fulllinkname\n if count > 0:\n try:\n os.remove(lastlinkname)\n except:\n pass\n os.symlink(os.path.basename(fulllinkname),lastlinkname)\n if Verbose:\n print \"versionedLibLinks: made sym link of %s -> %s\" % (lastlinkname,os.path.basename(fulllinkname))\n lastlinkname = fulllinkname\n # finish chain of sym links with link to the actual library\n if len(linknames)>0:\n try:\n os.remove(lastlinkname)\n except:\n pass\n os.symlink(lib_ver,lastlinkname)\n if Verbose:\n print \"versionedLibLinks: made sym link of %s -> %s\" % (lib_ver,lastlinkname)\n return", "metadata": "root.versionedLibLinks", "header": "['module', '___EOS___']", "index": 194 }, { "content": "def add_versioned_targets_to_INSTALLED_FILES(target, source, env):\n \"\"\" an emitter that adds all target files to the list stored in the\n _INSTALLED_FILES global variable. This way all installed files of one\n scons call will be collected.\n \"\"\"\n global _INSTALLED_FILES, _UNIQUE_INSTALLED_FILES\n Verbose = False\n _INSTALLED_FILES.extend(target)\n if Verbose:\n print \"ver lib emitter \",repr(target)\n\n # see if we have a versioned shared library, if so generate side effects\n version, libname, install_dir = versionedLibVersion(target[0].path, env)\n if version != None:\n # generate list of link names\n linknames = SCons.Tool.VersionShLibLinkNames(version,libname,env)\n for linkname in linknames:\n if Verbose:\n print \"make side effect of %s\" % os.path.join(install_dir, linkname)\n fulllinkname = os.path.join(install_dir, linkname)\n env.SideEffect(fulllinkname,target[0])\n env.Clean(target[0],fulllinkname)\n _INSTALLED_FILES.append(fulllinkname)\n if Verbose:\n print \"installed list \", _INSTALLED_FILES\n\n _UNIQUE_INSTALLED_FILES = None\n return (target, source)", "metadata": "root.add_versioned_targets_to_INSTALLED_FILES", "header": "['module', '___EOS___']", "index": 291 } ]
[ { "span": "print \"install: version_File \", version_File", "start_line": 176, "start_column": 8, "end_line": 176, "end_column": 52 }, { "span": "print \"versionedLibLinks: linknames \",linknames", "start_line": 204, "start_column": 12, "end_line": 204, "end_column": 59 }, { "span": "print \"full link name \",fulllinkname", "start_line": 212, "start_column": 16, "end_line": 212, "end_column": 52 }, { "span": "print \"versionedLibLinks: made sym link of %s -> %s\" % (lastlinkname,os.path.basename(fulllinkname))", "start_line": 220, "start_column": 20, "end_line": 220, "end_column": 120 }, { "span": "print \"versionedLibLinks: made sym link of %s -> %s\" % (lib_ver,lastlinkname)", "start_line": 230, "start_column": 16, "end_line": 230, "end_column": 93 }, { "span": "print \"ver lib emitter \",repr(target)", "start_line": 300, "start_column": 8, "end_line": 300, "end_column": 45 }, { "span": "print \"make side effect of %s\" % os.path.join(install_dir, linkname)", "start_line": 309, "start_column": 16, "end_line": 309, "end_column": 84 }, { "span": "print \"installed list \", _INSTALLED_FILES", "start_line": 315, "start_column": 16, "end_line": 315, "end_column": 57 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "versioned", "Lib", "Version_", "(_", "dest_", ",_", "env_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Check", " ", "if", " ", "dest", " ", "is", " ", "a", " ", "version", " ", "shared", " ", "librar", "y", " ", "name", ".", " ", "Return", " ", "version", ",", " ", "libname", ",", " ", "&", " ", "install", "\\u", "dir", " ", "if", " ", "it", " ", "is", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Verbos", "e_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "platform_", "=_", "env_", "._", "subst_", "(_", "'$", "PLATFORM", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "(_", "platform_", "==_", "'", "posix", "'_", "or_", "platform_", "==_", "'", "dar", "win", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "None_", ",_", "None_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "libname", "_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "install", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shl", "ib", "\\u", "suffix_", "=_", "env_", "._", "subst_", "(_", "'$", "SH", "LIBS", "UFF", "IX", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "See", " ", "if", " ", "the", " ", "source", " ", "name", " ", "is", " ", "a", " ", "versioned", " ", "shared", " ", "librar", "y", ",", " ", "get", " ", "the", " ", "version", " ", "number_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "version", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "\"[", "0", "-", "9", "]+\\\\", "\\\\.", "[", "0", "-", "9", "]+\\\\", "\\\\.", "[", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "]+\"", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "\\u", "File_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "platform_", "==_", "'", "posix", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "handle", " ", "unix", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "versioned", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "re_", "._", "escape_", "(_", "shl", "ib", "\\u", "suffix_", "+_", "'.'_", ")_", "+_", "\"[", "0", "-", "9", "]+\\\\", "\\\\.", "[", "0", "-", "9", "]+\\\\", "\\\\.", "[", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "]+\"", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "versioned", "\\u", "re_", "._", "findall_", "(_", "libname", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version", "\\u", "File_", "=_", "version", "\\u", "re_", "._", "findall_", "(_", "versioned", "\\u", "re_", "._", "findall_", "(_", "libname", "_", ")_", "[_", "-_", "1_", "]_", ")_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "platform_", "==_", "'", "dar", "win", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "handle", " ", "OSX", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "versioned", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "\"\\\\\\\\", ".", "[", "0", "-", "9", "]+\\\\", "\\\\.", "[", "0", "-", "9", "]+\\\\", "\\\\.", "[", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "]+\"", "_", "+_", "re_", "._", "escape_", "(_", "shl", "ib", "\\u", "suffix_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "versioned", "\\u", "re_", "._", "findall_", "(_", "libname", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version", "\\u", "File_", "=_", "version", "\\u", "re_", "._", "findall_", "(_", "versioned", "\\u", "re_", "._", "findall_", "(_", "libname", "_", ")_", "[_", "-_", "1_", "]_", ")_", "[_", "-_", "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_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "install", ":", " ", "version", "\\u", "File", " ", "\"_", ",_", "version", "\\u", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "result", " ", "is", " ", "Fal", "se", " ", "if", " ", "we", " ", "did", " ", "not", " ", "find", " ", "a", " ", "versioned", " ", "shared", " ", "librar", "y", " ", "name", ",", " ", "so", " ", "return", " ", "and", " ", "empty", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "None_", ",_", "libname", "_", ",_", "install", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "version", " ", "number", " ", "from", " ", "the", " ", "environment_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "env_", "._", "subst_", "(_", "'$", "SH", "LIB", "VERSI", "ON", "'_", ")_", "\\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 ", " _", "version_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "version_", "!=_", "version", "\\u", "File_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "raise", " ", "SC", "ons", ".", "Error", "s", ".", "User", "Error", "(\"", "SH", "LIB", "VERSI", "ON", " ", "'%", "s", "'", " ", "doe", "s", " ", "not", " ", "match", " ", "the", " ", "version", " ", "#", " ", "'%", "s", "'", " ", "in", " ", "the", " ", "filename", "\"", " ", "%", " ", "(", "version", ",", " ", "version", "\\u", "File", ")", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "SH", "LIB", "VERSI", "ON", " ", "'%", "s", "'", " ", "doe", "s", " ", "not", " ", "match", " ", "the", " ", "version", " ", "#", " ", "'%", "s", "'", " ", "in", " ", "the", " ", "filename", ",", " ", "proceed", "ing", " ", "based", " ", "on", " ", "file", " ", "name", "\"_", "%_", "(_", "version_", ",_", "version", "\\u", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "version", "\\u", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "version_", ",_", "libname", "_", ",_", "install", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "versioned", "Lib", "Links_", "(_", "dest_", ",_", "source_", ",_", "env_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "we", " ", "are", " ", "install", "ing", " ", "a", " ", "versioned", " ", "shared", " ", "librar", "y", " ", "create", " ", "the", " ", "require", "d", " ", "link", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Verbos", "e_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "link", "names_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", ",_", "libname", "_", ",_", "install", "\\u", "dir_", "=_", "versioned", "Lib", "Version_", "(_", "dest_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "version_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "libname", " ", "include", "s", " ", "the", " ", "version", " ", "number", " ", "if", " ", "one", " ", "was", " ", "given_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link", "names_", "=_", "SC", "ons_", "._", "Tool_", "._", "Version", "Sh", "Lib", "Link", "Names_", "(_", "version_", ",_", "libname", "_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "versioned", "Lib", "Link", "s", ":", " ", "link", "names", " ", "\"_", ",_", "link", "names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Her", "e", " ", "we", " ", "just", " ", "need", " ", "the", " ", "file", " ", "name", " ", "w", "/", "o", " ", "path", " ", "as", " ", "the", " ", "target", " ", "of", " ", "the", " ", "link_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lib", "\\u", "ver_", "=_", "libname", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "make", " ", "symlink", " ", "of", " ", "adjacent", " ", "names", " ", "in", " ", "link", "names_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "count_", "in_", "range_", "(_", "len_", "(_", "link", "names_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link", "name_", "=_", "link", "names_", "[_", "count_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "full", "link", "name_", "=_", "os_", "._", "path_", "._", "join_", "(_", "install", "\\u", "dir_", ",_", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "full", " ", "link", " ", "name", " ", "\"_", ",_", "full", "link", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "count_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "remove_", "(_", "last", "link", "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 ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "symlink_", "(_", "os_", "._", "path_", "._", "basename_", "(_", "full", "link", "name_", ")_", ",_", "last", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "\"", "versioned", "Lib", "Link", "s", ":", " ", "made", " ", "sym", " ", "link", " ", "of", " ", "%", "s", " ", "->", " ", "%", "s", "\"_", "%_", "(_", "last", "link", "name_", ",_", "os_", "._", "path_", "._", "basename_", "(_", "full", "link", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "last", "link", "name_", "=_", "full", "link", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "finish", " ", "chain", " ", "of", " ", "sym", " ", "link", "s", " ", "with", " ", "link", " ", "to", " ", "the", " ", "actual", " ", "library_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "link", "names_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "last", "link", "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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "symlink_", "(_", "lib", "\\u", "ver_", ",_", "last", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "versioned", "Lib", "Link", "s", ":", " ", "made", " ", "sym", " ", "link", " ", "of", " ", "%", "s", " ", "->", " ", "%", "s", "\"_", "%_", "(_", "lib", "\\u", "ver_", ",_", "last", "link", "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_", "\\u\\u\\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_", "add", "\\u", "versioned", "\\u", "target", "s", "\\u", "to", "\\u", "INSTALLE", "D", "\\u", "FILES_", "(_", "target_", ",_", "source_", ",_", "env_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "an", " ", "emitte", "r", " ", "tha", "t", " ", "adds", " ", "all", " ", "target", " ", "files", " ", "to", " ", "the", " ", "list", " ", "store", "d", " ", "in", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "\\u", "INSTALLE", "D", "\\u", "FILE", "S", " ", "global", " ", "variab", "le", ".", " ", "Thi", "s", " ", "way", " ", "all", " ", "install", "ed", " ", "files", " ", "of", " ", "one", "\\", "10", ";", " ", " ", " ", " ", "scons", " ", "call", " ", "will", " ", "be", " ", "collected", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global_", "\\u", "INSTALLE", "D", "\\u", "FILES_", ",_", "\\u", "UNI", "QUE", "\\u", "INSTALLE", "D", "\\u", "FILES_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Verbos", "e_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "INSTALLE", "D", "\\u", "FILES_", "._", "extend_", "(_", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "ver", " ", "lib", " ", "emitte", "r", " ", "\"_", ",_", "repr_", "(_", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "see", " ", "if", " ", "we", " ", "have", " ", "a", " ", "versioned", " ", "shared", " ", "librar", "y", ",", " ", "if", " ", "so", " ", "generat", "e", " ", "side", " ", "effects_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", ",_", "libname", "_", ",_", "install", "\\u", "dir_", "=_", "versioned", "Lib", "Version_", "(_", "target_", "[_", "0_", "]_", "._", "path_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "version_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "generat", "e", " ", "list", " ", "of", " ", "link", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link", "names_", "=_", "SC", "ons_", "._", "Tool_", "._", "Version", "Sh", "Lib", "Link", "Names_", "(_", "version_", ",_", "libname", "_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "link", "name_", "in_", "link", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "make", " ", "side", " ", "effect", " ", "of", " ", "%", "s", "\"_", "%_", "os_", "._", "path_", "._", "join_", "(_", "install", "\\u", "dir_", ",_", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "full", "link", "name_", "=_", "os_", "._", "path_", "._", "join_", "(_", "install", "\\u", "dir_", ",_", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "env_", "._", "Side", "Effect_", "(_", "full", "link", "name_", ",_", "target_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "env_", "._", "Clean", "_", "(_", "target_", "[_", "0_", "]_", ",_", "full", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "INSTALLE", "D", "\\u", "FILES_", "._", "append_", "(_", "full", "link", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Verbos", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "install", "ed", " ", "list", " ", "\"_", ",_", "\\u", "INSTALLE", "D", "\\u", "FILES_", "\\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", "UNI", "QUE", "\\u", "INSTALLE", "D", "\\u", "FILES_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "target_", ",_", "source_", ")_", "\\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, 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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, 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, 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 ]
Imprecise assert
GoogleCloudPlatform/gcloud-python/gcloud/bigquery/test_query.py
[ { "content": " def _verifySchema(self, query, resource):\n from gcloud.bigquery.table import SchemaField\n if 'schema' in resource:\n fields = resource['schema']['fields']\n self.assertEqual(len(query.schema), len(fields))\n for found, expected in zip(query.schema, fields):\n self.assertTrue(isinstance(found, SchemaField))\n self.assertEqual(found.name, expected['name'])\n self.assertEqual(found.field_type, expected['type'])\n self.assertEqual(found.mode, expected['mode'])\n self.assertEqual(found.description,\n expected.get('description'))\n self.assertEqual(found.fields, expected.get('fields'))\n else:\n self.assertTrue(query.schema is None)", "metadata": "root.TestQueryResults._verifySchema", "header": "['class', 'TestQueryResults', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 74 }, { "content": " def _verifyResourceProperties(self, query, resource):\n self.assertEqual(query.cache_hit, resource.get('cacheHit'))\n self.assertEqual(query.complete, resource.get('jobComplete'))\n self.assertEqual(query.errors, resource.get('errors'))\n self.assertEqual(query.page_token, resource.get('pageToken'))\n self.assertEqual(query.total_rows, resource.get('totalRows'))\n self.assertEqual(query.total_bytes_processed,\n resource.get('totalBytesProcessed'))\n\n if 'jobReference' in resource:\n self.assertEqual(query.name, resource['jobReference']['jobId'])\n else:\n self.assertTrue(query.name is None)\n\n self._verifySchema(query, resource)\n self._verifyRows(query, resource)", "metadata": "root.TestQueryResults._verifyResourceProperties", "header": "['class', 'TestQueryResults', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 101 }, { "content": " def test_ctor(self):\n client = _Client(self.PROJECT)\n query = self._makeOne(self.QUERY, client)\n self.assertEqual(query.query, self.QUERY)\n self.assertTrue(query._client is client)\n\n self.assertTrue(query.cache_hit is None)\n self.assertTrue(query.complete is None)\n self.assertTrue(query.errors is None)\n self.assertTrue(query.name is None)\n self.assertTrue(query.page_token is None)\n self.assertEqual(query.rows, [])\n self.assertTrue(query.schema is None)\n self.assertTrue(query.total_rows is None)\n self.assertTrue(query.total_bytes_processed is None)\n\n self.assertTrue(query.default_dataset is None)\n self.assertTrue(query.max_results is None)\n self.assertTrue(query.preserve_nulls is None)\n self.assertTrue(query.use_query_cache is None)", "metadata": "root.TestQueryResults.test_ctor", "header": "['class', 'TestQueryResults', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 118 }, { "content": " def test_job_wo_jobid(self):\n client = _Client(self.PROJECT)\n query = self._makeOne(self.QUERY, client)\n self.assertTrue(query.job is None)", "metadata": "root.TestQueryResults.test_job_wo_jobid", "header": "['class', 'TestQueryResults', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 139 }, { "content": " def test_job_w_jobid(self):\n from gcloud.bigquery.job import QueryJob\n SERVER_GENERATED = 'SERVER_GENERATED'\n client = _Client(self.PROJECT)\n query = self._makeOne(self.QUERY, client)\n query._properties['jobReference'] = {\n 'projectId': self.PROJECT,\n 'jobId': SERVER_GENERATED,\n }\n job = query.job\n self.assertTrue(isinstance(job, QueryJob))\n self.assertEqual(job.query, self.QUERY)\n self.assertTrue(job._client is client)\n self.assertEqual(job.name, SERVER_GENERATED)\n fetched_later = query.job\n self.assertTrue(fetched_later is job)", "metadata": "root.TestQueryResults.test_job_w_jobid", "header": "['class', 'TestQueryResults', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 144 } ]
[ { "span": "self.assertTrue(query.schema is None)", "start_line": 88, "start_column": 12, "end_line": 88, "end_column": 49 }, { "span": "self.assertTrue(query.name is None)", "start_line": 113, "start_column": 12, "end_line": 113, "end_column": 47 }, { "span": "self.assertTrue(query._client is client)", "start_line": 122, "start_column": 8, "end_line": 122, "end_column": 48 }, { "span": "self.assertTrue(query.cache_hit is None)", "start_line": 124, "start_column": 8, "end_line": 124, "end_column": 48 }, { "span": "self.assertTrue(query.complete is None)", "start_line": 125, "start_column": 8, "end_line": 125, "end_column": 47 }, { "span": "self.assertTrue(query.errors is None)", "start_line": 126, "start_column": 8, "end_line": 126, "end_column": 45 }, { "span": "self.assertTrue(query.name is None)", "start_line": 127, "start_column": 8, "end_line": 127, "end_column": 43 }, { "span": "self.assertTrue(query.page_token is None)", "start_line": 128, "start_column": 8, "end_line": 128, "end_column": 49 }, { "span": "self.assertTrue(query.schema is None)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 45 }, { "span": "self.assertTrue(query.total_rows is None)", "start_line": 131, "start_column": 8, "end_line": 131, "end_column": 49 }, { "span": "self.assertTrue(query.total_bytes_processed is None)", "start_line": 132, "start_column": 8, "end_line": 132, "end_column": 60 }, { "span": "self.assertTrue(query.default_dataset is None)", "start_line": 134, "start_column": 8, "end_line": 134, "end_column": 54 }, { "span": "self.assertTrue(query.max_results is None)", "start_line": 135, "start_column": 8, "end_line": 135, "end_column": 50 }, { "span": "self.assertTrue(query.preserve_nulls is None)", "start_line": 136, "start_column": 8, "end_line": 136, "end_column": 53 }, { "span": "self.assertTrue(query.use_query_cache is None)", "start_line": 137, "start_column": 8, "end_line": 137, "end_column": 54 }, { "span": "self.assertTrue(query.job is None)", "start_line": 142, "start_column": 8, "end_line": 142, "end_column": 42 }, { "span": "self.assertTrue(job._client is client)", "start_line": 156, "start_column": 8, "end_line": 156, "end_column": 46 }, { "span": "self.assertTrue(fetched_later is job)", "start_line": 159, "start_column": 8, "end_line": 159, "end_column": 45 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Query", "Results_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "verify", "Schema_", "(_", "self_", ",_", "query_", ",_", "resource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gcloud", "_", "._", "bigquery_", "._", "table_", "import_", "Schema", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "schema", "'_", "in_", "resource_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fields_", "=_", "resource_", "[_", "'", "schema", "'_", "]_", "[_", "'", "fields", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "query_", "._", "schema_", ")_", ",_", "len_", "(_", "fields_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "found_", ",_", "expected_", "in_", "zip_", "(_", "query_", "._", "schema_", ",_", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "found_", ",_", "Schema", "Field_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "name_", ",_", "expected_", "[_", "'", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "field", "\\u", "type_", ",_", "expected_", "[_", "'", "type", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "mode_", ",_", "expected_", "[_", "'", "mode", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected_", "._", "get_", "(_", "'", "description", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "fields_", ",_", "expected_", "._", "get_", "(_", "'", "fields", "'_", ")_", ")_", "\\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_", "._", "assert", "True_", "(_", "query_", "._", "schema_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Query", "Results_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "verify", "Reso", "urc", "e", "Properties_", "(_", "self_", ",_", "query_", ",_", "resource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "cache", "\\u", "hit_", ",_", "resource_", "._", "get_", "(_", "'", "cache", "Hit", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "complete_", ",_", "resource_", "._", "get_", "(_", "'", "job", "Complete", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "errors_", ",_", "resource_", "._", "get_", "(_", "'", "error", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "page", "\\u", "token_", ",_", "resource_", "._", "get_", "(_", "'", "page", "Token", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "total", "\\u", "rows_", ",_", "resource_", "._", "get_", "(_", "'", "total", "Row", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "total", "\\u", "bytes", "\\u", "processed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "resource_", "._", "get_", "(_", "'", "total", "Byte", "s", "Processe", "d", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "job", "Reference", "'_", "in_", "resource_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "name_", ",_", "resource_", "[_", "'", "job", "Reference", "'_", "]_", "[_", "'", "job", "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_", "._", "assert", "True_", "(_", "query_", "._", "name_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "verify", "Schema_", "(_", "query_", ",_", "resource_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "verify", "Rows_", "(_", "query_", ",_", "resource_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Query", "Results_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ctor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "\\u", "Client_", "(_", "self_", "._", "PROJECT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "self_", "._", "QUERY_", ",_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "query_", ",_", "self_", "._", "QUERY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "\\u", "client_", "is_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "cache", "\\u", "hit_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "complete_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "errors_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "name_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "page", "\\u", "token_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "query_", "._", "rows_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "schema_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "total", "\\u", "rows_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "total", "\\u", "bytes", "\\u", "processed_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "default", "\\u", "dataset_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "max", "\\u", "results_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "preserve", "\\u", "null", "s_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "use", "\\u", "query", "\\u", "cache_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Query", "Results_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "job", "\\u", "wo", "\\u", "jobid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "\\u", "Client_", "(_", "self_", "._", "PROJECT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "self_", "._", "QUERY_", ",_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "query_", "._", "job_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Query", "Results_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "job", "\\u", "w", "\\u", "jobid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gcloud", "_", "._", "bigquery_", "._", "job_", "import_", "Query", "Job_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SERVER", "\\u", "GENERATE", "D_", "=_", "'", "SERVER", "\\u", "GENERATE", "D", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "self_", "._", "PROJECT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "self_", "._", "QUERY_", ",_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "._", "\\u", "properties_", "[_", "'", "job", "Reference", "'_", "]_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "project", "Id", "'_", ":_", "self_", "._", "PROJECT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "job", "Id", "'_", ":_", "SERVER", "\\u", "GENERATE", "D_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "=_", "query_", "._", "job_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "job_", ",_", "Query", "Job_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "job_", "._", "query_", ",_", "self_", "._", "QUERY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "job_", "._", "\\u", "client_", "is_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "job_", "._", "name_", ",_", "SERVER", "\\u", "GENERATE", "D_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fetched", "\\u", "later_", "=_", "query_", "._", "job_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fetched", "\\u", "later_", "is_", "job_", ")_", "\\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, 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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, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Non-callable called
jdf/processing.py/mode/examples/Topics/Fractals and L-Systems/PenroseTile/l_system.py
[ { "content": " def render(self):\n translate(width / 2, height / 2)\n self.steps += 5\n if self.steps > len(self.production)():\n self.steps = len(self.production)()\n\n for i in range(self.steps):\n step = self.production.charAt(i)\n if step == 'F':\n rect(0, 0, -self.drawLength, -self.drawLength)\n noFill()\n translate(0, -self.drawLength)\n elif step == '+':\n rotate(self.theta)\n elif step == '-':\n rotate(-self.theta)\n elif step == '[':\n pushMatrix()\n elif step == ']':\n popMatrix()", "metadata": "root.LSystem.render", "header": "['class', 'LSystem', '(', 'object', ')', ':', '___EOS___']", "index": 18 } ]
[ { "span": "len(self.production)():", "start_line": 21, "start_column": 24, "end_line": 21, "end_column": 46 }, { "span": "len(self.production)()", "start_line": 22, "start_column": 25, "end_line": 22, "end_column": 47 } ]
[]
1
false
[ "[CLS]_", "Non", "_", "-_", "callable_", "called_", "[SEP]_", "class_", "LS", "ystem_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "render_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "translate_", "(_", "width_", "/_", "2_", ",_", "height_", "/_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "steps_", "+=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "steps_", ">_", "len_", "(_", "self_", "._", "production_", ")_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "steps_", "=_", "len_", "(_", "self_", "._", "production_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "steps_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "step_", "=_", "self_", "._", "production_", "._", "char", "At_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "step_", "==_", "'", "F", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rect_", "(_", "0_", ",_", "0_", ",_", "-_", "self_", "._", "draw", "Length_", ",_", "-_", "self_", "._", "draw", "Length_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "no", "Fill_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "translate_", "(_", "0_", ",_", "-_", "self_", "._", "draw", "Length_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "step_", "==_", "'+'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rotate_", "(_", "self_", "._", "theta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "step_", "==_", "'-'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rotate_", "(_", "-_", "self_", "._", "theta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "step_", "==_", "'['_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "push", "Matrix_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "step_", "==_", "']'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pop", "Matrix_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
First parameter of a method is not named 'self'
fredrik-johansson/mpmath/mpmath/rational.py
[ { "content": " def __repr__(s):\n return \"mpq(%s,%s)\" % s._mpq_", "metadata": "root.mpq.__repr__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 37 }, { "content": " def __str__(s):\n return \"(%s/%s)\" % s._mpq_", "metadata": "root.mpq.__str__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 40 }, { "content": " def __int__(s):\n a, b = s._mpq_\n return a // b", "metadata": "root.mpq.__int__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 43 }, { "content": " def __nonzero__(s):\n return bool(s._mpq_[0])", "metadata": "root.mpq.__nonzero__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 47 }, { "content": " def __hash__(s):\n a, b = s._mpq_\n if sys.version >= \"3.2\":\n inverse = pow(b, HASH_MODULUS-2, HASH_MODULUS)\n if not inverse:\n h = sys.hash_info.inf\n else:\n h = (abs(a) * inverse) % HASH_MODULUS\n if a < 0: h = -h\n if h == -1: h = -2\n return h\n else:\n if b == 1:\n return hash(a)\n # Power of two: mpf compatible hash\n if not (b & (b-1)):\n return mpf_hash(from_man_exp(a, 1-bitcount(b)))\n return hash((a,b))", "metadata": "root.mpq.__hash__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 52 }, { "content": " def __eq__(s, t):\n ttype = type(t)\n if ttype is mpq:\n return s._mpq_ == t._mpq_\n if ttype in int_types:\n a, b = s._mpq_\n if b != 1:\n return False\n return a == t\n return NotImplemented", "metadata": "root.mpq.__eq__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 71 }, { "content": " def __ne__(s, t):\n ttype = type(t)\n if ttype is mpq:\n return s._mpq_ != t._mpq_\n if ttype in int_types:\n a, b = s._mpq_\n if b != 1:\n return True\n return a != t\n return NotImplemented", "metadata": "root.mpq.__ne__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 82 }, { "content": " def _cmp(s, t, op):\n ttype = type(t)\n if ttype in int_types:\n a, b = s._mpq_\n return op(a, t*b)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return op(a*d, b*c)\n return NotImplementedError", "metadata": "root.mpq._cmp", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 93 }, { "content": " def __lt__(s, t): return s._cmp(t, operator.lt)", "metadata": "root.mpq.__lt__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 104 }, { "content": " def __le__(s, t): return s._cmp(t, operator.le)", "metadata": "root.mpq.__le__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 105 }, { "content": " def __gt__(s, t): return s._cmp(t, operator.gt)", "metadata": "root.mpq.__gt__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 106 }, { "content": " def __ge__(s, t): return s._cmp(t, operator.ge)", "metadata": "root.mpq.__ge__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 107 }, { "content": " def __abs__(s):\n a, b = s._mpq_\n if a >= 0:\n return s\n v = new(mpq)\n v._mpq_ = -a, b\n return v", "metadata": "root.mpq.__abs__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 109 }, { "content": " def __neg__(s):\n a, b = s._mpq_\n v = new(mpq)\n v._mpq_ = -a, b\n return v", "metadata": "root.mpq.__neg__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 117 }, { "content": " def __pos__(s):\n return s", "metadata": "root.mpq.__pos__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 123 }, { "content": " def __add__(s, t):\n ttype = type(t)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return create_reduced(a*d+b*c, b*d)\n if ttype in int_types:\n a, b = s._mpq_\n v = new(mpq)\n v._mpq_ = a+b*t, b\n return v\n return NotImplemented", "metadata": "root.mpq.__add__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 126 }, { "content": " def __sub__(s, t):\n ttype = type(t)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return create_reduced(a*d-b*c, b*d)\n if ttype in int_types:\n a, b = s._mpq_\n v = new(mpq)\n v._mpq_ = a-b*t, b\n return v\n return NotImplemented", "metadata": "root.mpq.__sub__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 141 }, { "content": " def __rsub__(s, t):\n ttype = type(t)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return create_reduced(b*c-a*d, b*d)\n if ttype in int_types:\n a, b = s._mpq_\n v = new(mpq)\n v._mpq_ = b*t-a, b\n return v\n return NotImplemented", "metadata": "root.mpq.__rsub__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 154 }, { "content": " def __mul__(s, t):\n ttype = type(t)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return create_reduced(a*c, b*d)\n if ttype in int_types:\n a, b = s._mpq_\n return create_reduced(a*t, b)\n return NotImplemented", "metadata": "root.mpq.__mul__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 167 }, { "content": " def __div__(s, t):\n ttype = type(t)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return create_reduced(a*d, b*c)\n if ttype in int_types:\n a, b = s._mpq_\n return create_reduced(a, b*t)\n return NotImplemented", "metadata": "root.mpq.__div__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 180 }, { "content": " def __rdiv__(s, t):\n ttype = type(t)\n if ttype is mpq:\n a, b = s._mpq_\n c, d = t._mpq_\n return create_reduced(b*c, a*d)\n if ttype in int_types:\n a, b = s._mpq_\n return create_reduced(b*t, a)\n return NotImplemented", "metadata": "root.mpq.__rdiv__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 191 }, { "content": " def __pow__(s, t):\n ttype = type(t)\n if ttype in int_types:\n a, b = s._mpq_\n if t:\n if t < 0:\n a, b, t = b, a, -t\n v = new(mpq)\n v._mpq_ = a**t, b**t\n return v\n raise ZeroDivisionError\n return NotImplemented", "metadata": "root.mpq.__pow__", "header": "['class', 'mpq', '(', 'object', ')', ':', '___EOS___']", "index": 202 } ]
[ { "span": "def __repr__(s):", "start_line": 37, "start_column": 4, "end_line": 37, "end_column": 20 }, { "span": "def __str__(s):", "start_line": 40, "start_column": 4, "end_line": 40, "end_column": 19 }, { "span": "def __int__(s):", "start_line": 43, "start_column": 4, "end_line": 43, "end_column": 19 }, { "span": "def __nonzero__(s):", "start_line": 47, "start_column": 4, "end_line": 47, "end_column": 23 }, { "span": "def __hash__(s):", "start_line": 52, "start_column": 4, "end_line": 52, "end_column": 20 }, { "span": "def __eq__(s, t):", "start_line": 71, "start_column": 4, "end_line": 71, "end_column": 21 }, { "span": "def __ne__(s, t):", "start_line": 82, "start_column": 4, "end_line": 82, "end_column": 21 }, { "span": "def _cmp(s, t, op):", "start_line": 93, "start_column": 4, "end_line": 93, "end_column": 23 }, { "span": "def __lt__(s, t): ", "start_line": 104, "start_column": 4, "end_line": 104, "end_column": 21 }, { "span": "def __le__(s, t): ", "start_line": 105, "start_column": 4, "end_line": 105, "end_column": 21 }, { "span": "def __gt__(s, t): ", "start_line": 106, "start_column": 4, "end_line": 106, "end_column": 21 }, { "span": "def __ge__(s, t): ", "start_line": 107, "start_column": 4, "end_line": 107, "end_column": 21 }, { "span": "def __abs__(s):", "start_line": 109, "start_column": 4, "end_line": 109, "end_column": 19 }, { "span": "def __neg__(s):", "start_line": 117, "start_column": 4, "end_line": 117, "end_column": 19 }, { "span": "def __pos__(s):", "start_line": 123, "start_column": 4, "end_line": 123, "end_column": 19 }, { "span": "def __add__(s, t):", "start_line": 126, "start_column": 4, "end_line": 126, "end_column": 22 }, { "span": "def __sub__(s, t):", "start_line": 141, "start_column": 4, "end_line": 141, "end_column": 22 }, { "span": "def __rsub__(s, t):", "start_line": 154, "start_column": 4, "end_line": 154, "end_column": 23 }, { "span": "def __mul__(s, t):", "start_line": 167, "start_column": 4, "end_line": 167, "end_column": 22 }, { "span": "def __div__(s, t):", "start_line": 180, "start_column": 4, "end_line": 180, "end_column": 22 }, { "span": "def __rdiv__(s, t):", "start_line": 191, "start_column": 4, "end_line": 191, "end_column": 23 }, { "span": "def __pow__(s, t):", "start_line": 202, "start_column": 4, "end_line": 202, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "mp", "q_", "(_", "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_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "mp", "q", "(%", "s", ",%", "s", ")\"_", "%_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "str\\u\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"(", "%", "s", "/", "%", "s", ")\"_", "%_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "int\\u", "\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "a_", "//_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "nonzero\\u", "\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "bool_", "(_", "s_", "._", "\\u", "mp", "q", "\\u_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "hash\\u\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "version_", ">=_", "\"", "3.2", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "inverse_", "=_", "pow_", "(_", "b_", ",_", "HAS", "H", "\\u", "MODUL", "US_", "-_", "2_", ",_", "HAS", "H", "\\u", "MODUL", "US_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "inverse_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h_", "=_", "sys_", "._", "hash", "\\u", "info_", "._", "inf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h_", "=_", "(_", "abs_", "(_", "a_", ")_", "*_", "inverse_", ")_", "%_", "HAS", "H", "\\u", "MODUL", "US_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "a_", "<_", "0_", ":_", "h_", "=_", "-_", "h_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "h_", "==_", "-_", "1_", ":_", "h_", "=_", "-_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "h_", "\\u\\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_", "b_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "hash_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Power", " ", "of", " ", "two", ":", " ", "mpf", " ", "compatible", " ", "hash_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "(_", "b_", "&_", "(_", "b_", "-_", "1_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "mpf", "\\u", "hash_", "(_", "from", "\\u", "man", "\\u", "exp_", "(_", "a_", ",_", "1_", "-_", "bit", "count_", "(_", "b_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "hash_", "(_", "(_", "a_", ",_", "b_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "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", "eq\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "s_", "._", "\\u", "mp", "q", "\\u_", "==_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "b_", "!=_", "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_", "return_", "a_", "==_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "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_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "s_", "._", "\\u", "mp", "q", "\\u_", "!=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "b_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "a_", "!=_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "cmp_", "(_", "s_", ",_", "t_", ",_", "op_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "op_", "(_", "a_", ",_", "t_", "*_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "op_", "(_", "a_", "*_", "d_", ",_", "b_", "*_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "lt\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "return_", "s_", "._", "\\u", "cmp_", "(_", "t_", ",_", "operator_", "._", "lt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "le", "\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "return_", "s_", "._", "\\u", "cmp_", "(_", "t_", ",_", "operator_", "._", "le_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "gt", "\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "return_", "s_", "._", "\\u", "cmp_", "(_", "t_", ",_", "operator_", "._", "gt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "ge", "\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "return_", "s_", "._", "\\u", "cmp_", "(_", "t_", ",_", "operator_", "._", "ge_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "abs", "\\u\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "a_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "v_", "=_", "new_", "(_", "mp", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "\\u", "mp", "q", "\\u_", "=_", "-_", "a_", ",_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "neg", "\\u\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "new_", "(_", "mp", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "\\u", "mp", "q", "\\u_", "=_", "-_", "a_", ",_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "pos", "\\u\\u_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "add\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "a_", "*_", "d_", "+_", "b_", "*_", "c_", ",_", "b_", "*_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "new_", "(_", "mp", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "\\u", "mp", "q", "\\u_", "=_", "a_", "+_", "b_", "*_", "t_", ",_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "sub\\u", "\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "a_", "*_", "d_", "-_", "b_", "*_", "c_", ",_", "b_", "*_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "new_", "(_", "mp", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "\\u", "mp", "q", "\\u_", "=_", "a_", "-_", "b_", "*_", "t_", ",_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "rsu", "b", "\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "b_", "*_", "c_", "-_", "a_", "*_", "d_", ",_", "b_", "*_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "new_", "(_", "mp", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "\\u", "mp", "q", "\\u_", "=_", "b_", "*_", "t_", "-_", "a_", ",_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "mul\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "a_", "*_", "c_", ",_", "b_", "*_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "a_", "*_", "t_", ",_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "div\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "a_", "*_", "d_", ",_", "b_", "*_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "a_", ",_", "b_", "*_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "rdi", "v", "\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "is_", "mp", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", ",_", "d_", "=_", "t_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "b_", "*_", "c_", ",_", "a_", "*_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "create", "\\u", "reduced_", "(_", "b_", "*_", "t_", ",_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "mp", "q_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "pow", "\\u\\u_", "(_", "s_", ",_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ttype_", "=_", "type_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ttype_", "in_", "int\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", ",_", "b_", "=_", "s_", "._", "\\u", "mp", "q", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "a_", ",_", "b_", ",_", "t_", "=_", "b_", ",_", "a_", ",_", "-_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "v_", "=_", "new_", "(_", "mp", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "\\u", "mp", "q", "\\u_", "=_", "a_", "**_", "t_", ",_", "b_", "**_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Zero", "Divis", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4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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 ]
Unused import
dongying/dear/dear/spectrogram.py
[ { "content": "#-*- coding: utf-8 -*-\n\nimport numpy as np\nimport matplotlib\n#matplotlib.use('GTKAgg')\nimport matplotlib.pyplot as plt\nimport matplotlib.cm as cm\nfrom matplotlib.image import NonUniformImage\nimport matplotlib.colors as colo\n\nfrom dear.spectrum import cqt, dft, auditory, SpectrogramFile\nfrom dear.analysis import MFCCs\n\n\n\n\nif __name__ == '__main__':\n import getopt, sys\n\n\n try:\n opts, args = getopt.getopt(sys.argv[1:], \"g:s:t:o:h:w:q:n:f:b:rc\")\n except getopt.GetoptError as ex:\n print ex\n exit_with_usage()\n if len(args) != 1:\n #print args\n exit_with_usage()\n\n import dear.io as io\n decoder = io.get_decoder(name='audioread')\n audio = decoder.Audio(args[0])\n print \"SampleRate: %d Hz\\nChannel(s): %d\\nDuration: %d sec\"\\\n % (audio.samplerate, audio.channels, audio.duration)\n\n graph = 'dft'\n st = 0\n to = None\n outfile = None\n norm=colo.LogNorm(vmin=0.000001)\n\n for o, a in opts:\n if o == '-s':\n st = float(a)\n elif o == '-t':\n to = float(a)\n elif o == '-g':\n graph = a\n assert graph in ('dft','cqt','cnt','gmt','Y1','Y2','Y3','Y4','Y5','mfcc')\n elif o == '-o':\n outfile = a\n\n if to is None or to > audio.duration:\n r_to = audio.duration\n else:\n r_to = to\n\n if graph == 'dft':\n win = 2048\n hop = 512\n for o, a in opts:\n if o == '-w':\n win = int(a)\n elif o == '-h':\n hop = int(a)\n spec = [[]]\n gram = dft.PowerSpectrum(audio)\n for freqs in gram.walk(win, hop, start=st, end=to, join_channels=True):\n spec[0].append(freqs)\n #\n elif graph == 'mfcc':\n N = 20\n fmin, fmax = 0., 7040.\n win = 2048\n hop = 1024\n for o, a in opts:\n if o == '-w':\n win = int(a)\n elif o == '-h':\n hop = int(a)\n elif o == '-n':\n N = int(a)\n elif o == '-f':\n fmin, fmax = [float(f) for f in a.split(',',1)]\n spec = [[]]\n gram = MFCCs(audio)\n for freqs in gram.walk(N, fmin, fmax, win, hop, st, to):\n spec[0].append(freqs)\n norm = colo.Normalize()\n #\n elif graph == 'cqt':\n Q = 34\n hop = 0.02\n for o, a in opts:\n if o == '-q':\n Q = int(a)\n elif o == '-h':\n hop = float(a)\n spec = [[]]\n gram = cqt.CQTPowerSpectrum(audio)\n print 'total:', int((r_to-st)/hop)\n for t,freqs in enumerate(gram.walk(Q=Q, freq_base=55., freq_max=7040, hop=hop, start=st, end=to, join_channels=True)):\n if t%100 == 0:\n sys.stdout.write('%d...' % t)\n sys.stdout.flush()\n spec[0].append(freqs)\n #\n elif graph == 'cnt':\n N = 24\n hop = 0.02\n rw = False\n for o, a in opts:\n if o == '-n':\n N = int(a)\n elif o == '-h':\n hop = float(a)\n elif o == '-r':\n rw = True\n spec = [[]]\n gram = cqt.CNTPowerSpectrum(audio)\n print 'total:', int((r_to-st)/hop)\n for t, freqs in enumerate(\n gram.walk(N=N, freq_base=55., freq_max=7040, hop=hop, start=st, end=to, resize_win=rw)):\n if t%100==0:\n sys.stdout.write('%d...' % t)\n sys.stdout.flush()\n spec[0].append(freqs)\n print \"\"\n #\n elif graph == 'gmt':\n N = 64\n win = 0.025\n hop = 0.010\n freqs = [110., 4435.]\n combine=False\n for o, a in opts:\n if o == '-n':\n N = int(a)\n elif o == '-h':\n hop = float(a)\n elif o == '-w':\n win = float(a)\n elif o == '-f':\n freqs = [float(f) for f in a.split(',',1)]\n elif o == '-c':\n combine=True\n spec = [[]]\n gram = auditory.GammatoneSpectrum(audio)\n print 'total:', int((r_to-st)/hop)\n for t, freqs in enumerate(\n gram.walk(N=N, freq_base=freqs[0], freq_max=freqs[1], \n start=st, end=to, combine=combine, twin=win, thop=hop)):\n if t%100==0:\n sys.stdout.write('%d...' % t)\n sys.stdout.flush()\n spec[0].append(freqs)\n print \"\"\n #\n elif graph in ('Y1','Y2','Y3','Y4','Y5'):\n N = 64\n win = 0.025\n hop = 0.010\n freqs = [110., 4435.]\n combine = False\n for o, a in opts:\n if o == '-n':\n N = int(a)\n elif o == '-h':\n hop = float(a)\n elif o == '-w':\n win = float(a)\n elif o == '-f':\n freqs = [float(f) for f in a.split(',',1)]\n elif o == '-c':\n combine=True\n spec = [[]]\n gram = getattr(auditory,graph)\n gram = gram(audio)\n print 'total:', int((r_to-st)/hop)\n for t, freqs in enumerate(\n gram.walk(N=N, freq_base=freqs[0], freq_max=freqs[1], \n start=st, end=to, combine=combine, twin=win, thop=hop)):\n if t%100==0:\n sys.stdout.write('%d...' % t)\n sys.stdout.flush()\n spec[0].append(freqs)\n print \"\"\n\n # to dB scale\n dBmax, dBmin = -15., -70.\n if graph in ('dft','cqt','cnt'):\n magmin = 10**(dBmin/20)\n for g in spec:\n for i,frame in enumerate(g):\n g[i] = 20*np.log10(np.maximum(frame/20.,magmin))\n norm = colo.Normalize(vmin=dBmin, vmax=dBmax) \n elif graph in ('gmt','Y1','Y2','Y3','Y4','Y5'):\n magmin = 10**(dBmin/20)\n for g in spec:\n for i,frame in enumerate(g):\n g[i] = 20*np.log10(np.maximum(frame,magmin))\n norm = colo.Normalize(vmin=dBmin, vmax=dBmax) \n\n figname = \"%s - %s\" % (graph, audio.path)\n plot_spectrogram(np.array(spec), (0,len(spec[0])), (0,len(spec[0][0])), norm=norm, figname=figname)\n if outfile:\n out = SpectrogramFile(outfile, 'w')\n out.dump(spec[0])\n out.close()\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def plot_spectrogram(spec, Xd=(0,1), Yd=(0,1), norm=colo.LogNorm(vmin=0.000001), figname=None):\n #\n x_min, x_max = Xd\n y_min, y_max = Yd\n #\n fig = plt.figure(num=figname)\n nf = len(spec)\n for ch, data in enumerate(spec):\n #print ch, data.shape\n x = np.linspace(x_min, x_max, data.shape[0])\n y = np.linspace(y_min, y_max, data.shape[1])\n #print x[0],x[-1],y[0],y[-1]\n ax = fig.add_subplot(nf*100+11+ch)\n im = NonUniformImage(ax, interpolation='bilinear', cmap=cm.gray_r,\n norm=norm)\n im.set_data(x, y, data.T)\n ax.images.append(im)\n ax.set_xlim(x_min, x_max)\n ax.set_ylim(y_min, y_max)\n ax.set_title('Channel %d' % ch)\n #ax.set_xlabel('timeline')\n ax.set_ylabel('frequency')\n print 'Statistics: max<%.3f> min<%.3f> mean<%.3f> median<%.3f>' % (data.max(), data.min(), data.mean(), np.median(data))\n #\n plt.show()", "metadata": "root.plot_spectrogram", "header": "['module', '___EOS___']", "index": 14 }, { "content": " def exit_with_usage():\n print \"\"\"Usage: $ python -m dear.spectrogram <options> /path/to/song\n\nOptions:\n [-s] start time in second, default 0\n [-t] end time, default is duration of song\n [-o] output file\n [-g] type of spectrogram, default dft:\n\n dft --- Discrete Fourier Transform\n [-w] window size, default 2048\n [-h] step size, default 512\n\n cqt --- Constant-Q Transform\n [-q] Q, default 34\n [-h] hop in second, default 0.02\n\n cnt --- Constant-N Transform\n [-n] N, default 24\n [-h] hop in second, default 0.02\n [-r] resize window size of each of the bands if specified.\n\n gmt --- Gammatone Wavelet Transform\n [-n] N, default 64\n [-w] combine length in second, default 0.025\n [-h] hop in second, default 0.01\n [-f] frequency boundary, default (110, 4200)\n\n Y1...Y5 --- Auditory Spectrograms\n [-n] N, default 64\n [-f] frequency boundary, default (110, 4200)\n [-c] Combine frames by -w and -h.\n [-w] combine length in second, default 0.025\n [-h] hop in second, default 0.01\n\n mfcc --- MFCCs Spectrogram\n [-n] number of bands, default 20\n [-w] window size, default 2048\n [-h] step size, default 1024\n [-f] frequency boundary, default (0, 7040)\n\"\"\"\n exit()", "metadata": "root.exit_with_usage", "header": "['module', '___EOS___']", "index": 44 } ]
[ { "span": "import matplotlib", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#-", "*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "mat", "plotlib", ".", "use", "('", "GTK", "Agg", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "matplotlib_", "._", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "._", "cm_", "as_", "cm_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "matplotlib_", "._", "image_", "import_", "Non", "Uniform", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "._", "colors_", "as_", "colo", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "dea", "r_", "._", "spectrum_", "import_", "cq", "t_", ",_", "dft", "_", ",_", "audit", "ory", "_", ",_", "Spect", "rogr", "am", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dea", "r_", "._", "analysis_", "import_", "MF", "CC", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "getopt_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opts_", ",_", "args_", "=_", "getopt_", "._", "getopt_", "(_", "sys_", "._", "argv_", "[_", "1_", ":_", "]_", ",_", "\"", "g", ":", "s", ":", "t", ":", "o", ":", "h", ":", "w", ":", "q", ":", "n", ":", "f", ":", "b", ":", "rc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "getopt_", "._", "Get", "opt", "Error_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "ex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exit", "\\u", "with", "\\u", "usage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "args_", ")_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "args_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exit", "\\u", "with", "\\u", "usage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "dea", "r_", "._", "io_", "as_", "io_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "decoder_", "=_", "io_", "._", "get", "\\u", "decoder_", "(_", "name_", "=_", "'", "audio", "read", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "audio_", "=_", "decoder_", "._", "Audio_", "(_", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Sampl", "e", "Rat", "e", ":", " ", "%", "d", " ", "H", "z", "\\\\", "n", "Chan", "nel", "(", "s", "):", " ", "%", "d", "\\\\", "n", "Dur", "ation", ":", " ", "%", "d", " ", "sec", "\"_", "%_", "(_", "audio_", "._", "samplerate", "_", ",_", "audio_", "._", "channels_", ",_", "audio_", "._", "duration_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "graph_", "=_", "'", "dft", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "st_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "to_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "outfile_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "norm_", "=_", "colo", "_", "._", "Log", "Norm_", "(_", "vmin_", "=_", "0.000001", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "st_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "t", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "to_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "g", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "graph_", "=_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "graph_", "in_", "(_", "'", "dft", "'_", ",_", "'", "cq", "t", "'_", ",_", "'", "cnt", "'_", ",_", "'", "gmt", "'_", ",_", "'", "Y", "1", "'_", ",_", "'", "Y", "2", "'_", ",_", "'", "Y", "3", "'_", ",_", "'", "Y", "4", "'_", ",_", "'", "Y", "5", "'_", ",_", "'", "mfc", "c", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "o", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "outfile_", "=_", "a_", "\\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_", "to_", "is_", "None_", "or_", "to_", ">_", "audio_", "._", "duration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r", "\\u", "to_", "=_", "audio_", "._", "duration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r", "\\u", "to_", "=_", "to_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "graph_", "==_", "'", "dft", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "win_", "=_", "2048_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hop_", "=_", "512_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "w", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "win_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hop_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "=_", "[_", "[_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "dft", "_", "._", "Power", "Spectrum_", "(_", "audio_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "freqs_", "in_", "gram_", "._", "walk_", "(_", "win_", ",_", "hop_", ",_", "start_", "=_", "st_", ",_", "end_", "=_", "to_", ",_", "join", "\\u", "channels_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "spec_", "[_", "0_", "]_", "._", "append_", "(_", "freqs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "graph_", "==_", "'", "mfc", "c", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fmin", "_", ",_", "fmax", "_", "=_", "0._", ",_", "704", "0._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "win_", "=_", "2048_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hop_", "=_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "w", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "win_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hop_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "n", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "f", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fmin", "_", ",_", "fmax", "_", "=_", "[_", "float_", "(_", "f_", ")_", "for_", "f_", "in_", "a_", "._", "split_", "(_", "','_", ",_", "1_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "=_", "[_", "[_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "MF", "CC", "s_", "(_", "audio_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "freqs_", "in_", "gram_", "._", "walk_", "(_", "N_", ",_", "fmin", "_", ",_", "fmax", "_", ",_", "win_", ",_", "hop_", ",_", "st_", ",_", "to_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "spec_", "[_", "0_", "]_", "._", "append_", "(_", "freqs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "norm_", "=_", "colo", "_", "._", "Normalize", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "graph_", "==_", "'", "cq", "t", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Q_", "=_", "34_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hop_", "=_", "0.02_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "q", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Q_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hop_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "=_", "[_", "[_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "cq", "t_", "._", "CQ", "TP", "ower", "Spectrum_", "(_", "audio_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "total", ":'_", ",_", "int_", "(_", "(_", "r", "\\u", "to_", "-_", "st_", ")_", "/_", "hop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", ",_", "freqs_", "in_", "enumerate_", "(_", "gram_", "._", "walk_", "(_", "Q_", "=_", "Q_", ",_", "freq", "\\u", "base_", "=_", "55.", "_", ",_", "freq", "\\u", "max_", "=_", "704", "0_", ",_", "hop_", "=_", "hop_", ",_", "start_", "=_", "st_", ",_", "end_", "=_", "to_", ",_", "join", "\\u", "channels_", "=_", "True_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "%_", "100_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "'%", "d", "...'_", "%_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "[_", "0_", "]_", "._", "append_", "(_", "freqs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "graph_", "==_", "'", "cnt", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "24_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hop_", "=_", "0.02_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rw_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "n", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hop_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "r", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rw_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "=_", "[_", "[_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "cq", "t_", "._", "CNT", "Power", "Spectrum_", "(_", "audio_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "total", ":'_", ",_", "int_", "(_", "(_", "r", "\\u", "to_", "-_", "st_", ")_", "/_", "hop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", ",_", "freqs_", "in_", "enumerate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "gram_", "._", "walk_", "(_", "N_", "=_", "N_", ",_", "freq", "\\u", "base_", "=_", "55.", "_", ",_", "freq", "\\u", "max_", "=_", "704", "0_", ",_", "hop_", "=_", "hop_", ",_", "start_", "=_", "st_", ",_", "end_", "=_", "to_", ",_", "resiz", "e\\u", "win_", "=_", "rw_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "%_", "100_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "'%", "d", "...'_", "%_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "[_", "0_", "]_", "._", "append_", "(_", "freqs_", ")_", "\\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_", "elif_", "graph_", "==_", "'", "gmt", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "win_", "=_", "0.025", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hop_", "=_", "0.010", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "freqs_", "=_", "[_", "110", "._", ",_", "443", "5._", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "combine_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "n", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hop_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "w", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "win_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "f", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "freqs_", "=_", "[_", "float_", "(_", "f_", ")_", "for_", "f_", "in_", "a_", "._", "split_", "(_", "','_", ",_", "1_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "c", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "combine_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "=_", "[_", "[_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "audit", "ory", "_", "._", "Gamma", "tone", "Spectrum_", "(_", "audio_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "total", ":'_", ",_", "int_", "(_", "(_", "r", "\\u", "to_", "-_", "st_", ")_", "/_", "hop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", ",_", "freqs_", "in_", "enumerate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "gram_", "._", "walk_", "(_", "N_", "=_", "N_", ",_", "freq", "\\u", "base_", "=_", "freqs_", "[_", "0_", "]_", ",_", "freq", "\\u", "max_", "=_", "freqs_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start_", "=_", "st_", ",_", "end_", "=_", "to_", ",_", "combine_", "=_", "combine_", ",_", "twin", "_", "=_", "win_", ",_", "tho", "p_", "=_", "hop_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "%_", "100_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "'%", "d", "...'_", "%_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "[_", "0_", "]_", "._", "append_", "(_", "freqs_", ")_", "\\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_", "elif_", "graph_", "in_", "(_", "'", "Y", "1", "'_", ",_", "'", "Y", "2", "'_", ",_", "'", "Y", "3", "'_", ",_", "'", "Y", "4", "'_", ",_", "'", "Y", "5", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "win_", "=_", "0.025", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hop_", "=_", "0.010", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "freqs_", "=_", "[_", "110", "._", ",_", "443", "5._", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "combine_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "o_", ",_", "a_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "o_", "==_", "'-", "n", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "int_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hop_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "w", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "win_", "=_", "float_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "f", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "freqs_", "=_", "[_", "float_", "(_", "f_", ")_", "for_", "f_", "in_", "a_", "._", "split_", "(_", "','_", ",_", "1_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "o_", "==_", "'-", "c", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "combine_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "=_", "[_", "[_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "getattr_", "(_", "audit", "ory", "_", ",_", "graph_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gram_", "=_", "gram_", "(_", "audio_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "total", ":'_", ",_", "int_", "(_", "(_", "r", "\\u", "to_", "-_", "st_", ")_", "/_", "hop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", ",_", "freqs_", "in_", "enumerate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "gram_", "._", "walk_", "(_", "N_", "=_", "N_", ",_", "freq", "\\u", "base_", "=_", "freqs_", "[_", "0_", "]_", ",_", "freq", "\\u", "max_", "=_", "freqs_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start_", "=_", "st_", ",_", "end_", "=_", "to_", ",_", "combine_", "=_", "combine_", ",_", "twin", "_", "=_", "win_", ",_", "tho", "p_", "=_", "hop_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "%_", "100_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "'%", "d", "...'_", "%_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "spec_", "[_", "0_", "]_", "._", "append_", "(_", "freqs_", ")_", "\\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_", "#", " ", "to", " ", "d", "B", " ", "scale_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d", "Bm", "ax_", ",_", "d", "Bm", "in_", "=_", "-_", "15.", "_", ",_", "-_", "70.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "graph_", "in_", "(_", "'", "dft", "'_", ",_", "'", "cq", "t", "'_", ",_", "'", "cnt", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mag", "min_", "=_", "10_", "**_", "(_", "d", "Bm", "in_", "/_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "g_", "in_", "spec_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", ",_", "frame_", "in_", "enumerate_", "(_", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "g_", "[_", "i_", "]_", "=_", "20_", "*_", "np_", "._", "log10_", "(_", "np_", "._", "maximum_", "(_", "frame_", "/_", "20._", ",_", "mag", "min_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "norm_", "=_", "colo", "_", "._", "Normalize", "_", "(_", "vmin_", "=_", "d", "Bm", "in_", ",_", "vmax_", "=_", "d", "Bm", "ax_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "graph_", "in_", "(_", "'", "gmt", "'_", ",_", "'", "Y", "1", "'_", ",_", "'", "Y", "2", "'_", ",_", "'", "Y", "3", "'_", ",_", "'", "Y", "4", "'_", ",_", "'", "Y", "5", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mag", "min_", "=_", "10_", "**_", "(_", "d", "Bm", "in_", "/_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "g_", "in_", "spec_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", ",_", "frame_", "in_", "enumerate_", "(_", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "g_", "[_", "i_", "]_", "=_", "20_", "*_", "np_", "._", "log10_", "(_", "np_", "._", "maximum_", "(_", "frame_", ",_", "mag", "min_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "norm_", "=_", "colo", "_", "._", "Normalize", "_", "(_", "vmin_", "=_", "d", "Bm", "in_", ",_", "vmax_", "=_", "d", "Bm", "ax_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fign", "ame_", "=_", "\"%", "s", " ", "-", " ", "%", "s", "\"_", "%_", "(_", "graph_", ",_", "audio_", "._", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot", "\\u", "spectrogram", "_", "(_", "np_", "._", "array_", "(_", "spec_", ")_", ",_", "(_", "0_", ",_", "len_", "(_", "spec_", "[_", "0_", "]_", ")_", ")_", ",_", "(_", "0_", ",_", "len_", "(_", "spec_", "[_", "0_", "]_", "[_", "0_", "]_", ")_", ")_", ",_", "norm_", "=_", "norm_", ",_", "fign", "ame_", "=_", "fign", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "outfile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out_", "=_", "Spect", "rogr", "am", "File_", "(_", "outfile_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "._", "dump_", "(_", "spec_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "._", "close_", "(_", ")_", "\\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_", "plot", "\\u", "spectrogram", "_", "(_", "spec_", ",_", "Xd", "_", "=_", "(_", "0_", ",_", "1_", ")_", ",_", "Yd", "_", "=_", "(_", "0_", ",_", "1_", ")_", ",_", "norm_", "=_", "colo", "_", "._", "Log", "Norm_", "(_", "vmin_", "=_", "0.000001", "_", ")_", ",_", "fign", "ame_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x", "\\u", "min_", ",_", "x", "\\u", "max_", "=_", "Xd", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y", "\\u", "min_", ",_", "y", "\\u", "max_", "=_", "Yd", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "fig_", "=_", "plt_", "._", "figure_", "(_", "num_", "=_", "fign", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nf_", "=_", "len_", "(_", "spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ch_", ",_", "data_", "in_", "enumerate_", "(_", "spec_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "ch", ",", " ", "data", ".", "shape_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "np_", "._", "linspace_", "(_", "x", "\\u", "min_", ",_", "x", "\\u", "max_", ",_", "data_", "._", "shape_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "np_", "._", "linspace_", "(_", "y", "\\u", "min_", ",_", "y", "\\u", "max_", ",_", "data_", "._", "shape_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "x", "[", "0", "],", "x", "[-", "1", "],", "y", "[", "0", "],", "y", "[-", "1", "]_", "\\u\\u\\uNL\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "nf_", "*_", "100_", "+_", "11_", "+_", "ch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "Non", "Uniform", "Image_", "(_", "ax_", ",_", "interpolation_", "=_", "'", "bili", "near", "'_", ",_", "cmap_", "=_", "cm_", "._", "gray", "\\u", "r_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "norm_", "=_", "norm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "._", "set\\u", "data_", "(_", "x_", ",_", "y_", ",_", "data_", "._", "T_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "images_", "._", "append_", "(_", "im_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "xlim_", "(_", "x", "\\u", "min_", ",_", "x", "\\u", "max_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "ylim_", "(_", "y", "\\u", "min_", ",_", "y", "\\u", "max_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "title_", "(_", "'", "Chan", "nel", " ", "%", "d", "'_", "%_", "ch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "ax", ".", "set\\u", "xlabel", "('", "timeline", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "ax_", "._", "set\\u", "ylabel_", "(_", "'", "freque", "nc", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Statistic", "s", ":", " ", "max", "<", "%", ".3", "f", ">", " ", "min", "<", "%", ".3", "f", ">", " ", "mean", "<", "%", ".3", "f", ">", " ", "median", "<", "%", ".3", "f", ">'_", "%_", "(_", "data_", "._", "max_", "(_", ")_", ",_", "data_", "._", "min_", "(_", ")_", ",_", "data_", "._", "mean_", "(_", ")_", ",_", "np_", "._", "median_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "exit", "\\u", "with", "\\u", "usage_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"\"\"", "Us", "age", ":", " ", "$", " ", "python", " ", "-", "m", " ", "dea", "r", ".", "spectrogram", " ", "<", "options", ">", " ", "/", "path", "/", "to", "/", "song", "\\", "10", ";", "\\", "10", ";", "Optio", "ns", ":", "\\", "10", ";", " ", " ", " ", " ", "[-", "s", "]", " ", " ", " ", " ", "start", " ", "time", " ", "in", " ", "second", ",", " ", "default", " ", "0", "\\", "10", ";", " ", " ", " ", " ", "[-", "t", "]", " ", " ", " ", " ", "end", " ", "time", ",", " ", "default", " ", "is", " ", "duration", " ", "of", " ", "song", "\\", "10", ";", " ", " ", " ", " ", "[-", "o", "]", " ", " ", " ", " ", "output", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "[-", "g", "]", " ", " ", " ", " ", "type", " ", "of", " ", "spectrogram", ",", " ", "default", " ", "dft", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "dft", " ", "---", " ", "Discr", "ete", " ", "Four", "ier", " ", "Transform", "\\", "10", ";", " ", " ", " ", " ", "[-", "w", "]", " ", " ", " ", " ", "window", " ", "size", ",", " ", "default", " ", "204", "8", "\\", "10", ";", " ", " ", " ", " ", "[-", "h", "]", " ", " ", " ", " ", "step", " ", "size", ",", " ", "default", " ", "512", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "cq", "t", " ", "---", " ", "Const", "ant", "-", "Q", " ", "Transform", "\\", "10", ";", " ", " ", " ", " ", "[-", "q", "]", " ", " ", " ", " ", "Q", ",", " ", "default", " ", "3", "4", "\\", "10", ";", " ", " ", " ", " ", "[-", "h", "]", " ", " ", " ", " ", "hop", " ", "in", " ", "second", ",", " ", "default", " ", "0.02", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "cnt", " ", "---", " ", "Const", "ant", "-", "N", " ", "Transform", "\\", "10", ";", " ", " ", " ", " ", "[-", "n", "]", " ", " ", " ", " ", "N", ",", " ", "default", " ", "24", "\\", "10", ";", " ", " ", " ", " ", "[-", "h", "]", " ", " ", " ", " ", "hop", " ", "in", " ", "second", ",", " ", "default", " ", "0.02", "\\", "10", ";", " ", " ", " ", " ", "[-", "r", "]", " ", " ", " ", " ", "resiz", "e", " ", "window", " ", "size", " ", "of", " ", "each", " ", "of", " ", "the", " ", "band", "s", " ", "if", " ", "specified", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "gmt", " ", "---", " ", "Gamma", "tone", " ", "Wave", "let", " ", "Transform", "\\", "10", ";", " ", " ", " ", " ", "[-", "n", "]", " ", " ", " ", " ", "N", ",", " ", "default", " ", "64", "\\", "10", ";", " ", " ", " ", " ", "[-", "w", "]", " ", " ", " ", " ", "combin", "e", " ", "length", " ", "in", " ", "second", ",", " ", "default", " ", "0.025", "\\", "10", ";", " ", " ", " ", " ", "[-", "h", "]", " ", " ", " ", " ", "hop", " ", "in", " ", "second", ",", " ", "default", " ", "0.01", "\\", "10", ";", " ", " ", " ", " ", "[-", "f", "]", " ", " ", " ", " ", "freque", "nc", "y", " ", "bound", "ary", ",", " ", "default", " ", "(", "110", ",", " ", "4200", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Y", "1", "...", "Y", "5", " ", "---", " ", "Audi", "tor", "y", " ", "Spect", "rogr", "ams", "\\", "10", ";", " ", " ", " ", " ", "[-", "n", "]", " ", " ", " ", " ", "N", ",", " ", "default", " ", "64", "\\", "10", ";", " ", " ", " ", " ", "[-", "f", "]", " ", " ", " ", " ", "freque", "nc", "y", " ", "bound", "ary", ",", " ", "default", " ", "(", "110", ",", " ", "4200", ")", "\\", "10", ";", " ", " ", " ", " ", "[-", "c", "]", " ", " ", " ", " ", "Combine", " ", "frames", " ", "by", " ", "-", "w", " ", "and", " ", "-", "h", ".", "\\", "10", ";", " ", " ", " ", " ", "[-", "w", "]", " ", " ", " ", " ", "combin", "e", " ", "length", " ", "in", " ", "second", ",", " ", "default", " ", "0.025", "\\", "10", ";", " ", " ", " ", " ", "[-", "h", "]", " ", " ", " ", " ", "hop", " ", "in", " ", "second", ",", " ", "default", " ", "0.01", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "mfc", "c", " ", "---", " ", "MF", "CC", "s", " ", "Spect", "rogr", "am", "\\", "10", ";", " ", " ", " ", " ", "[-", "n", "]", " ", " ", " ", " ", "number", " ", "of", " ", "band", "s", ",", " ", "default", " ", "20", "\\", "10", ";", " ", " ", " ", " ", "[-", "w", "]", " ", " ", " ", " ", "window", " ", "size", ",", " ", "default", " ", "204", "8", "\\", "10", ";", " ", " ", " ", " ", "[-", "h", "]", " ", " ", " ", " ", "step", " ", "size", ",", " ", "default", " ", "1024", "\\", "10", ";", " ", " ", " ", " ", "[-", "f", "]", " ", " ", " ", " ", "freque", "nc", "y", " ", "bound", "ary", ",", " ", "default", " ", "(", "0", ",", " ", "704", "0", ")", "\\", "10", ";\"\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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 ]
Unreachable code
amarandon/smeuhsocial/apps/blog/views.py
[ { "content": "@login_required\ndef destroy(request, id):\n post = Post.objects.get(pk=id)\n user = request.user\n title = post.title\n if post.author != request.user:\n messages.add_message(request, messages.ERROR,\n ugettext(\"You can't delete posts that aren't yours\")\n )\n return HttpResponseRedirect(reverse(\"blog_list_yours\"))\n \n if request.method == \"POST\" and request.POST[\"action\"] == \"delete\":\n post.delete()\n messages.add_message(request, messages.SUCCESS,\n ugettext(\"Successfully deleted post '%s'\") % title\n )\n return HttpResponseRedirect(reverse(\"blog_list_yours\"))\n else:\n return HttpResponseRedirect(reverse(\"blog_list_yours\"))\n \n return render_to_response(context_instance=RequestContext(request))", "metadata": "root.destroy", "header": "['module', '___EOS___']", "index": 63 } ]
[ { "span": "return render_to_response(context_instance=RequestContext(request))", "start_line": 83, "start_column": 4, "end_line": 83, "end_column": 71 } ]
[]
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_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "destroy_", "(_", "request_", ",_", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "post_", "=_", "Post_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "title_", "=_", "post_", "._", "title_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "post_", "._", "author_", "!=_", "request_", "._", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "add", "\\u", "message_", "(_", "request_", ",_", "messages_", "._", "ERROR_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ugettext_", "(_", "\"", "You", " ", "can", "'", "t", " ", "delete", " ", "posts", " ", "tha", "t", " ", "are", "n", "'", "t", " ", "your", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "blog", "\\u", "list", "\\u", "your", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", "and_", "request_", "._", "POST_", "[_", "\"", "action", "\"_", "]_", "==_", "\"", "delete", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "post_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "add", "\\u", "message_", "(_", "request_", ",_", "messages_", "._", "SUCCESS_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ugettext_", "(_", "\"", "Success", "full", "y", " ", "delete", "d", " ", "post", " ", "'%", "s", "'\"_", ")_", "%_", "title_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "blog", "\\u", "list", "\\u", "your", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "blog", "\\u", "list", "\\u", "your", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "context", "\\u", "instance_", "=_", "Request", "Context_", "(_", "request_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
AppScale/appscale/AppServer/google/appengine/api/datastore_admin.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\n\"\"\"The Python datastore admin API for managing indices and schemas.\n\"\"\"\n\n\n\n\n\n\n\nfrom google.appengine.api import api_base_pb\nfrom google.appengine.api import apiproxy_stub_map\nfrom google.appengine.api import datastore\nfrom google.appengine.api import datastore_errors\nfrom google.appengine.api import datastore_types\nfrom google.appengine.datastore import datastore_index\nfrom google.appengine.datastore import datastore_pb\nfrom google.appengine.runtime import apiproxy_errors\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def GetIndices(_app=None):\n \"\"\"Fetches all composite indices in the datastore for this app.\n\n Returns:\n list of entity_pb.CompositeIndex\n \"\"\"\n\n req = api_base_pb.StringProto()\n req.set_value(datastore_types.ResolveAppId(_app))\n resp = datastore_pb.CompositeIndices()\n resp = _Call('GetIndices', req, resp)\n return resp.index_list()", "metadata": "root.GetIndices", "header": "['module', '___EOS___']", "index": 39 }, { "content": "def CreateIndex(index):\n \"\"\"Creates a new composite index in the datastore for this app.\n\n Args:\n index: entity_pb.CompositeIndex\n\n Returns:\n int, the id allocated to the index\n \"\"\"\n resp = api_base_pb.Integer64Proto()\n resp = _Call('CreateIndex', index, resp)\n return resp.value()", "metadata": "root.CreateIndex", "header": "['module', '___EOS___']", "index": 53 }, { "content": "def UpdateIndex(index):\n \"\"\"Updates an index's status. The entire index definition must be present.\n\n Args:\n index: entity_pb.CompositeIndex\n \"\"\"\n _Call('UpdateIndex', index, api_base_pb.VoidProto())", "metadata": "root.UpdateIndex", "header": "['module', '___EOS___']", "index": 67 }, { "content": "def DeleteIndex(index):\n \"\"\"Deletes an index. The entire index definition must be present.\n\n Args:\n index: entity_pb.CompositeIndex\n \"\"\"\n _Call('DeleteIndex', index, api_base_pb.VoidProto())", "metadata": "root.DeleteIndex", "header": "['module', '___EOS___']", "index": 76 }, { "content": "def _Call(call, req, resp):\n \"\"\"Generic method for making a datastore API call.\n\n Args:\n call: string, the name of the RPC call\n req: the request PB. if the app_id field is not set, it defaults to the\n local app.\n resp: the response PB\n \"\"\"\n if hasattr(req, 'app_id'):\n req.set_app_id(datastore_types.ResolveAppId(req.app_id()))\n\n try:\n result = apiproxy_stub_map.MakeSyncCall('datastore_v3', call, req, resp)\n if result:\n return result\n return resp\n except apiproxy_errors.ApplicationError, err:\n raise datastore._ToDatastoreError(err)", "metadata": "root._Call", "header": "['module', '___EOS___']", "index": 85 } ]
[ { "span": "from google.appengine.api import datastore_errors", "start_line": 33, "start_column": 0, "end_line": 33, "end_column": 49 }, { "span": "from google.appengine.datastore import datastore_index", "start_line": 35, "start_column": 0, "end_line": 35, "end_column": 54 } ]
[]
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_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "The", " ", "Pyth", "on", " ", "datast", "ore", " ", "admin", " ", "API", " ", "for", " ", "mana", "ging", " ", "indice", "s", " ", "and", " ", "schema", "s", ".", "\\", "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_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "api_", "import_", "api", "\\u", "base", "\\u", "pb_", "\\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_", "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_", "._", "datastore_", "import_", "datast", "ore", "\\u", "index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "appengine_", "._", "datastore_", "import_", "datast", "ore", "\\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\\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_", "def_", "Get", "Indices_", "(_", "\\u", "app_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Fetche", "s", " ", "all", " ", "composi", "te", " ", "indice", "s", " ", "in", " ", "the", " ", "datast", "ore", " ", "for", " ", "this", " ", "app", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "list", " ", "of", " ", "entity", "\\u", "pb", ".", "Composit", "e", "Index", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "req_", "=_", "api", "\\u", "base", "\\u", "pb_", "._", "String", "Proto_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "._", "set\\u", "value_", "(_", "datast", "ore", "\\u", "types_", "._", "Resolv", "e", "App", "Id_", "(_", "\\u", "app_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resp_", "=_", "datast", "ore", "\\u", "pb_", "._", "Composit", "e", "Indices_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resp_", "=_", "\\u", "Call_", "(_", "'", "Get", "Indic", "es", "'_", ",_", "req_", ",_", "resp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "resp_", "._", "index", "\\u", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Creat", "e", "Index_", "(_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "es", " ", "a", " ", "new", " ", "composi", "te", " ", "index", " ", "in", " ", "the", " ", "datast", "ore", " ", "for", " ", "this", " ", "app", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "index", ":", " ", "entity", "\\u", "pb", ".", "Composit", "e", "Index", "\\", "10", ";", "\\", "10", ";", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "int", ",", " ", "the", " ", "id", " ", "allocated", " ", "to", " ", "the", " ", "index", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resp_", "=_", "api", "\\u", "base", "\\u", "pb_", "._", "Integer", "64", "Proto_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resp_", "=_", "\\u", "Call_", "(_", "'", "Creat", "e", "Index", "'_", ",_", "index_", ",_", "resp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "resp_", "._", "value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Update", "Index_", "(_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Update", "s", " ", "an", " ", "index", "'", "s", " ", "status", ".", " ", "The", " ", "entire", " ", "index", " ", "definit", "ion", " ", "must", " ", "be", " ", "presen", "t", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "index", ":", " ", "entity", "\\u", "pb", ".", "Composit", "e", "Index", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "Call_", "(_", "'", "Update", "Index", "'_", ",_", "index_", ",_", "api", "\\u", "base", "\\u", "pb_", "._", "Voi", "d", "Proto_", "(_", ")_", ")_", "\\u\\u\\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_", "Delete", "Index_", "(_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Delete", "s", " ", "an", " ", "index", ".", " ", "The", " ", "entire", " ", "index", " ", "definit", "ion", " ", "must", " ", "be", " ", "presen", "t", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "index", ":", " ", "entity", "\\u", "pb", ".", "Composit", "e", "Index", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "Call_", "(_", "'", "Delete", "Index", "'_", ",_", "index_", ",_", "api", "\\u", "base", "\\u", "pb_", "._", "Voi", "d", "Proto_", "(_", ")_", ")_", "\\u\\u\\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", "Call_", "(_", "call_", ",_", "req_", ",_", "resp_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Gene", "ric", " ", "method", " ", "for", " ", "mak", "ing", " ", "a", " ", "datast", "ore", " ", "API", " ", "call", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "call", ":", " ", "string", ",", " ", "the", " ", "name", " ", "of", " ", "the", " ", "RP", "C", " ", "call", "\\", "10", ";", " ", " ", " ", " ", "req", ":", " ", "the", " ", "request", " ", "PB", ".", " ", "if", " ", "the", " ", "app", "\\u", "id", " ", "field", " ", "is", " ", "not", " ", "set", ",", " ", "it", " ", "default", "s", " ", "to", " ", "the", "\\", "10", ";", " ", " ", "local", " ", "app", ".", "\\", "10", ";", " ", " ", " ", " ", "resp", ":", " ", "the", " ", "response", " ", "PB", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "req_", ",_", "'", "app", "\\u", "id", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req_", "._", "set\\u", "app", "\\u", "id_", "(_", "datast", "ore", "\\u", "types_", "._", "Resolv", "e", "App", "Id_", "(_", "req_", "._", "app", "\\u", "id_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "api", "proxy", "\\u", "stub", "\\u", "map_", "._", "Make", "Sync", "Call_", "(_", "'", "datast", "ore", "\\u", "v", "3", "'_", ",_", "call_", ",_", "req_", ",_", "resp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "resp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "api", "proxy", "\\u", "errors_", "._", "Applica", "tion", "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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 ]
Unnecessary pass
CollabQ/CollabQ/.google_appengine/google/appengine/api/urlfetch_service_pb.py
[ { "content": " def __init__(self, contents=None):\n pass\n if contents is not None: self.MergeFromString(contents)", "metadata": "root.URLFetchServiceError.__init__", "header": "['class', 'URLFetchServiceError', '(', 'ProtocolBuffer', '.', 'ProtocolMessage', ')', ':', '___EOS___']", "index": 46 } ]
[ { "span": "pass", "start_line": 47, "start_column": 4, "end_line": 47, "end_column": 8 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "class_", "URL", "Fe", "tch", "Service", "Error_", "(_", "Proto", "col", "Buffer_", "._", "Proto", "col", "Message_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "contents_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "contents_", "is_", "not_", "None_", ":_", "self_", "._", "Merge", "Fro", "m", "String_", "(_", "contents_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
saltstack/salt/tests/unit/modules/win_groupadd_test.py
[ { "content": "# -*- coding: utf-8 -*-\n'''\n :codeauthor: :email:`Jayesh Kariya <[email protected]>`\n'''\n\n# Import Python Libs\nfrom __future__ import absolute_import\n\n# Import Salt Testing Libs\nfrom salttesting import TestCase, skipIf\nfrom salttesting.mock import (\n patch,\n NO_MOCK,\n NO_MOCK_REASON\n)\n\nfrom salttesting.helpers import ensure_in_syspath\n\nensure_in_syspath('../../')\n\n# Import Salt Libs\nfrom salt.modules import win_groupadd\n\n# Import Other Libs\n# pylint: disable=W0611\ntry:\n import win32com\n import pythoncom\n import pywintypes\n HAS_WIN_LIBS = True\nexcept ImportError:\n HAS_WIN_LIBS = False\n# pylint: enable=W0611\n\n\nwin_groupadd.__context__ = {}\nwin_groupadd.__opts__ = {'test': False}\n\n\n\n\nif __name__ == '__main__':\n from integration import run_tests\n run_tests(WinGroupTestCase, needs_daemon=False)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@skipIf(not HAS_WIN_LIBS, 'win_groupadd unit tests can only be run if win32com, pythoncom, and pywintypes are installed')\n@skipIf(NO_MOCK, NO_MOCK_REASON)\nclass WinGroupTestCase(TestCase):\n '''\n Test cases for salt.modules.win_groupadd\n '''\n # 'add' function tests: 1\n\n\n # 'delete' function tests: 1\n\n\n # 'info' function tests: 1\n\n\n # 'getent' function tests: 1\n\n\n # 'adduser' function tests: 1\n\n\n # 'deluser' function tests: 1\n\n\n # 'members' function tests: 1\n", "metadata": "root.WinGroupTestCase", "header": "['module', '___EOS___']", "index": 39 }, { "content": " def test_add(self):\n '''\n Test if it add the specified group\n '''\n self.assertDictEqual(win_groupadd.add('foo'),\n {'changes': [], 'name': 'foo', 'result': None,\n 'comment': 'The group foo already exists.'})", "metadata": "root.WinGroupTestCase.test_add", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 47 }, { "content": " def test_delete(self):\n '''\n Test if it remove the specified group\n '''\n self.assertDictEqual(win_groupadd.delete('foo'),\n {'changes': [], 'name': 'foo', 'result': None,\n 'comment': 'The group foo does not exists.'})", "metadata": "root.WinGroupTestCase.test_delete", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 57 }, { "content": " def test_info(self):\n '''\n Test if it return information about a group.\n '''\n with patch(win_groupadd.win32.client, 'flag', None):\n self.assertDictEqual(win_groupadd.info('dc=salt'),\n {'gid': None,\n 'members': ['dc=\\\\user1'],\n 'passwd': None,\n 'name': 'WinNT://./dc=salt,group'})\n\n with patch(win_groupadd.win32.client, 'flag', 1):\n self.assertFalse(win_groupadd.info('dc=salt'))\n\n with patch(win_groupadd.win32.client, 'flag', 2):\n self.assertFalse(win_groupadd.info('dc=salt'))", "metadata": "root.WinGroupTestCase.test_info", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": " def test_getent(self):\n '''\n Test if it return info on all groups\n '''\n with patch.dict(win_groupadd.__context__, {'group.getent': True}):\n self.assertTrue(win_groupadd.getent())", "metadata": "root.WinGroupTestCase.test_getent", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 86 }, { "content": " def test_adduser(self):\n '''\n Test if it add a user to a group\n '''\n with patch(win_groupadd.win32.client, 'flag', None):\n self.assertDictEqual(win_groupadd.adduser('dc=foo', 'dc=\\\\username'),\n {'changes': {'Users Added': ['dc=\\\\username']},\n 'comment': '', 'name': 'dc=foo', 'result': True})\n\n with patch(win_groupadd.win32.client, 'flag', 1):\n comt = ('Failed to add dc=\\\\username to group dc=foo. C')\n self.assertDictEqual(win_groupadd.adduser('dc=foo', 'dc=\\\\username'),\n {'changes': {'Users Added': []}, 'name': 'dc=foo',\n 'comment': comt, 'result': False})", "metadata": "root.WinGroupTestCase.test_adduser", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 95 }, { "content": " def test_deluser(self):\n '''\n Test if it remove a user to a group\n '''\n ret = {'changes': {'Users Removed': []},\n 'comment': 'User dc=\\\\username is not a member of dc=foo',\n 'name': 'dc=foo', 'result': None}\n\n self.assertDictEqual(win_groupadd.deluser('dc=foo', 'dc=\\\\username'),\n ret)", "metadata": "root.WinGroupTestCase.test_deluser", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 112 }, { "content": " def test_members(self):\n '''\n Test if it remove a user to a group\n '''\n comment = ['Failure accessing group dc=foo. C']\n ret = {'name': 'dc=foo', 'result': False, 'comment': comment,\n 'changes': {'Users Added': [], 'Users Removed': []}}\n\n with patch(win_groupadd.win32.client, 'flag', 2):\n self.assertDictEqual(win_groupadd.members\n ('dc=foo', 'dc=\\\\user1,dc=\\\\user2,dc=\\\\user3'),\n ret)\n\n with patch(win_groupadd.win32.client, 'flag', 1):\n comment = ['Failed to add dc=\\\\user2 to dc=foo. C',\n 'Failed to remove dc=\\\\user1 from dc=foo. C']\n ret.update({'comment': comment, 'result': False})\n self.assertDictEqual(win_groupadd.members('dc=foo', 'dc=\\\\user2'), ret)\n\n with patch(win_groupadd.win32.client, 'flag', None):\n comment = ['dc=foo membership is correct']\n ret.update({'comment': comment, 'result': None})\n self.assertDictEqual(win_groupadd.members('dc=foo', 'dc=\\\\user1'), ret)", "metadata": "root.WinGroupTestCase.test_members", "header": "['class', 'WinGroupTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 125 } ]
[ { "span": "import win32com", "start_line": 26, "start_column": 4, "end_line": 26, "end_column": 19 }, { "span": "import pythoncom", "start_line": 27, "start_column": 4, "end_line": 27, "end_column": 20 }, { "span": "import pywintypes", "start_line": 28, "start_column": 4, "end_line": 28, "end_column": 21 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", " ", " ", " ", " ", ":", "code", "author", ":", " ", ":", "email", ":`", "Ja", "ye", "sh", " ", "Kar", "iy", "a", " ", "<", "ja", "ye", "sh", "k", "@", "salt", "stack", ".", "com", ">`", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "Pyth", "on", " ", "Lib", "s_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "Sal", "t", " ", "Test", "ing", " ", "Lib", "s_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "salt", "testing_", "import_", "Test", "Case_", ",_", "skip", "If_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "salt", "testing_", "._", "mock_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "patch_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "NO", "\\u", "MOC", "K_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "NO", "\\u", "MOC", "K", "\\u", "REASON", "_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "salt", "testing_", "._", "helpers_", "import_", "ensure", "\\u", "in", "\\u", "sysp", "ath_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ensure", "\\u", "in", "\\u", "sysp", "ath_", "(_", "'../../", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "Sal", "t", " ", "Lib", "s_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "salt_", "._", "modules_", "import_", "win", "\\u", "group", "add_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "Ot", "her", " ", "Lib", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pylint", ":", " ", "disable", "=", "W", "061", "1_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "win32", "com_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "python", "com_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pywi", "ntype", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "HAS", "\\u", "WIN", "\\u", "LIBS", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HAS", "\\u", "WIN", "\\u", "LIBS", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pylint", ":", " ", "enable", "=", "W", "061", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "win", "\\u", "group", "add_", "._", "\\u\\u", "context", "\\u\\u_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "win", "\\u", "group", "add_", "._", "\\u\\u", "opts", "\\u\\u_", "=_", "{_", "'", "test", "'_", ":_", "False_", "}_", "\\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_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "integration_", "import_", "run", "\\u", "tests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "run", "\\u", "tests_", "(_", "Win", "Group", "Test", "Case_", ",_", "need", "s", "\\u", "daemon_", "=_", "False_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "skip", "If_", "(_", "not_", "HAS", "\\u", "WIN", "\\u", "LIBS", "_", ",_", "'", "win", "\\u", "group", "add", " ", "unit", " ", "tests", " ", "can", " ", "only", " ", "be", " ", "run", " ", "if", " ", "win32", "com", ",", " ", "python", "com", ",", " ", "and", " ", "pywi", "ntype", "s", " ", "are", " ", "install", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "skip", "If_", "(_", "NO", "\\u", "MOC", "K_", ",_", "NO", "\\u", "MOC", "K", "\\u", "REASON", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "case", "s", " ", "for", " ", "salt", ".", "module", "s", ".", "win", "\\u", "group", "add", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "'", "add", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "delete", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "info", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "gete", "nt", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "add", "user", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "del", "user", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "member", "s", "'", " ", "function", " ", "tests", ":", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "add_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "add", " ", "the", " ", "specified", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "add_", "(_", "'", "foo", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "change", "s", "'_", ":_", "[_", "]_", ",_", "'", "name", "'_", ":_", "'", "foo", "'_", ",_", "'", "result", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "'_", ":_", "'", "The", " ", "group", " ", "foo", " ", "alr", "ead", "y", " ", "exist", "s", ".'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "remove", " ", "the", " ", "specified", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "delete_", "(_", "'", "foo", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "change", "s", "'_", ":_", "[_", "]_", ",_", "'", "name", "'_", ":_", "'", "foo", "'_", ",_", "'", "result", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "'_", ":_", "'", "The", " ", "group", " ", "foo", " ", "doe", "s", " ", "not", " ", "exist", "s", ".'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "info_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "return", " ", "informati", "on", " ", "abo", "ut", " ", "a", " ", "group", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "info_", "(_", "'", "dc", "=", "salt", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "gid", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "member", "s", "'_", ":_", "[_", "'", "dc", "=\\\\", "\\\\", "user", "1", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "passw", "d", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Win", "NT", "://", "./", "dc", "=", "salt", ",", "group", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "win", "\\u", "group", "add_", "._", "info_", "(_", "'", "dc", "=", "salt", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "win", "\\u", "group", "add_", "._", "info_", "(_", "'", "dc", "=", "salt", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "gete", "nt_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "return", " ", "info", " ", "on", " ", "all", " ", "group", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "patch_", "._", "dict_", "(_", "win", "\\u", "group", "add_", "._", "\\u\\u", "context", "\\u\\u_", ",_", "{_", "'", "group", ".", "gete", "nt", "'_", ":_", "True_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "win", "\\u", "group", "add_", "._", "gete", "nt_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "user_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "add", " ", "a", " ", "user", " ", "to", " ", "a", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "add", "user_", "(_", "'", "dc", "=", "foo", "'_", ",_", "'", "dc", "=\\\\", "\\\\", "user", "name", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "change", "s", "'_", ":_", "{_", "'", "User", "s", " ", "Added", "'_", ":_", "[_", "'", "dc", "=\\\\", "\\\\", "user", "name", "'_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "'_", ":_", "''_", ",_", "'", "name", "'_", ":_", "'", "dc", "=", "foo", "'_", ",_", "'", "result", "'_", ":_", "True_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "com", "t_", "=_", "(_", "'", "Fail", "ed", " ", "to", " ", "add", " ", "dc", "=\\\\", "\\\\", "user", "name", " ", "to", " ", "group", " ", "dc", "=", "foo", ".", " ", " ", "C", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "add", "user_", "(_", "'", "dc", "=", "foo", "'_", ",_", "'", "dc", "=\\\\", "\\\\", "user", "name", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "change", "s", "'_", ":_", "{_", "'", "User", "s", " ", "Added", "'_", ":_", "[_", "]_", "}_", ",_", "'", "name", "'_", ":_", "'", "dc", "=", "foo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "'_", ":_", "com", "t_", ",_", "'", "result", "'_", ":_", "False_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "del", "user_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "remove", " ", "a", " ", "user", " ", "to", " ", "a", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "{_", "'", "change", "s", "'_", ":_", "{_", "'", "User", "s", " ", "Remove", "d", "'_", ":_", "[_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "'_", ":_", "'", "User", " ", "dc", "=\\\\", "\\\\", "user", "name", " ", "is", " ", "not", " ", "a", " ", "member", " ", "of", " ", "dc", "=", "foo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "dc", "=", "foo", "'_", ",_", "'", "result", "'_", ":_", "None_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "del", "user_", "(_", "'", "dc", "=", "foo", "'_", ",_", "'", "dc", "=\\\\", "\\\\", "user", "name", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Win", "Group", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "members_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "it", " ", "remove", " ", "a", " ", "user", " ", "to", " ", "a", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment_", "=_", "[_", "'", "Fail", "ure", " ", "accessi", "ng", " ", "group", " ", "dc", "=", "foo", ".", " ", " ", "C", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "{_", "'", "name", "'_", ":_", "'", "dc", "=", "foo", "'_", ",_", "'", "result", "'_", ":_", "False_", ",_", "'", "comment", "'_", ":_", "comment_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "change", "s", "'_", ":_", "{_", "'", "User", "s", " ", "Added", "'_", ":_", "[_", "]_", ",_", "'", "User", "s", " ", "Remove", "d", "'_", ":_", "[_", "]_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "members_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "dc", "=", "foo", "'_", ",_", "'", "dc", "=\\\\", "\\\\", "user", "1", ",", "dc", "=\\\\", "\\\\", "user", "2", ",", "dc", "=\\\\", "\\\\", "user3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "comment_", "=_", "[_", "'", "Fail", "ed", " ", "to", " ", "add", " ", "dc", "=\\\\", "\\\\", "user", "2", " ", "to", " ", "dc", "=", "foo", ".", " ", " ", "C", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Fail", "ed", " ", "to", " ", "remove", " ", "dc", "=\\\\", "\\\\", "user", "1", " ", "from", " ", "dc", "=", "foo", ".", " ", " ", "C", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "._", "update_", "(_", "{_", "'", "comment", "'_", ":_", "comment_", ",_", "'", "result", "'_", ":_", "False_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "members_", "(_", "'", "dc", "=", "foo", "'_", ",_", "'", "dc", "=\\\\", "\\\\", "user", "2", "'_", ")_", ",_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "patch_", "(_", "win", "\\u", "group", "add_", "._", "win32", "_", "._", "client_", ",_", "'", "flag", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "comment_", "=_", "[_", "'", "dc", "=", "foo", " ", "member", "ship", " ", "is", " ", "correct", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "._", "update_", "(_", "{_", "'", "comment", "'_", ":_", "comment_", ",_", "'", "result", "'_", ":_", "None_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Dict", "Equal_", "(_", "win", "\\u", "group", "add_", "._", "members_", "(_", "'", "dc", "=", "foo", "'_", ",_", "'", "dc", "=\\\\", "\\\\", "user", "1", "'_", ")_", ",_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
sunlightlabs/clearspending/completeness/statlib/io.py
[ { "content": "# Copyright (c) Gary Strangman. All rights reserved\n#\n# Disclaimer\n#\n# This software is provided \"as-is\". There are no expressed or implied\n# warranties of any kind, including, but not limited to, the warranties\n# of merchantability and fittness for a given application. In no event\n# shall Gary Strangman be liable for any direct, indirect, incidental,\n# special, exemplary or consequential damages (including, but not limited\n# to, loss of use, data or profits, or business interruption) however\n# caused and on any theory of liability, whether in contract, strict\n# liability or tort (including negligence or otherwise) arising in any way\n# out of the use of this software, even if advised of the possibility of\n# such damage.\n#\n# Comments and/or additions are welcome (send e-mail to:\n# [email protected]).\n#\n\"\"\"\nDefines a number of functions for pseudo-command-line OS functionality.\n\n cd(directory)\n pwd <-- can be used WITHOUT parens\n ls(d='.')\n rename(from,to)\n get(namepatterns,verbose=1)\n getstrings(namepatterns,verbose=1)\n put(outlist,filename,writetype='w')\n aget(namepatterns,verbose=1)\n aput(outarray,filename,writetype='w')\n bget(filename,numslices=1,xsize=64,ysize=64)\n braw(filename,btype)\n bput(outarray,filename,writeheader=0,packstring='h',writetype='wb')\n mrget(filename)\n find_dirs(sourcedir)\n\"\"\"\n\n## CHANGES:\n## =======\n## 02-11-20 ... added binget(), binput(), array2afni(), version 0.5\n## 02-10-20 ... added find_dirs() function, changed version to 0.4\n## 01-11-15 ... changed aput() and put() to accept a delimiter\n## 01-04-19 ... added oneperline option to put() function\n## 99-11-07 ... added DAs quick flat-text-file loaders, load() and fload()\n## 99-11-01 ... added version number (0.1) for distribution\n## 99-08-30 ... Put quickload in here\n## 99-06-27 ... Changed bget thing back ... confused ...\n## 99-06-24 ... exchanged xsize and ysize in bget for non-square images (NT??)\n## modified bget to raise an IOError when file not found\n## 99-06-12 ... added load() and save() aliases for aget() and aput() (resp.)\n## 99-04-13 ... changed aget() to ignore (!!!!) lines beginning with # or %\n## 99-01-17 ... changed get() so ints come in as ints (not floats)\n##\n\n\n\ntry:\n import mmapfile\nexcept:\n pass\n\nimport pstat\nimport glob, re, string, types, os, numpy, struct, copy, time, tempfile, sys\nfrom types import *\nN = numpy\n\n__version__ = 0.5\n\n\n\n\n\npwd = wrap(pwd)\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# ALIASES ...\nsave = aput\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get (namepatterns,verbose=1):\n \"\"\"\nLoads a list of lists from text files (specified by a UNIX-style\nwildcard filename pattern) and converts all numeric values to floats.\nUses the glob module for filename pattern conversion. Loaded filename\nis printed if verbose=1.\n\nUsage: get (namepatterns,verbose=1)\nReturns: a 1D or 2D list of lists from whitespace delimited text files\n specified by namepatterns; numbers that can be converted to floats\n are so converted\n\"\"\"\n fnames = []\n if type(namepatterns) in [ListType,TupleType]:\n for item in namepatterns:\n fnames = fnames + glob.glob(item)\n else:\n fnames = glob.glob(namepatterns)\n\n if len(fnames) == 0:\n if verbose:\n print 'NO FILENAMES MATCH ('+namepatterns+') !!'\n return None\n\n if verbose:\n print fnames # so user knows what has been loaded\n elements = []\n for i in range(len(fnames)):\n file = open(fnames[i])\n newelements = map(string.split,file.readlines())\n for i in range(len(newelements)):\n for j in range(len(newelements[i])):\n try:\n newelements[i][j] = string.atoi(newelements[i][j])\n except ValueError:\n try:\n newelements[i][j] = string.atof(newelements[i][j])\n except:\n pass\n elements = elements + newelements\n if len(elements)==1: elements = elements[0]\n return elements", "metadata": "root.get", "header": "['module', '___EOS___']", "index": 147 }, { "content": "def aget (namepattern,verbose=1):\n \"\"\"\nLoads an array from 2D text files (specified by a UNIX-style wildcard\nfilename pattern). ONLY 'GET' FILES WITH EQUAL NUMBERS OF COLUMNS\nON EVERY ROW (otherwise returned array will be zero-dimensional).\n\nUsage: aget (namepattern)\nReturns: an array of integers, floats or objects (type='O'), depending on the\n contents of the files specified by namepattern\n\"\"\"\n fnames = glob.glob(namepattern)\n if len(fnames) == 0:\n if verbose:\n print 'NO FILENAMES MATCH ('+namepattern+') !!'\n return None\n if verbose:\n print fnames\n elements = []\n for filename in fnames:\n file = open(filename)\n newelements = file.readlines()\n del_list = []\n for row in range(len(newelements)):\n if (newelements[row][0]=='%' or newelements[row][0]=='#'\n or len(newelements[row])==1):\n del_list.append(row)\n del_list.reverse()\n for i in del_list:\n newelements.pop(i)\n newelements = map(string.split,newelements)\n for i in range(len(newelements)):\n for j in range(len(newelements[i])):\n try:\n newelements[i][j] = string.atof(newelements[i][j])\n except:\n pass\n elements = elements + newelements\n for row in range(len(elements)):\n if N.add.reduce(N.array(map(isstring,elements[row])))==len(elements[row]):\n print \"A row of strings was found. Returning a LIST.\"\n return elements\n try:\n elements = N.array(elements)\n except TypeError:\n elements = N.array(elements,'O')\n return elements", "metadata": "root.aget", "header": "['module', '___EOS___']", "index": 255 }, { "content": "def brikget(imfile,unpackstr=N.int16,shp=None):\n \"\"\"\nGets an AFNI BRIK file.\n\nUsage: brikget(imfile,unpackstr=N.int16,shp=None) default shp: (-1,48,61,51)\n\"\"\"\n if shp == None:\n shp = (-1,48,61,51)\n try:\n file = open(imfile, \"rb\")\n except:\n print \"Couldn't find file: \"+imfile\n raise IOError, \"Couldn't find file in brikget()\"\n try:\n header = imfile[0:-4]+'HEAD'\n lines = open(header).readlines()\n for i in range(len(lines)):\n if string.find(lines[i],'DATASET_DIMENSIONS') <> -1:\n dims = string.split(lines[i+2][0:string.find(lines[i+2],' 0')])\n dims = map(string.atoi,dims)\n if string.find(lines[i],'BRICK_FLOAT_FACS') <> -1:\n count = string.atoi(string.split(lines[i+1])[2])\n mults = []\n for j in range(int(N.ceil(count/5.))):\n mults += map(string.atof,string.split(lines[i+2+j]))\n mults = N.array(mults)\n dims.reverse()\n shp = [-1]+dims\n except IOError:\n print \"No header file. Continuing ...\"\n lines = None\n\n print shp\n print 'Using unpackstr:',unpackstr #,', bytesperpixel=',bytesperpixel\n\n file = open(imfile, \"rb\")\n bdata = file.read()\n\n # the > forces big-endian (for or from Sun/SGI)\n bdata = N.fromstring(bdata,unpackstr)\n littleEndian = ( struct.pack('i',1)==struct.pack('<i',1) )\n if (littleEndian and os.uname()[0]<>'Linux') or (max(bdata)>1e30):\n bdata = bdata.byteswapped()\n try:\n bdata.shape = shp\n except:\n print 'Incorrect shape ...',shp,len(bdata)\n raise ValueError, 'Incorrect shape for file size'\n if len(bdata) == 1:\n bdata = bdata[0]\n\n if N.sum(mults) == 0:\n return bdata\n try:\n multshape = [1]*len(bdata.shape)\n for i in range(len(bdata.shape)):\n if len(mults) == bdata.shape[i]:\n multshape[i] = len(mults)\n break\n mults.shape = multshape\n return bdata*mults\n except:\n return bdata", "metadata": "root.brikget", "header": "['module', '___EOS___']", "index": 384 }, { "content": "def mghbget(imfile,numslices=-1,xsize=64,ysize=64,\n unpackstr=N.int16,bytesperpixel=2.0,sliceinit=0):\n \"\"\"\nReads in a binary file, typically with a .bshort or .bfloat extension.\nIf so, the last 3 parameters are set appropriately. If not, the last 3\nparameters default to reading .bshort files (2-byte integers in big-endian\nbinary format).\n\nUsage: mghbget(imfile, numslices=-1, xsize=64, ysize=64,\n unpackstr=N.int16, bytesperpixel=2.0, sliceinit=0)\n\"\"\"\n try:\n file = open(imfile, \"rb\")\n except:\n print \"Couldn't find file: \"+imfile\n raise IOError, \"Couldn't find file in bget()\"\n try:\n header = imfile[0:-6]+'hdr'\n vals = get(header,0) # '0' means no missing-file warning msg\n if type(vals[0]) == ListType: # it's an extended header\n xsize = int(vals[0][0])\n ysize = int(vals[0][1])\n numslices = int(vals[0][2])\n else:\n xsize = int(vals[0])\n ysize = int(vals[1])\n numslices = int(vals[2])\n except:\n print \"No header file. Continuing ...\"\n\n suffix = imfile[-6:]\n if suffix == 'bshort':\n pass\n elif suffix[-3:] == 'img':\n pass\n elif suffix == 'bfloat':\n unpackstr = N.Float32\n bytesperpixel = 4.0\n sliceinit = 0.0\n else:\n print 'Not a bshort, bfloat or img file.'\n print 'Using unpackstr:',unpackstr,', bytesperpixel=',bytesperpixel\n\n imsize = xsize*ysize\n file = open(imfile, \"rb\")\n bdata = file.read()\n\n numpixels = len(bdata) / bytesperpixel\n if numpixels%1 != 0:\n raise ValueError, \"Incorrect file size in fmri.bget()\"\n else: # the > forces big-endian (for or from Sun/SGI)\n bdata = N.fromstring(bdata,unpackstr)\n littleEndian = ( struct.pack('i',1)==struct.pack('<i',1) )\n# if littleEndian:\n# bdata = bdata.byteswapped()\n if (littleEndian and os.uname()[0]<>'Linux') or (max(bdata)>1e30):\n bdata = bdata.byteswapped()\n if suffix[-3:] == 'img':\n if numslices == -1:\n numslices = len(bdata)/8200 # 8200=(64*64*2)+8 bytes per image\n xsize = 64\n ysize = 128\n slices = N.zeros((numslices,xsize,ysize),N.Int)\n for i in range(numslices):\n istart = i*8 + i*xsize*ysize\n iend = i*8 + (i+1)*xsize*ysize\n print i, istart,iend\n slices[i] = N.reshape(N.array(bdata[istart:iend]),(xsize,ysize))\n else:\n if numslices == 1:\n slices = N.reshape(N.array(bdata),[xsize,ysize])\n else:\n slices = N.reshape(N.array(bdata),[numslices,xsize,ysize])\n if len(slices) == 1:\n slices = slices[0]\n return slices", "metadata": "root.mghbget", "header": "['module', '___EOS___']", "index": 448 }, { "content": "def braw(fname,btype,shp=None):\n \"\"\"\nOpens a binary file, unpacks it, and returns a flat array of the\ntype specified. Use Numeric types ... N.Float32, N.Int64, etc.\n\nUsage: braw(fname,btype,shp=None)\nReturns: flat array of floats, or ints (if btype=N.int16)\n\"\"\"\n file = open(fname,'rb')\n bdata = file.read()\n bdata = N.fromstring(bdata,btype)\n littleEndian = ( struct.pack('i',1)==struct.pack('<i',1) )\n# if littleEndian:\n# bdata = bdata.byteswapped() # didn't used to need this with '>' above\n if (littleEndian and os.uname()[0]<>'Linux') or (max(bdata)>1e30):\n bdata = bdata.byteswapped()\n if shp:\n try:\n bdata.shape = shp\n return bdata\n except:\n pass\n return N.array(bdata)", "metadata": "root.braw", "header": "['module', '___EOS___']", "index": 526 }, { "content": "def glget(fname,btype):\n \"\"\"\nLoad in a file containing pixels from glReadPixels dump.\n\nUsage: glget(fname,btype)\nReturns: array of 'btype elements with shape 'shape', suitable for im.ashow()\n\"\"\"\n d = braw(fname,btype)\n d = d[8:]\n f = open(fname,'rb')\n shp = f.read(8)\n f.close()\n shp = N.fromstring(shp,N.Int)\n shp[0],shp[1] = shp[1],shp[0]\n try:\n carray = N.reshape(d,shp)\n return\n except:\n pass\n try:\n r = d[0::3]+0\n g = d[1::3]+0\n b = d[2::3]+0\n r.shape = shp\n g.shape = shp\n b.shape = shp\n carray = N.array([r,g,b])\n except:\n outstr = \"glget: shape not correct for data of length \"+str(len(d))\n raise ValueError, outstr\n return carray", "metadata": "root.glget", "header": "['module', '___EOS___']", "index": 551 }, { "content": "def mget(fname,btype):\n \"\"\"\nLoad in a file that was saved from matlab\n\nUsage: mget(fname,btype)\n\"\"\"\n d = braw(fname,btype)\n try:\n header = fname[0:-6]+'hdr'\n vals = get(header,0) # '0' means no missing-file warning msg\n if type(vals[0]) == ListType: # it's an extended header\n xsize = int(vals[0][0])\n ysize = int(vals[0][1])\n numslices = int(vals[0][2])\n else:\n xsize = int(vals[0])\n ysize = int(vals[1])\n numslices = int(vals[2])\n print xsize,ysize,numslices, d.shape\n except:\n print \"No header file. Continuing ...\"\n if numslices == 1:\n d.shape = [ysize,xsize]\n return N.transpose(d)*1\n else:\n d.shape = [numslices,ysize,xsize]\n return N.transpose(d)*1", "metadata": "root.mget", "header": "['module', '___EOS___']", "index": 584 }, { "content": "def binget(fname,btype=None):\n \"\"\"\nLoads a binary file from disk. Assumes associated hdr file is in same\nlocation. You can force an unpacking type, or else it tries to figure\nit out from the filename (4th-to-last character). Hence, readable file\nformats are ...\n\n1bin=Int8, sbin=int16, ibin=Int32, fbin=Float32, dbin=Float64, etc.\n\nUsage: binget(fname,btype=None)\nReturns: data in file fname of type btype\n\"\"\"\n file = open(fname,'rb')\n bdata = file.read()\n file.close()\n\n # if none given, assume character preceeding 'bin' is the unpacktype\n if not btype:\n btype = fname[-4]\n try:\n bdata = N.fromstring(bdata,btype)\n except:\n raise ValueError, \"Bad unpacking type.\"\n\n # force the data on disk to be LittleEndian (for more efficient PC/Linux use)\n if not N.LittleEndian:\n bdata = bdata.byteswapped()\n\n try:\n header = fname[:-3]+'hdr'\n vals = get(header,0) # '0' means no missing-file warning msg\n print vals\n if type(vals[0]) == ListType: # it's an extended header\n xsize = int(vals[0][0])\n ysize = int(vals[0][1])\n numslices = int(vals[0][2])\n else:\n bdata.shape = vals\n except:\n print \"No (or bad) header file. Returning unshaped array.\"\n return N.array(bdata)", "metadata": "root.binget", "header": "['module', '___EOS___']", "index": 916 } ]
[ { "span": "except:", "start_line": 58, "start_column": 0, "end_line": 58, "end_column": 7 }, { "span": "except:", "start_line": 184, "start_column": 20, "end_line": 184, "end_column": 27 }, { "span": "except:", "start_line": 289, "start_column": 16, "end_line": 289, "end_column": 23 }, { "span": "except:", "start_line": 445, "start_column": 4, "end_line": 445, "end_column": 11 }, { "span": "except:", "start_line": 475, "start_column": 4, "end_line": 475, "end_column": 11 }, { "span": "except:", "start_line": 546, "start_column": 8, "end_line": 546, "end_column": 15 }, { "span": "except:", "start_line": 568, "start_column": 4, "end_line": 568, "end_column": 11 }, { "span": "except:", "start_line": 603, "start_column": 4, "end_line": 603, "end_column": 11 }, { "span": "except:", "start_line": 954, "start_column": 4, "end_line": 954, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "Gar", "y", " ", "Stra", "ng", "man", ".", " ", " ", "All", " ", "rights", " ", "reserved_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Disc", "lai", "mer_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "software", " ", "is", " ", "provided", " ", "\"", "as", "-", "is", "\".", " ", " ", "There", " ", "are", " ", "no", " ", "express", "ed", " ", "or", " ", "impli", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "warr", "anti", "es", " ", "of", " ", "any", " ", "kind", ",", " ", "inclu", "ding", ",", " ", "but", " ", "not", " ", "limited", " ", "to", ",", " ", "the", " ", "warr", "anti", "es_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "merchant", "abilit", "y", " ", "and", " ", "fit", "tne", "ss", " ", "for", " ", "a", " ", "give", "n", " ", "applica", "tion", ".", " ", " ", "In", " ", "no", " ", "event_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sha", "ll", " ", "Gar", "y", " ", "Stra", "ng", "man", " ", "be", " ", "lia", "ble", " ", "for", " ", "any", " ", "direct", ",", " ", "indirect", ",", " ", "incident", "al", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "special", ",", " ", "exemp", "lar", "y", " ", "or", " ", "consequ", "ential", " ", "damage", "s", " ", "(", "inclu", "ding", ",", " ", "but", " ", "not", " ", "limited", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", ",", " ", "loss", " ", "of", " ", "use", ",", " ", "data", " ", "or", " ", "profit", "s", ",", " ", "or", " ", "business", " ", "interrupt", "ion", ")", " ", "how", "ever", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "caus", "ed", " ", "and", " ", "on", " ", "any", " ", "theory", " ", "of", " ", "lia", "bilit", "y", ",", " ", "whe", "ther", " ", "in", " ", "contract", ",", " ", "strict_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "lia", "bilit", "y", " ", "or", " ", "tor", "t", " ", "(", "inclu", "ding", " ", "neg", "lig", "ence", " ", "or", " ", "other", "wis", "e", ")", " ", "aris", "ing", " ", "in", " ", "any", " ", "way_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "out", " ", "of", " ", "the", " ", "use", " ", "of", " ", "this", " ", "software", ",", " ", "even", " ", "if", " ", "advi", "sed", " ", "of", " ", "the", " ", "possibilit", "y", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "suc", "h", " ", "damage", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Comme", "nts", " ", "and", "/", "or", " ", "additions", " ", "are", " ", "welcome", " ", "(", "send", " ", "e-", "mail", " ", "to", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "stran", "g", "@", "nm", "r", ".", "mg", "h", ".", "har", "vard", ".", "edu", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Define", "s", " ", "a", " ", "number", " ", "of", " ", "function", "s", " ", "for", " ", "pseudo", "-", "command", "-", "line", " ", "OS", " ", "functional", "it", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "cd", "(", "director", "y", ")", "\\", "10", ";", " ", " ", " ", " ", "pwd", " ", " ", " ", " ", " ", "<-", "-", " ", "can", " ", "be", " ", "used", " ", "WITH", "OUT", " ", "paren", "s", "\\", "10", ";", " ", " ", " ", " ", "ls", "(", "d", "='", ".'", ")", "\\", "10", ";", " ", " ", " ", " ", "rename", "(", "from", ",", "to", ")", "\\", "10", ";", " ", " ", " ", " ", "get", "(", "name", "pattern", "s", ",", "verbo", "se", "=", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "gets", "tring", "s", "(", "name", "pattern", "s", ",", "verbo", "se", "=", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "put", "(", "outl", "ist", ",", "filename", ",", "writet", "ype", "='", "w", "')", "\\", "10", ";", " ", " ", " ", " ", "age", "t", "(", "name", "pattern", "s", ",", "verbo", "se", "=", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "apu", "t", "(", "out", "array", ",", "filename", ",", "writet", "ype", "='", "w", "')", "\\", "10", ";", " ", " ", " ", " ", "bg", "et", "(", "filename", ",", "nums", "lice", "s", "=", "1", ",", "xsi", "ze", "=", "64", ",", "ysize", "=", "64", ")", "\\", "10", ";", " ", " ", " ", " ", "bra", "w", "(", "filename", ",", "bt", "ype", ")", "\\", "10", ";", " ", " ", " ", " ", "bp", "ut", "(", "out", "array", ",", "filename", ",", "write", "header", "=", "0", ",", "packs", "tring", "='", "h", "',", "writet", "ype", "='", "wb", "')", "\\", "10", ";", " ", " ", " ", " ", "mr", "get", "(", "filename", ")", "\\", "10", ";", " ", " ", " ", " ", "find", "\\u", "dirs", "(", "sourced", "ir", ")", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "CHANGE", "S", ":_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "=======", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "02", "-1", "1", "-", "20", " ", "...", " ", "adde", "d", " ", "bing", "et", "()", ",", " ", "bin", "put", "()", ",", " ", "array", "2a", "fn", "i", "()", ",", " ", "version", " ", "0.5_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "02", "-1", "0", "-", "20", " ", "...", " ", "adde", "d", " ", "find", "\\u", "dirs", "()", " ", "function", ",", " ", "change", "d", " ", "version", " ", "to", " ", "0.4_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "01", "-1", "1", "-1", "5", " ", "...", " ", "change", "d", " ", "apu", "t", "()", " ", "and", " ", "put", "()", " ", "to", " ", "accept", " ", "a", " ", "delimiter_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "01", "-0", "4", "-1", "9", " ", "...", " ", "adde", "d", " ", "one", "perl", "ine", " ", "option", " ", "to", " ", "put", "()", " ", "function_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-1", "1", "-0", "7", " ", "...", " ", "adde", "d", " ", "DA", "s", " ", "quick", " ", "flat", "-", "text", "-", "file", " ", "load", "ers", ",", " ", "load", "()", " ", "and", " ", "flo", "ad", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-1", "1", "-0", "1", " ", "...", " ", "adde", "d", " ", "version", " ", "number", " ", "(", "0.", "1", ")", " ", "for", " ", "distribution_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-0", "8", "-", "30", " ", "...", " ", "Put", " ", "quickl", "oad", " ", "in", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-0", "6", "-", "2", "7", " ", "...", " ", "Change", "d", " ", "bg", "et", " ", "thing", " ", "back", " ", "...", " ", "conf", "used", " ", "..._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-0", "6", "-", "24", " ", "...", " ", "exchange", "d", " ", "xsi", "ze", " ", "and", " ", "ysize", " ", "in", " ", "bg", "et", " ", "for", " ", "non", "-", "square", " ", "images", " ", "(", "NT", "??", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", " ", " ", "modifi", "ed", " ", "bg", "et", " ", "to", " ", "raise", " ", "an", " ", "IO", "Error", " ", "whe", "n", " ", "file", " ", "not", " ", "found_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-0", "6", "-1", "2", " ", "...", " ", "adde", "d", " ", "load", "()", " ", "and", " ", "save", "()", " ", "alias", "es", " ", "for", " ", "age", "t", "()", " ", "and", " ", "apu", "t", "()", " ", "(", "resp", ".)", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-0", "4", "-1", "3", " ", "...", " ", "change", "d", " ", "age", "t", "()", " ", "to", " ", "ignore", " ", "(!", "!!!", ")", " ", "lines", " ", "beginn", "ing", " ", "with", " ", "#", " ", "or", " ", "%_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "9", "9", "-0", "1", "-1", "7", " ", "...", " ", "change", "d", " ", "get", "()", " ", "so", " ", "ints", " ", "come", " ", "in", " ", "as", " ", "ints", " ", "(", "not", " ", "float", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "mma", "pfile", "_", "\\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_", "import_", "pstat", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "glob_", ",_", "re_", ",_", "string_", ",_", "types_", ",_", "os_", ",_", "numpy_", ",_", "struct_", ",_", "copy_", ",_", "time_", ",_", "tempfile_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "types_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "N_", "=_", "numpy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "version\\u\\u_", "=_", "0.5_", "\\u\\u\\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\\uDEDENT\\u\\u\\u_", "pwd_", "=_", "wrap_", "(_", "pwd_", ")_", "\\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\\uN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\u\\u\\u_", "\\u\\u\\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\\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_", "#", " ", "ALIAS", "ES", " ", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "save_", "=_", "apu", "t_", "\\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\\uDEDENT\\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_", "(_", "name", "patterns_", ",_", "verbose_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Load", "s", " ", "a", " ", "list", " ", "of", " ", "lists", " ", "from", " ", "text", " ", "files", " ", "(", "specified", " ", "by", " ", "a", " ", "UNIX", "-", "style", "\\", "10", ";", "wild", "card", " ", "filename", " ", "pattern", ")", " ", "and", " ", "convert", "s", " ", "all", " ", "numeri", "c", " ", "values", " ", "to", " ", "float", "s", ".", "\\", "10", ";", "Us", "es", " ", "the", " ", "glob", " ", "module", " ", "for", " ", "filename", " ", "pattern", " ", "conve", "rsi", "on", ".", " ", " ", "Load", "ed", " ", "filename", "\\", "10", ";", "is", " ", "printed", " ", "if", " ", "verbo", "se", "=", "1", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "get", " ", "(", "name", "pattern", "s", ",", "verbo", "se", "=", "1", ")", "\\", "10", ";", "Return", "s", ":", " ", "a", " ", "1", "D", " ", "or", " ", "2", "D", " ", "list", " ", "of", " ", "lists", " ", "from", " ", "whitespace", " ", "delim", "ited", " ", "text", " ", "files", "\\", "10", ";", " ", " ", " ", " ", " ", "specified", " ", "by", " ", "name", "pattern", "s", ";", " ", "numbers", " ", "tha", "t", " ", "can", " ", "be", " ", "convert", "ed", " ", "to", " ", "float", "s", "\\", "10", ";", " ", " ", " ", " ", " ", "are", " ", "so", " ", "convert", "ed", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fnames_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "name", "patterns_", ")_", "in_", "[_", "List", "Type_", ",_", "Tup", "le", "Type_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "name", "patterns_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fnames_", "=_", "fnames_", "+_", "glob_", "._", "glob_", "(_", "item_", ")_", "\\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 ", " _", "fnames_", "=_", "glob_", "._", "glob_", "(_", "name", "patterns_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "fnames_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "NO", " ", "FILE", "NAMES", " ", "MATCH", " ", "('_", "+_", "name", "patterns_", "+_", "')", " ", "!!", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "fnames_", "#", " ", "so", " ", "user", " ", "knows", " ", "what", " ", "has", " ", "bee", "n", " ", "loaded_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elements_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "fnames_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file_", "=_", "open_", "(_", "fnames_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newe", "lement", "s_", "=_", "map_", "(_", "string_", "._", "split_", ",_", "file_", "._", "readlines_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "newe", "lement", "s_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "range_", "(_", "len_", "(_", "newe", "lement", "s_", "[_", "i_", "]_", ")_", ")_", ":_", "\\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 ", " ", "_", "newe", "lement", "s_", "[_", "i_", "]_", "[_", "j_", "]_", "=_", "string_", "._", "ato", "i_", "(_", "newe", "lement", "s_", "[_", "i_", "]_", "[_", "j_", "]_", ")_", "\\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 ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "newe", "lement", "s_", "[_", "i_", "]_", "[_", "j_", "]_", "=_", "string_", "._", "ato", "f_", "(_", "newe", "lement", "s_", "[_", "i_", "]_", "[_", "j_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elements_", "=_", "elements_", "+_", "newe", "lement", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "elements_", ")_", "==_", "1_", ":_", "elements_", "=_", "elements_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "elements_", "\\u\\u\\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_", "age", "t_", "(_", "name", "pattern_", ",_", "verbose_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Load", "s", " ", "an", " ", "array", " ", "from", " ", "2", "D", " ", "text", " ", "files", " ", "(", "specified", " ", "by", " ", "a", " ", "UNIX", "-", "style", " ", "wild", "card", "\\", "10", ";", "filename", " ", "pattern", ").", " ", " ", "ONL", "Y", " ", "'", "GET", "'", " ", "FILE", "S", " ", "WITH", " ", "EQUAL", " ", "NUMB", "ERS", " ", "OF", " ", "COL", "UM", "NS", "\\", "10", ";", "ON", " ", "EVE", "RY", " ", "ROW", " ", "(", "other", "wis", "e", " ", "return", "ed", " ", "array", " ", "will", " ", "be", " ", "zero", "-", "dimension", "al", ").", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "age", "t", " ", "(", "name", "pattern", ")", "\\", "10", ";", "Return", "s", ":", " ", "an", " ", "array", " ", "of", " ", "integ", "ers", ",", " ", "float", "s", " ", "or", " ", "object", "s", " ", "(", "type", "='", "O", "')", ",", " ", "depend", "ing", " ", "on", " ", "the", "\\", "10", ";", " ", " ", " ", " ", " ", "content", "s", " ", "of", " ", "the", " ", "files", " ", "specified", " ", "by", " ", "name", "pattern", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fnames_", "=_", "glob_", "._", "glob_", "(_", "name", "pattern_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "fnames_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "NO", " ", "FILE", "NAMES", " ", "MATCH", " ", "('_", "+_", "name", "pattern_", "+_", "')", " ", "!!", "'_", "\\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_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "fnames_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elements_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "filename_", "in_", "fnames_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file_", "=_", "open_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newe", "lement", "s_", "=_", "file_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del", "\\u", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "range_", "(_", "len_", "(_", "newe", "lement", "s_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "newe", "lement", "s_", "[_", "row_", "]_", "[_", "0_", "]_", "==_", "'%'_", "or_", "newe", "lement", "s_", "[_", "row_", "]_", "[_", "0_", "]_", "==_", "'#'_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "len_", "(_", "newe", "lement", "s_", "[_", "row_", "]_", ")_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del", "\\u", "list_", "._", "append_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del", "\\u", "list_", "._", "reverse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "del", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "newe", "lement", "s_", "._", "pop_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "newe", "lement", "s_", "=_", "map_", "(_", "string_", "._", "split_", ",_", "newe", "lement", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "newe", "lement", "s_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "range_", "(_", "len_", "(_", "newe", "lement", "s_", "[_", "i_", "]_", ")_", ")_", ":_", "\\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 ", " ", "_", "newe", "lement", "s_", "[_", "i_", "]_", "[_", "j_", "]_", "=_", "string_", "._", "ato", "f_", "(_", "newe", "lement", "s_", "[_", "i_", "]_", "[_", "j_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elements_", "=_", "elements_", "+_", "newe", "lement", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "row_", "in_", "range_", "(_", "len_", "(_", "elements_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "N_", "._", "add_", "._", "reduce_", "(_", "N_", "._", "array_", "(_", "map_", "(_", "iss", "tring_", ",_", "elements_", "[_", "row_", "]_", ")_", ")_", ")_", "==_", "len_", "(_", "elements_", "[_", "row_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "A", " ", "row", " ", "of", " ", "string", "s", " ", "was", " ", "found", ".", " ", " ", "Return", "ing", " ", "a", " ", "LIST", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "elements_", "\\u\\u\\uNEWLINE\\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 ", " _", "elements_", "=_", "N_", "._", "array_", "(_", "elements_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "elements_", "=_", "N_", "._", "array_", "(_", "elements_", ",_", "'", "O", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "elements_", "\\u\\u\\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_", "bri", "kg", "et_", "(_", "im", "file_", ",_", "unpack", "str_", "=_", "N_", "._", "int16_", ",_", "shp_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Get", "s", " ", "an", " ", "AF", "NI", " ", "BRI", "K", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", "bri", "kg", "et", "(", "im", "file", ",", "unpack", "str", "=", "N", ".", "int", "16", ",", "shp", "=", "Non", "e", ")", " ", " ", "default", " ", "shp", ":", " ", "(-", "1", ",", "4", "8", ",", "6", "1", ",", "5", "1", ")", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "shp_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "shp_", "=_", "(_", "-_", "1_", ",_", "48_", ",_", "61_", ",_", "51_", ")_", "\\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 ", " _", "file_", "=_", "open_", "(_", "im", "file_", ",_", "\"", "rb", "\"_", ")_", "\\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_", "\"", "Cou", "ld", "n", "'", "t", " ", "find", " ", "file", ":", " ", " ", "\"_", "+_", "im", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "IO", "Error_", ",_", "\"", "Cou", "ld", "n", "'", "t", " ", "find", " ", "file", " ", "in", " ", "bri", "kg", "et", "()\"_", "\\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 ", " _", "header_", "=_", "im", "file_", "[_", "0_", ":_", "-_", "4_", "]_", "+_", "'", "HEAD", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "open_", "(_", "header_", ")_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "lines_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "string_", "._", "find_", "(_", "lines_", "[_", "i_", "]_", ",_", "'", "DATASET", "\\u", "DIMENSION", "S", "'_", ")_", "<_", ">_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dims_", "=_", "string_", "._", "split_", "(_", "lines_", "[_", "i_", "+_", "2_", "]_", "[_", "0_", ":_", "string_", "._", "find_", "(_", "lines_", "[_", "i_", "+_", "2_", "]_", ",_", "'", " ", "0", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dims_", "=_", "map_", "(_", "string_", "._", "ato", "i_", ",_", "dims_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "string_", "._", "find_", "(_", "lines_", "[_", "i_", "]_", ",_", "'", "BRI", "CK", "\\u", "FLOAT", "\\u", "FAC", "S", "'_", ")_", "<_", ">_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "count_", "=_", "string_", "._", "ato", "i_", "(_", "string_", "._", "split_", "(_", "lines_", "[_", "i_", "+_", "1_", "]_", ")_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mult", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "range_", "(_", "int_", "(_", "N_", "._", "ceil_", "(_", "count_", "/_", "5._", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "mult", "s_", "+=_", "map_", "(_", "string_", "._", "ato", "f_", ",_", "string_", "._", "split_", "(_", "lines_", "[_", "i_", "+_", "2_", "+_", "j_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mult", "s_", "=_", "N_", "._", "array_", "(_", "mult", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dims_", "._", "reverse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shp_", "=_", "[_", "-_", "1_", "]_", "+_", "dims_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", " ", "header", " ", "file", ".", " ", " ", "Continu", "ing", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lines_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "shp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Us", "ing", " ", "unpack", "str", ":'_", ",_", "unpack", "str_", "#", ",'", ",", " ", "bytes", "perp", "ixel", "='", ",", "bytes", "perp", "ixel", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "file_", "=_", "open_", "(_", "im", "file_", ",_", "\"", "rb", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bda", "ta_", "=_", "file_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", ">", " ", "force", "s", " ", "big", "-", "endian", " ", "(", "for", " ", "or", " ", "from", " ", "Sun", "/", "SGI", ")_", "\\u\\u\\uNL\\u\\u\\u_", "bda", "ta_", "=_", "N_", "._", "fromstring_", "(_", "bda", "ta_", ",_", "unpack", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "litt", "le", "Endi", "an_", "=_", "(_", "struct_", "._", "pack_", "(_", "'", "i", "'_", ",_", "1_", ")_", "==_", "struct_", "._", "pack_", "(_", "'<", "i", "'_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "litt", "le", "Endi", "an_", "and_", "os_", "._", "uname_", "(_", ")_", "[_", "0_", "]_", "<_", ">_", "'", "Lin", "ux", "'_", ")_", "or_", "(_", "max_", "(_", "bda", "ta_", ")_", ">_", "1e", "30_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "=_", "bda", "ta_", "._", "bytes", "wap", "ped_", "(_", ")_", "\\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 ", " _", "bda", "ta_", "._", "shape_", "=_", "shp_", "\\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_", "'", "Inco", "rrect", " ", "shape", " ", "...'_", ",_", "shp_", ",_", "len_", "(_", "bda", "ta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Value", "Error_", ",_", "'", "Inco", "rrect", " ", "shape", " ", "for", " ", "file", " ", "size", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "bda", "ta_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "=_", "bda", "ta_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "N_", "._", "sum_", "(_", "mult", "s_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "bda", "ta_", "\\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 ", " _", "mult", "shape_", "=_", "[_", "1_", "]_", "*_", "len_", "(_", "bda", "ta_", "._", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "bda", "ta_", "._", "shape_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "mult", "s_", ")_", "==_", "bda", "ta_", "._", "shape_", "[_", "i_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mult", "shape_", "[_", "i_", "]_", "=_", "len_", "(_", "mult", "s_", ")_", "\\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_", "mult", "s_", "._", "shape_", "=_", "mult", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "bda", "ta_", "*_", "mult", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "bda", "ta_", "\\u\\u\\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_", "mg", "hb", "get_", "(_", "im", "file_", ",_", "nums", "lice", "s_", "=_", "-_", "1_", ",_", "xsize_", "=_", "64_", ",_", "ysize", "_", "=_", "64_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unpack", "str_", "=_", "N_", "._", "int16_", ",_", "bytes", "perp", "ixel", "_", "=_", "2.0_", ",_", "slice", "init_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Read", "s", " ", "in", " ", "a", " ", "binar", "y", " ", "file", ",", " ", "typical", "ly", " ", "with", " ", "a", " ", ".", "bs", "hort", " ", "or", " ", ".", "bf", "loa", "t", " ", "extensi", "on", ".", "\\", "10", ";", "If", " ", "so", ",", " ", "the", " ", "last", " ", "3", " ", "parameter", "s", " ", "are", " ", "set", " ", "appropr", "iate", "ly", ".", " ", " ", "If", " ", "not", ",", " ", "the", " ", "last", " ", "3", "\\", "10", ";", "parameter", "s", " ", "default", " ", "to", " ", "readi", "ng", " ", ".", "bs", "hort", " ", "files", " ", "(", "2", "-", "byte", " ", "integ", "ers", " ", "in", " ", "big", "-", "endian", "\\", "10", ";", "binar", "y", " ", "format", ").", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "mg", "hb", "get", "(", "im", "file", ",", " ", "nums", "lice", "s", "=-", "1", ",", " ", "xsi", "ze", "=", "64", ",", " ", "ysize", "=", "64", ",", "\\", "10", ";", " ", " ", " ", " ", "unpack", "str", "=", "N", ".", "int", "16", ",", " ", "bytes", "perp", "ixel", "=", "2.0", ",", " ", "slice", "init", "=", "0", ")", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file_", "=_", "open_", "(_", "im", "file_", ",_", "\"", "rb", "\"_", ")_", "\\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_", "\"", "Cou", "ld", "n", "'", "t", " ", "find", " ", "file", ":", " ", " ", "\"_", "+_", "im", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "IO", "Error_", ",_", "\"", "Cou", "ld", "n", "'", "t", " ", "find", " ", "file", " ", "in", " ", "bg", "et", "()\"_", "\\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 ", " _", "header_", "=_", "im", "file_", "[_", "0_", ":_", "-_", "6_", "]_", "+_", "'", "hdr", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "get_", "(_", "header_", ",_", "0_", ")_", "#", " ", "'", "0", "'", " ", "means", " ", "no", " ", "missi", "ng", "-", "file", " ", "warn", "ing", " ", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "vals_", "[_", "0_", "]_", ")_", "==_", "List", "Type_", ":_", "#", " ", "it", "'", "s", " ", "an", " ", "extend", "ed", " ", "header_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xsize_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ysize", "_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nums", "lice", "s_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xsize_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ysize", "_", "=_", "int_", "(_", "vals_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nums", "lice", "s_", "=_", "int_", "(_", "vals_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", " ", "header", " ", "file", ".", " ", " ", "Continu", "ing", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "suffix_", "=_", "im", "file_", "[_", "-_", "6_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "suffix_", "==_", "'", "bs", "hort", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "suffix_", "[_", "-_", "3_", ":_", "]_", "==_", "'", "img", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "suffix_", "==_", "'", "bf", "loa", "t", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unpack", "str_", "=_", "N_", "._", "Float", "32_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bytes", "perp", "ixel", "_", "=_", "4.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slice", "init_", "=_", "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 ", " _", "print_", "'", "Not", " ", "a", " ", "bs", "hort", ",", " ", "bf", "loa", "t", " ", "or", " ", "img", " ", "file", ".'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Us", "ing", " ", "unpack", "str", ":'_", ",_", "unpack", "str_", ",_", "',", " ", "bytes", "perp", "ixel", "='_", ",_", "bytes", "perp", "ixel", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ims", "ize_", "=_", "xsize_", "*_", "ysize", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file_", "=_", "open_", "(_", "im", "file_", ",_", "\"", "rb", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bda", "ta_", "=_", "file_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nump", "ixel", "s_", "=_", "len_", "(_", "bda", "ta_", ")_", "/_", "bytes", "perp", "ixel", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "nump", "ixel", "s_", "%_", "1_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", ",_", "\"", "Inco", "rrect", " ", "file", " ", "size", " ", "in", " ", "fm", "ri", ".", "bg", "et", "()\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", " ", "the", " ", ">", " ", "force", "s", " ", "big", "-", "endian", " ", "(", "for", " ", "or", " ", "from", " ", "Sun", "/", "SGI", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "=_", "N_", "._", "fromstring_", "(_", "bda", "ta_", ",_", "unpack", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "litt", "le", "Endi", "an_", "=_", "(_", "struct_", "._", "pack_", "(_", "'", "i", "'_", ",_", "1_", ")_", "==_", "struct_", "._", "pack_", "(_", "'<", "i", "'_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "if", " ", "litt", "le", "Endi", "an", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "bda", "ta", " ", "=", " ", "bda", "ta", ".", "bytes", "wap", "ped", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "litt", "le", "Endi", "an_", "and_", "os_", "._", "uname_", "(_", ")_", "[_", "0_", "]_", "<_", ">_", "'", "Lin", "ux", "'_", ")_", "or_", "(_", "max_", "(_", "bda", "ta_", ")_", ">_", "1e", "30_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "=_", "bda", "ta_", "._", "bytes", "wap", "ped_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "suffix_", "[_", "-_", "3_", ":_", "]_", "==_", "'", "img", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "nums", "lice", "s_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nums", "lice", "s_", "=_", "len_", "(_", "bda", "ta_", ")_", "/_", "820", "0_", "#", " ", "820", "0", "=(", "64", "*", "64", "*", "2", ")+", "8", " ", "bytes", " ", "per", " ", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xsize_", "=_", "64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ysize", "_", "=_", "128_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "slices_", "=_", "N_", "._", "zeros_", "(_", "(_", "nums", "lice", "s_", ",_", "xsize_", ",_", "ysize", "_", ")_", ",_", "N_", "._", "Int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "nums", "lice", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ista", "rt_", "=_", "i_", "*_", "8_", "+_", "i_", "*_", "xsize_", "*_", "ysize", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ien", "d_", "=_", "i_", "*_", "8_", "+_", "(_", "i_", "+_", "1_", ")_", "*_", "xsize_", "*_", "ysize", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "i_", ",_", "ista", "rt_", ",_", "ien", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slices_", "[_", "i_", "]_", "=_", "N_", "._", "reshape_", "(_", "N_", "._", "array_", "(_", "bda", "ta_", "[_", "ista", "rt_", ":_", "ien", "d_", "]_", ")_", ",_", "(_", "xsize_", ",_", "ysize", "_", ")_", ")_", "\\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_", "nums", "lice", "s_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slices_", "=_", "N_", "._", "reshape_", "(_", "N_", "._", "array_", "(_", "bda", "ta_", ")_", ",_", "[_", "xsize_", ",_", "ysize", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slices_", "=_", "N_", "._", "reshape_", "(_", "N_", "._", "array_", "(_", "bda", "ta_", ")_", ",_", "[_", "nums", "lice", "s_", ",_", "xsize_", ",_", "ysize", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "slices_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slices_", "=_", "slices_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "slices_", "\\u\\u\\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_", "bra", "w_", "(_", "fname_", ",_", "bt", "ype_", ",_", "shp_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Opens", " ", "a", " ", "binar", "y", " ", "file", ",", " ", "unpack", "s", " ", "it", ",", " ", "and", " ", "return", "s", " ", "a", " ", "flat", " ", "array", " ", "of", " ", "the", "\\", "10", ";", "type", " ", "specified", ".", " ", " ", "Us", "e", " ", "Numer", "ic", " ", "types", " ", "...", " ", "N", ".", "Float", "32", ",", " ", "N", ".", "Int64", ",", " ", "etc", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "bra", "w", "(", "fname", ",", "bt", "ype", ",", "shp", "=", "Non", "e", ")", "\\", "10", ";", "Return", "s", ":", " ", "flat", " ", "array", " ", "of", " ", "float", "s", ",", " ", "or", " ", "ints", " ", "(", "if", " ", "bt", "ype", "=", "N", ".", "int", "16", ")", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file_", "=_", "open_", "(_", "fname_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bda", "ta_", "=_", "file_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bda", "ta_", "=_", "N_", "._", "fromstring_", "(_", "bda", "ta_", ",_", "bt", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "litt", "le", "Endi", "an_", "=_", "(_", "struct_", "._", "pack_", "(_", "'", "i", "'_", ",_", "1_", ")_", "==_", "struct_", "._", "pack_", "(_", "'<", "i", "'_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "if", " ", "litt", "le", "Endi", "an", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "bda", "ta", " ", "=", " ", "bda", "ta", ".", "bytes", "wap", "ped", "()", " ", " ", "#", " ", "did", "n", "'", "t", " ", "used", " ", "to", " ", "need", " ", "this", " ", "with", " ", "'>", "'", " ", "above_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "litt", "le", "Endi", "an_", "and_", "os_", "._", "uname_", "(_", ")_", "[_", "0_", "]_", "<_", ">_", "'", "Lin", "ux", "'_", ")_", "or_", "(_", "max_", "(_", "bda", "ta_", ")_", ">_", "1e", "30_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "=_", "bda", "ta_", "._", "bytes", "wap", "ped_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "shp_", ":_", "\\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 ", " _", "bda", "ta_", "._", "shape_", "=_", "shp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "bda", "ta_", "\\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_", "N_", "._", "array_", "(_", "bda", "ta_", ")_", "\\u\\u\\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_", "gl", "get_", "(_", "fname_", ",_", "bt", "ype_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Load", " ", "in", " ", "a", " ", "file", " ", "contain", "ing", " ", "pixel", "s", " ", "from", " ", "gl", "Read", "Pixels", " ", "dump", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "gl", "get", "(", "fname", ",", "bt", "ype", ")", "\\", "10", ";", "Return", "s", ":", " ", "array", " ", "of", " ", "'", "bt", "ype", " ", "element", "s", " ", "with", " ", "shape", " ", "'", "shape", "',", " ", "suit", "able", " ", "for", " ", "im", ".", "ash", "ow", "()", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "bra", "w_", "(_", "fname_", ",_", "bt", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "d_", "[_", "8_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "open_", "(_", "fname_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shp_", "=_", "f_", "._", "read_", "(_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shp_", "=_", "N_", "._", "fromstring_", "(_", "shp_", ",_", "N_", "._", "Int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shp_", "[_", "0_", "]_", ",_", "shp_", "[_", "1_", "]_", "=_", "shp_", "[_", "1_", "]_", ",_", "shp_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "carr", "ay_", "=_", "N_", "._", "reshape_", "(_", "d_", ",_", "shp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "d_", "[_", "0_", ":_", ":_", "3_", "]_", "+_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "d_", "[_", "1_", ":_", ":_", "3_", "]_", "+_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "d_", "[_", "2_", ":_", ":_", "3_", "]_", "+_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "shape_", "=_", "shp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "shape_", "=_", "shp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "._", "shape_", "=_", "shp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "carr", "ay_", "=_", "N_", "._", "array_", "(_", "[_", "r_", ",_", "g_", ",_", "b_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "outstr_", "=_", "\"", "gl", "get", ":", " ", "shape", " ", "not", " ", "correct", " ", "for", " ", "data", " ", "of", " ", "length", " ", "\"_", "+_", "str_", "(_", "len_", "(_", "d_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Value", "Error_", ",_", "outstr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "carr", "ay_", "\\u\\u\\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_", "mg", "et_", "(_", "fname_", ",_", "bt", "ype_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Load", " ", "in", " ", "a", " ", "file", " ", "tha", "t", " ", "was", " ", "saved", " ", "from", " ", "matlab", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "mg", "et", "(", "fname", ",", "bt", "ype", ")", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "bra", "w_", "(_", "fname_", ",_", "bt", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "header_", "=_", "fname_", "[_", "0_", ":_", "-_", "6_", "]_", "+_", "'", "hdr", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "get_", "(_", "header_", ",_", "0_", ")_", "#", " ", "'", "0", "'", " ", "means", " ", "no", " ", "missi", "ng", "-", "file", " ", "warn", "ing", " ", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "vals_", "[_", "0_", "]_", ")_", "==_", "List", "Type_", ":_", "#", " ", "it", "'", "s", " ", "an", " ", "extend", "ed", " ", "header_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xsize_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ysize", "_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nums", "lice", "s_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xsize_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ysize", "_", "=_", "int_", "(_", "vals_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nums", "lice", "s_", "=_", "int_", "(_", "vals_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "xsize_", ",_", "ysize", "_", ",_", "nums", "lice", "s_", ",_", "d_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", " ", "header", " ", "file", ".", " ", " ", "Continu", "ing", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "nums", "lice", "s_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "._", "shape_", "=_", "[_", "ysize", "_", ",_", "xsize_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "N_", "._", "transpose_", "(_", "d_", ")_", "*_", "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 ", " _", "d_", "._", "shape_", "=_", "[_", "nums", "lice", "s_", ",_", "ysize", "_", ",_", "xsize_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "N_", "._", "transpose_", "(_", "d_", ")_", "*_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "bing", "et_", "(_", "fname_", ",_", "bt", "ype_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "Load", "s", " ", "a", " ", "binar", "y", " ", "file", " ", "from", " ", "disk", ".", " ", "Assume", "s", " ", "associate", "d", " ", "hdr", " ", "file", " ", "is", " ", "in", " ", "same", "\\", "10", ";", "location", ".", " ", "You", " ", "can", " ", "force", " ", "an", " ", "unpack", "ing", " ", "type", ",", " ", "or", " ", "else", " ", "it", " ", "trie", "s", " ", "to", " ", "figure", "\\", "10", ";", "it", " ", "out", " ", "from", " ", "the", " ", "filename", " ", "(", "4", "th", "-", "to", "-", "last", " ", "character", ").", " ", "Hen", "ce", ",", " ", "reada", "ble", " ", "file", "\\", "10", ";", "formats", " ", "are", " ", "...", "\\", "10", ";", "\\", "10", ";", "1b", "in", "=", "Int", "8", ",", " ", "sb", "in", "=", "int", "16", ",", " ", "ibi", "n", "=", "Int", "32", ",", " ", "fb", "in", "=", "Float", "32", ",", " ", "dbi", "n", "=", "Float", "64", ",", " ", "etc", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", " ", " ", " ", "bing", "et", "(", "fname", ",", "bt", "ype", "=", "Non", "e", ")", "\\", "10", ";", "Return", "s", ":", " ", "data", " ", "in", " ", "file", " ", "fname", " ", "of", " ", "type", " ", "bt", "ype", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file_", "=_", "open_", "(_", "fname_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bda", "ta_", "=_", "file_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "none", " ", "give", "n", ",", " ", "assume", " ", "character", " ", "prece", "eding", " ", "'", "bin", "'", " ", "is", " ", "the", " ", "unpack", "type_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "bt", "ype_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bt", "ype_", "=_", "fname_", "[_", "-_", "4_", "]_", "\\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 ", " _", "bda", "ta_", "=_", "N_", "._", "fromstring_", "(_", "bda", "ta_", ",_", "bt", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", ",_", "\"", "Ba", "d", " ", "unpack", "ing", " ", "type", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "force", " ", "the", " ", "data", " ", "on", " ", "disk", " ", "to", " ", "be", " ", "Litt", "le", "Endi", "an", " ", "(", "for", " ", "more", " ", "efficien", "t", " ", "PC", "/", "Lin", "ux", " ", "use", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "N_", "._", "Litt", "le", "Endi", "an_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "=_", "bda", "ta_", "._", "bytes", "wap", "ped_", "(_", ")_", "\\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 ", " _", "header_", "=_", "fname_", "[_", ":_", "-_", "3_", "]_", "+_", "'", "hdr", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "get_", "(_", "header_", ",_", "0_", ")_", "#", " ", "'", "0", "'", " ", "means", " ", "no", " ", "missi", "ng", "-", "file", " ", "warn", "ing", " ", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "vals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "vals_", "[_", "0_", "]_", ")_", "==_", "List", "Type_", ":_", "#", " ", "it", "'", "s", " ", "an", " ", "extend", "ed", " ", "header_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xsize_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ysize", "_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nums", "lice", "s_", "=_", "int_", "(_", "vals_", "[_", "0_", "]_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bda", "ta_", "._", "shape_", "=_", "vals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", " ", "(", "or", " ", "bad", ")", " ", "header", " ", "file", ".", " ", "Return", "ing", " ", "unsh", "ape", "d", " ", "array", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "N_", "._", "array_", "(_", "bda", "ta_", ")_", "\\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, 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_return + stream.next()\n except:\n to_return = to_return\n\n return to_return", "metadata": "root.TheTvDb.create_string_from_stream", "header": "['class', 'TheTvDb', ':', '___NEWLINE___', '# this finds an acceptable mirror for future thetvdb requests.', '___NL___', '___EOS___']", "index": 188 }, { "content": " def get_string(self, xml_element, sub_element_name, default):\n try:\n return xml_element.findtext(sub_element_name)\n except:\n return default", "metadata": "root.TheTvDb.get_string", "header": "['class', 'TheTvDb', ':', '___NEWLINE___', '# this finds an acceptable mirror for future thetvdb requests.', '___NL___', '___EOS___']", "index": 250 }, { "content": " def get_string_list(self, xml_element, sub_element_name, separator, default):\n try:\n text = xml_element.findtext(sub_element_name)\n return [ t for t in text.split(separator) ]\n\n except:\n return [ t for t in default ]", "metadata": "root.TheTvDb.get_string_list", "header": "['class', 'TheTvDb', ':', '___NEWLINE___', '# this finds an acceptable mirror for future thetvdb requests.', '___NL___', '___EOS___']", "index": 256 }, { "content": " def get_int(self, xml_element, sub_element_name, default):\n try:\n return int(xml_element.findtext(sub_element_name))\n except:\n return default", "metadata": "root.TheTvDb.get_int", "header": "['class', 'TheTvDb', ':', '___NEWLINE___', '# this finds an acceptable mirror for future thetvdb requests.', '___NL___', '___EOS___']", "index": 264 }, { "content": " def get_float(self, xml_element, sub_element_name, default):\n try:\n return float(xml_element.findtext(sub_element_name))\n except:\n return default", "metadata": "root.TheTvDb.get_float", "header": "['class', 'TheTvDb', ':', '___NEWLINE___', '# this finds an acceptable mirror for future thetvdb requests.', '___NL___', '___EOS___']", "index": 270 }, { "content": " def get_datetime(self, xml_element, sub_element_name, default):\n try:\n date_text = xml_element.findtext(sub_element_name)\n return datetime.strptime(date_text, \"%Y-%m-%d\")\n except ValueError:\n if self.debug:\n print \"Error parsing string '%s' into datetime.\\n\" % date_text, \n return default\n except:\n return default", "metadata": "root.TheTvDb.get_datetime", "header": "['class', 'TheTvDb', ':', '___NEWLINE___', '# this finds an acceptable mirror for future thetvdb requests.', '___NL___', '___EOS___']", "index": 276 } ]
[ { "span": "except:", "start_line": 194, "start_column": 8, "end_line": 194, "end_column": 15 }, { "span": "except:", "start_line": 253, "start_column": 8, "end_line": 253, "end_column": 15 }, { "span": "except:", "start_line": 261, "start_column": 8, "end_line": 261, "end_column": 15 }, { "span": "except:", "start_line": 267, "start_column": 8, "end_line": 267, "end_column": 15 }, { "span": "except:", "start_line": 273, "start_column": 8, "end_line": 273, "end_column": 15 }, { "span": "except:", "start_line": 284, "start_column": 8, "end_line": 284, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "The", "Tv", "Db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "find", "s", " ", "an", " ", "acceptabl", "e", " ", "mirror", " ", "for", " ", "future", " ", "thet", "vdb", " ", "request", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "string", "\\u", "from", "\\u", "stream_", "(_", "self_", ",_", "stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "to", "\\u", "return_", "=_", "''_", "\\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 ", " _", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "to", "\\u", "return_", "=_", "to", "\\u", "return_", "+_", "stream_", "._", "next_", "(_", ")_", "\\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 ", " _", "to", "\\u", "return_", "=_", "to", "\\u", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "to", "\\u", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "The", "Tv", "Db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "find", "s", " ", "an", " ", "acceptabl", "e", " ", "mirror", " ", "for", " ", "future", " ", "thet", "vdb", " ", "request", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "string_", "(_", "self_", ",_", "xml", "\\u", "element_", ",_", "sub\\u", "element", "\\u", "name_", ",_", "default_", ")_", ":_", "\\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_", "xml", "\\u", "element_", "._", "findtext_", "(_", "sub\\u", "element", "\\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 ", " _", "return_", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "The", "Tv", "Db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "find", "s", " ", "an", " ", "acceptabl", "e", " ", "mirror", " ", "for", " ", "future", " ", "thet", "vdb", " ", "request", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "string", "\\u", "list_", "(_", "self_", ",_", "xml", "\\u", "element_", ",_", "sub\\u", "element", "\\u", "name_", ",_", "separator_", ",_", "default_", ")_", ":_", "\\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 ", " _", "text_", "=_", "xml", "\\u", "element_", "._", "findtext_", "(_", "sub\\u", "element", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "t_", "for_", "t_", "in_", "text_", "._", "split_", "(_", "separator_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "t_", "for_", "t_", "in_", "default_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "The", "Tv", "Db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "find", "s", " ", "an", " ", "acceptabl", "e", " ", "mirror", " ", "for", " ", "future", " ", "thet", "vdb", " ", "request", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "int_", "(_", "self_", ",_", "xml", "\\u", "element_", ",_", "sub\\u", "element", "\\u", "name_", ",_", "default_", ")_", ":_", "\\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_", "int_", "(_", "xml", "\\u", "element_", "._", "findtext_", "(_", "sub\\u", "element", "\\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 ", " _", "return_", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "The", "Tv", "Db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "find", "s", " ", "an", " ", "acceptabl", "e", " ", "mirror", " ", "for", " ", "future", " ", "thet", "vdb", " ", "request", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "float_", "(_", "self_", ",_", "xml", "\\u", "element_", ",_", "sub\\u", "element", "\\u", "name_", ",_", "default_", ")_", ":_", "\\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_", "float_", "(_", "xml", "\\u", "element_", "._", "findtext_", "(_", "sub\\u", "element", "\\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 ", " _", "return_", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "The", "Tv", "Db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "find", "s", " ", "an", " ", "acceptabl", "e", " ", "mirror", " ", "for", " ", "future", " ", "thet", "vdb", " ", "request", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "datetime_", "(_", "self_", ",_", "xml", "\\u", "element_", ",_", "sub\\u", "element", "\\u", "name_", ",_", "default_", ")_", ":_", "\\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 ", " _", "date", "\\u", "text_", "=_", "xml", "\\u", "element_", "._", "findtext_", "(_", "sub\\u", "element", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "datetime_", "._", "strptime_", "(_", "date", "\\u", "text_", ",_", "\"%", "Y", "-%", "m", "-%", "d", "\"_", ")_", "\\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 ", " _", "if_", "self_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Error", " ", "pars", "ing", " ", "string", " ", "'%", "s", "'", " ", "int", "o", " ", "datetime", ".\\\\", "n", "\"_", "%_", "date", "\\u", "text_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "default_", "\\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_", "default_" ]
[ 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, 0, 1, 1, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
operasoftware/tlsprober/cluster_manager.py
[ { "content": "@transaction.commit_manually\ndef main():\n\t\"\"\"Main management handler on each cluster, checks every 10 minutes for new tasks\"\"\"\n\n\n\tcomputername = os.environ.get('COMPUTERNAME',\"any\").lower()\n\tif computername == \"any\":\n\t\tcomputername = os.environ.get('HOSTNAME',\"any\").lower()\n\tif computername == \"any\":\n\t\traise Exception(\"Computername was empty\")\n\t\n\tcomputername = computername.partition('.')[0]\n\t\n\toptions_config = OptionParser()\n\t\n\toptions_config.add_option(\"--testbase2\", action=\"store_true\", dest=\"use_testbase2\")\n\toptions_config.add_option(\"--verbose\", action=\"store_true\", dest=\"verbose\")\n\toptions_config.add_option(\"--persistent\", action=\"store_true\", dest=\"persistent\")\n\toptions_config.add_option(\"--nogit\", action=\"store_true\", dest=\"nogit\")\n\t\n\t\n\t(options, args) = options_config.parse_args()\n\t\n\twhile True:\n\t\tmaster_configuration,created = Cluster.ClusterNode.objects.get_or_create(hostname = \"tlsprober-cluster\", defaults={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"probe_parameters\":\"not used\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#\"result_parameters\":\"not used\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"active_node\":True,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\tconfiguration,created = Cluster.ClusterNode.objects.get_or_create(hostname = computername, defaults={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"probe_parameters\":\"--processes 40 --iterations 40\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#\"result_parameters\":\"--processes 10 --iterations 100\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"active_node\":True,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\tconfiguration.save()\n\t\ttransaction.commit()\n\t\tdone_something = False\n\t\tif Cluster.ClusterRun.objects.filter(enabled=True).count() >0:\n\t\t\t\"\"\"Any enabled TLS Prober jobs?\"\"\"\n\t\t\tdone_something = True\n\t\t\tif master_configuration.active_node and configuration.active_node:\n\t\t\t\tif not options.nogit:\n\t\t\t\t\t\"\"\"Check out the code to be used\"\"\"\n\t\t\t\t\tsubprocess.call([\"git\", \"pull\",])\n\t\t\t\t\tsubprocess.call([\"git\", \"submodule\", \"update\", \"--recursive\"])\n\t\t\t\t\t\n\t\t\t\t\tmaster_branch = \"pincushion\" if options.use_testbase2 else \"master\"\n\t\t\t\t\t\t\n\t\t\t\t\trun = Cluster.ClusterRun.objects.filter(enabled=True).order_by(\"-priority\", \"entered_date\")[0]\n\t\t\t\t\tbranch = run.perform_run.branch\n\t\t\t\t\tsubprocess.call([\"git\", \"checkout\", branch if branch else master_branch])\n\t\t\t\t\tsubprocess.call([\"git\", \"submodule\", \"update\", \"--recursive\"])\n\t\t\n\t\t\t\ttry:\n\t\t\t\t\tconnection.close()\n\t\t\t\texcept:\n\t\t\t\t\tpass\n\t\t\t\t\"\"\"Start the prober on this cluster node for the job\"\"\"\n\t\t\t\tsubprocess.call([\"python\", \"-O\", \n\t\t\t\t\t\t\t\t\t\"cluster_start.py\",\n\t\t\t\t\t\t\t\t\t\t\"--performance\",\n\t\t\t\t\t\t\t\t\t\t\"--managed\"]\n\t\t\t\t\t\t\t\t\t+ ([\"--testbase2\"] if options.use_testbase2 else [])\n\t\t\t\t\t\t\t\t\t+ ([\"--verbose\"] if options.verbose else [])\n\t\t\t\t\t\t\t\t, shell=False)\n\t\t\telse:\n\t\t\t\ttry:\n\t\t\t\t\tconnection.close()\n\t\t\t\texcept:\n\t\t\t\t\tpass\n\t\t\t\ttime.sleep(30)\n\t\telse:\n\t\t\tmaster_configuration,created = Scanner.ScannerNode.objects.get_or_create(hostname = \"tlsprober-cluster\", defaults={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"scan_parameters\":\"not used\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"active_node\":True,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\tconfiguration,created = Scanner.ScannerNode.objects.get_or_create(hostname = computername, defaults={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"scan_parameters\":\"--processes 40 --iterations 40\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"active_node\":True,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\tconfiguration.save()\n\t\t\ttransaction.commit()\n\t\n\t\t\tif (master_configuration.active_node and configuration.active_node and \n\t\t\t\tScanner.ScannerRun.objects.filter(enabled=True).count() >0):\n\t\t\t\t\"\"\"Any enabled Scanner jobs?\"\"\"\n\t\t\t\tdone_something = True\n\t\t\t\tif master_configuration.active_node and configuration.active_node:\n\t\t\t\t\tif not options.nogit:\n\t\t\t\t\t\t\"\"\"Check out code to be used\"\"\"\n\t\t\t\t\t\tsubprocess.call([\"git\", \"pull\",])\n\t\t\t\t\t\tsubprocess.call([\"git\", \"submodule\", \"update\", \"--recursive\"])\n\t\t\t\t\t\t\n\t\t\t\t\t\tmaster_branch = \"pincushion\" if options.use_testbase2 else \"master\"\n\t\t\t\t\t\t\t\n\t\t\t\t\t\trun = Scanner.ScannerRun.objects.filter(enabled=True).order_by(\"-priority\", \"entered_date\")[0]\n\t\t\t\t\t\tbranch = run.branch\n\t\t\t\t\t\tsubprocess.call([\"git\", \"checkout\", branch if branch else master_branch])\n\t\t\t\t\t\tsubprocess.call([\"git\", \"submodule\", \"update\", \"--recursive\"])\n\t\t\t\t\t\t\n\t\t\t\t\ttry:\n\t\t\t\t\t\tconnection.close()\n\t\t\t\t\texcept:\n\t\t\t\t\t\tpass\n\t\t\t\t\t\"\"\"Start the scanner on this node for the job\"\"\"\n\t\t\t\t\tsubprocess.call([\"python\", \"-O\", \n\t\t\t\t\t\t\t\t\t\t\"scan_start.py\",\n\t\t\t\t\t\t\t\t\t\t\t\"--performance\",\n\t\t\t\t\t\t\t\t\t\t\t\"--managed\"]\n\t\t\t\t\t\t\t\t\t\t+ ([\"--testbase2\"] if options.use_testbase2 else [])\n\t\t\t\t\t\t\t\t\t\t+ ([\"--verbose\"] if options.verbose else [])\n\t\t\t\t\t\t\t\t\t, cwd = \"scan\"\n\t\t\t\t\t\t\t\t\t, shell=False)\n\t\t\t\telse:\n\t\t\t\t\ttry:\n\t\t\t\t\t\tconnection.close()\n\t\t\t\t\texcept:\n\t\t\t\t\t\tpass\n\t\t\t\t\ttime.sleep(30)\n\t\t\t\n\t\tif not done_something :\n\t\t\tif not options.persistent:\t\n\t\t\t\tbreak; # exit if nothing is going on, wait 20 minutes, then recheck\n\t\t\ttry:\n\t\t\t\tconnection.close()\n\t\t\texcept:\n\t\t\t\tpass\n\t\t\ttime.sleep(10*60) # if there are no runs, sleep for 10 minutes", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 23 } ]
[ { "span": "except:", "start_line": 78, "start_column": 4, "end_line": 78, "end_column": 11 }, { "span": "except:", "start_line": 91, "start_column": 4, "end_line": 91, "end_column": 11 }, { "span": "except:", "start_line": 125, "start_column": 5, "end_line": 125, "end_column": 12 }, { "span": "except:", "start_line": 139, "start_column": 5, "end_line": 139, "end_column": 12 }, { "span": "except:", "start_line": 148, "start_column": 3, "end_line": 148, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "transaction_", "._", "commit", "\\u", "manu", "ally", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\"\"\"", "Main", " ", "manage", "ment", " ", "handler", " ", "on", " ", "each", " ", "cluster", ",", " ", "checks", " ", "every", " ", "10", " ", "minute", "s", " ", "for", " ", "new", " ", "task", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "computer", "name_", "=_", "os_", "._", "environ_", "._", "get_", "(_", "'", "COMPUTE", "RNA", "ME", "'_", ",_", "\"", "any", "\"_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "computer", "name_", "==_", "\"", "any", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "computer", "name_", "=_", "os_", "._", "environ_", "._", "get_", "(_", "'", "HOSTNAME", "'_", ",_", "\"", "any", "\"_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "computer", "name_", "==_", "\"", "any", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "raise_", "Exception_", "(_", "\"", "Compute", "rnam", "e", " ", "was", " ", "empty", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "computer", "name_", "=_", "computer", "name_", "._", "partition_", "(_", "'.'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "options", "\\u", "config_", "=_", "Optio", "n", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "options", "\\u", "config_", "._", "add", "\\u", "option_", "(_", "\"--", "testb", "ase", "2", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "dest_", "=_", "\"", "use", "\\u", "testb", "ase", "2", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options", "\\u", "config_", "._", "add", "\\u", "option_", "(_", "\"--", "verbo", "se", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "dest_", "=_", "\"", "verbo", "se", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options", "\\u", "config_", "._", "add", "\\u", "option_", "(_", "\"--", "persiste", "nt", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "dest_", "=_", "\"", "persiste", "nt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options", "\\u", "config_", "._", "add", "\\u", "option_", "(_", "\"--", "nog", "it", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "dest_", "=_", "\"", "nog", "it", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "options_", ",_", "args_", ")_", "=_", "options", "\\u", "config_", "._", "parse", "\\u", "args_", "(_", ")_", "\\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\t", "\t_", "master", "\\u", "configuration_", ",_", "created_", "=_", "Cluster_", "._", "Cluster", "Node_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "hostname_", "=_", "\"", "tls", "prob", "er", "-", "cluster", "\"_", ",_", "defaults_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "prob", "e\\u", "parameter", "s", "\"_", ":_", "\"", "not", " ", "used", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "result", "\\u", "parameter", "s", "\":\"", "not", " ", "used", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "active", "\\u", "node", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "configuration_", ",_", "created_", "=_", "Cluster_", "._", "Cluster", "Node_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "hostname_", "=_", "computer", "name_", ",_", "defaults_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "prob", "e\\u", "parameter", "s", "\"_", ":_", "\"--", "process", "es", " ", "40", " ", "--", "iterati", "ons", " ", "40", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "result", "\\u", "parameter", "s", "\":\"", "--", "process", "es", " ", "10", " ", "--", "iterati", "ons", " ", "100", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "active", "\\u", "node", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "configuration_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "transaction_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "don", "e\\u", "something_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Cluster_", "._", "Cluster", "Run_", "._", "objects_", "._", "filter_", "(_", "enabled_", "=_", "True_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "\"\"\"", "Any", " ", "enable", "d", " ", "TLS", " ", "Probe", "r", " ", "jobs", "?\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "don", "e\\u", "something_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "master", "\\u", "configuration_", "._", "active", "\\u", "node_", "and_", "configuration_", "._", "active", "\\u", "node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "not_", "options_", "._", "nog", "it_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "\"\"\"", "Check", " ", "out", " ", "the", " ", "code", " ", "to", " ", "be", " ", "used", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "pull", "\"_", ",_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "submodule", "\"_", ",_", "\"", "update", "\"_", ",_", "\"--", "recurs", "ive", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master", "\\u", "branch_", "=_", "\"", "pin", "cus", "hio", "n", "\"_", "if_", "options_", "._", "use", "\\u", "testb", "ase", "2_", "else_", "\"", "master", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "run_", "=_", "Cluster_", "._", "Cluster", "Run_", "._", "objects_", "._", "filter_", "(_", "enabled_", "=_", "True_", ")_", "._", "order", "\\u", "by_", "(_", "\"-", "priorit", "y", "\"_", ",_", "\"", "enter", "ed", "\\u", "date", "\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "branch_", "=_", "run_", "._", "perform", "\\u", "run_", "._", "branch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "check", "out", "\"_", ",_", "branch_", "if_", "branch_", "else_", "master", "\\u", "branch_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "submodule", "\"_", ",_", "\"", "update", "\"_", ",_", "\"--", "recurs", "ive", "\"_", "]_", ")_", "\\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\t", "\t\t\t\t_", "connection_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "Start", " ", "the", " ", "prob", "er", " ", "on", " ", "this", " ", "cluster", " ", "node", " ", "for", " ", "the", " ", "job", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "python", "\"_", ",_", "\"-", "O", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "cluster", "\\u", "start", ".", "py", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", "perform", "anc", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", "manage", "d", "\"_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "(_", "[_", "\"--", "testb", "ase", "2", "\"_", "]_", "if_", "options_", "._", "use", "\\u", "testb", "ase", "2_", "else_", "[_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "(_", "[_", "\"--", "verbo", "se", "\"_", "]_", "if_", "options_", "._", "verbose_", "else_", "[_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "shell_", "=_", "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\t", "\t\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "connection_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "30_", ")_", "\\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\t", "\t\t_", "master", "\\u", "configuration_", ",_", "created_", "=_", "Scanner_", "._", "Scann", "er", "Node_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "hostname_", "=_", "\"", "tls", "prob", "er", "-", "cluster", "\"_", ",_", "defaults_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "scan", "\\u", "parameter", "s", "\"_", ":_", "\"", "not", " ", "used", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "active", "\\u", "node", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "configuration_", ",_", "created_", "=_", "Scanner_", "._", "Scann", "er", "Node_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "hostname_", "=_", "computer", "name_", ",_", "defaults_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "scan", "\\u", "parameter", "s", "\"_", ":_", "\"--", "process", "es", " ", "40", " ", "--", "iterati", "ons", " ", "40", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "active", "\\u", "node", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "configuration_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "transaction_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "master", "\\u", "configuration_", "._", "active", "\\u", "node_", "and_", "configuration_", "._", "active", "\\u", "node_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "Scanner_", "._", "Scann", "er", "Run_", "._", "objects_", "._", "filter_", "(_", "enabled_", "=_", "True_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "\"\"\"", "Any", " ", "enable", "d", " ", "Scann", "er", " ", "jobs", "?\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "don", "e\\u", "something_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "master", "\\u", "configuration_", "._", "active", "\\u", "node_", "and_", "configuration_", "._", "active", "\\u", "node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "if_", "not_", "options_", "._", "nog", "it_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "\"\"\"", "Check", " ", "out", " ", "code", " ", "to", " ", "be", " ", "used", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "pull", "\"_", ",_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "submodule", "\"_", ",_", "\"", "update", "\"_", ",_", "\"--", "recurs", "ive", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master", "\\u", "branch_", "=_", "\"", "pin", "cus", "hio", "n", "\"_", "if_", "options_", "._", "use", "\\u", "testb", "ase", "2_", "else_", "\"", "master", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "run_", "=_", "Scanner_", "._", "Scann", "er", "Run_", "._", "objects_", "._", "filter_", "(_", "enabled_", "=_", "True_", ")_", "._", "order", "\\u", "by_", "(_", "\"-", "priorit", "y", "\"_", ",_", "\"", "enter", "ed", "\\u", "date", "\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "branch_", "=_", "run_", "._", "branch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "check", "out", "\"_", ",_", "branch_", "if_", "branch_", "else_", "master", "\\u", "branch_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "git", "\"_", ",_", "\"", "submodule", "\"_", ",_", "\"", "update", "\"_", ",_", "\"--", "recurs", "ive", "\"_", "]_", ")_", "\\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\t", "\t\t\t\t\t_", "connection_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "Start", " ", "the", " ", "scanner", " ", "on", " ", "this", " ", "node", " ", "for", " ", "the", " ", "job", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "\"", "python", "\"_", ",_", "\"-", "O", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "scan", "\\u", "start", ".", "py", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", "perform", "anc", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", "manage", "d", "\"_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "(_", "[_", "\"--", "testb", "ase", "2", "\"_", "]_", "if_", "options_", "._", "use", "\\u", "testb", "ase", "2_", "else_", "[_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "(_", "[_", "\"--", "verbo", "se", "\"_", "]_", "if_", "options_", "._", "verbose_", "else_", "[_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "cwd_", "=_", "\"", "scan", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "shell_", "=_", "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\t", "\t\t\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "connection_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "30_", ")_", "\\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_", "not_", "don", "e\\u", "something_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "not_", "options_", "._", "persistent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "break_", ";_", "#", " ", "exit", " ", "if", " ", "not", "hing", " ", "is", " ", "goi", "ng", " ", "on", ",", " ", "wait", " ", "20", " ", "minute", "s", ",", " ", "then", " ", "rech", "eck", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "connection_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "10_", "*_", "60_", ")_", "#", " ", "if", " ", "there", " ", "are", " ", "no", " ", "runs", ",", " ", "sleep", " ", "for", " ", "10", " ", "minutes_", "\\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,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1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Incomplete ordering
quantmind/pulsar/pulsar/apps/ds/utils.py
[ { "content": "class Null:\n __slots__ = ()\n", "metadata": "root.Null", "header": "['module', '___EOS___']", "index": 135 }, { "content": " def __lt__(self, other):\n return False", "metadata": "root.Null.__lt__", "header": "['class', 'Null', ':', '___EOS___']", "index": 138 }, { "content": "class Sortable:\n __slots__ = ('value',)\n\n", "metadata": "root.Sortable", "header": "['module', '___EOS___']", "index": 144 }, { "content": " def __init__(self, value):\n self.value = value", "metadata": "root.Sortable.__init__", "header": "['class', 'Sortable', ':', '___EOS___']", "index": 147 }, { "content": " def __lt__(self, other):\n if other is null:\n return True\n else:\n return self.value < other.value", "metadata": "root.Sortable.__lt__", "header": "['class', 'Sortable', ':', '___EOS___']", "index": 150 }, { "content": "class SortableDesc:\n __slots__ = ('value',)\n\n", "metadata": "root.SortableDesc", "header": "['module', '___EOS___']", "index": 157 }, { "content": " def __init__(self, value):\n self.value = value", "metadata": "root.SortableDesc.__init__", "header": "['class', 'SortableDesc', ':', '___EOS___']", "index": 160 }, { "content": " def __lt__(self, other):\n if other is null:\n return True\n else:\n return self.value > other.value", "metadata": "root.SortableDesc.__lt__", "header": "['class', 'SortableDesc', ':', '___EOS___']", "index": 163 } ]
[ { "span": "class Null:", "start_line": 135, "start_column": 0, "end_line": 135, "end_column": 11 }, { "span": "class Sortable:", "start_line": 144, "start_column": 0, "end_line": 144, "end_column": 15 }, { "span": "class SortableDesc:", "start_line": 157, "start_column": 0, "end_line": 157, "end_column": 19 } ]
[ { "span": "def __lt__(self, other):", "start_line": 138, "start_column": 4, "end_line": 138, "end_column": 28 }, { "span": "def __lt__(self, other):", "start_line": 150, "start_column": 4, "end_line": 150, "end_column": 28 }, { "span": "def __lt__(self, other):", "start_line": 163, "start_column": 4, "end_line": 163, "end_column": 28 } ]
1
false
[ "[CLS]_", "Incomp", "lete", "_", "ordering_", "[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_", "Null_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Null_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "lt\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Sort", "able_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", "'", "value", "'_", ",_", ")_", "\\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_", "Sort", "able_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\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_", "Sort", "able_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "lt\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "other_", "is_", "null_", ":_", "\\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_", "self_", "._", "value_", "<_", "other_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Sort", "able", "Desc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", "'", "value", "'_", ",_", ")_", "\\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_", "Sort", "able", "Desc_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\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_", "Sort", "able", "Desc_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "lt\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "other_", "is_", "null_", ":_", "\\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_", "self_", "._", "value_", ">_", "other_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 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, 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, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 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, 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, 2, 2, 2, 2 ]
Unused import
Futubank/django-futupayments/futupayments/migrations/0001_initial.py
[ { "content": "# -*- coding: utf-8 -*-\nfrom south.utils import datetime_utils as datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration(SchemaMigration):\n\n\n\n\n\n models = {\n 'futupayments.payment': {\n 'Meta': {'ordering': \"('-creation_datetime',)\", 'unique_together': \"(('state', 'transaction_id'),)\", 'object_name': 'Payment'},\n 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '2'}),\n 'creation_datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'currency': ('django.db.models.fields.CharField', [], {'max_length': '3'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'message': ('django.db.models.fields.TextField', [], {'blank': 'True'}),\n 'meta': ('django.db.models.fields.TextField', [], {'blank': 'True'}),\n 'order_id': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\n 'state': ('django.db.models.fields.CharField', [], {'max_length': '10'}),\n 'transaction_id': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True'})\n }\n }\n\n complete_apps = ['futupayments']", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 7 }, { "content": " def forwards(self, orm):\n # Adding model 'Payment'\n db.create_table('futupayments_payment', (\n ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\n ('creation_datetime', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),\n ('transaction_id', self.gf('django.db.models.fields.BigIntegerField')(db_index=True)),\n ('amount', self.gf('django.db.models.fields.DecimalField')(max_digits=10, decimal_places=2)),\n ('currency', self.gf('django.db.models.fields.CharField')(max_length=3)),\n ('order_id', self.gf('django.db.models.fields.CharField')(max_length=128)),\n ('state', self.gf('django.db.models.fields.CharField')(max_length=10)),\n ('message', self.gf('django.db.models.fields.TextField')(blank=True)),\n ('meta', self.gf('django.db.models.fields.TextField')(blank=True)),\n ))\n db.send_create_signal('futupayments', ['Payment'])\n\n # Adding unique constraint on 'Payment', fields ['state', 'transaction_id']\n db.create_unique('futupayments_payment', ['state', 'transaction_id'])", "metadata": "root.Migration.forwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 9 }, { "content": " def backwards(self, orm):\n # Removing unique constraint on 'Payment', fields ['state', 'transaction_id']\n db.delete_unique('futupayments_payment', ['state', 'transaction_id'])\n\n # Deleting model 'Payment'\n db.delete_table('futupayments_payment')", "metadata": "root.Migration.backwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 28 } ]
[ { "span": "from south.utils import datetime_utils as datetime", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 50 }, { "span": "from django.db import models", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "south_", "._", "utils_", "import_", "datetime", "\\u", "utils_", "as_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "db_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "v2_", "import_", "Schema", "Migration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "models_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fut", "upa", "yme", "nts", ".", "pay", "ment", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'-", "creati", "on", "\\u", "datetime", "',)\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "state", "',", " ", "'", "transaction", "\\u", "id", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Payment", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "amo", "unt", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Deci", "mal", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "digit", "s", "'_", ":_", "'", "10", "'_", ",_", "'", "decima", "l\\u", "place", "s", "'_", ":_", "'", "2", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "creati", "on", "\\u", "datetime", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "auto", "\\u", "now", "\\u", "add", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "curr", "ency", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "3", "'_", "}_", ")_", ",_", "\\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_", "'", "message", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "meta", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "order", "\\u", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "128", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "state", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "10", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "transaction", "\\u", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Big", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "apps_", "=_", "[_", "'", "fut", "upa", "yme", "nts", "'_", "]_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "forwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", "ing", " ", "model", " ", "'", "Payment", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "create", "\\u", "table_", "(_", "'", "fut", "upa", "yme", "nts", "\\u", "pay", "ment", "'_", ",_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ")_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "creati", "on", "\\u", "datetime", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ")_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "transaction", "\\u", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Big", "Integer", "Field", "'_", ")_", "(_", "db", "\\u", "index_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "amo", "unt", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Deci", "mal", "Field", "'_", ")_", "(_", "max", "\\u", "digits_", "=_", "10_", ",_", "decima", "l\\u", "places_", "=_", "2_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "curr", "ency", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "max", "\\u", "length_", "=_", "3_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "order", "\\u", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "max", "\\u", "length_", "=_", "128_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "state", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "max", "\\u", "length_", "=_", "10_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "message", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ")_", "(_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "meta", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ")_", "(_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "send", "\\u", "create", "\\u", "signal_", "(_", "'", "fut", "upa", "yme", "nts", "'_", ",_", "[_", "'", "Payment", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", "ing", " ", "unique", " ", "constraint", " ", "on", " ", "'", "Payment", "',", " ", "fields", " ", "['", "state", "',", " ", "'", "transaction", "\\u", "id", "']", "_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "create", "\\u", "unique_", "(_", "'", "fut", "upa", "yme", "nts", "\\u", "pay", "ment", "'_", ",_", "[_", "'", "state", "'_", ",_", "'", "transaction", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "backwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remo", "ving", " ", "unique", " ", "constraint", " ", "on", " ", "'", "Payment", "',", " ", "fields", " ", "['", "state", "',", " ", "'", "transaction", "\\u", "id", "']", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "delete", "\\u", "unique_", "(_", "'", "fut", "upa", "yme", "nts", "\\u", "pay", "ment", "'_", ",_", "[_", "'", "state", "'_", ",_", "'", "transaction", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\u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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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
StartTheShift/thunderdome/thunderdome/tests/model/test_class_construction.py
[ { "content": " def test_attempting_to_make_duplicate_column_names_fails(self):\n \"\"\"\n Tests that trying to create conflicting db column names will fail\n \"\"\"\n\n with self.assertRaises(ModelException):\n class BadNames(Vertex):\n words = properties.Text()\n content = properties.Text(db_field='words')", "metadata": "root.TestModelClassFunction.test_attempting_to_make_duplicate_column_names_fails", "header": "['class', 'TestModelClassFunction', '(', 'BaseThunderdomeTestCase', ')', ':', '___EOS___']", "index": 69 }, { "content": " def validate_num(self, value):\n val = self.validate_field('num', value)\n return 5", "metadata": "root.TestValidationVertex.validate_num", "header": "['class', 'TestValidationVertex', '(', 'Vertex', ')', ':', '___EOS___']", "index": 131 } ]
[ { "span": "BadNames(", "start_line": 75, "start_column": 18, "end_line": 75, "end_column": 26 }, { "span": "val ", "start_line": 132, "start_column": 8, "end_line": 132, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Model", "Class", "Function_", "(_", "Base", "Thu", "nder", "dome", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "atte", "mpt", "ing", "\\u", "to", "\\u", "make", "\\u", "duplicat", "e\\u", "column", "\\u", "names", "\\u", "fails_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "try", "ing", " ", "to", " ", "create", " ", "conflicting", " ", "db", " ", "column", " ", "names", " ", "will", " ", "fail", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Model", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Ba", "d", "Names_", "(_", "Vertex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "words_", "=_", "properties_", "._", "Text_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "properties_", "._", "Text_", "(_", "db", "\\u", "field_", "=_", "'", "words", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Validat", "ion", "Vertex_", "(_", "Vertex_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "validat", "e\\u", "num_", "(_", "self_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "val_", "=_", "self_", "._", "validat", "e\\u", "field_", "(_", "'", "num", "'_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 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 ]
Unused import
zorna/zorna/zorna/__init__.py
[ { "content": "# Copyright (c) 2010, AFRAZ ( http://www.afraz.fr )\n# All rights reserved.\n\nVERSION = (1, 1, 8, \"final\", 0)\n\nfrom django.contrib.auth.models import User, Group\nfrom django.contrib.sites.models import Site\nimport mptt\n\nfrom django.db.models.signals import post_save, post_delete\nimport settings\n\nfrom zorna.account.models import UserProfile\n\n\n\n\npost_save.connect(user_post_save, sender=User)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_version():\n version = '%s.%s' % (VERSION[0], VERSION[1])\n if VERSION[2]:\n version = '%s.%s' % (version, VERSION[2])\n if VERSION[3:] == ('alpha', 0):\n version = '%s pre-alpha' % version\n else:\n if VERSION[3] != 'final':\n version = '%s %s %s' % (version, VERSION[3], VERSION[4])\n return version", "metadata": "root.get_version", "header": "['module', '___EOS___']", "index": 14 }, { "content": "def user_post_save(sender, **kwargs):\n instance = kwargs['instance']\n if kwargs['created'] == True:\n try:\n instance.get_profile()\n except UserProfile.DoesNotExist:\n UserProfile.objects.create_user_profile(instance, {}, True)", "metadata": "root.user_post_save", "header": "['module', '___EOS___']", "index": 26 } ]
[ { "span": "from django.contrib.auth.models import User, Group", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 50 }, { "span": "from django.contrib.sites.models import Site", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 44 }, { "span": "import mptt", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 11 }, { "span": "from django.db.models.signals import post_save, post_delete", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 59 }, { "span": "import settings", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 15 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2010", ",", " ", "AF", "RA", "Z", " ", "(", " ", "http", "://", "www", ".", "afr", "az", ".", "fr", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "VERSION_", "=_", "(_", "1_", ",_", "1_", ",_", "8_", ",_", "\"", "final", "\"_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", ",_", "Group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "sites_", "._", "models_", "import_", "Site_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "mpt", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "signals_", "import_", "post", "\\u", "save_", ",_", "post", "\\u", "delete_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "zor", "na_", "._", "account_", "._", "models_", "import_", "User", "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\\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_", "post", "\\u", "save_", "._", "connect_", "(_", "user", "\\u", "post", "\\u", "save_", ",_", "sender_", "=_", "User_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "version_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "'%", "s", ".", "%", "s", "'_", "%_", "(_", "VERSION_", "[_", "0_", "]_", ",_", "VERSION_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "VERSION_", "[_", "2_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "'%", "s", ".", "%", "s", "'_", "%_", "(_", "version_", ",_", "VERSION_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "VERSION_", "[_", "3_", ":_", "]_", "==_", "(_", "'", "alpha", "'_", ",_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "'%", "s", " ", "pre", "-", "alpha", "'_", "%_", "version_", "\\u\\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_", "VERSION_", "[_", "3_", "]_", "!=_", "'", "final", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "'%", "s", " ", "%", "s", " ", "%", "s", "'_", "%_", "(_", "version_", ",_", "VERSION_", "[_", "3_", "]_", ",_", "VERSION_", "[_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "user", "\\u", "post", "\\u", "save_", "(_", "sender_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "=_", "kwargs_", "[_", "'", "instance", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "kwargs_", "[_", "'", "created", "'_", "]_", "==_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "get", "\\u", "profile_", "(_", ")_", "\\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 ", " _", "User", "Profile_", "._", "objects_", "._", "create", "\\u", "user", "\\u", "profile_", "(_", "instance_", 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
neuropoly/spinalcordtoolbox/dev/sct_dmri_moco__old.py
[ { "content": "def main():\n\n # get path of the toolbox\n status, path_sct = commands.getstatusoutput('echo $SCT_DIR')\n print path_sct\n\n # Initialization\n fsloutput = 'export FSLOUTPUTTYPE=NIFTI; ' # for faster processing, all outputs are in NIFTI\n fname_data = ''\n fname_bvecs = ''\n fname_schedule = path_sct+'/flirtsch/schedule_TxTy.sch'\n interp = param.interp\n remove_temp_files = param.remove_temp_files\n verbose = param.verbose\n start_time = time.time()\n\n # Parameters for debug mode\n if param.debug:\n fname_data = path_sct+'/testing/data/errsm_23/dmri/dmri.nii.gz'\n fname_bvecs = path_sct+'/testing/data/errsm_23/dmri/bvecs.txt'\n interp = 'trilinear'\n remove_temp_files = 0\n verbose = 1\n\n # Check input parameters\n try:\n opts, args = getopt.getopt(sys.argv[1:],'hb:i:v:s:')\n except getopt.GetoptError:\n usage()\n for opt, arg in opts:\n if opt == '-h':\n usage()\n elif opt in (\"-b\"):\n fname_bvecs = arg\n elif opt in (\"-i\"):\n fname_data = arg\n elif opt in ('-s'):\n interp = str(arg)\n elif opt in ('-v'):\n verbose = int(arg)\n\n # display usage if a mandatory argument is not provided\n if fname_data == '' or fname_bvecs == '':\n usage()\n\n # check existence of input files\n sct.check_file_exist(fname_data)\n sct.check_file_exist(fname_bvecs)\n\n # print arguments\n print '\\nCheck parameters:'\n print '.. DWI data: '+fname_data\n print '.. bvecs file: '+fname_bvecs\n print ''\n\n # Get full path\n fname_data = os.path.abspath(fname_data)\n fname_bvecs = os.path.abspath(fname_bvecs)\n\n # Extract path, file and extension\n path_data, file_data, ext_data = sct.extract_fname(fname_data)\n\n # create temporary folder\n path_tmp = 'tmp.'+time.strftime(\"%y%m%d%H%M%S\")\n sct.run('mkdir '+path_tmp)\n\n # go to tmp folder\n os.chdir(path_tmp)\n\n # Get size of data\n print '\\nGet dimensions data...'\n nx, ny, nz, nt, px, py, pz, pt = sct.get_dimension(fname_data)\n print '.. '+str(nx)+' x '+str(ny)+' x '+str(nz)+' x '+str(nt)\n\n # Open bvecs file\n print '\\nOpen bvecs file...'\n bvecs = []\n with open(fname_bvecs) as f:\n for line in f:\n bvecs_new = map(float, line.split())\n bvecs.append(bvecs_new)\n\n # Check if bvecs file is nx3\n if not len(bvecs[0][:]) == 3:\n print '.. WARNING: bvecs file is 3xn instead of nx3. Consider using sct_dmri_transpose_bvecs.'\n print 'Transpose bvecs...'\n # transpose bvecs\n bvecs = zip(*bvecs)\n\n # Identify b=0 and DW images\n print '\\nIdentify b=0 and DW images...'\n index_b0 = []\n index_dwi = []\n for it in xrange(0,nt):\n if math.sqrt(math.fsum([i**2 for i in bvecs[it]])) < 0.01:\n index_b0.append(it)\n else:\n index_dwi.append(it)\n n_b0 = len(index_b0)\n n_dwi = len(index_dwi)\n print '.. Index of b=0:'+str(index_b0)\n print '.. Index of DWI:'+str(index_dwi)\n\n #TODO: check if number of bvecs and nt match\n\n # Split into T dimension\n print '\\nSplit along T dimension...'\n #cmd = fsloutput+'fslsplit tmp.data tmp.data_splitT'\n status, output = sct.run(fsloutput+'fslsplit '+fname_data+' tmp.data_splitT')\n\n # retrieve output names\n status, output = sct.run('ls tmp.data_splitT*.*')\n file_data_split = output.split()\n # Remove .nii extension\n file_data_split = [file_data_split[i].replace('.nii','') for i in xrange (0,len(file_data_split))]\n\n # Merge b=0 images\n print '\\nMerge b=0...'\n file_b0 = 'tmp.b0'\n cmd = fsloutput+'fslmerge -t '+file_b0\n for it in xrange(0,n_b0):\n cmd += ' '+file_data_split[index_b0[it]]\n #print('>> '+cmd)\n status, output = sct.run(cmd)\n\n # Merge DWI images\n print '\\nMerge DWI...'\n file_dwi = 'tmp.dwi'\n cmd = fsloutput+'fslmerge -t '+file_dwi\n for it in xrange(0,n_dwi):\n cmd += ' '+file_data_split[index_dwi[it]]\n status, output = sct.run(cmd)\n\n # Average b=0 images\n print '\\nAverage b=0...'\n file_b0_mean = 'tmp.b0_mean'\n cmd = fsloutput+'fslmaths '+file_b0+' -Tmean '+file_b0_mean\n status, output = sct.run(cmd)\n\n # Average DWI images\n print '\\nAverage DWI...'\n file_dwi_mean = 'tmp.dwi_mean'\n cmd = fsloutput+'fslmaths '+file_dwi+' -Tmean '+file_dwi_mean\n status, output = sct.run(cmd)\n\n\n\n # REGISTER DWI TO THE MEAN DWI --> output transfo Tdwi\n # ---------------------------------------------------------------------------------------\n\n # loop across DWI data\n print '\\nRegister DWI data to '+file_dwi_mean+'...'\n for it in xrange(0,n_dwi):\n # estimate transformation matrix\n file_target = file_dwi_mean\n file_mat = 'tmp.mat_'+str(index_dwi[it]).zfill(4)\n cmd = fsloutput+'flirt -in '+file_data_split[index_dwi[it]]+' -ref '+file_target+' -omat '+file_mat+' -cost normcorr -schedule '+fname_schedule+' -interp trilinear -out '+file_data_split[index_dwi[it]]+'_moco'\n status, output = sct.run(cmd)\n\n # Merge corrected DWI images\n print '\\nMerge corrected DWI...'\n file_dwi = 'tmp.dwi_moco'\n cmd = fsloutput+'fslmerge -t '+file_dwi\n for it in xrange(0,n_dwi):\n cmd += ' '+file_data_split[index_dwi[it]]+'_moco'\n status, output = sct.run(cmd)\n\n # Average corrected DWI\n print '\\nAverage corrected DWI...'\n file_dwi_mean = 'tmp.dwi_moco_mean'\n cmd = fsloutput+'fslmaths '+file_dwi+' -Tmean '+file_dwi_mean\n status, output = sct.run(cmd)\n\n\n # REGISTER B=0 DATA TO THE FIRST B=0 --> output transfo Tb0\n # ---------------------------------------------------------------------------------------\n print '\\nRegister b=0 data to the first b=0...'\n for it in xrange(0,n_b0):\n # estimate transformation matrix\n file_target = file_data_split[int(index_b0[0])]\n file_mat = 'tmp.mat_'+str(index_b0[it]).zfill(4)\n cmd = fsloutput+'flirt -in '+file_data_split[index_b0[it]]+' -ref '+file_target+' -omat '+file_mat+' -cost normcorr -forcescaling -2D -out '+file_data_split[index_b0[it]]+'_moco'\n status, output = sct.run(cmd)\n\n # Merge corrected b=0 images\n print '\\nMerge corrected b=0...'\n cmd = fsloutput+'fslmerge -t tmp.b0_moco'\n for it in xrange(0,n_b0):\n cmd += ' '+file_data_split[index_b0[it]]+'_moco'\n status, output = sct.run(cmd)\n\n # Average corrected b=0\n print '\\nAverage corrected b=0...'\n cmd = fsloutput+'fslmaths tmp.b0_moco -Tmean tmp.b0_moco_mean'\n status, output = sct.run(cmd)\n\n\n # REGISTER MEAN DWI TO THE MEAN B=0 --> output transfo Tdwi2b0\n # ---------------------------------------------------------------------------------------\n print '\\nRegister mean DWI to the mean b=0...'\n cmd = fsloutput+'flirt -in tmp.dwi_moco_mean -ref tmp.b0_moco_mean -omat tmp.mat_dwi2b0 -cost mutualinfo -forcescaling -dof 12 -2D -out tmp.dwi_mean_moco_reg2b0'\n status, output = sct.run(cmd)\n\n\n # COMBINE TRANSFORMATIONS\n # ---------------------------------------------------------------------------------------\n print '\\nCombine all transformations...'\n # USE FSL convert_xfm: convert_xfm -omat AtoC.mat -concat BtoC.mat AtoB.mat\n # For DWI\n print '\\n.. For DWI:'\n for it in xrange(0,n_dwi):\n cmd = 'convert_xfm -omat tmp.mat_final_'+str(index_dwi[it]).zfill(4)+' -concat tmp.mat_dwi2b0 tmp.mat_'+str(index_dwi[it]).zfill(4)\n status, output = sct.run(cmd)\n # For b=0 (don't concat because there is just one mat file -- just rename it)\n print '\\n.. For b=0:'\n for it in xrange(0,n_b0):\n cmd = 'cp tmp.mat_'+str(index_b0[it]).zfill(4)+' tmp.mat_final_'+str(index_b0[it]).zfill(4)\n status, output = sct.run(cmd)\n\n\n # APPLY TRANSFORMATIONS\n # ---------------------------------------------------------------------------------------\n ## Split original data into T dimension\n #print '\\nSplit original data along T dimension...'\n #cmd = fsloutput+'fslsplit '+fname_data+' tmp.data_raw_splitT'\n #print('>> '+cmd)\n #status, output = commands.getstatusoutput(cmd)\n\n #print '\\nApply transformations to original data...'\n #for it in xrange(0,nt):\n # cmd = fsloutput+'flirt -in tmp.data_raw_splitT'+str(it).zfill(4)+' -ref tmp.data_raw_splitT'+index_b0[0].zfill(4)+' -applyxfm -init tmp.mat_final_'+str(it).zfill(4)+' -out tmp.data_raw_splitT'+str(it).zfill(4)+'_moco'\n # print('>> '+cmd)\n # status, output = commands.getstatusoutput(cmd)\n #\n ## Merge corrected data\n #print '\\nMerge corrected data...'\n #cmd = fsloutput+'fslmerge -t tmp.data_raw_moco'\n #for it in xrange(0,it):\n # cmd += ' tmp.data_raw_splitT'+str(it).zfill(4)+'_moco'\n #print('>> '+cmd)\n #status, output = commands.getstatusoutput(cmd)\n\n print '\\nApply transformations...'\n for it in xrange(0,nt):\n # -paddingsize 3 prevents from having missing slices at the edge\n cmd = fsloutput+'flirt -in tmp.data_splitT'+str(it).zfill(4)+' -ref tmp.data_splitT'+str(index_b0[0]).zfill(4)+' -applyxfm -init tmp.mat_final_'+str(it).zfill(4)+' -out tmp.data_splitT'+str(it).zfill(4)+'_moco -paddingsize 3'+' -interp '+interp\n status, output = sct.run(cmd)\n\n # Merge corrected data\n print '\\nMerge all corrected data...'\n cmd = fsloutput+'fslmerge -t tmp.data_moco'\n for it in xrange(0,nt):\n cmd += ' tmp.data_splitT'+str(it).zfill(4)+'_moco'\n status, output = sct.run(cmd)\n\n # Merge corrected DWI images\n print '\\nMerge corrected DWI...'\n cmd = fsloutput+'fslmerge -t tmp.dwi_moco'\n for it in xrange(0,n_dwi):\n cmd += ' tmp.data_splitT'+str(index_dwi[it]).zfill(4)+'_moco'\n status, output = sct.run(cmd)\n\n # Average corrected DWI\n print '\\nAverage corrected DWI...'\n cmd = fsloutput+'fslmaths tmp.dwi_moco -Tmean tmp.dwi_moco_mean'\n status, output = sct.run(cmd)\n\n # Merge corrected b=0 images\n print '\\nMerge corrected b=0...'\n cmd = fsloutput+'fslmerge -t tmp.b0_moco'\n for it in xrange(0,n_b0):\n cmd += ' tmp.data_splitT'+str(index_b0[it]).zfill(4)+'_moco'\n status, output = sct.run(cmd)\n\n # Average corrected b=0\n print '\\nAverage corrected b=0...'\n cmd = fsloutput+'fslmaths tmp.b0_moco -Tmean tmp.b0_moco_mean'\n status, output = sct.run(cmd)\n\n # Generate output files\n print('\\nGenerate output files...')\n sct.generate_output_file('tmp.data_moco.nii',path_data,file_data+'_moco',ext_data)\n sct.generate_output_file('tmp.dwi_moco_mean.nii',path_data,'dwi_moco_mean',ext_data)\n sct.generate_output_file('tmp.b0_moco_mean.nii',path_data,'b0_moco_mean',ext_data)\n\n # come back to parent folder\n os.chdir('..')\n\n # Delete temporary files\n if remove_temp_files == 1:\n print '\\nDelete temporary files...'\n sct.run('rm -rf '+path_tmp)\n\n # display elapsed time\n elapsed_time = time.time() - start_time\n print '\\nFinished! Elapsed time: '+str(int(round(elapsed_time)))+'s'\n\n # to view results\n print '\\nTo view results, type:'\n print 'fslview '+file_data+' '+file_data+'_moco &\\n'", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 47 } ]
[ { "span": "verbose ", "start_line": 86, "start_column": 12, "end_line": 86, "end_column": 19 }, { "span": "status,", "start_line": 324, "start_column": 4, "end_line": 324, "end_column": 10 }, { "span": "output ", "start_line": 324, "start_column": 12, "end_line": 324, "end_column": 18 } ]
[]
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_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "path", " ", "of", " ", "the", " ", "toolbox_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", ",_", "path", "\\u", "sct", "_", "=_", "commands_", "._", "getstatus", "output_", "(_", "'", "echo", " ", "$", "SC", "T", "\\u", "DIR", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "path", "\\u", "sct", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initializ", "ation_", "\\u\\u\\uNL\\u\\u\\u_", "fs", "lou", "tpu", "t_", "=_", "'", "export", " ", "FS", "LO", "UT", "PU", "TTY", "PE", "=", "NI", "FT", "I", ";", " ", "'_", "#", " ", "for", " ", "faste", "r", " ", "process", "ing", ",", " ", "all", " ", "output", "s", " ", "are", " ", "in", " ", "NI", "FT", "I_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fname", "\\u", "data_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fname", "\\u", "bv", "ecs_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fname", "\\u", "schedule_", "=_", "path", "\\u", "sct", "_", "+_", "'/", "fli", "rts", "ch", "/", "schedule", "\\u", "Tx", "Ty", ".", "sch", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "interp_", "=_", "param_", "._", "interp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remove", "\\u", "temp", "\\u", "files_", "=_", "param_", "._", "remove", "\\u", "temp", "\\u", "files_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verbose_", "=_", "param_", "._", "verbose_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter", "s", " ", "for", " ", "debug", " ", "mode_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "param_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fname", "\\u", "data_", "=_", "path", "\\u", "sct", "_", "+_", "'/", "testi", "ng", "/", "data", "/", "err", "sm", "\\u", "23", "/", "dmr", "i", "/", "dmr", "i", ".", "ni", "i", ".", "gz", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fname", "\\u", "bv", "ecs_", "=_", "path", "\\u", "sct", "_", "+_", "'/", "testi", "ng", "/", "data", "/", "err", "sm", "\\u", "23", "/", "dmr", "i", "/", "bv", "ecs", ".", "txt", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "interp_", "=_", "'", "tril", "ine", "ar", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remove", "\\u", "temp", "\\u", "files_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verbose_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "input", " ", "parameters_", "\\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 ", " _", "opts_", ",_", "args_", "=_", "getopt_", "._", "getopt_", "(_", "sys_", "._", "argv_", "[_", "1_", ":_", "]_", ",_", "'", "hb", ":", "i", ":", "v", ":", "s", ":'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "getopt_", "._", "Get", "opt", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "usage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "opt_", ",_", "arg_", "in_", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "opt_", "==_", "'-", "h", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "usage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "opt_", "in_", "(_", "\"-", "b", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fname", "\\u", "bv", "ecs_", "=_", "arg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "opt_", "in_", "(_", "\"-", "i", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fname", "\\u", "data_", "=_", "arg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "opt_", "in_", "(_", "'-", "s", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "interp_", "=_", "str_", "(_", "arg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "opt_", "in_", "(_", "'-", "v", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "verbose_", "=_", "int_", "(_", "arg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "display", " ", "usage", " ", "if", " ", "a", " ", "mandat", "ory", " ", "argu", "ment", " ", "is", " ", "not", " ", "provided", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fname", "\\u", "data_", "==_", "''_", "or_", "fname", "\\u", "bv", "ecs_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "usage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "existence", " ", "of", " ", "input", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sct", "_", "._", "check", "\\u", "file", "\\u", "exist_", "(_", "fname", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sct", "_", "._", "check", "\\u", "file", "\\u", "exist_", "(_", "fname", "\\u", "bv", "ecs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Check", " ", "parameter", "s", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'..", " ", "DW", "I", " ", "data", ":", " ", " ", " ", " ", " ", "'_", "+_", "fname", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'..", " ", "bv", "ecs", " ", "file", ":", " ", " ", " ", "'_", "+_", "fname", "\\u", "bv", "ecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "full", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "fname", "\\u", "data_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "fname", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fname", "\\u", "bv", "ecs_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "fname", "\\u", "bv", "ecs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Extract", " ", "path", ",", " ", "file", " ", "and", " ", "extension_", "\\u\\u\\uNL\\u\\u\\u_", "path", "\\u", "data_", ",_", "file", "\\u", "data_", ",_", "ext", "\\u", "data_", "=_", "sct", "_", "._", "extract", "\\u", "fname_", "(_", "fname", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "temporar", "y", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "path", "\\u", "tmp_", "=_", "'", "tmp", ".'_", "+_", "time_", "._", "strftime_", "(_", "\"%", "y", "%", "m", "%", "d", "%", "H", "%", "M", "%", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sct", "_", "._", "run_", "(_", "'", "mkd", "ir", " ", "'_", "+_", "path", "\\u", "tmp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "go", " ", "to", " ", "tmp", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "chdir_", "(_", "path", "\\u", "tmp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "size", " ", "of", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Get", " ", "dimension", "s", " ", "data", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nx_", ",_", "ny_", ",_", "nz_", ",_", "nt_", ",_", "px_", ",_", "py_", ",_", "pz", "_", ",_", "pt_", "=_", "sct", "_", "._", "get", "\\u", "dimension_", "(_", "fname", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'..", " ", "'_", "+_", "str_", "(_", "nx_", ")_", "+_", "'", " ", "x", " ", "'_", "+_", "str_", "(_", "ny_", ")_", "+_", "'", " ", "x", " ", "'_", "+_", "str_", "(_", "nz_", ")_", "+_", "'", " ", "x", " ", "'_", "+_", "str_", "(_", "nt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Open", " ", "bv", "ecs", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Open", " ", "bv", "ecs", " ", "file", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bv", "ecs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "fname", "\\u", "bv", "ecs_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bv", "ecs", "\\u", "new_", "=_", "map_", "(_", "float_", ",_", "line_", "._", "split_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bv", "ecs_", "._", "append_", "(_", "bv", "ecs", "\\u", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "bv", "ecs", " ", "file", " ", "is", " ", "nx", "3_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "len_", "(_", "bv", "ecs_", "[_", "0_", "]_", "[_", ":_", "]_", ")_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'..", " ", "WARN", "ING", ":", " ", "bv", "ecs", " ", "file", " ", "is", " ", "3x", "n", " ", "inst", "ead", " ", "of", " ", "nx", "3", ".", " ", "Consider", " ", "usi", "ng", " ", "sct", "\\u", "dmr", "i", "\\u", "transpose", "\\u", "bv", "ecs", ".'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Transpose", " ", "bv", "ecs", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "transpose", " ", "bv", "ecs_", "\\u\\u\\uNL\\u\\u\\u_", "bv", "ecs_", "=_", "zip_", "(_", "*_", "bv", "ecs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Identif", "y", " ", "b", "=", "0", " ", "and", " ", "DW", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'\\\\", "n", "Identif", "y", " ", "b", "=", "0", " ", "and", " ", "DW", " ", "images", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "b0_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "dwi", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "nt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "math_", "._", "sqrt_", "(_", "math_", "._", "fsu", "m_", "(_", "[_", "i_", "**_", "2_", "for_", "i_", "in_", "bv", "ecs_", "[_", "it_", "]_", "]_", ")_", ")_", "<_", "0.01_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index", "\\u", "b0_", "._", "append_", "(_", "it_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index", "\\u", "dwi", "_", "._", "append_", "(_", "it_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "n", "\\u", "b0_", "=_", "len_", "(_", "index", "\\u", "b0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "\\u", "dwi", "_", "=_", "len_", "(_", "index", "\\u", "dwi", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'..", " ", "Index", " ", "of", " ", "b", "=", "0", ":'_", "+_", "str_", "(_", "index", "\\u", "b0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'..", " ", "Index", " ", "of", " ", "DW", "I", ":'_", "+_", "str_", "(_", "index", "\\u", "dwi", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "check", " ", "if", " ", "number", " ", "of", " ", "bv", "ecs", " ", "and", " ", "nt", " ", "match_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Split", " ", "int", "o", " ", "T", " ", "dimension_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Split", " ", "along", " ", "T", " ", "dimension", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "cmd", " ", "=", " ", "fs", "lou", "tpu", "t", "+'", "fs", "lsp", "lit", " ", "tmp", ".", "data", " ", "tmp", ".", "data\\u", "split", "T", "'_", "\\u\\u\\uNL\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lsp", "lit", " ", "'_", "+_", "fname", "\\u", "data_", "+_", "'", " ", "tmp", ".", "data\\u", "split", "T", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "retrieve", " ", "output", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "'", "ls", " ", "tmp", ".", "data\\u", "split", "T", "*.", "*'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "data\\u", "split_", "=_", "output_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remove", " ", ".", "ni", "i", " ", "extension_", "\\u\\u\\uNL\\u\\u\\u_", "file", "\\u", "data\\u", "split_", "=_", "[_", "file", "\\u", "data\\u", "split_", "[_", "i_", "]_", "._", "replace_", "(_", "'.", "ni", "i", "'_", ",_", "''_", ")_", "for_", "i_", "in_", "xrange_", "(_", "0_", ",_", "len_", "(_", "file", "\\u", "data\\u", "split_", ")_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "b", "=", "0", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "b0_", "=_", "'", "tmp", ".", "b0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "'_", "+_", "file", "\\u", "b0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "b0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "b0_", "[_", "it_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "('", ">>", " ", "'+", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "DW", "I", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "DW", "I", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "dwi", "_", "=_", "'", "tmp", ".", "dwi", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "'_", "+_", "file", "\\u", "dwi", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "dwi", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Average", " ", "b", "=", "0", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Average", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "b0", "\\u", "mean_", "=_", "'", "tmp", ".", "b0", "\\u", "mean", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lma", "ths", " ", "'_", "+_", "file", "\\u", "b0_", "+_", "'", " ", "-", "Tm", "ean", " ", "'_", "+_", "file", "\\u", "b0", "\\u", "mean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Average", " ", "DW", "I", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Average", " ", "DW", "I", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "dwi", "\\u", "mean_", "=_", "'", "tmp", ".", "dwi", "\\u", "mean", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lma", "ths", " ", "'_", "+_", "file", "\\u", "dwi", "_", "+_", "'", " ", "-", "Tm", "ean", " ", "'_", "+_", "file", "\\u", "dwi", "\\u", "mean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "REGISTER", " ", "DW", "I", " ", "TO", " ", "THE", " ", "MEAN", " ", "DW", "I", " ", " ", "-->", " ", " ", "output", " ", "transf", "o", " ", "Td", "wi", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "loop", " ", "acro", "ss", " ", "DW", "I", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Register", " ", "DW", "I", " ", "data", " ", "to", " ", "'_", "+_", "file", "\\u", "dwi", "\\u", "mean_", "+_", "'...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "dwi", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "estimate", " ", "transformation", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file", "\\u", "target_", "=_", "file", "\\u", "dwi", "\\u", "mean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "mat_", "=_", "'", "tmp", ".", "mat", "\\u'_", "+_", "str_", "(_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fli", "rt", " ", "-", "in", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", "]_", "+_", "'", " ", "-", "ref", " ", "'_", "+_", "file", "\\u", "target_", "+_", "'", " ", "-", "oma", "t", " ", "'_", "+_", "file", "\\u", "mat_", "+_", "'", " ", "-", "cost", " ", "norm", "corr", " ", "-", "schedule", " ", "'_", "+_", "fname", "\\u", "schedule_", "+_", "'", " ", "-", "interp", " ", "tril", "ine", "ar", " ", "-", "out", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", "]_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "corrected", " ", "DW", "I", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "corrected", " ", "DW", "I", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "dwi", "_", "=_", "'", "tmp", ".", "dwi", "\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "'_", "+_", "file", "\\u", "dwi", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "dwi", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", "]_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Average", " ", "corrected", " ", "DW", "I_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Average", " ", "corrected", " ", "DW", "I", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "dwi", "\\u", "mean_", "=_", "'", "tmp", ".", "dwi", "\\u", "moc", "o", "\\u", "mean", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lma", "ths", " ", "'_", "+_", "file", "\\u", "dwi", "_", "+_", "'", " ", "-", "Tm", "ean", " ", "'_", "+_", "file", "\\u", "dwi", "\\u", "mean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "REGISTER", " ", "B", "=", "0", " ", "DATA", " ", "TO", " ", "THE", " ", "FIR", "ST", " ", "B", "=", "0", " ", " ", "-->", " ", "output", " ", "transf", "o", " ", "Tb", "0_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Register", " ", "b", "=", "0", " ", "data", " ", "to", " ", "the", " ", "first", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "b0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "estimate", " ", "transformation", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file", "\\u", "target_", "=_", "file", "\\u", "data\\u", "split_", "[_", "int_", "(_", "index", "\\u", "b0_", "[_", "0_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "mat_", "=_", "'", "tmp", ".", "mat", "\\u'_", "+_", "str_", "(_", "index", "\\u", "b0_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fli", "rt", " ", "-", "in", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "b0_", "[_", "it_", "]_", "]_", "+_", "'", " ", "-", "ref", " ", "'_", "+_", "file", "\\u", "target_", "+_", "'", " ", "-", "oma", "t", " ", "'_", "+_", "file", "\\u", "mat_", "+_", "'", " ", "-", "cost", " ", "norm", "corr", " ", "-", "force", "scal", "ing", " ", "-", "2", "D", " ", "-", "out", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "b0_", "[_", "it_", "]_", "]_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "corrected", " ", "b", "=", "0", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "corrected", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "tmp", ".", "b0", "\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "b0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "'_", "+_", "file", "\\u", "data\\u", "split_", "[_", "index", "\\u", "b0_", "[_", "it_", "]_", "]_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Average", " ", "corrected", " ", "b", "=", "0_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Average", " ", "corrected", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lma", "ths", " ", "tmp", ".", "b0", "\\u", "moc", "o", " ", "-", "Tm", "ean", " ", "tmp", ".", "b0", "\\u", "moc", "o", "\\u", "mean", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "REGISTER", " ", "MEAN", " ", "DW", "I", " ", "TO", " ", "THE", " ", "MEAN", " ", "B", "=", "0", " ", " ", "-->", " ", "output", " ", "transf", "o", " ", "Td", "wi", "2b", "0_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Register", " ", "mean", " ", "DW", "I", " ", "to", " ", "the", " ", "mean", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fli", "rt", " ", "-", "in", " ", "tmp", ".", "dwi", "\\u", "moc", "o", "\\u", "mean", " ", "-", "ref", " ", "tmp", ".", "b0", "\\u", "moc", "o", "\\u", "mean", " ", "-", "oma", "t", " ", "tmp", ".", "mat", "\\u", "dwi", "2b", "0", " ", "-", "cost", " ", "mutual", "info", " ", "-", "force", "scal", "ing", " ", "-", "dof", " ", "1", "2", " ", "-", "2", "D", " ", "-", "out", " ", "tmp", ".", "dwi", "\\u", "mean", "\\u", "moc", "o", "\\u", "reg", "2b", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "COMBI", "NE", " ", "TRANSFORM", "ATION", "S_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Combine", " ", "all", " ", "transformation", "s", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "USE", " ", "FS", "L", " ", "convert", "\\u", "xf", "m", ":", " ", "convert", "\\u", "xf", "m", " ", "-", "oma", "t", " ", "At", "o", "C", ".", "mat", " ", "-", "conc", "at", " ", "Bt", "o", "C", ".", "mat", " ", "At", "o", "B", ".", "mat_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "DW", "I_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "..", " ", "For", " ", "DW", "I", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "dwi", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "'", "convert", "\\u", "xf", "m", " ", "-", "oma", "t", " ", "tmp", ".", "mat", "\\u", "final", "\\u'_", "+_", "str_", "(_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'", " ", "-", "conc", "at", " ", "tmp", ".", "mat", "\\u", "dwi", "2b", "0", " ", "tmp", ".", "mat", "\\u'_", "+_", "str_", "(_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "For", " ", "b", "=", "0", " ", "(", "don", "'", "t", " ", "conc", "at", " ", "bec", "aus", "e", " ", "there", " ", "is", " ", "just", " ", "one", " ", "mat", " ", "file", " ", "--", " ", "just", " ", "rename", " ", "it", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'\\\\", "n", "..", " ", "For", " ", "b", "=", "0", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "b0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "'", "cp", " ", "tmp", ".", "mat", "\\u'_", "+_", "str_", "(_", "index", "\\u", "b0_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'", " ", "tmp", ".", "mat", "\\u", "final", "\\u'_", "+_", "str_", "(_", "index", "\\u", "b0_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "APPL", "Y", " ", "TRANSFORM", "ATION", "S_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Split", " ", "original", " ", "data", " ", "int", "o", " ", "T", " ", "dimension_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'\\\\", "n", "Split", " ", "original", " ", "data", " ", "along", " ", "T", " ", "dimension", "...'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cmd", " ", "=", " ", "fs", "lou", "tpu", "t", "+'", "fs", "lsp", "lit", " ", "'+", "fname", "\\u", "data", "+'", " ", "tmp", ".", "data\\u", "raw", "\\u", "split", "T", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "('", ">>", " ", "'+", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "status", ",", " ", "output", " ", "=", " ", "command", "s", ".", "getstatus", "output", "(", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'\\\\", "n", "Apply", " ", "transformation", "s", " ", "to", " ", "original", " ", "data", "...'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "for", " ", "it", " ", "in", " ", "xran", "ge", "(", "0", ",", "nt", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "cmd", " ", "=", " ", "fs", "lou", "tpu", "t", "+'", "fli", "rt", " ", "-", "in", " ", "tmp", ".", "data\\u", "raw", "\\u", "split", "T", "'+", "str", "(", "it", ").", "zfil", "l", "(", "4", ")+", "'", " ", "-", "ref", " ", "tmp", ".", "data\\u", "raw", "\\u", "split", "T", "'+", "index", "\\u", "b0", "[", "0", "].", "zfil", "l", "(", "4", ")+", "'", " ", "-", "appl", "yx", "fm", " ", "-", "init", " ", "tmp", ".", "mat", "\\u", "final", "\\u", "'+", "str", "(", "it", ").", "zfil", "l", "(", "4", ")+", "'", " ", "-", "out", " ", "tmp", ".", "data\\u", "raw", "\\u", "split", "T", "'+", "str", "(", "it", ").", "zfil", "l", "(", "4", ")+", "'\\u", "moc", "o", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "print", "('", ">>", " ", "'+", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "status", ",", " ", "output", " ", "=", " ", "command", "s", ".", "getstatus", "output", "(", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Merge", " ", "corrected", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'\\\\", "n", "Merge", " ", "corrected", " ", "data", "...'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cmd", " ", "=", " ", "fs", "lou", "tpu", "t", "+'", "fs", "lm", "erge", " ", "-", "t", " ", "tmp", ".", "data\\u", "raw", "\\u", "moc", "o", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "for", " ", "it", " ", "in", " ", "xran", "ge", "(", "0", ",", "it", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "cmd", " ", "+=", " ", "'", " ", "tmp", ".", "data\\u", "raw", "\\u", "split", "T", "'+", "str", "(", "it", ").", "zfil", "l", "(", "4", ")+", "'\\u", "moc", "o", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "('", ">>", " ", "'+", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "status", ",", " ", "output", " ", "=", " ", "command", "s", ".", "getstatus", "output", "(", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'\\\\", "n", "Apply", " ", "transformation", "s", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "nt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "-", "paddings", "ize", " ", "3", " ", "prevent", "s", " ", "from", " ", "hav", "ing", " ", "missi", "ng", " ", "slice", "s", " ", "at", " ", "the", " ", "edge_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fli", "rt", " ", "-", "in", " ", "tmp", ".", "data\\u", "split", "T", "'_", "+_", "str_", "(_", "it_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'", " ", "-", "ref", " ", "tmp", ".", "data\\u", "split", "T", "'_", "+_", "str_", "(_", "index", "\\u", "b0_", "[_", "0_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'", " ", "-", "appl", "yx", "fm", " ", "-", "init", " ", "tmp", ".", "mat", "\\u", "final", "\\u'_", "+_", "str_", "(_", "it_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'", " ", "-", "out", " ", "tmp", ".", "data\\u", "split", "T", "'_", "+_", "str_", "(_", "it_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'\\u", "moc", "o", " ", "-", "paddings", "ize", " ", "3", "'_", "+_", "'", " ", "-", "interp", " ", "'_", "+_", "interp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "corrected", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "all", " ", "corrected", " ", "data", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "tmp", ".", "data\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "nt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "tmp", ".", "data\\u", "split", "T", "'_", "+_", "str_", "(_", "it_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "corrected", " ", "DW", "I", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "corrected", " ", "DW", "I", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "tmp", ".", "dwi", "\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "dwi", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "tmp", ".", "data\\u", "split", "T", "'_", "+_", "str_", "(_", "index", "\\u", "dwi", "_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Average", " ", "corrected", " ", "DW", "I_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Average", " ", "corrected", " ", "DW", "I", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lma", "ths", " ", "tmp", ".", "dwi", "\\u", "moc", "o", " ", "-", "Tm", "ean", " ", "tmp", ".", "dwi", "\\u", "moc", "o", "\\u", "mean", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Merge", " ", "corrected", " ", "b", "=", "0", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Merge", " ", "corrected", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lm", "erge", " ", "-", "t", " ", "tmp", ".", "b0", "\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "it_", "in_", "xrange_", "(_", "0_", ",_", "n", "\\u", "b0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "+=_", "'", " ", "tmp", ".", "data\\u", "split", "T", "'_", "+_", "str_", "(_", "index", "\\u", "b0_", "[_", "it_", "]_", ")_", "._", "zfill_", "(_", "4_", ")_", "+_", "'\\u", "moc", "o", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Average", " ", "corrected", " ", "b", "=", "0_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "Average", " ", "corrected", " ", "b", "=", "0.", "..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "fs", "lou", "tpu", "t_", "+_", "'", "fs", "lma", "ths", " ", "tmp", ".", "b0", "\\u", "moc", "o", " ", "-", "Tm", "ean", " ", "tmp", ".", "b0", "\\u", "moc", "o", "\\u", "mean", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", ",_", "output_", "=_", "sct", "_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "output", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'\\\\", "n", "Generate", " ", "output", " ", "files", "...'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sct", "_", "._", "generat", "e\\u", "output", "\\u", "file_", "(_", "'", "tmp", ".", "data\\u", "moc", "o", ".", "ni", "i", "'_", ",_", "path", "\\u", "data_", ",_", "file", "\\u", "data_", "+_", "'\\u", "moc", "o", "'_", ",_", "ext", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sct", "_", "._", "generat", "e\\u", "output", "\\u", "file_", "(_", "'", "tmp", ".", "dwi", "\\u", "moc", "o", "\\u", "mean", ".", "ni", "i", "'_", ",_", "path", "\\u", "data_", ",_", "'", "dwi", "\\u", "moc", "o", "\\u", "mean", "'_", ",_", "ext", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sct", "_", "._", "generat", "e\\u", "output", "\\u", "file_", "(_", "'", "tmp", ".", "b0", "\\u", "moc", "o", "\\u", "mean", ".", "ni", "i", "'_", ",_", "path", "\\u", "data_", ",_", "'", "b0", "\\u", "moc", "o", "\\u", "mean", "'_", ",_", "ext", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "come", " ", "back", " ", "to", " ", "parent", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "chdir_", "(_", "'..'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "temporar", "y", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "remove", "\\u", "temp", "\\u", "files_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'\\\\", "n", "Delete", " ", "temporar", "y", " ", "files", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sct", "_", "._", "run_", "(_", "'", "rm", " ", "-", "rf", " ", "'_", "+_", "path", "\\u", "tmp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "display", " ", "ela", "pse", "d", " ", "time_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ela", "pse", "d\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "-_", "start", "\\u", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'\\\\", "n", "Finish", "ed", "!", " ", "El", "aps", "ed", " ", "time", ":", " ", "'_", "+_", "str_", "(_", "int_", "(_", "round_", "(_", "ela", "pse", "d\\u", "time_", ")_", ")_", ")_", "+_", "'", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "view", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'\\\\", "n", "To", " ", "view", " ", "results", ",", " ", "type", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "fs", "lv", "iew", " ", "'_", "+_", "file", "\\u", "data_", "+_", "'", " ", "'_", "+_", "file", "\\u", "data_", "+_", "'\\u", "moc", "o", " ", "&", "\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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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 ]
Variable defined multiple times
AppScale/appscale/AppServer/lib/django-1.4/tests/modeltests/field_subclassing/tests.py
[ { "content": " def test_field_subclassing(self):\n o = OtherModel.objects.create(data=Small(\"a\", \"b\"))\n o = OtherModel.objects.get()\n self.assertEqual(o.data.first, \"a\")\n self.assertEqual(o.data.second, \"b\")", "metadata": "root.CustomField.test_field_subclassing", "header": "['class', 'CustomField', '(', 'TestCase', ')', ':', '___EOS___']", "index": 78 } ]
[ { "span": "o ", "start_line": 79, "start_column": 8, "end_line": 79, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Custom", "Field_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "field", "\\u", "subclassing", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "o_", "=_", "Ot", "her", "Model_", "._", "objects_", "._", "create_", "(_", "data_", "=_", "Small", "_", "(_", "\"", "a", "\"_", ",_", "\"", "b", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "o_", "=_", "Ot", "her", "Model_", "._", "objects_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "o_", "._", "data_", "._", "first_", ",_", "\"", "a", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "o_", "._", "data_", "._", "second_", ",_", "\"", "b", "\"_", ")_" ]
[ 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, 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 ]
Unused import
msmbuilder/osprey/osprey/plugins/tests/test_plugin_pylearn2.py
[ { "content": "from __future__ import print_function, absolute_import, division\nimport json\nimport shutil\nimport sys\nimport tempfile\nimport unittest\nfrom argparse import Namespace\nimport numpy as np\nfrom numpy.testing.decorators import skipif\n\ntry:\n import pylearn2\n del pylearn2 # for flake8, since not used in tests\nexcept ImportError:\n pass\n\nfrom osprey import execute_worker, execute_dump\nfrom osprey.plugins.plugin_pylearn2 import Pylearn2DatasetLoader\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestPluginPylearn2(unittest.TestCase):\n \"\"\"\n Test plugin_pylearn2.\n \"\"\"\n\n\n\n\n\n\n", "metadata": "root.TestPluginPylearn2", "header": "['module', '___EOS___']", "index": 20 }, { "content": " def setUp(self):\n self.temp_dir = tempfile.mkdtemp()", "metadata": "root.TestPluginPylearn2.setUp", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 24 }, { "content": " def tearDown(self):\n shutil.rmtree(self.temp_dir)", "metadata": "root.TestPluginPylearn2.tearDown", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 27 }, { "content": " def run_osprey(self, config):\n \"\"\"\n Run osprey-worker.\n\n Parameters\n ----------\n config : str\n Configuration string.\n \"\"\"\n fh, filename = tempfile.mkstemp(dir=self.temp_dir)\n with open(filename, 'wb') as f:\n f.write(config)\n args = Namespace(config=filename, n_iters=1, output='json')\n execute_worker.execute(args, None)\n dump = json.loads(execute_dump.execute(args, None))\n assert len(dump) == 1\n assert dump[0]['status'] == 'SUCCEEDED', dump[0]['status']", "metadata": "root.TestPluginPylearn2.run_osprey", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 30 }, { "content": " @skipif('pylearn2' not in sys.modules, 'this test requires pylearn2')\n def test_pylearn2_classifier(self):\n config = \"\"\"\nestimator:\n entry_point: osprey.plugins.plugin_pylearn2.Pylearn2Classifier\n params:\n yaml_string: \"!obj:pylearn2.train.Train {\n dataset: null,\n model: !obj:pylearn2.models.mlp.MLP {\n nvis: 4,\n layers: [\n !obj:pylearn2.models.mlp.Sigmoid {\n layer_name: h0,\n dim: $dim,\n irange: 0.05,\n },\n !obj:pylearn2.models.mlp.Softmax {\n layer_name: y,\n n_classes: 3,\n irange: 0.,\n },\n ],\n },\n algorithm: !obj:pylearn2.training_algorithms.bgd.BGD {\n batch_size: 10,\n termination_criterion: !obj:pylearn2.termination_criteria.EpochCounter {\n max_epochs: 1,\n },\n },\n}\"\n\ndataset_loader:\n name: sklearn_dataset\n params:\n method: load_iris\n\nstrategy:\n name: random\n\nsearch_space:\n dim:\n min: 1\n max: 10\n type: int\n\ncv:\n name: stratifiedkfold\n\ntrials:\n uri: sqlite:///test.db\n\"\"\"\n self.run_osprey(config)", "metadata": "root.TestPluginPylearn2.test_pylearn2_classifier", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 48 }, { "content": " @skipif('pylearn2' not in sys.modules, 'this test requires pylearn2')\n def test_pylearn2_regressor(self):\n config = \"\"\"\nestimator:\n entry_point: osprey.plugins.plugin_pylearn2.Pylearn2Regressor\n params:\n yaml_string: \"!obj:pylearn2.train.Train {\n dataset: null,\n model: !obj:pylearn2.models.mlp.MLP {\n nvis: 13,\n layers: [\n !obj:pylearn2.models.mlp.Sigmoid {\n layer_name: h0,\n dim: $dim,\n irange: 0.05,\n },\n !obj:pylearn2.models.mlp.Linear {\n layer_name: y,\n dim: 1,\n irange: 0.,\n },\n ],\n },\n algorithm: !obj:pylearn2.training_algorithms.bgd.BGD {\n batch_size: 10,\n termination_criterion: !obj:pylearn2.termination_criteria.EpochCounter {\n max_epochs: 1,\n },\n },\n}\"\n\ndataset_loader:\n name: sklearn_dataset\n params:\n method: load_boston\n\nstrategy:\n name: random\n\nsearch_space:\n dim:\n min: 1\n max: 10\n type: int\n\ncv: 3\n\ntrials:\n uri: sqlite:///test.db\n\"\"\"\n self.run_osprey(config)", "metadata": "root.TestPluginPylearn2.test_pylearn2_regressor", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 101 }, { "content": " @skipif('pylearn2' not in sys.modules, 'this test requires pylearn2')\n def test_pylearn2_autoencoder(self):\n config = \"\"\"\nestimator:\n entry_point: osprey.plugins.plugin_pylearn2.Pylearn2Autoencoder\n params:\n yaml_string: \"!obj:pylearn2.train.Train {\n dataset: null,\n model: !obj:pylearn2.models.autoencoder.Autoencoder {\n act_dec: null,\n act_enc: sigmoid,\n irange: 0.05,\n nvis: 13,\n nhid: $dim,\n },\n algorithm: !obj:pylearn2.training_algorithms.bgd.BGD {\n batch_size: 10,\n cost: !obj:pylearn2.costs.autoencoder.MeanSquaredReconstructionError {},\n termination_criterion: !obj:pylearn2.termination_criteria.EpochCounter {\n max_epochs: 1,\n },\n },\n}\"\n\ndataset_loader:\n name: sklearn_dataset\n params:\n method: load_boston\n\nstrategy:\n name: random\n\nsearch_space:\n dim:\n min: 1\n max: 10\n type: int\n\ncv: 3\n\ntrials:\n uri: sqlite:///test.db\n\"\"\"\n self.run_osprey(config)", "metadata": "root.TestPluginPylearn2.test_pylearn2_autoencoder", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 153 }, { "content": " @skipif('pylearn2' not in sys.modules, 'this test requires pylearn2')\n def test_pylearn2_dataset_loader(self):\n yaml_string = \"\"\"\n!obj:pylearn2.testing.datasets.random_dense_design_matrix {\n rng: !obj:numpy.random.RandomState { seed: 1 },\n num_examples: 10,\n dim: 5,\n num_classes: 3,\n}\n\"\"\"\n dataset_loader = Pylearn2DatasetLoader(yaml_string, one_hot=False)\n X, y = dataset_loader.load()\n assert X.shape == (10, 5)\n assert y.shape == (10,)\n assert np.unique(y).size == 3", "metadata": "root.TestPluginPylearn2.test_pylearn2_dataset_loader", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 198 }, { "content": " @skipif('pylearn2' not in sys.modules, 'this test requires pylearn2')\n def test_pylearn2_dataset_loader_one_hot(self):\n yaml_string = \"\"\"\n!obj:pylearn2.testing.datasets.random_one_hot_dense_design_matrix {\n rng: !obj:numpy.random.RandomState { seed: 1 },\n num_examples: 10,\n dim: 5,\n num_classes: 3,\n}\n\"\"\"\n dataset_loader = Pylearn2DatasetLoader(yaml_string, one_hot=True)\n X, y = dataset_loader.load()\n assert X.shape == (10, 5)\n assert y.shape == (10,)\n assert np.unique(y).size == 3", "metadata": "root.TestPluginPylearn2.test_pylearn2_dataset_loader_one_hot", "header": "['class', 'TestPluginPylearn2', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 214 } ]
[ { "span": "import pylearn2", "start_line": 11, "start_column": 4, "end_line": 11, "end_column": 19 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", ",_", "abs", "olute", "\\u", "import_", ",_", "division_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "argparse_", "import_", "Namespace_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numpy_", "._", "testing_", "._", "decorators_", "import_", "skipif_", "\\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_", "pyl", "earn", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "pyl", "earn", "2_", "#", " ", "for", " ", "flake", "8", ",", " ", "sinc", "e", " ", "not", " ", "used", " ", "in", " ", "tests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "osp", "rey", "_", "import_", "execute", "\\u", "worker_", ",_", "execute", "\\u", "dump_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "osp", "rey", "_", "._", "plugins_", "._", "plugin", "\\u", "pyl", "earn", "2_", "import_", "Py", "learn", "2", "Datas", "et", "Loader_", "\\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", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "plugin", "\\u", "pyl", "earn", "2", ".", "\\", "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_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "set", "Up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "temp", "\\u", "dir_", "=_", "tempfile_", "._", "mkdtemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "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 ", " _", "shutil_", "._", "rmtree_", "(_", "self_", "._", "temp", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "osp", "rey", "_", "(_", "self_", ",_", "config_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "osp", "rey", "-", "worker", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "config", " ", ":", " ", "str", "\\", "10", ";", " ", " ", " ", " ", "Configura", "tion", " ", "string", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", ",_", "filename_", "=_", "tempfile_", "._", "mkstemp_", "(_", "dir_", "=_", "self_", "._", "temp", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "filename_", ",_", "'", "wb", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "=_", "Namespace_", "(_", "config_", "=_", "filename_", ",_", "n", "\\u", "iters_", "=_", "1_", ",_", "output_", "=_", "'", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "execute", "\\u", "worker_", "._", "execute_", "(_", "args_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dump_", "=_", "json_", "._", "loads_", "(_", "execute", "\\u", "dump_", "._", "execute_", "(_", "args_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "dump_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "dump_", "[_", "0_", "]_", "[_", "'", "status", "'_", "]_", "==_", "'", "SUC", "CEE", "DED", "'_", ",_", "dump_", "[_", "0_", "]_", "[_", "'", "status", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skipif_", "(_", "'", "pyl", "earn", "2", "'_", "not_", "in_", "sys_", "._", "modules_", ",_", "'", "this", " ", "test", " ", "require", "s", " ", "pyl", "earn", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "pyl", "earn", "2", "\\u", "classifier_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "=_", "\"\"\"", "\\", "10", ";", "esti", "mat", "or", ":", "\\", "10", ";", " ", " ", "entry", "\\u", "point", ":", " ", "osp", "rey", ".", "plugin", "s", ".", "plugin", "\\u", "pyl", "earn", "2", ".", "Py", "learn", "2", "Classif", "ier", "\\", "10", ";", " ", " ", "params", ":", "\\", "10", ";", " ", " ", " ", " ", "yaml", "\\u", "string", ":", " ", "\"!", "obj", ":", "pyl", "earn", "2", ".", "train", ".", "Train", " ", "{", "\\", "10", ";", " ", " ", "dataset", ":", " ", "null", ",", "\\", "10", ";", " ", " ", "model", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "mlp", ".", "MLP", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "nvi", "s", ":", " ", "4", ",", "\\", "10", ";", " ", " ", " ", " ", "layer", "s", ":", " ", "[", "\\", "10", ";", " ", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "mlp", ".", "Sigm", "oid", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "layer", "\\u", "name", ":", " ", "h", "0", ",", "\\", "10", ";", " ", " ", " ", " ", "dim", ":", " ", "$", "dim", ",", "\\", "10", ";", " ", " ", " ", " ", "ira", "nge", ":", " ", "0.05", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "mlp", ".", "Softmax", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "layer", "\\u", "name", ":", " ", "y", ",", "\\", "10", ";", " ", " ", " ", " ", "n", "\\u", "classe", "s", ":", " ", "3", ",", "\\", "10", ";", " ", " ", " ", " ", "ira", "nge", ":", " ", "0.", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", " ", " ", "],", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "algo", "rit", "hm", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "train", "ing", "\\u", "algo", "rit", "hms", ".", "bg", "d", ".", "BG", "D", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", ":", " ", "10", ",", "\\", "10", ";", " ", " ", " ", " ", "termination", "\\u", "criterio", "n", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "termination", "\\u", "crite", "ria", ".", "Epoch", "Counter", " ", "{", "\\", "10", ";", " ", " ", "max", "\\u", "epoch", "s", ":", " ", "1", ",", "\\", "10", ";", " ", " ", " ", " ", "},", "\\", "10", ";", " ", " ", "},", "\\", "10", ";}", "\"", "\\", "10", ";", "\\", "10", ";", "dataset", "\\u", "load", "er", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "skl", "earn", "\\u", "dataset", "\\", "10", ";", " ", " ", "params", ":", "\\", "10", ";", " ", " ", " ", " ", "method", ":", " ", "load", "\\u", "iri", "s", "\\", "10", ";", "\\", "10", ";", "strat", "eg", "y", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "random", "\\", "10", ";", "\\", "10", ";", "search", "\\u", "space", ":", "\\", "10", ";", " ", " ", "dim", ":", "\\", "10", ";", " ", " ", " ", " ", "min", ":", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "max", ":", " ", "10", "\\", "10", ";", " ", " ", " ", " ", "type", ":", " ", "int", "\\", "10", ";", "\\", "10", ";", "cv", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "strat", "ified", "kf", "old", "\\", "10", ";", "\\", "10", ";", "tria", "ls", ":", "\\", "10", ";", " ", " ", "uri", ":", " ", "sql", "ite", ":///", "test", ".", "db", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "run", "\\u", "osp", "rey", "_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skipif_", "(_", "'", "pyl", "earn", "2", "'_", "not_", "in_", "sys_", "._", "modules_", ",_", "'", "this", " ", "test", " ", "require", "s", " ", "pyl", "earn", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "pyl", "earn", "2", "\\u", "regressor", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "=_", "\"\"\"", "\\", "10", ";", "esti", "mat", "or", ":", "\\", "10", ";", " ", " ", "entry", "\\u", "point", ":", " ", "osp", "rey", ".", "plugin", "s", ".", "plugin", "\\u", "pyl", "earn", "2", ".", "Py", "learn", "2", "Regr", "esso", "r", "\\", "10", ";", " ", " ", "params", ":", "\\", "10", ";", " ", " ", " ", " ", "yaml", "\\u", "string", ":", " ", "\"!", "obj", ":", "pyl", "earn", "2", ".", "train", ".", "Train", " ", "{", "\\", "10", ";", " ", " ", "dataset", ":", " ", "null", ",", "\\", "10", ";", " ", " ", "model", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "mlp", ".", "MLP", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "nvi", "s", ":", " ", "13", ",", "\\", "10", ";", " ", " ", " ", " ", "layer", "s", ":", " ", "[", "\\", "10", ";", " ", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "mlp", ".", "Sigm", "oid", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "layer", "\\u", "name", ":", " ", "h", "0", ",", "\\", "10", ";", " ", " ", " ", " ", "dim", ":", " ", "$", "dim", ",", "\\", "10", ";", " ", " ", " ", " ", "ira", "nge", ":", " ", "0.05", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "mlp", ".", "Linea", "r", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "layer", "\\u", "name", ":", " ", "y", ",", "\\", "10", ";", " ", " ", " ", " ", "dim", ":", " ", "1", ",", "\\", "10", ";", " ", " ", " ", " ", "ira", "nge", ":", " ", "0.", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", " ", " ", "],", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "algo", "rit", "hm", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "train", "ing", "\\u", "algo", "rit", "hms", ".", "bg", "d", ".", "BG", "D", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", ":", " ", "10", ",", "\\", "10", ";", " ", " ", " ", " ", "termination", "\\u", "criterio", "n", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "termination", "\\u", "crite", "ria", ".", "Epoch", "Counter", " ", "{", "\\", "10", ";", " ", " ", "max", "\\u", "epoch", "s", ":", " ", "1", ",", "\\", "10", ";", " ", " ", " ", " ", "},", "\\", "10", ";", " ", " ", "},", "\\", "10", ";}", "\"", "\\", "10", ";", "\\", "10", ";", "dataset", "\\u", "load", "er", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "skl", "earn", "\\u", "dataset", "\\", "10", ";", " ", " ", "params", ":", "\\", "10", ";", " ", " ", " ", " ", "method", ":", " ", "load", "\\u", "bos", "ton", "\\", "10", ";", "\\", "10", ";", "strat", "eg", "y", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "random", "\\", "10", ";", "\\", "10", ";", "search", "\\u", "space", ":", "\\", "10", ";", " ", " ", "dim", ":", "\\", "10", ";", " ", " ", " ", " ", "min", ":", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "max", ":", " ", "10", "\\", "10", ";", " ", " ", " ", " ", "type", ":", " ", "int", "\\", "10", ";", "\\", "10", ";", "cv", ":", " ", "3", "\\", "10", ";", "\\", "10", ";", "tria", "ls", ":", "\\", "10", ";", " ", " ", "uri", ":", " ", "sql", "ite", ":///", "test", ".", "db", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "run", "\\u", "osp", "rey", "_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skipif_", "(_", "'", "pyl", "earn", "2", "'_", "not_", "in_", "sys_", "._", "modules_", ",_", "'", "this", " ", "test", " ", "require", "s", " ", "pyl", "earn", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "pyl", "earn", "2", "\\u", "autoe", "ncode", "r_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "=_", "\"\"\"", "\\", "10", ";", "esti", "mat", "or", ":", "\\", "10", ";", " ", " ", "entry", "\\u", "point", ":", " ", "osp", "rey", ".", "plugin", "s", ".", "plugin", "\\u", "pyl", "earn", "2", ".", "Py", "learn", "2", "Auto", "encode", "r", "\\", "10", ";", " ", " ", "params", ":", "\\", "10", ";", " ", " ", " ", " ", "yaml", "\\u", "string", ":", " ", "\"!", "obj", ":", "pyl", "earn", "2", ".", "train", ".", "Train", " ", "{", "\\", "10", ";", " ", " ", "dataset", ":", " ", "null", ",", "\\", "10", ";", " ", " ", "model", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "model", "s", ".", "autoe", "ncode", "r", ".", "Auto", "encode", "r", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "act", "\\u", "dec", ":", " ", "null", ",", "\\", "10", ";", " ", " ", " ", " ", "act", "\\u", "enc", ":", " ", "sigm", "oid", ",", "\\", "10", ";", " ", " ", " ", " ", "ira", "nge", ":", " ", "0.05", ",", "\\", "10", ";", " ", " ", " ", " ", "nvi", "s", ":", " ", "13", ",", "\\", "10", ";", " ", " ", " ", " ", "nh", "id", ":", " ", "$", "dim", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "algo", "rit", "hm", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "train", "ing", "\\u", "algo", "rit", "hms", ".", "bg", "d", ".", "BG", "D", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", ":", " ", "10", ",", "\\", "10", ";", " ", " ", " ", " ", "cost", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "cost", "s", ".", "autoe", "ncode", "r", ".", "Mea", "n", "Square", "d", "Recon", "struct", "ion", "Error", " ", "{}", ",", "\\", "10", ";", " ", " ", " ", " ", "termination", "\\u", "criterio", "n", ":", " ", "!", "obj", ":", "pyl", "earn", "2", ".", "termination", "\\u", "crite", "ria", ".", "Epoch", "Counter", " ", "{", "\\", "10", ";", " ", " ", "max", "\\u", "epoch", "s", ":", " ", "1", ",", "\\", "10", ";", " ", " ", " ", " ", "},", "\\", "10", ";", " ", " ", "},", "\\", "10", ";}", "\"", "\\", "10", ";", "\\", "10", ";", "dataset", "\\u", "load", "er", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "skl", "earn", "\\u", "dataset", "\\", "10", ";", " ", " ", "params", ":", "\\", "10", ";", " ", " ", " ", " ", "method", ":", " ", "load", "\\u", "bos", "ton", "\\", "10", ";", "\\", "10", ";", "strat", "eg", "y", ":", "\\", "10", ";", " ", " ", "name", ":", " ", "random", "\\", "10", ";", "\\", "10", ";", "search", "\\u", "space", ":", "\\", "10", ";", " ", " ", "dim", ":", "\\", "10", ";", " ", " ", " ", " ", "min", ":", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "max", ":", " ", "10", "\\", "10", ";", " ", " ", " ", " ", "type", ":", " ", "int", "\\", "10", ";", "\\", "10", ";", "cv", ":", " ", "3", "\\", "10", ";", "\\", "10", ";", "tria", "ls", ":", "\\", "10", ";", " ", " ", "uri", ":", " ", "sql", "ite", ":///", "test", ".", "db", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "run", "\\u", "osp", "rey", "_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skipif_", "(_", "'", "pyl", "earn", "2", "'_", "not_", "in_", "sys_", "._", "modules_", ",_", "'", "this", " ", "test", " ", "require", "s", " ", "pyl", "earn", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "pyl", "earn", "2", "\\u", "dataset", "\\u", "loader_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yaml", "\\u", "string_", "=_", "\"\"\"", "\\", "10", ";", "!", "obj", ":", "pyl", "earn", "2", ".", "testi", "ng", ".", "dataset", "s", ".", "random", "\\u", "dens", "e\\u", "design", "\\u", "matrix", " ", "{", "\\", "10", ";", " ", " ", "rng", ":", " ", "!", "obj", ":", "nump", "y", ".", "random", ".", "Random", "State", " ", "{", " ", "seed", ":", " ", "1", " ", "},", "\\", "10", ";", " ", " ", "num", "\\u", "example", "s", ":", " ", "10", ",", "\\", "10", ";", " ", " ", "dim", ":", " ", "5", ",", "\\", "10", ";", " ", " ", "num", "\\u", "classe", "s", ":", " ", "3", ",", "\\", "10", ";}", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dataset", "\\u", "loader_", "=_", "Py", "learn", "2", "Datas", "et", "Loader_", "(_", "yaml", "\\u", "string_", ",_", "one", "\\u", "hot_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "X_", ",_", "y_", "=_", "dataset", "\\u", "loader_", "._", "load_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "X_", "._", "shape_", "==_", "(_", "10_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "y_", "._", "shape_", "==_", "(_", "10_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "unique_", "(_", "y_", ")_", "._", "size_", "==_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plug", "in", "Py", "learn", "2_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skipif_", "(_", "'", "pyl", "earn", "2", "'_", "not_", "in_", "sys_", "._", "modules_", ",_", "'", "this", " ", "test", " ", "require", "s", " ", "pyl", "earn", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "pyl", "earn", "2", "\\u", "dataset", "\\u", "load", "er", "\\u", "one", "\\u", "hot_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yaml", "\\u", "string_", "=_", "\"\"\"", "\\", "10", ";", "!", "obj", ":", "pyl", "earn", "2", ".", "testi", "ng", ".", "dataset", "s", ".", "random", "\\u", "one", "\\u", "hot", "\\u", "dens", "e\\u", "design", "\\u", "matrix", " ", "{", "\\", "10", ";", " ", " ", "rng", ":", " ", "!", "obj", ":", "nump", "y", ".", "random", ".", "Random", "State", " ", "{", " ", "seed", ":", " ", "1", " ", "},", "\\", "10", ";", " ", " ", "num", "\\u", "example", "s", ":", " ", "10", ",", "\\", "10", ";", " ", " ", "dim", ":", " ", "5", ",", "\\", "10", ";", " ", " ", "num", "\\u", "classe", "s", ":", " ", "3", ",", "\\", "10", ";}", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dataset", "\\u", "loader_", "=_", "Py", "learn", "2", "Datas", "et", "Loader_", "(_", "yaml", "\\u", "string_", ",_", "one", "\\u", "hot_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "X_", ",_", "y_", "=_", "dataset", "\\u", "loader_", "._", "load_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "X_", "._", "shape_", "==_", "(_", "10_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "y_", "._", "shape_", "==_", "(_", "10_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "unique_", "(_", "y_", ")_", "._", "size_", "==_", "3_" ]
[ 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, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unnecessary pass
Havate/havate-openstack/proto-build/gui/horizon/Horizon_GUI/openstack_dashboard/static-raw/scripts/UcsUtils.py
[ { "content": "import sys\nimport os\nimport ast\nimport time\nimport daemon\nimport logging\nimport yaml\nfrom UcsSdk import *\nfrom passlib.apps import custom_app_context as pwd_context\nfrom jinja2 import Template, Environment, FileSystemLoader\n\n\n\n# Applications supported\npass\n\npass\n\n\n\n# function returns Rn for ServiceProfile instances.\npass\n\n\n###############################################################################################\n# Helper functions can be moved to sepratate file\n\n#\npass\n\n\n#\npass\n\n\n#\npass\n\n# This function is to retrieve LsbootDef of a particular server instance.\npass\n\n# This function is to get lsbootLan Info of lsbootDef\n\npass\n\n#\npass\n\n\n\n# This function is add the system to cobbler\npass\n\n\n\n#get the node-type based on service-profile prefix.\npass\n\n\n###############################################################################################\n# Helper functions can be moved to separate file.\n# Add server-ports to system\npass\n\n# Add Mac-pool to system\npass\n\n# Add service-profiles\npass\n\n# Add service-profiles\n\npass\n\n#\npass\n\n\n\n#\npass\n\n\n#def\npass\n\n#\n\n# dn = serverPoolDn + \"/blade-\" + serverPoolList[ComputePooledSlot.CHASSIS_ID] +\"-\" +serverPoolList[ComputePooledSlot.SLOT_ID]\n# computePooledSlotList = {ComputePooledSlot.CHASSIS_ID: serverPoolList[ComputePooledSlot.CHASSIS_ID], \\\n# ComputePooledSlot.SLOT_ID: serverPoolList[ComputePooledSlot.SLOT_ID]}\n\n # Add server to the pool created above\n# addObjectToUcs(inUcsmHost, serverPoolDn, ComputePool.ClassId(), ComputePooledSlot.ClassId(), computePooledSlotList)\npass\n\n\n#\npass\n\n#\n\npass\n\n\n#\npass\n\n#\npass\n\n\n# Vlan { 'Name':'vlan106', 'SwitchId':'dual', 'Id': '106', 'Sharing':'none', 'DefaultNet':'yes'}\npass\n\npass\n\n# create OrgOrg\npass\n\n\n#UplinkPort {'SwitchId':'A', 'SlotId':'1', 'PortId':'8', 'AdminSpeed':'1gbps'}\npass\n\n#LsRequirement {'SrcTemplDn':'org-root/ls-control-node', 'Name':'control-node'}\npass\n\n\npass\n\n\npass\n\n\npass\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class UcsmHost:\n pass", "metadata": "root.UcsmHost", "header": "['module', '___EOS___']", "index": 20 }, { "content": "def addObjectToUcs(inUcsmHost, pDn, pClassId, classId, pList, inDn):\n \"\"\"This function gets the session and configures the MO in UCS Manager\n If that doesn't exists. If the MO already exists, it just updates the MO.\n \"\"\"\n try:\n handle = UcsHandle()\n login = handle.Login(inUcsmHost.hostname, inUcsmHost.username, inUcsmHost.password)\n if (login == False):\n logging.debug('[Error]: Login Failed')\n sys.exit(0)\n\n res = handle.GetManagedObject(None, pClassId, {\"Dn\":pDn}, dumpXml=inUcsmHost.debug)\n moRes = handle.GetManagedObject(None, classId, {\"Dn\":inDn}, dumpXml=inUcsmHost.debug)\n if not moRes:\n result = handle.AddManagedObject(res, classId, pList, dumpXml=inUcsmHost.debug)\n else:\n logging.debug('Mo exists, just updating')\n result = handle.SetManagedObject(moRes, classId, pList, dumpXml=inUcsmHost.debug, force=True)\n pass\n\n handle.Logout()\n\n except Exception, err:\n print \"1Exception:\", str(err)\n import traceback, sys\n print '-'*60\n traceback.print_exc(file=sys.stdout)\n print '-'*60\n pass", "metadata": "root.addObjectToUcs", "header": "['module', '___EOS___']", "index": 42 }, { "content": "def getHostAdaptorEthIf(handle, inComputeServer, inHostName, inImagePath, inAssignedToDn):\n logging.debug('[Info] Add System to Cobbler')\n hostEthIfs = getAdaptorHostEthIf(handle, inComputeServer, inImagePath.getattr(\"VnicName\"))\n\n for hostEthIf in hostEthIfs:\n isExists = isSystemExists(hostEthIf.getattr(\"Mac\"))\n logging.debug('Mac -' + hostEthIf.getattr(\"Mac\"))\n if (not isExists):\n logging.debug('[Info] cobbler system add --name=' + inHostName + \\\n ' --interface=' + inImagePath.getattr(\"Type\") + ' --mac=' + \\\n hostEthIf.getattr(\"Mac\") + ' --profile=' + getRn(inAssignedToDn))\n if (inImagePath.getattr(\"Type\") == \"primary\"):\n addSystem(inHostName, getRn(inAssignedToDn), hostEthIf.getattr(\"Mac\"))\n elif (inImagePath.getattr(\"Type\") == \"secondary\"):\n updateSystem(inHostName, getRn(inAssignedToDn), hostEthIf.getattr(\"Mac\"))\n else:\n logging.debug('System exists')\n pass\n\n pass", "metadata": "root.getHostAdaptorEthIf", "header": "['module', '___EOS___']", "index": 102 }, { "content": "def getLsbootLan(connHandle, lsbootDef):\n logging.debug('In getLsbootLan')\n inFilter = FilterFilter()\n wcardFilter = WcardFilter()\n wcardFilter.Class = \"lsbootLan\"\n wcardFilter.Property = \"dn\"\n wcardFilter.Value = \"%s/\"%lsbootDef.getattr(\"Dn\")\n inFilter.AddChild(wcardFilter)\n\n lsbootLan = connHandle.ConfigResolveClass(LsbootLan.ClassId(), inFilter, YesOrNo.TRUE, dumpXml = False)\n if (lsbootLan.errorCode == 0):\n return lsbootLan.OutConfigs.GetChild()\n else:\n logging.debug('Failed to get lsbootLan')\n pass", "metadata": "root.getLsbootLan", "header": "['module', '___EOS___']", "index": 140 }, { "content": "def addHostsToCobbler(connHandle, lsbootDef, inCompServer):\n logging.debug('In addHostsToCobbler')\n # lsbootDef contains only one LsbootLan Mo\n bootLan = getLsbootLan(connHandle, lsbootDef)\n for lsbootLan in bootLan:\n if ((lsbootLan != 0) and (isinstance(lsbootLan, ManagedObject) == True) and (lsbootLan.classId == \"LsbootLan\")):\n for imagePath in lsbootLan.GetChild():\n if ((imagePath != 0)):\n server_dn = inCompServer.Dn\n actual_name = server_dn.replace('/', '_')\n hostEthIfs = getHostAdaptorEthIf(connHandle, inCompServer, actual_name, imagePath, inCompServer.getattr(\"AssignedToDn\"))\n pass\n pass\n pass\n pass\n pass", "metadata": "root.addHostsToCobbler", "header": "['module', '___EOS___']", "index": 189 }, { "content": "def getNodeType(inHostName):\n \"\"\" Retunrs the node-type, the convention is,\n if the node is strting with compute- returns compute node\n if the node is strting with control- returns control node.\n \"\"\"\n if (inHostName.startswith(\"compute-\")):\n return \"compute\"\n elif (inHostName.startswith(\"control-\")):\n return \"control\"\n pass\n\n return \" \"", "metadata": "root.getNodeType", "header": "['module', '___EOS___']", "index": 210 }, { "content": "def createVnicEther(inUcsmHost, vnicInfoStr):\n \"\"\"Configures vNIC interface in UCS Manager.\"\"\"\n logging.debug('creating vnic-ether')\n vnicInfoList = ast.literal_eval(vnicInfoStr)\n\n pDn = \"org-root/ls-\" + vnicInfoList[\"LsServer\"]\n vnicEtherDn = pDn + \"/ether-\" + vnicInfoList[VnicEther.NAME]\n\n\tvnicEtherOrder = VnicEther.CONST_ORDER_UNSPECIFIED\n\n\tif VnicEther.ORDER in vnicInfoList.keys():\n\t\tlogging.debug('VnicEther Order specified %s' %(vnicInfoList[VnicEther.ORDER]))\n\t\tvnicEtherOrder = vnicInfoList[VnicEther.ORDER]\n\tpass\n\n vnicEtherList = {VnicEther.NAME: vnicInfoList[VnicEther.NAME], \\\n VnicEther.SWITCH_ID: vnicInfoList[VnicEther.SWITCH_ID], \\\n VnicEther.IDENT_POOL_NAME: vnicInfoList[VnicEther.IDENT_POOL_NAME], \\\n\t\t\t VnicEther.ORDER: vnicEtherOrder}\n\n # add vnicEther to the LsServer\n addObjectToUcs(inUcsmHost, pDn, LsServer.ClassId(), VnicEther.ClassId(), vnicEtherList, vnicEtherDn)\n\n vnicEtherIfDn = vnicEtherDn + \"/if-\" + vnicInfoList[\"VlanName\"]\n vnicEtherIfList = {VnicEtherIf.NAME: vnicInfoList[\"VlanName\"], \\\n VnicEtherIf.DEFAULT_NET: vnicInfoList[VnicEtherIf.DEFAULT_NET]}\n\n # Add the Vlan to vnicEther created above.\n addObjectToUcs(inUcsmHost, vnicEtherDn, VnicEther.ClassId(), VnicEtherIf.ClassId(), vnicEtherIfList, vnicEtherIfDn)", "metadata": "root.createVnicEther", "header": "['module', '___EOS___']", "index": 337 }, { "content": "def createComputeQual(inUcsmHost, computeQualStr):\n \"\"\"Configures Server Qualification policy in UCS Manager.\"\"\"\n logging.debug('create compute qual')\n computeQualList = ast.literal_eval(computeQualStr)\n\n pDn = \"org-root\" # is this added under org-root always?\n computeQualDn = pDn + \"/blade-qualifier-\" + computeQualList[ComputeQual.NAME]\n computeQualStr = {ComputeQual.NAME: computeQualList[ComputeQual.NAME]}\n\n # Create compute-qualifier\n addObjectToUcs(inUcsmHost, pDn, OrgOrg.ClassId(), ComputeQual.ClassId(), computeQualStr, computeQualDn)\n\n computeChassisQualStr = {ComputeChassisQual.MIN_ID: computeQualList[ComputeChassisQual.MIN_ID], \\\n ComputeChassisQual.MAX_ID: computeQualList[ComputeChassisQual.MAX_ID]}\n computeChassisQualDn = computeQualDn + \"/chassis-from-\" + computeQualList[ComputeChassisQual.MIN_ID] + \"-to-\" + computeQualList[ComputeChassisQual.MAX_ID]\n\n # Add Chassis Qualifier\n addObjectToUcs(inUcsmHost, computeQualDn, ComputeQual.ClassId(), ComputeChassisQual.ClassId(), computeChassisQualStr, computeChassisQualDn)\n logging.debug(\"computeQualDn\"+computeQualDn)\n i = int(computeQualList[ComputeChassisQual.MIN_ID])\n while i <= (int(computeQualList[ComputeChassisQual.MAX_ID])):\n computeSlotQualDn = computeChassisQualDn + \"/slot-from-\" + computeQualList[\"SlotMinId\"] + \"-to-\" + computeQualList[\"SlotMaxId\"]\n computeSlotQualList = {ComputeSlotQual.MIN_ID: computeQualList[\"SlotMinId\"], \\\n ComputeSlotQual.MAX_ID: computeQualList[\"SlotMaxId\"]}\n logging.debug(\"computeQual:\" + computeChassisQualDn)\n addObjectToUcs(inUcsmHost, computeChassisQualDn, ComputeChassisQual.ClassId(), ComputeSlotQual.ClassId(), computeSlotQualList, computeSlotQualDn)\n\t\ti += 1\n pass", "metadata": "root.createComputeQual", "header": "['module', '___EOS___']", "index": 391 }, { "content": "def createVlan(inUcsmHost, fabricVlanStr):\n \"\"\" Configures VLAN in UCS Manager. \"\"\"\n logging.debug('create vlan')\n fabricVlanList = ast.literal_eval(fabricVlanStr)\n\n pDn = \"fabric/lan\" # fabricLanCloud\n fabricVlanDn = pDn + \"/net-\" + fabricVlanList[FabricVlan.NAME]\n\n # Check if user is intended to create range of vLANs\n vlanIds = fabricVlanList[FabricVlan.ID]\n ids = vlanIds.rsplit('-')\n\n if (len(ids) == 2):\n for i in range(int(ids[0]), int(ids[1])):\n fabricVlanRes = {FabricVlan.NAME: \"vlan-os\" + str(i), \\\n FabricVlan.ID: i,\\\n FabricVlan.SHARING: 'none',\\\n FabricVlan.DEFAULT_NET: 'no'}\n #Add Mo to UCS Manager\n addObjectToUcs(inUcsmHost, pDn, FabricLanCloud.ClassId(), FabricVlan.ClassId(), fabricVlanRes, fabricVlanDn)\n pass\n else:\n fabricVlanRes = {FabricVlan.NAME: fabricVlanList[FabricVlan.NAME], \\\n FabricVlan.ID: fabricVlanList[FabricVlan.ID],\\\n FabricVlan.SHARING: fabricVlanList[FabricVlan.SHARING],\\\n FabricVlan.DEFAULT_NET: fabricVlanList[FabricVlan.DEFAULT_NET]}\n\n # Add Mo to UCS Manager\n addObjectToUcs(inUcsmHost, pDn, FabricLanCloud.ClassId(), FabricVlan.ClassId(), fabricVlanRes, fabricVlanDn)\n\tpass", "metadata": "root.createVlan", "header": "['module', '___EOS___']", "index": 474 }, { "content": "def createSPInstance(inUcsmHost, lsServerInstancesStr):\n\t\"\"\"Creates N number of service profiles instantiating from SrcTempl.\"\"\"\n\tlogging.debug('creating SP Instances')\n\tlsServerInstancesList = ast.literal_eval(lsServerInstancesStr)\n\n\thandle = UcsHandle()\n\tlogin = handle.Login(inUcsmHost.hostname, inUcsmHost.username, inUcsmHost.password)\n\tif (login == False):\n\t\tlogging.debug('[Error]: Login Failed')\n\t\tsys.exit(0)\n\n\tresMos = handle.GetManagedObject(None, LsServer.ClassId(), {\"Name\":lsServerInstancesList['SrcTempl']}, dumpXml=inUcsmHost.debug)\n\tif resMos:\n\t\tfor spMo in resMos:\n\t\t\thandle.LsInstantiateNTemplate(spMo.getattr(LsServer.DN), lsServerInstancesList['NumberOf'], \\\n\t\t\t\tlsServerInstancesList['NamePrefix'], lsServerInstancesList['TargetOrg'], dumpXml=True)\n\t\t\tpass\n\t\tpass\n\tpass\n\n\thandle.Logout()", "metadata": "root.createSPInstance", "header": "['module', '___EOS___']", "index": 506 }, { "content": "def getClassId(lsbootPolicyList):\n \"\"\" returns the classId based on the type\"\"\"\n\tlClassId = 'None'\n\n if 'vm' == lsbootPolicyList['type']:\n lClassId = LsbootVirtualMedia.ClassId()\n elif 'storage' == lsbootPolicyList['type']:\n lClassId = LsbootStorage.ClassId()\n elif 'lan' == lsbootPolicyList['type']:\n lClassId = LsbootLan.ClassId()\n pass\n\tlogging.debug('ClassId'+lClassId)\n\treturn lClassId", "metadata": "root.getClassId", "header": "['module', '___EOS___']", "index": 598 }, { "content": "def createLsbootPolicy(inUcsmHost, lsbootPolicyStr):\n \"\"\"Configures the LsbootPolicy policies.\"\"\"\n logging.debug('create LsbootPolicy ' + lsbootPolicyStr)\n lsbootPolicyList = ast.literal_eval(lsbootPolicyStr)\n\n pDn = lsbootPolicyList['TargetOrg']\n\n lsbootPolicyDn = pDn + \"/boot-policy-\" + lsbootPolicyList[LsbootPolicy.NAME]\n inUcsmHost.debug = True\n lsbootPolicyResList = {\n LsbootPolicy.NAME: lsbootPolicyList[LsbootPolicy.NAME], \\\n LsbootPolicy.PURPOSE: lsbootPolicyList[LsbootPolicy.PURPOSE], \\\n LsbootPolicy.REBOOT_ON_UPDATE: lsbootPolicyList[LsbootPolicy.REBOOT_ON_UPDATE], \\\n LsbootPolicy.ENFORCE_VNIC_NAME: lsbootPolicyList[LsbootPolicy.ENFORCE_VNIC_NAME], \\\n LsbootPolicy.DESCR: lsbootPolicyList[LsbootPolicy.DESCR]\n }\n\n addObjectToUcs(inUcsmHost, pDn, OrgOrg.ClassId(), LsbootPolicy.ClassId(), lsbootPolicyResList, lsbootPolicyDn)\n\n # VirtualMedia read-only Access\n if 'vm-ro' in lsbootPolicyList.keys():\n rnPrefix = lsbootPolicyList['vm-ro']['Access'] + \"-\" + lsbootPolicyList['vm-ro']['Type']\n lsbootVirtualMediaDn = lsbootPolicyDn + \"/\" + rnPrefix\n lsbootVirtualMediaList = lsbootPolicyList['vm-ro'] \n \taddObjectToUcs(inUcsmHost, lsbootPolicyDn, LsbootPolicy.ClassId(), LsbootVirtualMedia.ClassId(), lsbootVirtualMediaList, lsbootVirtualMediaDn)\n\tpass\n\n # LAN or PXE Boot option\n if 'lan' in lsbootPolicyList.keys():\n rnPrefix = lsbootPolicyList['lan']['Type']\n lsbootLanDn = lsbootPolicyDn + \"/\" + rnPrefix\n\t\tlsbootLanImagePathList = lsbootPolicyList['lan'].pop('ImagePath')\n lsbootLanList = lsbootPolicyList['lan']\n\t addObjectToUcs(inUcsmHost, lsbootPolicyDn, LsbootPolicy.ClassId(), LsbootLan.ClassId(), lsbootLanList, lsbootLanDn)\n\t\t#ImagePath\n\t\tlsbootLanImagePathDn = lsbootLanDn + \"/path-\" + lsbootLanImagePathList['Type']\n\t\taddObjectToUcs(inUcsmHost, lsbootLanDn, LsbootLan.ClassId(), LsbootLanImagePath.ClassId(), lsbootLanImagePathList, lsbootLanImagePathDn)\n\n\tpass\n\n # Storage/LocalStorage\n if 'storage' in lsbootPolicyList.keys():\n\n rnPrefix = lsbootPolicyList['storage']['Type']\n\n lsbootStorageDn = lsbootPolicyDn + \"/\" + rnPrefix\n lsbootStorageList = lsbootPolicyList['storage'] \n \taddObjectToUcs(inUcsmHost, lsbootPolicyDn, LsbootPolicy.ClassId(), LsbootStorage.ClassId(), lsbootStorageList, lsbootStorageDn)\n\t\tlsbootLocalStorageDn = lsbootStorageDn + \"/\" + \"local-storage\"\n\t\taddObjectToUcs(inUcsmHost, lsbootStorageDn, LsbootStorage.ClassId(), LsbootLocalStorage.ClassId(), {}, lsbootLocalStorageDn)\n\n\tpass\n\n # VirtualMedia read-write Access\n if 'vm-rw' in lsbootPolicyList.keys():\n rnPrefix = lsbootPolicyList['vm-rw']['Access'] + \"-\" + lsbootPolicyList['vm-rw']['Type']\n lsbootVirtualMediaDn = lsbootPolicyDn + \"/\" + rnPrefix\n lsbootVirtualMediaList = lsbootPolicyList['vm-rw']\n \taddObjectToUcs(inUcsmHost, lsbootPolicyDn, LsbootPolicy.ClassId(), LsbootVirtualMedia.ClassId(), lsbootVirtualMediaList, lsbootVirtualMediaDn)\n\tpass", "metadata": "root.createLsbootPolicy", "header": "['module', '___EOS___']", "index": 614 } ]
[ { "span": "pass", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 4 }, { "span": "pass", "start_line": 28, "start_column": 0, "end_line": 28, "end_column": 4 }, { "span": "pass", "start_line": 35, "start_column": 0, "end_line": 35, "end_column": 4 }, { "span": "pass", "start_line": 71, "start_column": 0, "end_line": 71, "end_column": 4 }, { "span": "pass", "start_line": 98, "start_column": 0, "end_line": 98, "end_column": 4 }, { "span": "pass", "start_line": 122, "start_column": 0, "end_line": 122, "end_column": 4 }, { "span": "pass", "start_line": 137, "start_column": 0, "end_line": 137, "end_column": 4 }, { "span": "pass", "start_line": 156, "start_column": 0, "end_line": 156, "end_column": 4 }, { "span": "pass", "start_line": 184, "start_column": 0, "end_line": 184, "end_column": 4 }, { "span": "pass", "start_line": 205, "start_column": 0, "end_line": 205, "end_column": 4 }, { "span": "pass", "start_line": 222, "start_column": 0, "end_line": 222, "end_column": 4 }, { "span": "pass", "start_line": 241, "start_column": 0, "end_line": 241, "end_column": 4 }, { "span": "pass", "start_line": 261, "start_column": 0, "end_line": 261, "end_column": 4 }, { "span": "pass", "start_line": 274, "start_column": 0, "end_line": 274, "end_column": 4 }, { "span": "pass", "start_line": 292, "start_column": 0, "end_line": 292, "end_column": 4 }, { "span": "pass", "start_line": 305, "start_column": 0, "end_line": 305, "end_column": 4 }, { "span": "pass", "start_line": 333, "start_column": 0, "end_line": 333, "end_column": 4 }, { "span": "pass", "start_line": 366, "start_column": 0, "end_line": 366, "end_column": 4 }, { "span": "pass", "start_line": 387, "start_column": 0, "end_line": 387, "end_column": 4 }, { "span": "pass", "start_line": 419, "start_column": 0, "end_line": 419, "end_column": 4 }, { "span": "pass", "start_line": 440, "start_column": 0, "end_line": 440, "end_column": 4 }, { "span": "pass", "start_line": 457, "start_column": 0, "end_line": 457, "end_column": 4 }, { "span": "pass", "start_line": 470, "start_column": 0, "end_line": 470, "end_column": 4 }, { "span": "pass", "start_line": 504, "start_column": 0, "end_line": 504, "end_column": 4 }, { "span": "pass", "start_line": 527, "start_column": 0, "end_line": 527, "end_column": 4 }, { "span": "pass", "start_line": 542, "start_column": 0, "end_line": 542, "end_column": 4 }, { "span": "pass", "start_line": 556, "start_column": 0, "end_line": 556, "end_column": 4 }, { "span": "pass", "start_line": 574, "start_column": 0, "end_line": 574, "end_column": 4 }, { "span": "pass", "start_line": 595, "start_column": 0, "end_line": 595, "end_column": 4 }, { "span": "pass", "start_line": 611, "start_column": 0, "end_line": 611, "end_column": 4 }, { "span": "pass", "start_line": 674, "start_column": 0, "end_line": 674, "end_column": 4 }, { "span": "pass", "start_line": 27, "start_column": 8, "end_line": 27, "end_column": 12 }, { "span": "pass", "start_line": 60, "start_column": 16, "end_line": 60, "end_column": 20 }, { "span": "pass", "start_line": 70, "start_column": 8, "end_line": 70, "end_column": 12 }, { "span": "pass", "start_line": 119, "start_column": 16, "end_line": 119, "end_column": 20 }, { "span": "pass", "start_line": 121, "start_column": 8, "end_line": 121, "end_column": 12 }, { "span": "pass", "start_line": 154, "start_column": 8, "end_line": 154, "end_column": 12 }, { "span": "pass", "start_line": 200, "start_column": 40, "end_line": 200, "end_column": 44 }, { "span": "pass", "start_line": 201, "start_column": 32, "end_line": 201, "end_column": 36 }, { "span": "pass", "start_line": 202, "start_column": 24, "end_line": 202, "end_column": 28 }, { "span": "pass", "start_line": 203, "start_column": 16, "end_line": 203, "end_column": 20 }, { "span": "pass", "start_line": 204, "start_column": 8, "end_line": 204, "end_column": 12 }, { "span": "pass", "start_line": 219, "start_column": 8, "end_line": 219, "end_column": 12 }, { "span": "pass", "start_line": 350, "start_column": 1, "end_line": 350, "end_column": 5 }, { "span": "pass", "start_line": 418, "start_column": 8, "end_line": 418, "end_column": 12 }, { "span": "pass", "start_line": 494, "start_column": 16, "end_line": 494, "end_column": 20 }, { "span": "pass", "start_line": 503, "start_column": 1, "end_line": 503, "end_column": 5 }, { "span": "pass", "start_line": 522, "start_column": 3, "end_line": 522, "end_column": 7 }, { "span": "pass", "start_line": 523, "start_column": 2, "end_line": 523, "end_column": 6 }, { "span": "pass", "start_line": 524, "start_column": 1, "end_line": 524, "end_column": 5 }, { "span": "pass", "start_line": 608, "start_column": 8, "end_line": 608, "end_column": 12 }, { "span": "pass", "start_line": 639, "start_column": 1, "end_line": 639, "end_column": 5 }, { "span": "pass", "start_line": 652, "start_column": 1, "end_line": 652, "end_column": 5 }, { "span": "pass", "start_line": 665, "start_column": 1, "end_line": 665, "end_column": 5 }, { "span": "pass", "start_line": 673, "start_column": 1, "end_line": 673, "end_column": 5 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[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_", "ast_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "daemon_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "yaml_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Uc", "s", "Sd", "k_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pass", "lib_", "._", "apps_", "import_", "custom", "\\u", "app", "\\u", "context_", "as_", "pwd", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "jinja2_", "import_", "Template_", ",_", "Environment_", ",_", "File", "System", "Loader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Applica", "tion", "s", " ", "supported_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "function", " ", "return", "s", " ", "Rn", " ", "for", " ", "Service", "Profil", "e", " ", "instance", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Help", "er", " ", "function", "s", " ", "can", " ", "be", " ", "moved", " ", "to", " ", "sep", "rat", "ate", " ", "file_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "function", " ", "is", " ", "to", " ", "retrieve", " ", "Ls", "boot", "Def", " ", "of", " ", "a", " ", "partic", "ular", " ", "server", " ", "instance", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "function", " ", "is", " ", "to", " ", "get", " ", "lsb", "oot", "Lan", " ", "Info", " ", "of", " ", "lsb", "oot", "Def_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "function", " ", "is", " ", "add", " ", "the", " ", "system", " ", "to", " ", "cobble", "r_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "get", " ", "the", " ", "node", "-", "type", " ", "based", " ", "on", " ", "service", "-", "profile", " ", "prefix", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Help", "er", " ", "function", "s", " ", "can", " ", "be", " ", "moved", " ", "to", " ", "separate", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "server", "-", "port", "s", " ", "to", " ", "system_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "Mac", "-", "pool", " ", "to", " ", "system_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "service", "-", "profiles_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "service", "-", "profiles_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "def_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\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_", "#", " ", " ", " ", "dn", " ", "=", " ", "server", "Poo", "l", "Dn", " ", "+", " ", "\"/", "blade", "-\"", " ", "+", " ", "server", "Poo", "l", "List", "[", "Compute", "Poo", "led", "Slot", ".", "CHA", "SSI", "S", "\\u", "ID", "]", " ", "+\"", "-\"", " ", "+", "server", "Poo", "l", "List", "[", "Compute", "Poo", "led", "Slot", ".", "SLOT", "\\u", "ID", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "compute", "Poo", "led", "Slot", "List", " ", "=", " ", "{", "Compute", "Poo", "led", "Slot", ".", "CHA", "SSI", "S", "\\u", "ID", ":", " ", "server", "Poo", "l", "List", "[", "Compute", "Poo", "led", "Slot", ".", "CHA", "SSI", "S", "\\u", "ID", "],", " ", "\\\\_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", "Compute", "Poo", "led", "Slot", ".", "SLOT", "\\u", "ID", ":", " ", "server", "Poo", "l", "List", "[", "Compute", "Poo", "led", "Slot", ".", "SLOT", "\\u", "ID", "]}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "server", " ", "to", " ", "the", " ", "pool", " ", "created", " ", "above_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "add", "Object", "To", "Uc", "s", "(", "in", "Uc", "sm", "Host", ",", " ", "server", "Poo", "l", "Dn", ",", " ", "Compute", "Poo", "l", ".", "Class", "Id", "()", ",", " ", "Compute", "Poo", "led", "Slot", ".", "Class", "Id", "()", ",", " ", "compute", "Poo", "led", "Slot", "List", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\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_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Vla", "n", " ", "{", " ", "'", "Name", "':", "'", "vlan", "106", "',", " ", "'", "Switch", "Id", "':", "'", "dual", "',", " ", "'", "Id", "':", " ", "'", "106", "',", " ", "'", "Shar", "ing", "':", "'", "none", "',", " ", "'", "Default", "Net", "':", "'", "ye", "s", "'}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "Org", "Org", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Up", "link", "Port", " ", "{", "'", "Switch", "Id", "':", "'", "A", "',", " ", "'", "Slot", "Id", "':", "'", "1", "',", " ", "'", "Port", "Id", "':", "'", "8", "',", " ", "'", "Admi", "n", "Spee", "d", "':", "'", "1", "gbp", "s", "'}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Ls", "Requirement", " ", "{", "'", "Sr", "c", "Temp", "l", "Dn", "':", "'", "org", "-", "root", "/", "ls", "-", "control", "-", "node", "',", " ", "'", "Name", "':", "'", "control", "-", "node", "'}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\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_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "\\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\\uDEDENT\\u\\u\\u_", "pass_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Uc", "sm", "Host_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "p", "Dn", "_", ",_", "p", "Class", "Id_", ",_", "class", "Id_", ",_", "p", "List_", ",_", "in", "Dn", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Thi", "s", " ", "function", " ", "gets", " ", "the", " ", "session", " ", "and", " ", "configur", "es", " ", "the", " ", "MO", " ", "in", " ", "UCS", " ", "Manager", "\\", "10", ";", " ", " ", " ", "If", " ", "tha", "t", " ", "doe", "sn", "'", "t", " ", "exist", "s", ".", " ", "If", " ", "the", " ", "MO", " ", "alr", "ead", "y", " ", "exist", "s", ",", " ", "it", " ", "just", " ", "update", "s", " ", "the", " ", "MO", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handle_", "=_", "Uc", "s", "Handle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "login_", "=_", "handle_", "._", "Login_", "(_", "in", "Uc", "sm", "Host_", "._", "hostname_", ",_", "in", "Uc", "sm", "Host_", "._", "username_", ",_", "in", "Uc", "sm", "Host_", "._", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "login_", "==_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "logging_", "._", "debug_", "(_", "'[", "Error", "]:", " ", "Logi", "n", " ", "Fail", "ed", "'_", ")_", "\\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_", "res_", "=_", "handle_", "._", "Get", "Manage", "d", "Object_", "(_", "None_", ",_", "p", "Class", "Id_", ",_", "{_", "\"", "Dn", "\"_", ":_", "p", "Dn", "_", "}_", ",_", "dump", "Xml_", "=_", "in", "Uc", "sm", "Host_", "._", "debug_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mo", "Res_", "=_", "handle_", "._", "Get", "Manage", "d", "Object_", "(_", "None_", ",_", "class", "Id_", ",_", "{_", "\"", "Dn", "\"_", ":_", "in", "Dn", "_", "}_", ",_", "dump", "Xml_", "=_", "in", "Uc", "sm", "Host_", "._", "debug_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "mo", "Res_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "result_", "=_", "handle_", "._", "Add", "Manage", "d", "Object_", "(_", "res_", ",_", "class", "Id_", ",_", "p", "List_", ",_", "dump", "Xml_", "=_", "in", "Uc", "sm", "Host_", "._", "debug_", ")_", "\\u\\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_", "._", "debug_", "(_", "'", "Mo", " ", "exist", "s", ",", " ", "just", " ", "updat", "ing", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "handle_", "._", "Set", "Manage", "d", "Object_", "(_", "mo", "Res_", ",_", "class", "Id_", ",_", "p", "List_", ",_", "dump", "Xml_", "=_", "in", "Uc", "sm", "Host_", "._", "debug_", ",_", "force_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "handle_", "._", "Logo", "ut_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "1E", "xcept", "ion", ":\"_", ",_", "str_", "(_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'-'_", "*_", "60_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", "file_", "=_", "sys_", "._", "stdout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'-'_", "*_", "60_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Host", "Adapt", "or", "Eth", "If_", "(_", "handle_", ",_", "in", "Compute", "Server_", ",_", "in", "Host", "Name_", ",_", "in", "Image", "Path_", ",_", "in", "Assign", "ed", "To", "Dn", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "debug_", "(_", "'[", "Info", "]", " ", "Add", " ", "System", " ", "to", " ", "Cob", "bler", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "Eth", "If", "s_", "=_", "get", "Adapt", "or", "Host", "Eth", "If_", "(_", "handle_", ",_", "in", "Compute", "Server_", ",_", "in", "Image", "Path_", "._", "getattr_", "(_", "\"", "Vn", "ic", "Name", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "host", "Eth", "If_", "in_", "host", "Eth", "If", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "Exists_", "=_", "is", "System", "Exists_", "(_", "host", "Eth", "If_", "._", "getattr_", "(_", "\"", "Mac", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "Mac", " ", "-'_", "+_", "host", "Eth", "If_", "._", "getattr_", "(_", "\"", "Mac", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "is", "Exists_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "logging_", "._", "debug_", "(_", "'[", "Info", "]", " ", "cobble", "r", " ", "system", " ", "add", " ", "--", "name", "='_", "+_", "in", "Host", "Name_", "+_", "'", " ", "--", "interface", "='_", "+_", "in", "Image", "Path_", "._", "getattr_", "(_", "\"", "Type", "\"_", ")_", "+_", "'", " ", "--", "mac", "='_", "+_", "host", "Eth", "If_", "._", "getattr_", "(_", "\"", "Mac", "\"_", ")_", "+_", "'", " ", "--", "profile", "='_", "+_", "get", "Rn", "_", "(_", "in", "Assign", "ed", "To", "Dn", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "in", "Image", "Path_", "._", "getattr_", "(_", "\"", "Type", "\"_", ")_", "==_", "\"", "primary", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "add", "System_", "(_", "in", "Host", "Name_", ",_", "get", "Rn", "_", "(_", "in", "Assign", "ed", "To", "Dn", "_", ")_", ",_", "host", "Eth", "If_", "._", "getattr_", "(_", "\"", "Mac", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "in", "Image", "Path_", "._", "getattr_", "(_", "\"", "Type", "\"_", ")_", "==_", "\"", "second", "ary", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "update", "System_", "(_", "in", "Host", "Name_", ",_", "get", "Rn", "_", "(_", "in", "Assign", "ed", "To", "Dn", "_", ")_", ",_", "host", "Eth", "If_", "._", "getattr_", "(_", "\"", "Mac", "\"_", ")_", ")_", "\\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 ", " ", " _", "logging_", "._", "debug_", "(_", "'", "System", " ", "exist", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Ls", "boot", "Lan", "_", "(_", "conn", "Handle_", ",_", "lsb", "oot", "Def_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "debug_", "(_", "'", "In", " ", "get", "Ls", "boot", "Lan", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Filter_", "=_", "Filter", "Filter_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wc", "ard", "Filter_", "=_", "Wc", "ard", "Filter_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wc", "ard", "Filter_", "._", "Class_", "=_", "\"", "lsb", "oot", "Lan", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wc", "ard", "Filter_", "._", "Property_", "=_", "\"", "dn", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wc", "ard", "Filter_", "._", "Value_", "=_", "\"%", "s", "/\"_", "%_", "lsb", "oot", "Def_", "._", "getattr_", "(_", "\"", "Dn", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Filter_", "._", "Add", "Child_", "(_", "wc", "ard", "Filter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lsb", "oot", "Lan", "_", "=_", "conn", "Handle_", "._", "Config", "Resolv", "e", "Class_", "(_", "Ls", "boot", "Lan", "_", "._", "Class", "Id_", "(_", ")_", ",_", "in", "Filter_", ",_", "Ye", "s", "Or", "No_", "._", "TRUE_", ",_", "dump", "Xml_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "lsb", "oot", "Lan", "_", "._", "error", "Code_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "lsb", "oot", "Lan", "_", "._", "Out", "Configs", "_", "._", "Get", "Child_", "(_", ")_", "\\u\\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_", "._", "debug_", "(_", "'", "Fail", "ed", " ", "to", " ", "get", " ", "lsb", "oot", "Lan", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "add", "Host", "s", "To", "Cob", "bler", "_", "(_", "conn", "Handle_", ",_", "lsb", "oot", "Def_", ",_", "in", "Comp", "Server_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "debug_", "(_", "'", "In", " ", "add", "Host", "s", "To", "Cob", "bler", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "lsb", "oot", "Def", " ", "contain", "s", " ", "only", " ", "one", " ", "Ls", "boot", "Lan", " ", "Mo", "_", "\\u\\u\\uNL\\u\\u\\u_", "boot", "Lan", "_", "=_", "get", "Ls", "boot", "Lan", "_", "(_", "conn", "Handle_", ",_", "lsb", "oot", "Def_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "lsb", "oot", "Lan", "_", "in_", "boot", "Lan", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "(_", "lsb", "oot", "Lan", "_", "!=_", "0_", ")_", "and_", "(_", "isinstance_", "(_", "lsb", "oot", "Lan", "_", ",_", "Manage", "d", "Object_", ")_", "==_", "True_", ")_", "and_", "(_", "lsb", "oot", "Lan", "_", "._", "class", "Id_", "==_", "\"", "Ls", "boot", "Lan", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "image", "Path_", "in_", "lsb", "oot", "Lan", "_", "._", "Get", "Child_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "(_", "(_", "image", "Path_", "!=_", "0_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " _", "server", "\\u", "dn_", "=_", "in", "Comp", "Server_", "._", "Dn", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actual", "\\u", "name_", "=_", "server", "\\u", "dn_", "._", "replace_", "(_", "'/'_", ",_", "'\\u'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "Eth", "If", "s_", "=_", "get", "Host", "Adapt", "or", "Eth", "If_", "(_", "conn", "Handle_", ",_", "in", "Comp", "Server_", ",_", "actual", "\\u", "name_", ",_", "image", "Path_", ",_", "in", "Comp", "Server_", "._", "getattr_", "(_", "\"", "Assign", "ed", "To", "Dn", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\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_", "pass_", "\\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_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Node", "Type_", "(_", "in", "Host", "Name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Ret", "unr", "s", " ", "the", " ", "node", "-", "type", ",", " ", "the", " ", "convention", " ", "is", ",", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "the", " ", "node", " ", "is", " ", "strt", "ing", " ", "with", " ", "compute", "-", " ", "return", "s", " ", "compute", " ", "node", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "the", " ", "node", " ", "is", " ", "strt", "ing", " ", "with", " ", "control", "-", " ", "return", "s", " ", "control", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "in", "Host", "Name_", "._", "startswith_", "(_", "\"", "compute", "-\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "compute", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "in", "Host", "Name_", "._", "startswith_", "(_", "\"", "control", "-\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "control", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\"", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create", "Vn", "ic", "Ether", "_", "(_", "in", "Uc", "sm", "Host_", ",_", "vnic", "Info", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Configure", "s", " ", "v", "NIC", " ", "interface", " ", "in", " ", "UCS", " ", "Manager", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "creati", "ng", " ", "vnic", "-", "ether", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vnic", "Info", "List_", "=_", "ast_", "._", "literal", "\\u", "eval_", "(_", "vnic", "Info", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "Dn", "_", "=_", "\"", "org", "-", "root", "/", "ls", "-\"_", "+_", "vnic", "Info", "List_", "[_", "\"", "Ls", "Server", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vnic", "Ether", "Dn", "_", "=_", "p", "Dn", "_", "+_", "\"/", "ether", "-\"_", "+_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "_", "._", "NAME_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vnic", "Ether", "Order_", "=_", "Vn", "ic", "Ether", "_", "._", "CONST", "\\u", "ORDE", "R", "\\u", "UNSPEC", "IFIED", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "Vn", "ic", "Ether", "_", "._", "ORDER_", "in_", "vnic", "Info", "List_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "logging_", "._", "debug_", "(_", "'", "Vn", "ic", "Ether", " ", "Order", " ", "specified", " ", "%", "s", "'_", "%_", "(_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "_", "._", "ORDER_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vnic", "Ether", "Order_", "=_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "_", "._", "ORDER_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vnic", "Ether", "List_", "=_", "{_", "Vn", "ic", "Ether", "_", "._", "NAME_", ":_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "_", "._", "NAME_", "]_", ",_", "Vn", "ic", "Ether", "_", "._", "SWITCH", "\\u", "ID_", ":_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "_", "._", "SWITCH", "\\u", "ID_", "]_", ",_", "Vn", "ic", "Ether", "_", "._", "IDENT", "\\u", "POOL", "\\u", "NAME_", ":_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "_", "._", "IDENT", "\\u", "POOL", "\\u", "NAME_", "]_", ",_", "Vn", "ic", "Ether", "_", "._", "ORDER_", ":_", "vnic", "Ether", "Order_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "vnic", "Ether", " ", "to", " ", "the", " ", "Ls", "Server_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "p", "Dn", "_", ",_", "Ls", "Server_", "._", "Class", "Id_", "(_", ")_", ",_", "Vn", "ic", "Ether", "_", "._", "Class", "Id_", "(_", ")_", ",_", "vnic", "Ether", "List_", ",_", "vnic", "Ether", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vnic", "Ether", "If", "Dn", "_", "=_", "vnic", "Ether", "Dn", "_", "+_", "\"/", "if", "-\"_", "+_", "vnic", "Info", "List_", "[_", "\"", "Vla", "n", "Name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vnic", "Ether", "If", "List_", "=_", "{_", "Vn", "ic", "Ether", "If_", "._", "NAME_", ":_", "vnic", "Info", "List_", "[_", "\"", "Vla", "n", "Name", "\"_", "]_", ",_", "Vn", "ic", "Ether", "If_", "._", "DEF", "AUL", "T", "\\u", "NET", "_", ":_", "vnic", "Info", "List_", "[_", "Vn", "ic", "Ether", "If_", "._", "DEF", "AUL", "T", "\\u", "NET", "_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "the", " ", "Vla", "n", " ", "to", " ", "vnic", "Ether", " ", "created", " ", "above", "._", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "vnic", "Ether", "Dn", "_", ",_", "Vn", "ic", "Ether", "_", "._", "Class", "Id_", "(_", ")_", ",_", "Vn", "ic", "Ether", "If_", "._", "Class", "Id_", "(_", ")_", ",_", "vnic", "Ether", "If", "List_", ",_", "vnic", "Ether", "If", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create", "Compute", "Qual", "_", "(_", "in", "Uc", "sm", "Host_", ",_", "compute", "Qual", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Configure", "s", " ", "Server", " ", "Qualifi", "cation", " ", "policy", " ", "in", " ", "UCS", " ", "Manager", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "create", " ", "compute", " ", "qual", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compute", "Qual", "List_", "=_", "ast_", "._", "literal", "\\u", "eval_", "(_", "compute", "Qual", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "Dn", "_", "=_", "\"", "org", "-", "root", "\"_", "#", " ", "is", " ", "this", " ", "adde", "d", " ", "under", " ", "org", "-", "root", " ", "alw", "ay", "s", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compute", "Qual", "Dn", "_", "=_", "p", "Dn", "_", "+_", "\"/", "blade", "-", "qualifier", "-\"_", "+_", "compute", "Qual", "List_", "[_", "Compute", "Qual", "_", "._", "NAME_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compute", "Qual", "Str_", "=_", "{_", "Compute", "Qual", "_", "._", "NAME_", ":_", "compute", "Qual", "List_", "[_", "Compute", "Qual", "_", "._", "NAME_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "compute", "-", "qualifier_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "p", "Dn", "_", ",_", "Org", "Org", "_", "._", "Class", "Id_", "(_", ")_", ",_", "Compute", "Qual", "_", "._", "Class", "Id_", "(_", ")_", ",_", "compute", "Qual", "Str_", ",_", "compute", "Qual", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "compute", "Chas", "sis", "Qual", "Str_", "=_", "{_", "Compute", "Chas", "sis", "Qual", "_", "._", "MIN", "\\u", "ID_", ":_", "compute", "Qual", "List_", "[_", "Compute", "Chas", "sis", "Qual", "_", "._", "MIN", "\\u", "ID_", "]_", ",_", "Compute", "Chas", "sis", "Qual", "_", "._", "MAX", "\\u", "ID_", ":_", "compute", "Qual", "List_", "[_", "Compute", "Chas", "sis", "Qual", "_", "._", "MAX", "\\u", "ID_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compute", "Chas", "sis", "Qual", "Dn", "_", "=_", "compute", "Qual", "Dn", "_", "+_", "\"/", "chassis", "-", "from", "-\"_", "+_", "compute", "Qual", "List_", "[_", "Compute", "Chas", "sis", "Qual", "_", "._", "MIN", "\\u", "ID_", "]_", "+_", "\"-", "to", "-\"_", "+_", "compute", "Qual", "List_", "[_", "Compute", "Chas", "sis", "Qual", "_", "._", "MAX", "\\u", "ID_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "Chas", "sis", " ", "Qualifier", "_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "compute", "Qual", "Dn", "_", ",_", "Compute", "Qual", "_", "._", "Class", "Id_", "(_", ")_", ",_", "Compute", "Chas", "sis", "Qual", "_", "._", "Class", "Id_", "(_", ")_", ",_", "compute", "Chas", "sis", "Qual", "Str_", ",_", "compute", "Chas", "sis", "Qual", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "\"", "compute", "Qual", "Dn", "\"_", "+_", "compute", "Qual", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "int_", "(_", "compute", "Qual", "List_", "[_", "Compute", "Chas", "sis", "Qual", "_", "._", "MIN", "\\u", "ID_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "i_", "<=_", "(_", "int_", "(_", "compute", "Qual", "List_", "[_", "Compute", "Chas", "sis", "Qual", "_", "._", "MAX", "\\u", "ID_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "compute", "Slot", "Qual", "Dn", "_", "=_", "compute", "Chas", "sis", "Qual", "Dn", "_", "+_", "\"/", "slot", "-", "from", "-\"_", "+_", "compute", "Qual", "List_", "[_", "\"", "Slot", "Min", "Id", "\"_", "]_", "+_", "\"-", "to", "-\"_", "+_", "compute", "Qual", "List_", "[_", "\"", "Slot", "Max", "Id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compute", "Slot", "Qual", "List_", "=_", "{_", "Compute", "Slot", "Qual", "_", "._", "MIN", "\\u", "ID_", ":_", "compute", "Qual", "List_", "[_", "\"", "Slot", "Min", "Id", "\"_", "]_", ",_", "Compute", "Slot", "Qual", "_", "._", "MAX", "\\u", "ID_", ":_", "compute", "Qual", "List_", "[_", "\"", "Slot", "Max", "Id", "\"_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "\"", "compute", "Qual", ":\"_", "+_", "compute", "Chas", "sis", "Qual", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "compute", "Chas", "sis", "Qual", "Dn", "_", ",_", "Compute", "Chas", "sis", "Qual", "_", "._", "Class", "Id_", "(_", ")_", ",_", "Compute", "Slot", "Qual", "_", "._", "Class", "Id_", "(_", ")_", ",_", "compute", "Slot", "Qual", "List_", ",_", "compute", "Slot", "Qual", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create", "Vla", "n_", "(_", "in", "Uc", "sm", "Host_", ",_", "fab", "ric", "Vla", "n", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Configure", "s", " ", "VLAN", " ", "in", " ", "UCS", " ", "Manager", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "create", " ", "vlan", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fab", "ric", "Vla", "n", "List_", "=_", "ast_", "._", "literal", "\\u", "eval_", "(_", "fab", "ric", "Vla", "n", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "Dn", "_", "=_", "\"", "fab", "ric", "/", "lan", "\"_", "#", " ", "fab", "ric", "Lan", "Cloud_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fab", "ric", "Vla", "n", "Dn", "_", "=_", "p", "Dn", "_", "+_", "\"/", "net", "-\"_", "+_", "fab", "ric", "Vla", "n", "List_", "[_", "Fabric", "Vla", "n_", "._", "NAME_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "user", " ", "is", " ", "inten", "ded", " ", "to", " ", "create", " ", "range", " ", "of", " ", "v", "LAN", "s_", "\\u\\u\\uNL\\u\\u\\u_", "vlan", "Ids_", "=_", "fab", "ric", "Vla", "n", "List_", "[_", "Fabric", "Vla", "n_", "._", "ID_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ids_", "=_", "vlan", "Ids_", "._", "rsplit_", "(_", "'-'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "len_", "(_", "ids_", ")_", "==_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "range_", "(_", "int_", "(_", "ids_", "[_", "0_", "]_", ")_", ",_", "int_", "(_", "ids_", "[_", "1_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fab", "ric", "Vla", "n", "Res_", "=_", "{_", "Fabric", "Vla", "n_", "._", "NAME_", ":_", "\"", "vlan", "-", "os", "\"_", "+_", "str_", "(_", "i_", ")_", ",_", "Fabric", "Vla", "n_", "._", "ID_", ":_", "i_", ",_", "Fabric", "Vla", "n_", "._", "SHAR", "ING_", ":_", "'", "none", "'_", ",_", "Fabric", "Vla", "n_", "._", "DEF", "AUL", "T", "\\u", "NET", "_", ":_", "'", "no", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Add", " ", "Mo", " ", "to", " ", "UCS", " ", "Manager_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "p", "Dn", "_", ",_", "Fabric", "Lan", "Cloud_", "._", "Class", "Id_", "(_", ")_", ",_", "Fabric", "Vla", "n_", "._", "Class", "Id_", "(_", ")_", ",_", "fab", "ric", "Vla", "n", "Res_", ",_", "fab", "ric", "Vla", "n", "Dn", "_", ")_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fab", "ric", "Vla", "n", "Res_", "=_", "{_", "Fabric", "Vla", "n_", "._", "NAME_", ":_", "fab", "ric", "Vla", "n", "List_", "[_", "Fabric", "Vla", "n_", "._", "NAME_", "]_", ",_", "Fabric", "Vla", "n_", "._", "ID_", ":_", "fab", "ric", "Vla", "n", "List_", "[_", "Fabric", "Vla", "n_", "._", "ID_", "]_", ",_", "Fabric", "Vla", "n_", "._", "SHAR", "ING_", ":_", "fab", "ric", "Vla", "n", "List_", "[_", "Fabric", "Vla", "n_", "._", "SHAR", "ING_", "]_", ",_", "Fabric", "Vla", "n_", "._", "DEF", "AUL", "T", "\\u", "NET", "_", ":_", "fab", "ric", "Vla", "n", "List_", "[_", "Fabric", "Vla", "n_", "._", "DEF", "AUL", "T", "\\u", "NET", "_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "Mo", " ", "to", " ", "UCS", " ", "Manager_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "p", "Dn", "_", ",_", "Fabric", "Lan", "Cloud_", "._", "Class", "Id_", "(_", ")_", ",_", "Fabric", "Vla", "n_", "._", "Class", "Id_", "(_", ")_", ",_", "fab", "ric", "Vla", "n", "Res_", ",_", "fab", "ric", "Vla", "n", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create", "SPI", "nstance", "_", "(_", "in", "Uc", "sm", "Host_", ",_", "ls", "Server", "Insta", "nce", "s", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\"\"\"", "Creat", "es", " ", "N", " ", "number", " ", "of", " ", "service", " ", "profile", "s", " ", "instant", "iati", "ng", " ", "from", " ", "Sr", "c", "Temp", "l", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "creati", "ng", " ", "SP", " ", "Insta", "nce", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ls", "Server", "Insta", "nce", "s", "List_", "=_", "ast_", "._", "literal", "\\u", "eval_", "(_", "ls", "Server", "Insta", "nce", "s", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "handle_", "=_", "Uc", "s", "Handle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "login_", "=_", "handle_", "._", "Login_", "(_", "in", "Uc", "sm", "Host_", "._", "hostname_", ",_", "in", "Uc", "sm", "Host_", "._", "username_", ",_", "in", "Uc", "sm", "Host_", "._", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "login_", "==_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "logging_", "._", "debug_", "(_", "'[", "Error", "]:", " ", "Logi", "n", " ", "Fail", "ed", "'_", ")_", "\\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_", "res", "Mos", "_", "=_", "handle_", "._", "Get", "Manage", "d", "Object_", "(_", "None_", ",_", "Ls", "Server_", "._", "Class", "Id_", "(_", ")_", ",_", "{_", "\"", "Name", "\"_", ":_", "ls", "Server", "Insta", "nce", "s", "List_", "[_", "'", "Sr", "c", "Temp", "l", "'_", "]_", "}_", ",_", "dump", "Xml_", "=_", "in", "Uc", "sm", "Host_", "._", "debug_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "res", "Mos", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "for_", "sp", "Mo", "_", "in_", "res", "Mos", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "handle_", "._", "Ls", "Instantiate", "NT", "empla", "te_", "(_", "sp", "Mo", "_", "._", "getattr_", "(_", "Ls", "Server_", "._", "DN_", ")_", ",_", "ls", "Server", "Insta", "nce", "s", "List_", "[_", "'", "Number", "Of", "'_", "]_", ",_", "ls", "Server", "Insta", "nce", "s", "List_", "[_", "'", "Name", "Pref", "ix", "'_", "]_", ",_", "ls", "Server", "Insta", "nce", "s", "List_", "[_", "'", "Target", "Org", "'_", "]_", ",_", "dump", "Xml_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\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_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "handle_", "._", "Logo", "ut_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Class", "Id_", "(_", "lsb", "oot", "Polic", "y", "List_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "return", "s", " ", "the", " ", "class", "Id", " ", "based", " ", "on", " ", "the", " ", "type", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l", "Class", "Id_", "=_", "'", "Non", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "vm", "'_", "==_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "type", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l", "Class", "Id_", "=_", "Ls", "boot", "Virt", "ual", "Media_", "._", "Class", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "'", "storage", "'_", "==_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "type", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l", "Class", "Id_", "=_", "Ls", "boot", "Storage_", "._", "Class", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "'", "lan", "'_", "==_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "type", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l", "Class", "Id_", "=_", "Ls", "boot", "Lan", "_", "._", "Class", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "Class", "Id", "'_", "+_", "l", "Class", "Id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "l", "Class", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create", "Ls", "boot", "Policy_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Polic", "y", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Configure", "s", " ", "the", " ", "Ls", "boot", "Polic", "y", " ", "poli", "cies", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "create", " ", "Ls", "boot", "Polic", "y", " ", "'_", "+_", "lsb", "oot", "Polic", "y", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Polic", "y", "List_", "=_", "ast_", "._", "literal", "\\u", "eval_", "(_", "lsb", "oot", "Polic", "y", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "Dn", "_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "Target", "Org", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lsb", "oot", "Polic", "y", "Dn", "_", "=_", "p", "Dn", "_", "+_", "\"/", "boot", "-", "policy", "-\"_", "+_", "lsb", "oot", "Polic", "y", "List_", "[_", "Ls", "boot", "Policy_", "._", "NAME_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Uc", "sm", "Host_", "._", "debug_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Polic", "y", "Res", "List_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "Ls", "boot", "Policy_", "._", "NAME_", ":_", "lsb", "oot", "Polic", "y", "List_", "[_", "Ls", "boot", "Policy_", "._", "NAME_", "]_", ",_", "Ls", "boot", "Policy_", "._", "PUR", "POS", "E_", ":_", "lsb", "oot", "Polic", "y", "List_", "[_", "Ls", "boot", "Policy_", "._", "PUR", "POS", "E_", "]_", ",_", "Ls", "boot", "Policy_", "._", "REB", "OOT", "\\u", "ON", "\\u", "UPDATE_", ":_", "lsb", "oot", "Polic", "y", "List_", "[_", "Ls", "boot", "Policy_", "._", "REB", "OOT", "\\u", "ON", "\\u", "UPDATE_", "]_", ",_", "Ls", "boot", "Policy_", "._", "EN", "FORCE", "\\u", "VN", "IC", "\\u", "NAME_", ":_", "lsb", "oot", "Polic", "y", "List_", "[_", "Ls", "boot", "Policy_", "._", "EN", "FORCE", "\\u", "VN", "IC", "\\u", "NAME_", "]_", ",_", "Ls", "boot", "Policy_", "._", "DESC", "R_", ":_", "lsb", "oot", "Polic", "y", "List_", "[_", "Ls", "boot", "Policy_", "._", "DESC", "R_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "p", "Dn", "_", ",_", "Org", "Org", "_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Policy_", "._", "Class", "Id_", "(_", ")_", ",_", "lsb", "oot", "Polic", "y", "Res", "List_", ",_", "lsb", "oot", "Polic", "y", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Virt", "ual", "Media", " ", "read", "-", "only", " ", "Access_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "vm", "-", "ro", "'_", "in_", "lsb", "oot", "Polic", "y", "List_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rn", "Prefix_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "vm", "-", "ro", "'_", "]_", "[_", "'", "Access", "'_", "]_", "+_", "\"-\"_", "+_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "vm", "-", "ro", "'_", "]_", "[_", "'", "Type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Virt", "ual", "Media", "Dn", "_", "=_", "lsb", "oot", "Polic", "y", "Dn", "_", "+_", "\"/\"_", "+_", "rn", "Prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Virt", "ual", "Media", "List_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "vm", "-", "ro", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Polic", "y", "Dn", "_", ",_", "Ls", "boot", "Policy_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Virt", "ual", "Media_", "._", "Class", "Id_", "(_", ")_", ",_", "lsb", "oot", "Virt", "ual", "Media", "List_", ",_", "lsb", "oot", "Virt", "ual", "Media", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "LAN", " ", "or", " ", "PX", "E", " ", "Boot", " ", "option_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "lan", "'_", "in_", "lsb", "oot", "Polic", "y", "List_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rn", "Prefix_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "lan", "'_", "]_", "[_", "'", "Type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Lan", "Dn", "_", "=_", "lsb", "oot", "Polic", "y", "Dn", "_", "+_", "\"/\"_", "+_", "rn", "Prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Lan", "Image", "Path", "List_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "lan", "'_", "]_", "._", "pop_", "(_", "'", "Image", "Path", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Lan", "List_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "lan", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Polic", "y", "Dn", "_", ",_", "Ls", "boot", "Policy_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Lan", "_", "._", "Class", "Id_", "(_", ")_", ",_", "lsb", "oot", "Lan", "List_", ",_", "lsb", "oot", "Lan", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Image", "Path_", "\\u\\u\\uNL\\u\\u\\u_", "lsb", "oot", "Lan", "Image", "Path", "Dn", "_", "=_", "lsb", "oot", "Lan", "Dn", "_", "+_", "\"/", "path", "-\"_", "+_", "lsb", "oot", "Lan", "Image", "Path", "List_", "[_", "'", "Type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Lan", "Dn", "_", ",_", "Ls", "boot", "Lan", "_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Lan", "Image", "Path_", "._", "Class", "Id_", "(_", ")_", ",_", "lsb", "oot", "Lan", "Image", "Path", "List_", ",_", "lsb", "oot", "Lan", "Image", "Path", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Stor", "age", "/", "Local", "Storage_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "storage", "'_", "in_", "lsb", "oot", "Polic", "y", "List_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rn", "Prefix_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "storage", "'_", "]_", "[_", "'", "Type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lsb", "oot", "Stor", "age", "Dn", "_", "=_", "lsb", "oot", "Polic", "y", "Dn", "_", "+_", "\"/\"_", "+_", "rn", "Prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Stor", "age", "List_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "storage", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Polic", "y", "Dn", "_", ",_", "Ls", "boot", "Policy_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Storage_", "._", "Class", "Id_", "(_", ")_", ",_", "lsb", "oot", "Stor", "age", "List_", ",_", "lsb", "oot", "Stor", "age", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Local", "Stor", "age", "Dn", "_", "=_", "lsb", "oot", "Stor", "age", "Dn", "_", "+_", "\"/\"_", "+_", "\"", "local", "-", "storage", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Stor", "age", "Dn", "_", ",_", "Ls", "boot", "Storage_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Local", "Storage_", "._", "Class", "Id_", "(_", ")_", ",_", "{_", "}_", ",_", "lsb", "oot", "Local", "Stor", "age", "Dn", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Virt", "ual", "Media", " ", "read", "-", "write", " ", "Access_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "vm", "-", "rw", "'_", "in_", "lsb", "oot", "Polic", "y", "List_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rn", "Prefix_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "vm", "-", "rw", "'_", "]_", "[_", "'", "Access", "'_", "]_", "+_", "\"-\"_", "+_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "vm", "-", "rw", "'_", "]_", "[_", "'", "Type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Virt", "ual", "Media", "Dn", "_", "=_", "lsb", "oot", "Polic", "y", "Dn", "_", "+_", "\"/\"_", "+_", "rn", "Prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lsb", "oot", "Virt", "ual", "Media", "List_", "=_", "lsb", "oot", "Polic", "y", "List_", "[_", "'", "vm", "-", "rw", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Object", "To", "Uc", "s_", "(_", "in", "Uc", "sm", "Host_", ",_", "lsb", "oot", "Polic", "y", "Dn", "_", ",_", "Ls", "boot", "Policy_", "._", "Class", "Id_", "(_", ")_", ",_", "Ls", "boot", "Virt", "ual", "Media_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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, 0, 1, 2 ]
First parameter of a method is not named 'self'
infrae/pyoai/src/oaipmh/interfaces.py
[ { "content": " def getRecord(metadataPrefix, identifier):\n \"\"\"Get a record for a metadataPrefix and identifier.\n\n metadataPrefix - identifies metadata set to retrieve\n identifier - repository-unique identifier of record\n \n Should raise error.CannotDisseminateFormatError if\n metadataPrefix is unknown or not supported by identifier.\n \n Should raise error.IdDoesNotExistError if identifier is\n unknown or illegal.\n\n Returns a header, metadata, about tuple describing the record.\n \"\"\"", "metadata": "root.IOAI.getRecord", "header": "['class', 'IOAI', ':', '___EOS___']", "index": 1 }, { "content": " def identify():\n \"\"\"Retrieve information about the repository.\n\n Returns an Identify object describing the repository.\n \"\"\"", "metadata": "root.IOAI.identify", "header": "['class', 'IOAI', ':', '___EOS___']", "index": 16 }, { "content": " def listIdentifiers(metadataPrefix, set=None, from_=None, until=None):\n \"\"\"Get a list of header information on records.\n\n metadataPrefix - identifies metadata set to retrieve\n set - set identifier; only return headers in set (optional)\n from_ - only retrieve headers from from_ date forward (optional)\n until - only retrieve headers with dates up to and including\n until date (optional)\n\n Should raise error.CannotDisseminateFormatError if metadataPrefix\n is not supported by the repository.\n\n Should raise error.NoSetHierarchyError if the repository does not\n support sets.\n \n Returns an iterable of headers.\n \"\"\"", "metadata": "root.IOAI.listIdentifiers", "header": "['class', 'IOAI', ':', '___EOS___']", "index": 22 }, { "content": " def listMetadataFormats(identifier=None):\n \"\"\"List metadata formats supported by repository or record.\n\n identifier - identify record for which we want to know all\n supported metadata formats. if absent, list all metadata\n formats supported by repository. (optional)\n\n\n Should raise error.IdDoesNotExistError if record with\n identifier does not exist.\n \n Should raise error.NoMetadataFormatsError if no formats are\n available for the indicated record.\n\n Returns an iterable of metadataPrefix, schema, metadataNamespace\n tuples (each entry in the tuple is a string).\n \"\"\"", "metadata": "root.IOAI.listMetadataFormats", "header": "['class', 'IOAI', ':', '___EOS___']", "index": 40 }, { "content": " def listRecords(metadataPrefix, set=None, from_=None, until=None):\n \"\"\"Get a list of header, metadata and about information on records.\n\n metadataPrefix - identifies metadata set to retrieve\n set - set identifier; only return records in set (optional)\n from_ - only retrieve records from from_ date forward (optional)\n until - only retrieve records with dates up to and including\n until date (optional)\n\n Should raise error.CannotDisseminateFormatError if metadataPrefix\n is not supported by the repository.\n\n Should raise error.NoSetHierarchyError if the repository does not\n support sets.\n\n Returns an iterable of header, metadata, about tuples.\n \"\"\"", "metadata": "root.IOAI.listRecords", "header": "['class', 'IOAI', ':', '___EOS___']", "index": 58 }, { "content": " def listSets():\n \"\"\"Get a list of sets in the repository.\n\n Should raise error.NoSetHierarchyError if the repository does not\n support sets.\n\n Returns an iterable of setSpec, setName tuples (strings).\n \"\"\"", "metadata": "root.IOAI.listSets", "header": "['class', 'IOAI', ':', '___EOS___']", "index": 76 }, { "content": " def getRecord(metadataPrefix, identifier):\n pass", "metadata": "root.IBatchingOAI.getRecord", "header": "['class', 'IBatchingOAI', ':', '___EOS___']", "index": 93 }, { "content": " def identify():\n pass", "metadata": "root.IBatchingOAI.identify", "header": "['class', 'IBatchingOAI', ':', '___EOS___']", "index": 96 }, { "content": " def listIdentifiers(metadataPrefix, set=None, from_=None, until=None,\n cursor=0, batch_size=10):\n pass", "metadata": "root.IBatchingOAI.listIdentifiers", "header": "['class', 'IBatchingOAI', ':', '___EOS___']", "index": 99 }, { "content": " def listMetadataFormats(identifier=None):\n pass", "metadata": "root.IBatchingOAI.listMetadataFormats", "header": "['class', 'IBatchingOAI', ':', '___EOS___']", "index": 103 }, { "content": " def listRecords(metadataPrefix, set=None, from_=None, until=None,\n cursor=0, batch_size=10):\n pass", "metadata": "root.IBatchingOAI.listRecords", "header": "['class', 'IBatchingOAI', ':', '___EOS___']", "index": 106 }, { "content": " def listSets():\n pass", "metadata": "root.IBatchingOAI.listSets", "header": "['class', 'IBatchingOAI', ':', '___EOS___']", "index": 110 }, { "content": " def repositoryName():\n \"\"\"Name of repository.\n \"\"\"", "metadata": "root.IIdentify.repositoryName", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 114 }, { "content": " def baseURL():\n \"\"\"Base URL for OAI-PMH requests.\n \"\"\"", "metadata": "root.IIdentify.baseURL", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 118 }, { "content": " def protocolVersion():\n \"\"\"OAI-PMH protocol version (should always be '2.0')\n \"\"\"", "metadata": "root.IIdentify.protocolVersion", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 122 }, { "content": " def adminEmails():\n \"\"\"List of email addresses of repository administrators.\n \"\"\"", "metadata": "root.IIdentify.adminEmails", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 126 }, { "content": " def earliestDateStamp():\n \"\"\"The datetime (datestamp) of the earliest record in repository.\n \"\"\"", "metadata": "root.IIdentify.earliestDateStamp", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 130 }, { "content": " def deletedRecord():\n \"\"\"Way the repository handles deleted records.\n\n Either 'no', 'transient' or 'persistent'.\n \"\"\"", "metadata": "root.IIdentify.deletedRecord", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 134 }, { "content": " def granularity():\n \"\"\"Datetime granularity of datestamps in repository.\n\n Either YYYY-MM-DD or YYYY-MM-DDThh:mm:ssZ\n \"\"\"", "metadata": "root.IIdentify.granularity", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 140 }, { "content": " def compression():\n \"\"\"List of types of compression schemes supported by repository.\n\n 'identity' is the 'do-nothing' scheme.\n \"\"\"", "metadata": "root.IIdentify.compression", "header": "['class', 'IIdentify', ':', '___EOS___']", "index": 146 }, { "content": " def identifier():\n \"\"\"Repository-unique identifier of this record.\n \"\"\"", "metadata": "root.IHeader.identifier", "header": "['class', 'IHeader', ':', '___EOS___']", "index": 153 }, { "content": " def datestamp():\n \"\"\"Datetime of creation, last modification or deletion of the record.\n\n This can be used for selective harvesting.\n \"\"\"", "metadata": "root.IHeader.datestamp", "header": "['class', 'IHeader', ':', '___EOS___']", "index": 157 }, { "content": " def setSpec():\n \"\"\"A list of sets this record is a member of.\n \"\"\"", "metadata": "root.IHeader.setSpec", "header": "['class', 'IHeader', ':', '___EOS___']", "index": 163 }, { "content": " def isDeleted():\n \"\"\"If true, record has been deleted.\n \"\"\"", "metadata": "root.IHeader.isDeleted", "header": "['class', 'IHeader', ':', '___EOS___']", "index": 167 } ]
[ { "span": "def getRecord(metadataPrefix, identifier):", "start_line": 1, "start_column": 4, "end_line": 1, "end_column": 46 }, { "span": "def identify():", "start_line": 16, "start_column": 4, "end_line": 16, "end_column": 19 }, { "span": "def listIdentifiers(metadataPrefix, set=None, from_=None, until=None):", "start_line": 22, "start_column": 4, "end_line": 22, "end_column": 74 }, { "span": "def listMetadataFormats(identifier=None):", "start_line": 40, "start_column": 4, "end_line": 40, "end_column": 45 }, { "span": "def listRecords(metadataPrefix, set=None, from_=None, until=None):", "start_line": 58, "start_column": 4, "end_line": 58, "end_column": 70 }, { "span": "def listSets():", "start_line": 76, "start_column": 4, "end_line": 76, "end_column": 19 }, { "span": "def getRecord(metadataPrefix, identifier):", "start_line": 93, "start_column": 4, "end_line": 93, "end_column": 46 }, { "span": "def identify():", "start_line": 96, "start_column": 4, "end_line": 96, "end_column": 19 }, { "span": "def listIdentifiers(metadataPrefix, set=None, from_=None, until=None,\n cursor=0, batch_size=10):", "start_line": 99, "start_column": 4, "end_line": 100, "end_column": 49 }, { "span": "def listMetadataFormats(identifier=None):", "start_line": 103, "start_column": 4, "end_line": 103, "end_column": 45 }, { "span": "def listRecords(metadataPrefix, set=None, from_=None, until=None,\n cursor=0, batch_size=10):", "start_line": 106, "start_column": 4, "end_line": 107, "end_column": 45 }, { "span": "def listSets():", "start_line": 110, "start_column": 4, "end_line": 110, "end_column": 19 }, { "span": "def repositoryName():", "start_line": 114, "start_column": 4, "end_line": 114, "end_column": 25 }, { "span": "def baseURL():", "start_line": 118, "start_column": 4, "end_line": 118, "end_column": 18 }, { "span": "def protocolVersion():", "start_line": 122, "start_column": 4, "end_line": 122, "end_column": 26 }, { "span": "def adminEmails():", "start_line": 126, "start_column": 4, "end_line": 126, "end_column": 22 }, { "span": "def earliestDateStamp():", "start_line": 130, "start_column": 4, "end_line": 130, "end_column": 28 }, { "span": "def deletedRecord():", "start_line": 134, "start_column": 4, "end_line": 134, "end_column": 24 }, { "span": "def granularity():", "start_line": 140, "start_column": 4, "end_line": 140, "end_column": 22 }, { "span": "def compression():", "start_line": 146, "start_column": 4, "end_line": 146, "end_column": 22 }, { "span": "def identifier():", "start_line": 153, "start_column": 4, "end_line": 153, "end_column": 21 }, { "span": "def datestamp():", "start_line": 157, "start_column": 4, "end_line": 157, "end_column": 20 }, { "span": "def setSpec():", "start_line": 163, "start_column": 4, "end_line": 163, "end_column": 18 }, { "span": "def isDeleted():", "start_line": 167, "start_column": 4, "end_line": 167, "end_column": 20 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "IO", "AI_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "get", "Record_", "(_", "metadata", "Prefix_", ",_", "identifier_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "a", " ", "record", " ", "for", " ", "a", " ", "metadata", "Pref", "ix", " ", "and", " ", "identifi", "er", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "metadata", "Pref", "ix", " ", "-", " ", "identifi", "es", " ", "metadata", " ", "set", " ", "to", " ", "retrieve", "\\", "10", ";", " ", " ", " ", " ", "identifi", "er", " ", "-", " ", "repos", "itor", "y", "-", "unique", " ", "identifi", "er", " ", "of", " ", "record", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "Cann", "ot", "Dis", "semi", "nat", "e", "Format", "Error", " ", "if", "\\", "10", ";", " ", " ", " ", " ", "metadata", "Pref", "ix", " ", "is", " ", "unknown", " ", "or", " ", "not", " ", "support", "ed", " ", "by", " ", "identifi", "er", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "Id", "Do", "es", "Not", "Exist", "Error", " ", "if", " ", "identifi", "er", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "unknown", " ", "or", " ", "ille", "gal", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "header", ",", " ", "metadata", ",", " ", "abo", "ut", " ", "tuple", " ", "descri", "bing", " ", "the", " ", "record", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IO", "AI_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "identify", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Retrieve", " ", "informati", "on", " ", "abo", "ut", " ", "the", " ", "repos", "itor", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "an", " ", "Identif", "y", " ", "object", " ", "descri", "bing", " ", "the", " ", "repos", "itor", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IO", "AI_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Identifiers_", "(_", "metadata", "Prefix_", ",_", "set_", "=_", "None_", ",_", "from\\u_", "=_", "None_", ",_", "until_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "a", " ", "list", " ", "of", " ", "header", " ", "informati", "on", " ", "on", " ", "record", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "metadata", "Pref", "ix", " ", "-", " ", "identifi", "es", " ", "metadata", " ", "set", " ", "to", " ", "retrieve", "\\", "10", ";", " ", " ", " ", " ", "set", " ", "-", " ", "set", " ", "identifi", "er", ";", " ", "only", " ", "return", " ", "header", "s", " ", "in", " ", "set", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", "from", "\\u", " ", "-", " ", "only", " ", "retrieve", " ", "header", "s", " ", "from", " ", "from", "\\u", " ", "date", " ", "forward", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", "unti", "l", " ", "-", " ", "only", " ", "retrieve", " ", "header", "s", " ", "with", " ", "dates", " ", "up", " ", "to", " ", "and", " ", "inclu", "ding", "\\", "10", ";", " ", " ", " ", " ", "unti", "l", " ", "date", " ", "(", "option", "al", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "Cann", "ot", "Dis", "semi", "nat", "e", "Format", "Error", " ", "if", " ", "metadata", "Pref", "ix", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "not", " ", "support", "ed", " ", "by", " ", "the", " ", "repos", "itor", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "No", "Set", "Hier", "arch", "y", "Error", " ", "if", " ", "the", " ", "repos", "itor", "y", " ", "doe", "s", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "support", " ", "sets", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "an", " ", "iterable", " ", "of", " ", "header", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IO", "AI_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Meta", "data", "Format", "s_", "(_", "identifier_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "List", " ", "metadata", " ", "formats", " ", "support", "ed", " ", "by", " ", "repos", "itor", "y", " ", "or", " ", "record", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "identifi", "er", " ", "-", " ", "identify", " ", "record", " ", "for", " ", "whi", "ch", " ", "we", " ", "want", " ", "to", " ", "know", " ", "all", "\\", "10", ";", " ", " ", " ", "support", "ed", " ", "metadata", " ", "formats", ".", " ", "if", " ", "absen", "t", ",", " ", "list", " ", "all", " ", "metadata", "\\", "10", ";", " ", " ", " ", "formats", " ", "support", "ed", " ", "by", " ", "repos", "itor", "y", ".", " ", "(", "option", "al", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "Id", "Do", "es", "Not", "Exist", "Error", " ", "if", " ", "record", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "identifi", "er", " ", "doe", "s", " ", "not", " ", "exist", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "No", "Meta", "data", "Format", "s", "Error", " ", "if", " ", "no", " ", "formats", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "avail", "able", " ", "for", " ", "the", " ", "indicat", "ed", " ", "record", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "an", " ", "iterable", " ", "of", " ", "metadata", "Pref", "ix", ",", " ", "schema", ",", " ", "metadata", "Names", "pace", "\\", "10", ";", " ", " ", " ", " ", "tuple", "s", " ", "(", "each", " ", "entry", " ", "in", " ", "the", " ", "tuple", " ", "is", " ", "a", " ", "string", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IO", "AI_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Records_", "(_", "metadata", "Prefix_", ",_", "set_", "=_", "None_", ",_", "from\\u_", "=_", "None_", ",_", "until_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "a", " ", "list", " ", "of", " ", "header", ",", " ", "metadata", " ", "and", " ", "abo", "ut", " ", "informati", "on", " ", "on", " ", "record", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "metadata", "Pref", "ix", " ", "-", " ", "identifi", "es", " ", "metadata", " ", "set", " ", "to", " ", "retrieve", "\\", "10", ";", " ", " ", " ", " ", "set", " ", "-", " ", "set", " ", "identifi", "er", ";", " ", "only", " ", "return", " ", "record", "s", " ", "in", " ", "set", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", "from", "\\u", " ", "-", " ", "only", " ", "retrieve", " ", "record", "s", " ", "from", " ", "from", "\\u", " ", "date", " ", "forward", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", "unti", "l", " ", "-", " ", "only", " ", "retrieve", " ", "record", "s", " ", "with", " ", "dates", " ", "up", " ", "to", " ", "and", " ", "inclu", "ding", "\\", "10", ";", " ", " ", " ", " ", "unti", "l", " ", "date", " ", "(", "option", "al", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "Cann", "ot", "Dis", "semi", "nat", "e", "Format", "Error", " ", "if", " ", "metadata", "Pref", "ix", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "not", " ", "support", "ed", " ", "by", " ", "the", " ", "repos", "itor", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "No", "Set", "Hier", "arch", "y", "Error", " ", "if", " ", "the", " ", "repos", "itor", "y", " ", "doe", "s", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "support", " ", "sets", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "an", " ", "iterable", " ", "of", " ", "header", ",", " ", "metadata", ",", " ", "abo", "ut", " ", "tuple", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IO", "AI_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Sets_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "a", " ", "list", " ", "of", " ", "sets", " ", "in", " ", "the", " ", "repos", "itor", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ul", "d", " ", "raise", " ", "error", ".", "No", "Set", "Hier", "arch", "y", "Error", " ", "if", " ", "the", " ", "repos", "itor", "y", " ", "doe", "s", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "support", " ", "sets", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "an", " ", "iterable", " ", "of", " ", "set", "Spec", ",", " ", "set", "Name", " ", "tuple", "s", " ", "(", "string", "s", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IB", "atch", "ing", "OA", "I_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Record_", "(_", "metadata", "Prefix_", ",_", "identifier_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IB", "atch", "ing", "OA", "I_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "identify", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IB", "atch", "ing", "OA", "I_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Identifiers_", "(_", "metadata", "Prefix_", ",_", "set_", "=_", "None_", ",_", "from\\u_", "=_", "None_", ",_", "until_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cursor_", "=_", "0_", ",_", "batch", "\\u", "size_", "=_", "10_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IB", "atch", "ing", "OA", "I_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Meta", "data", "Format", "s_", "(_", "identifier_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IB", "atch", "ing", "OA", "I_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Records_", "(_", "metadata", "Prefix_", ",_", "set_", "=_", "None_", ",_", "from\\u_", "=_", "None_", ",_", "until_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cursor_", "=_", "0_", ",_", "batch", "\\u", "size_", "=_", "10_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IB", "atch", "ing", "OA", "I_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "Sets_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "repos", "itor", "y", "Name_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Name", " ", "of", " ", "repos", "itor", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "base", "URL_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Base", " ", "URL", " ", "for", " ", "OA", "I", "-", "PM", "H", " ", "request", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "protoc", "ol", "Version_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "OA", "I", "-", "PM", "H", " ", "protoc", "ol", " ", "version", " ", "(", "shou", "ld", " ", "alw", "ay", "s", " ", "be", " ", "'", "2.0", "')", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "admin", "Ema", "ils_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "List", " ", "of", " ", "email", " ", "addresse", "s", " ", "of", " ", "repos", "itor", "y", " ", "administrat", "ors", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "earliest", "Date", "Stamp_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "The", " ", "datetime", " ", "(", "dates", "tamp", ")", " ", "of", " ", "the", " ", "earliest", " ", "record", " ", "in", " ", "repos", "itor", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "d", "Record_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Way", " ", "the", " ", "repos", "itor", "y", " ", "handle", "s", " ", "delete", "d", " ", "record", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ei", "ther", " ", "'", "no", "',", " ", "'", "transient", "'", " ", "or", " ", "'", "persiste", "nt", "'.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "granularity", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Date", "time", " ", "granularity", " ", "of", " ", "dates", "tamp", "s", " ", "in", " ", "repos", "itor", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ei", "ther", " ", "YYY", "Y", "-", "MM", "-", "DD", " ", "or", " ", "YYY", "Y", "-", "MM", "-", "DD", "Th", "h", ":", "mm", ":", "ss", "Z", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "II", "denti", "fy_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "compression_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "List", " ", "of", " ", "types", " ", "of", " ", "compress", "ion", " ", "schemes", " ", "support", "ed", " ", "by", " ", "repos", "itor", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "'", "identi", "ty", "'", " ", "is", " ", "the", " ", "'", "do", "-", "not", "hing", "'", " ", "sche", "me", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IH", "eader", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "identifier_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Repos", "itor", "y", "-", "unique", " ", "identifi", "er", " ", "of", " ", "this", " ", "record", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IH", "eader", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dates", "tamp", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Date", "time", " ", "of", " ", "creati", "on", ",", " ", "last", " ", "modification", " ", "or", " ", "deletion", " ", "of", " ", "the", " ", "record", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "can", " ", "be", " ", "used", " ", "for", " ", "selecti", "ve", " ", "harvest", "ing", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IH", "eader", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Spec_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "list", " ", "of", " ", "sets", " ", "this", " ", "record", " ", "is", " ", "a", " ", "member", " ", "of", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "IH", "eader", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "Delete", "d_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "true", ",", " ", "record", " ", "has", " ", "bee", "n", " ", "delete", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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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, 4, 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, 4, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
hardikvasa/webb/setup.py
[ { "content": "#!/usr/bin/env python\n\nfrom setuptools import setup\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\"\"\"\nSuper S3 command line tool, setup.py\n\"\"\"\n\nimport sys\nfrom distutils.core import setup\nfrom codecs import open\nfrom os import path\n\nhere = path.abspath(path.dirname(__file__))\nwith open(path.join(here, 'README.md'), encoding='utf-8') as f:\n long_description = f.read()\n\t\n\t\nsetup(\n name='webb',\n version='0.9.2.5',\n description='An all-in-one Web Crawler, Web Parser and Web Scrapping library!',\n author='Hardik Vasa',\n maintainer='Hardik Vasa',\n author_email='[email protected]',\n long_description=long_description,\n license=\"Apache License, Version 2.0\",\n url='https://github.com/hardikvasa/webb',\n keywords='scraper crawler spider webb',\n\t classifiers=[\n\t 'Development Status :: 4 - Beta',\n 'Programming Language :: Python :: 2',\n 'Programming Language :: Python :: 2.6',\n 'Programming Language :: Python :: 2.7',\n 'Programming Language :: Python :: 3',\n 'Programming Language :: Python :: 3.3',\n 'Programming Language :: Python :: 3.4',\n\n 'License :: OSI Approved :: Apache Software License',\n\n 'Intended Audience :: Developers',\n 'Operating System :: OS Independent',\n 'Environment :: Web Environment',\n\n 'Topic :: Internet :: WWW/HTTP',\n 'Topic :: Software Development :: Libraries :: Application Frameworks',\n 'Topic :: Software Development :: Libraries :: Python Modules',\n\t ],\n\t zip_safe=False,\n packages=['webb'],\n\t )\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import sys", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 10 } ]
[]
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_", "from_", "setuptools_", "import_", "setup_", "\\u\\u\\uNEWLINE\\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_", "\"\"\"", "\\", "10", ";", "Super", " ", "S", "3", " ", "command", " ", "line", " ", "tool", ",", " ", "setup", ".", "py", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "distutils_", "._", "core_", "import_", "setup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "codecs_", "import_", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "import_", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "here_", "=_", "path_", "._", "abspath_", "(_", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "path_", "._", "join_", "(_", "here_", ",_", "'", "READ", "ME", ".", "md", "'_", ")_", ",_", "encoding_", "=_", "'", "utf", "-", "8", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "long", "\\u", "description_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "setup_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "'", "web", "b", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "0.", "9.2", ".5", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'", "An", " ", "all", "-", "in", "-", "one", " ", "Web", " ", "Crawler", ",", " ", "Web", " ", "Parser", " ", "and", " ", "Web", " ", "Scra", "ppi", "ng", " ", "librar", "y", "!'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author_", "=_", "'", "Hard", "ik", " ", "Va", "sa", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "maintainer_", "=_", "'", "Hard", "ik", " ", "Va", "sa", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author", "\\u", "email_", "=_", "'", "hn", "vas", "a", "@", "gma", "il", ".", "com", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "long", "\\u", "description_", "=_", "long", "\\u", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "license_", "=_", "\"", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "'", "https", "://", "git", "hub", ".", "com", "/", "hard", "ik", "vas", "a", "/", "web", "b", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "keywords_", "=_", "'", "scraper", " ", "crawle", "r", " ", "spider", " ", "web", "b", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "classifiers_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Dev", "elo", "pme", "nt", " ", "Status", " ", "::", " ", "4", " ", "-", " ", "Beta", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "2.6", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "2.7", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "3.3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "3.4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'", "License", " ", "::", " ", "OSI", " ", "Appro", "ved", " ", "::", " ", "Ap", "ache", " ", "Sof", "twa", "re", " ", "License", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Inten", "ded", " ", "Audi", "ence", " ", "::", " ", "Dev", "elope", "rs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Opera", "ting", " ", "System", " ", "::", " ", "OS", " ", "Inde", "pend", "ent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Environ", "ment", " ", "::", " ", "Web", " ", "Environ", "ment", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "Intern", "et", " ", "::", " ", "WW", "W", "/", "HTTP", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "Sof", "twa", "re", " ", "Dev", "elo", "pme", "nt", " ", "::", " ", "Libr", "aries", " ", "::", " ", "Applica", "tion", " ", "Frame", "works", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "Sof", "twa", "re", " ", "Dev", "elo", "pme", "nt", " ", "::", " ", "Libr", "aries", " ", "::", " ", "Pyth", "on", " ", "Modul", "es", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "zip", "\\u", "safe_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "packages_", "=_", "[_", "'", "web", "b", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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ved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are met:\n#\n# * Redistributions of source code must retain the above copyright notice,\n# this list of conditions, and the following disclaimer.\n# * Redistributions in binary form must reproduce the above copyright notice,\n# this list of conditions, and the following disclaimer in the\n# documentation and/or other materials provided with the distribution.\n# * Neither the name of the author of this software nor the name of\n# contributors to this software may be used to endorse or promote products\n# derived from this software without specific prior written consent.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n# POSSIBILITY OF SUCH DAMAGE.\n###\n\n\"\"\"\nContains simple socket drivers. Asyncore bugged (haha, pun!) me.\n\"\"\"\n\nfrom __future__ import division\n\nimport os\nimport time\nimport errno\nimport select\nimport socket\n\nfrom .. import (conf, drivers, log, utils, world)\nfrom ..utils import minisix\nfrom ..utils.str import decode_raw_line\n\ntry:\n import ssl\n SSLError = ssl.SSLError\nexcept:\n drivers.log.debug('ssl module is not available, '\n 'cannot connect to SSL servers.')\n\n\n\n\n\nDriver = SocketDriver\n\n# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def _handleSocketError(self, e):\n # (11, 'Resource temporarily unavailable') raised if connect\n # hasn't finished yet. We'll keep track of how many we get.\n if e.args[0] != 11 or self.eagains > 120:\n drivers.log.disconnect(self.currentServer, e)\n if self in self._instances:\n self._instances.remove(self)\n try:\n self.conn.close()\n except:\n pass\n self.connected = False\n self.scheduleReconnect()\n else:\n log.debug('Got EAGAIN, current count: %s.', self.eagains)\n self.eagains += 1", "metadata": "root.SocketDriver._handleSocketError", "header": "['class', 'SocketDriver', '(', 'drivers', '.', 'IrcDriver', ',', 'drivers', '.', 'ServersMixin', ')', ':', '___EOS___']", "index": 102 }, { "content": " def reconnect(self, wait=False, reset=True):\n self._attempt += 1\n self.nextReconnectTime = None\n if self.connected:\n drivers.log.reconnect(self.irc.network)\n if self in self._instances:\n self._instances.remove(self)\n try:\n self.conn.shutdown(socket.SHUT_RDWR)\n except: # \"Transport endpoint not connected\"\n pass\n self.conn.close()\n self.connected = False\n if reset:\n drivers.log.debug('Resetting %s.', self.irc)\n self.irc.reset()\n else:\n drivers.log.debug('Not resetting %s.', self.irc)\n if wait:\n self.scheduleReconnect()\n return\n self.server = self._getNextServer()\n network_config = getattr(conf.supybot.networks, self.irc.network)\n socks_proxy = network_config.socksproxy()\n try:\n if socks_proxy:\n import socks\n except ImportError:\n log.error('Cannot use socks proxy (SocksiPy not installed), '\n 'using direct connection instead.')\n socks_proxy = ''\n if socks_proxy:\n address = self.server[0]\n else:\n try:\n address = utils.net.getAddressFromHostname(self.server[0],\n attempt=self._attempt)\n except (socket.gaierror, socket.error) as e:\n drivers.log.connectError(self.currentServer, e)\n self.scheduleReconnect()\n return\n port = self.server[1]\n drivers.log.connect(self.currentServer)\n try:\n self.conn = utils.net.getSocket(address, port=port,\n socks_proxy=socks_proxy,\n vhost=conf.supybot.protocols.irc.vhost(),\n vhostv6=conf.supybot.protocols.irc.vhostv6(),\n )\n except socket.error as e:\n drivers.log.connectError(self.currentServer, e)\n self.scheduleReconnect()\n return\n # We allow more time for the connect here, since it might take longer.\n # At least 10 seconds.\n self.conn.settimeout(max(10, conf.supybot.drivers.poll()*10))\n try:\n # Connect before SSL, otherwise SSL is disabled if we use SOCKS.\n # See http://stackoverflow.com/q/16136916/539465\n self.conn.connect((address, port))\n if network_config.ssl():\n self.starttls()\n elif not network_config.requireStarttls():\n drivers.log.warning(('Connection to network %s '\n 'does not use SSL/TLS, which makes it vulnerable to '\n 'man-in-the-middle attacks and passive eavesdropping. '\n 'You should consider upgrading your connection to SSL/TLS '\n '<http://doc.supybot.aperio.fr/en/latest/use/faq.html#how-to-make-a-connection-secure>')\n % self.irc.network)\n\n def setTimeout():\n self.conn.settimeout(conf.supybot.drivers.poll())\n conf.supybot.drivers.poll.addCallback(setTimeout)\n setTimeout()\n self.connected = True\n self.resetDelay()\n except socket.error as e:\n if e.args[0] == 115:\n now = time.time()\n when = now + 60\n whenS = log.timestamp(when)\n drivers.log.debug('Connection in progress, scheduling '\n 'connectedness check for %s', whenS)\n self.writeCheckTime = when\n else:\n drivers.log.connectError(self.currentServer, e)\n self.scheduleReconnect()\n return\n self._instances.append(self)", "metadata": "root.SocketDriver.reconnect", "header": "['class', 'SocketDriver', '(', 'drivers', '.', 'IrcDriver', ',', 'drivers', '.', 'ServersMixin', ')', ':', '___EOS___']", "index": 219 } ]
[ { "span": "except:", "start_line": 49, "start_column": 0, "end_line": 49, "end_column": 7 }, { "span": "except:", "start_line": 111, "start_column": 12, "end_line": 111, "end_column": 19 }, { "span": "except: ", "start_line": 228, "start_column": 12, "end_line": 228, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2002", "-", "2004", ",", " ", "Jer", "emi", "ah", " ", "Fin", "cher", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2010", ",", " ", "2013", ",", " ", "Jam", "es", " ", "Mc", "Co", "y_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Redistributi", "on", " ", "and", " ", "use", " ", "in", " ", "source", " ", "and", " ", "binar", "y", " ", "forms", ",", " ", "with", " ", "or", " ", "with", "out_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "modification", ",", " ", "are", " ", "permit", "ted", " ", "provided", " ", "tha", "t", " ", "the", " ", "follow", "ing", " ", "condition", "s", " ", "are", " ", "met", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "*", " ", "Redistributi", "ons", " ", "of", " ", "source", " ", "code", " ", "must", " ", "retain", " ", "the", " ", "above", " ", "copyr", "ight", " ", "notice", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "list", " ", "of", " ", "condition", "s", ",", " ", "and", " ", "the", " ", "follow", "ing", " ", "discl", "aime", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "*", " ", "Redistributi", "ons", " ", "in", " ", "binar", "y", " ", "form", " ", "must", " ", "reproduce", " ", "the", " ", "above", " ", "copyr", "ight", " ", "notice", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "list", " ", "of", " ", "condition", "s", ",", " ", "and", " ", "the", " ", "follow", "ing", " ", "discl", "aime", "r", " ", "in", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "documentation", " ", "and", "/", "or", " ", "other", " ", "material", "s", " ", "provided", " ", "with", " ", "the", " ", "distribu", "tion", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "*", " ", "Nei", "ther", " ", "the", " ", "name", " ", "of", " ", "the", " ", "author", " ", "of", " ", "this", " ", "software", " ", "nor", " ", "the", " ", "name", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "contributor", "s", " ", "to", " ", "this", " ", "software", " ", "may", " ", "be", " ", "used", " ", "to", " ", "endo", "rse", " ", "or", " ", "promote", " ", "products_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "derive", "d", " ", "from", " ", "this", " ", "software", " ", "with", "out", " ", "specific", " ", "prior", " ", "writt", "en", " ", "consent", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THIS", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "BY", " ", "THE", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS", " ", "AND", " ", "CONTRIB", "UTO", "RS", " ", "\"", "AS", " ", "IS", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "AND", " ", "ANY", " ", "EXPR", "ESS", " ", "OR", " ", "IMPL", "IED", " ", "WAR", "RAN", "TIES", ",", " ", "INC", "LU", "DING", ",", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", ",", " ", "THE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IMPL", "IED", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", " ", "AND", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ARE", " ", "DISC", "LAI", "MED", ".", " ", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", " ", "COPY", "RIG", "HT", " ", "OWNER", " ", "OR", " ", "CONTRIB", "UTO", "RS", " ", "BE_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "DIRECT", ",", " ", "INDI", "RECT", ",", " ", "INC", "IDENT", "AL", ",", " ", "SPECIAL", ",", " ", "EXE", "MPL", "ARY", ",", " ", "OR_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CONS", "EQU", "ENTI", "AL", " ", "DA", "MAGE", "S", " ", "(", "INC", "LU", "DING", ",", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", ",", " ", "PROC", "URE", "MENT", " ", "OF_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SUBST", "ITU", "TE", " ", "GOOD", "S", " ", "OR", " ", "SERVICES", ";", " ", "LOSS", " ", "OF", " ", "USE", ",", " ", "DATA", ",", " ", "OR", " ", "PROF", "IT", "S", ";", " ", "OR", " ", "BUS", "INE", "SS_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "INTER", "RU", "PTION", ")", " ", "HO", "WE", "VER", " ", "CAU", "SED", " ", "AND", " ", "ON", " ", "ANY", " ", "THE", "ORY", " ", "OF", " ", "LI", "ABI", "LIT", "Y", ",", " ", "WHE", "THER", " ", "IN_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CONTR", "ACT", ",", " ", "STRI", "CT", " ", "LI", "ABI", "LIT", "Y", ",", " ", "OR", " ", "TOR", "T", " ", "(", "INC", "LU", "DING", " ", "NEG", "LIG", "ENCE", " ", "OR", " ", "OTHER", "WI", "SE", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ARI", "SIN", "G", " ", "IN", " ", "ANY", " ", "WAY", " ", "OUT", " ", "OF", " ", "THE", " ", "USE", " ", "OF", " ", "THIS", " ", "SOFT", "WARE", ",", " ", "EVE", "N", " ", "IF", " ", "ADV", "ISE", "D", " ", "OF", " ", "THE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "POS", "SIB", "ILI", "TY", " ", "OF", " ", "SUC", "H", " ", "DA", "MAGE", "._", "\\u\\u\\uNL\\u\\u\\u_", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Contain", "s", " ", "simple", " ", "socket", " ", "driver", "s", ".", " ", " ", "Async", "ore", " ", "bug", "ged", " ", "(", "hah", "a", ",", " ", "pun", "!)", " ", "me", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "division_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "errno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "select_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "._", "import_", "(_", "conf_", ",_", "drivers_", ",_", "log_", ",_", "utils_", ",_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "utils_", "import_", "mini", "six_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "utils_", "._", "str_", "import_", "decode", "\\u", "raw", "\\u", "line_", "\\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_", "ssl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SS", "LE", "rror_", "=_", "ssl_", "._", "SS", "LE", "rror_", "\\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 ", " _", "drivers_", "._", "log_", "._", "debug_", "(_", "'", "ssl", " ", "module", " ", "is", " ", "not", " ", "avail", "able", ",", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "cann", "ot", " ", "connect", " ", "to", " ", "SS", "L", " ", "server", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Driver_", "=_", "Sock", "et", "Driver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "vim", ":", "set", " ", "shift", "widt", "h", "=", "4", " ", "soft", "tabs", "top", "=", "4", " ", "expand", "tab", " ", "text", "widt", "h", "=", "7", "9", ":_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Sock", "et", "Driver_", "(_", "drivers_", "._", "Ir", "c", "Driver_", ",_", "drivers_", "._", "Server", "s", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "handle", "Sock", "et", "Error_", "(_", "self_", ",_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "(", "11", ",", " ", "'", "Reso", "urc", "e", " ", "temporar", "il", "y", " ", "unava", "ilab", "le", "')", " ", "raise", "d", " ", "if", " ", "connect_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hasn", "'", "t", " ", "finish", "ed", " ", "ye", "t", ".", " ", " ", "We", "'", "ll", " ", "keep", " ", "track", " ", "of", " ", "how", " ", "many", " ", "we", " ", "get", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", "._", "args_", "[_", "0_", "]_", "!=_", "11_", "or_", "self_", "._", "ea", "gains", "_", ">_", "120_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "disconnect_", "(_", "self_", "._", "current", "Server_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "in_", "self_", "._", "\\u", "instances_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "instances_", "._", "remove_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "conn_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "connected_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "schedule", "Recon", "nect", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "debug_", "(_", "'", "Got", " ", "EA", "GAIN", ",", " ", "current", " ", "count", ":", " ", "%", "s", ".'_", ",_", "self_", "._", "ea", "gains", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ea", "gains", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sock", "et", "Driver_", "(_", "drivers_", "._", "Ir", "c", "Driver_", ",_", "drivers_", "._", "Server", "s", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reconnect_", "(_", "self_", ",_", "wait_", "=_", "False_", ",_", "reset_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "attempt_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "next", "Recon", "nect", "Time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "connected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "reconnect_", "(_", "self_", "._", "irc_", "._", "network_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "in_", "self_", "._", "\\u", "instances_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "instances_", "._", "remove_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "conn_", "._", "shutdown_", "(_", "socket_", "._", "SHU", "T", "\\u", "RD", "WR", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "\"", "Transp", "ort", " ", "endpoint", " ", "not", " ", "connect", "ed", "\"_", "\\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_", "._", "conn_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connected_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "reset_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "debug_", "(_", "'", "Reset", "ting", " ", "%", "s", ".'_", ",_", "self_", "._", "irc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "irc_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "debug_", "(_", "'", "Not", " ", "reset", "ting", " ", "%", "s", ".'_", ",_", "self_", "._", "irc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "wait_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "schedule", "Recon", "nect", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "server_", "=_", "self_", "._", "\\u", "get", "Ne", "xt", "Server_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network", "\\u", "config_", "=_", "getattr_", "(_", "conf_", "._", "sup", "ybo", "t_", "._", "networks_", ",_", "self_", "._", "irc_", "._", "network_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socks", "\\u", "proxy_", "=_", "network", "\\u", "config_", "._", "socks", "proxy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "socks", "\\u", "proxy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "socks", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "'", "Cann", "ot", " ", "use", " ", "socks", " ", "proxy", " ", "(", "Sock", "si", "Py", " ", "not", " ", "install", "ed", "),", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "usi", "ng", " ", "direct", " ", "connecti", "on", " ", "inst", "ead", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socks", "\\u", "proxy_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "socks", "\\u", "proxy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "address_", "=_", "self_", "._", "server_", "[_", "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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "address_", "=_", "utils_", "._", "net_", "._", "get", "Address", "Fro", "m", "Host", "name_", "(_", "self_", "._", "server_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attempt_", "=_", "self_", "._", "\\u", "attempt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "socket_", "._", "gai", "error_", ",_", "socket_", "._", "error_", ")_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "connect", "Error_", "(_", "self_", "._", "current", "Server_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "schedule", "Recon", "nect", "_", "(_", ")_", "\\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_", "port_", "=_", "self_", "._", "server_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drivers_", "._", "log_", "._", "connect_", "(_", "self_", "._", "current", "Server_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "conn_", "=_", "utils_", "._", "net_", "._", "get", "Socket_", "(_", "address_", ",_", "port_", "=_", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "socks", "\\u", "proxy_", "=_", "socks", "\\u", "proxy_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vhost", "_", "=_", "conf_", "._", "sup", "ybo", "t_", "._", "protocols_", "._", "irc_", "._", "vhost", "_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vhost", "v6_", "=_", "conf_", "._", "sup", "ybo", "t_", "._", "protocols_", "._", "irc_", "._", "vhost", "v6_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "connect", "Error_", "(_", "self_", "._", "current", "Server_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "schedule", "Recon", "nect", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "allow", " ", "more", " ", "time", " ", "for", " ", "the", " ", "connect", " ", "here", ",", " ", "sinc", "e", " ", "it", " ", "mig", "ht", " ", "take", " ", "long", "er", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "At", " ", "leas", "t", " ", "10", " ", "second", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "conn_", "._", "settimeout_", "(_", "max_", "(_", "10_", ",_", "conf_", "._", "sup", "ybo", "t_", "._", "drivers_", "._", "poll_", "(_", ")_", "*_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Connect", " ", "bef", "ore", " ", "SS", "L", ",", " ", "other", "wis", "e", " ", "SS", "L", " ", "is", " ", "disable", "d", " ", "if", " ", "we", " ", "use", " ", "SOCK", "S", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "http", "://", "stack", "overflow", ".", "com", "/", "q", "/", "161", "369", "16", "/", "539", "465", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "conn_", "._", "connect_", "(_", "(_", "address_", ",_", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "network", "\\u", "config_", "._", "ssl_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "startt", "ls_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "network", "\\u", "config_", "._", "require", "Start", "tls_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "warning_", "(_", "(_", "'", "Connect", "ion", " ", "to", " ", "network", " ", "%", "s", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "doe", "s", " ", "not", " ", "use", " ", "SS", "L", "/", "TLS", ",", " ", "whi", "ch", " ", "make", "s", " ", "it", " ", "vulnerab", "le", " ", "to", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "man", "-", "in", "-", "the", "-", "middle", " ", "attacks", " ", "and", " ", "passive", " ", "ea", "ves", "drop", "ping", ".", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "You", " ", "shou", "ld", " ", "consider", " ", "up", "gradi", "ng", " ", "your", " ", "connecti", "on", " ", "to", " ", "SS", "L", "/", "TLS", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'<", "http", "://", "doc", ".", "sup", "ybo", "t", ".", "aper", "io", ".", "fr", "/", "en", "/", "late", "st", "/", "use", "/", "faq", ".", "html", "#", "how", "-", "to", "-", "make", "-", "a", "-", "connecti", "on", "-", "secure", ">'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "self_", "._", "irc_", "._", "network_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Timeout_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "conn_", "._", "settimeout_", "(_", "conf_", "._", "sup", "ybo", "t_", "._", "drivers_", "._", "poll_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "conf_", "._", "sup", "ybo", "t_", "._", "drivers_", "._", "poll_", "._", "add", "Callback_", "(_", "set", "Timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set", "Timeout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connected_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reset", "Delay_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", "._", "args_", "[_", "0_", "]_", "==_", "115_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "now_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "when_", "=_", "now_", "+_", "60_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "whe", "n", "S_", "=_", "log_", "._", "timestamp_", "(_", "when_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drivers_", "._", "log_", "._", "debug_", "(_", "'", "Connect", "ion", " ", "in", " ", "progress", ",", " ", "sched", "ulin", "g", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "connect", "edn", "ess", " ", "check", " ", "for", " ", "%", "s", "'_", ",_", "whe", "n", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "Check", "Time_", "=_", "when_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "drivers_", "._", "log_", "._", "connect", "Error_", "(_", "self_", "._", "current", "Server_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "schedule", "Recon", "nect", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "instances_", "._", "append_", "(_", "self_", ")_", "\\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,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 2, 2 ]
First parameter of a method is not named 'self'
Jahaja/psdash/psdash/run.py
[ { "content": " def _get_args(cls, args):\n parser = argparse.ArgumentParser(\n description='psdash %s - system information web dashboard' % __version__\n )\n parser.add_argument(\n '-l', '--log',\n action='append',\n dest='logs',\n default=None,\n metavar='path',\n help='log files to make available for psdash. Patterns (e.g. /var/log/**/*.log) are supported. '\n 'This option can be used multiple times.'\n )\n parser.add_argument(\n '-b', '--bind',\n action='store',\n dest='bind_host',\n default=None,\n metavar='host',\n help='host to bind to. Defaults to 0.0.0.0 (all interfaces).'\n )\n parser.add_argument(\n '-p', '--port',\n action='store',\n type=int,\n dest='port',\n default=None,\n metavar='port',\n help='port to listen on. Defaults to 5000.'\n )\n parser.add_argument(\n '-d', '--debug',\n action='store_true',\n dest='debug',\n help='enables debug mode.'\n )\n parser.add_argument(\n '-a', '--agent',\n action='store_true',\n dest='agent',\n help='Enables agent mode. This launches a RPC server, using zerorpc, on given bind host and port.'\n )\n parser.add_argument(\n '--register-to',\n action='store',\n dest='register_to',\n default=None,\n metavar='host:port',\n help='The psdash node running in web mode to register this agent to on start up. e.g 10.0.1.22:5000'\n )\n parser.add_argument(\n '--register-as',\n action='store',\n dest='register_as',\n default=None,\n metavar='name',\n help='The name to register as. (This will default to the node\\'s hostname)'\n )\n\n return parser.parse_args(args)", "metadata": "root.PsDashRunner._get_args", "header": "['class', 'PsDashRunner', '(', 'object', ')', ':', '___EOS___']", "index": 45 } ]
[ { "span": "def _get_args(cls, args):", "start_line": 45, "start_column": 4, "end_line": 45, "end_column": 29 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Ps", "Dash", "Runner_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "args_", "(_", "cls_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'", "psd", "ash", " ", "%", "s", " ", "-", " ", "system", " ", "informati", "on", " ", "web", " ", "dash", "board", "'_", "%_", "\\u\\u", "version\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "l", "'_", ",_", "'--", "log", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "append", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "logs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "path", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "log", " ", "files", " ", "to", " ", "make", " ", "avail", "able", " ", "for", " ", "psd", "ash", ".", " ", "Patterns", " ", "(", "e", ".", "g", ".", " ", "/", "var", "/", "log", "/**", "/*", ".", "log", ")", " ", "are", " ", "support", "ed", ".", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Thi", "s", " ", "option", " ", "can", " ", "be", " ", "used", " ", "multiple", " ", "times", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "b", "'_", ",_", "'--", "bind", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "bind", "\\u", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "host", " ", "to", " ", "bind", " ", "to", ".", " ", "Default", "s", " ", "to", " ", "0.", "0.", "0.", "0", " ", "(", "all", " ", "interface", "s", ").'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "p", "'_", ",_", "'--", "port", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "type_", "=_", "int_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "port", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "port", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "port", " ", "to", " ", "listen", " ", "on", ".", " ", "Default", "s", " ", "to", " ", "5000", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "d", "'_", ",_", "'--", "debug", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "debug", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "enable", "s", " ", "debug", " ", "mode", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "a", "'_", ",_", "'--", "agent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "agent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Enable", "s", " ", "agent", " ", "mode", ".", " ", "Thi", "s", " ", "launch", "es", " ", "a", " ", "RP", "C", " ", "server", ",", " ", "usi", "ng", " ", "zero", "rpc", ",", " ", "on", " ", "give", "n", " ", "bind", " ", "host", " ", "and", " ", "port", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'--", "register", "-", "to", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "register", "\\u", "to", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "host", ":", "port", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "The", " ", "psd", "ash", " ", "node", " ", "runn", "ing", " ", "in", " ", "web", " ", "mode", " ", "to", " ", "register", " ", "this", " ", "agent", " ", "to", " ", "on", " ", "start", " ", "up", ".", " ", "e", ".", "g", " ", "10.", "0.", "1.2", "2", ":", "5000", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'--", "register", "-", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "register", "\\u", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "name", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "The", " ", "name", " ", "to", " ", "register", " ", "as", ".", " ", "(", "Thi", "s", " ", "will", " ", "default", " ", "to", " ", "the", " ", "node", "\\\\'", "s", " ", "host", "name", ")'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "parser_", "._", "parse", "\\u", "args_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
scottrice/Ice/ice/error/__init__.py
[ { "content": "\nfrom human_readable_error import HumanReadableError", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from human_readable_error import HumanReadableError", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 51 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "human", "\\u", "reada", "ble", "\\u", "error_", "import_", "Huma", "n", "Read", "able", "Error_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Comparison of constants
PythonJS/PythonJS/regtests/lang/equality.py
[ { "content": "def main():\n\tTestError( 0==0 )\n\tTestError( 1==1 )\n\tTestError( 1.0==1 )\n\tTestError('a'=='a')\n\n\n\ta = [6]\n\tb = [6]\n\tt = a==b\n\tTestError( t==True )\n\n\ta = (6,)\n\tb = (6,)\n\tt = a==b\n\tTestError( t==True )\n\n\tt = ''==0 ## javascript gotcha\n\tTestError( t==False )\n\n\tt = [1,2]==[1,2] ## javascript gotcha\n\tTestError( t==True )\n\n\tt = [\"1\",\"2\"] != [1,2] ## javascript gotcha\n\tTestError( t==True )", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 5 } ]
[ { "span": "0==0 ", "start_line": 6, "start_column": 12, "end_line": 6, "end_column": 16 }, { "span": "1==1 ", "start_line": 7, "start_column": 12, "end_line": 7, "end_column": 16 }, { "span": "1.0==1 ", "start_line": 8, "start_column": 12, "end_line": 8, "end_column": 18 }, { "span": "'a'=='a')", "start_line": 9, "start_column": 11, "end_line": 9, "end_column": 19 }, { "span": "''==0 ", "start_line": 22, "start_column": 5, "end_line": 22, "end_column": 10 }, { "span": "[1,2]==[1,2] ", "start_line": 25, "start_column": 5, "end_line": 25, "end_column": 17 }, { "span": "[\"1\",\"2\"] != [1,2] ", "start_line": 28, "start_column": 5, "end_line": 28, "end_column": 23 } ]
[]
1
true
[ "[CLS]_", "Compari", "son_", "of_", "constants_", "[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\t", "_", "Test", "Error_", "(_", "0_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "1_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "1.0_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "'", "a", "'_", "==_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a_", "=_", "[_", "6_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "[_", "6_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "a_", "==_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "t_", "==_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a_", "=_", "(_", "6_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "(_", "6_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "a_", "==_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "t_", "==_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "''_", "==_", "0_", "##", " ", "javascript", " ", "got", "cha", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "t_", "==_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "[_", "1_", ",_", "2_", "]_", "==_", "[_", "1_", ",_", "2_", "]_", "##", " ", "javascript", " ", "got", "cha", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "t_", "==_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "[_", "\"", "1", "\"_", ",_", "\"", "2", "\"_", "]_", "!=_", "[_", "1_", ",_", "2_", "]_", "##", " ", "javascript", " ", "got", "cha", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Error_", "(_", "t_", "==_", "True_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
LxMLS/lxmls-toolkit/lxmls/parsing/dependency_parser.py
[ { "content": " def train_crf_sgd(self, n_epochs, sigma, eta0 = 0.001):\n '''Trains the parser by running the online MaxEnt algorithm for n_epochs, regularization coefficient sigma, \n and initial stepsize eta0 (which anneals as O(1/(sigma*t))).''' \n self.weights = np.zeros(self.features.n_feats)\n t = 0\n t0 = 1.0 / (sigma * eta0)\n for epoch in range(n_epochs):\n print \"Epoch {0}\".format(epoch+1)\n n_mistakes = 0\n n_tokens = 0\n n_instances = 0\n objective = 0.0\n for instance in self.reader.train_instances:\n eta = 1.0 / (sigma * (t + t0))\n feats = self.features.create_features(instance)\n scores = self.features.compute_scores(feats, self.weights)\n\n # Compute marginals and log-partition function, and move away from that direction\n marginals, logZ = self.decoder.parse_marginals_nonproj(scores)\n self.weights -= eta * sigma * self.weights # Scale the weight vector\n for h in range(np.size(marginals,0)):\n for m in range(1, np.size(marginals,1)):\n if feats[h][m] == None:\n continue\n for f in feats[h][m]: \n if f < 0:\n continue\n self.weights[f] -= eta * marginals[h,m]\n\n # Compute score of the correct parse, and move the weight vector towards that direction. \n score_corr = 0.0 \n for m in range(1, np.size(instance.heads)):\n h = instance.heads[m]\n score_corr += scores[h,m]\n for f in feats[h][m]: \n if f < 0:\n continue\n self.weights[f] += eta\n\n # Compute objective (w.r.t. this instance only)\n objective += 0.5 * sigma * np.dot(self.weights,self.weights) - score_corr + logZ\n\n n_instances += 1\n t += 1\n\n print \"Training objective: {0}\".format(objective / n_instances)", "metadata": "root.DependencyParser.train_crf_sgd", "header": "['class', 'DependencyParser', '(', ')', ':', '___EOS___']", "index": 62 } ]
[ { "span": "n_mistakes ", "start_line": 70, "start_column": 12, "end_line": 70, "end_column": 22 }, { "span": "n_tokens ", "start_line": 71, "start_column": 12, "end_line": 71, "end_column": 20 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Dependenc", "y", "Parser_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "train", "\\u", "cr", "f", "\\u", "sgd", "_", "(_", "self_", ",_", "n", "\\u", "epochs_", ",_", "sigma_", ",_", "eta", "0_", "=_", "0.001_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Train", "s", " ", "the", " ", "parser", " ", "by", " ", "runn", "ing", " ", "the", " ", "onli", "ne", " ", "Max", "Ent", " ", "algo", "rit", "hm", " ", "for", " ", "n", "\\u", "epoch", "s", ",", " ", "regularization", " ", "coefficient", " ", "sigma", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "initial", " ", "stepsize", " ", "eta", "0", " ", "(", "whi", "ch", " ", "anne", "als", " ", "as", " ", "O", "(", "1", "/(", "sigma", "*", "t", ")))", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "weights_", "=_", "np_", "._", "zeros_", "(_", "self_", "._", "features_", "._", "n", "\\u", "feats_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t0_", "=_", "1.0_", "/_", "(_", "sigma_", "*_", "eta", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "epoch_", "in_", "range_", "(_", "n", "\\u", "epochs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Epoch", " ", "{", "0", "}\"_", "._", "format_", "(_", "epoch_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "\\u", "mist", "ake", "s_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "\\u", "tokens_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "\\u", "instances_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "objective_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "instance_", "in_", "self_", "._", "reader_", "._", "train", "\\u", "instances_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eta_", "=_", "1.0_", "/_", "(_", "sigma_", "*_", "(_", "t_", "+_", "t0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feats_", "=_", "self_", "._", "features_", "._", "create", "\\u", "features_", "(_", "instance_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scores_", "=_", "self_", "._", "features_", "._", "compute", "\\u", "scores_", "(_", "feats_", ",_", "self_", "._", "weights_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "marginal", "s", " ", "and", " ", "log", "-", "partit", "ion", " ", "function", ",", " ", "and", " ", "move", " ", "awa", "y", " ", "from", " ", "tha", "t", " ", "direction_", "\\u\\u\\uNL\\u\\u\\u_", "marginal", "s_", ",_", "log", "Z_", "=_", "self_", "._", "decoder_", "._", "parse", "\\u", "marginal", "s", "\\u", "nonp", "roj", "_", "(_", "scores_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "weights_", "-=_", "eta_", "*_", "sigma_", "*_", "self_", "._", "weights_", "#", " ", "Scale", " ", "the", " ", "weight", " ", "vector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "h_", "in_", "range_", "(_", "np_", "._", "size_", "(_", "marginal", "s_", ",_", "0_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "m_", "in_", "range_", "(_", "1_", ",_", "np_", "._", "size_", "(_", "marginal", "s_", ",_", "1_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "feats_", "[_", "h_", "]_", "[_", "m_", "]_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "f_", "in_", "feats_", "[_", "h_", "]_", "[_", "m_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "f_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "weights_", "[_", "f_", "]_", "-=_", "eta_", "*_", "marginal", "s_", "[_", "h_", ",_", "m_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "score", " ", "of", " ", "the", " ", "correct", " ", "parse", ",", " ", "and", " ", "move", " ", "the", " ", "weight", " ", "vector", " ", "towards", " ", "tha", "t", " ", "direction", ".", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "score", "\\u", "corr_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "m_", "in_", "range_", "(_", "1_", ",_", "np_", "._", "size_", "(_", "instance_", "._", "heads_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "h_", "=_", "instance_", "._", "heads_", "[_", "m_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "score", "\\u", "corr_", "+=_", "scores_", "[_", "h_", ",_", "m_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "feats_", "[_", "h_", "]_", "[_", "m_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "f_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "weights_", "[_", "f_", "]_", "+=_", "eta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "objecti", "ve", " ", "(", "w", ".", "r", ".", "t", ".", " ", "this", " ", "instance", " ", "only", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "objective_", "+=_", "0.5_", "*_", "sigma_", "*_", "np_", "._", "dot_", "(_", "self_", "._", "weights_", ",_", "self_", "._", "weights_", ")_", "-_", "score", "\\u", "corr_", "+_", "log", "Z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "instances_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\"", "Train", "ing", " ", "objecti", "ve", ":", " ", "{", "0", "}\"_", "._", "format_", "(_", "objective_", "/_", "n", "\\u", "instances_", ")_", "\\u\\u\\uNEWLIN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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
openstack/swift/test/probe/test_reconstructor_durable.py
[ { "content": " def _check_node(self, node, part, etag, headers_post):\n # get fragment archive etag\n fragment_archive_etag = self.direct_get(node, part)\n\n # remove the .durable from the selected node\n part_dir = self.storage_dir('object', node, part=part)\n for dirs, subdirs, files in os.walk(part_dir):\n for fname in files:\n if fname.endswith('.durable'):\n durable = os.path.join(dirs, fname)\n os.remove(durable)\n break\n try:\n os.remove(os.path.join(part_dir, 'hashes.pkl'))\n except OSError as e:\n if e.errno != errno.ENOENT:\n raise\n\n # fire up reconstructor to propagate the .durable\n self.reconstructor.once()\n\n # fragment is still exactly as it was before!\n self.assertEqual(fragment_archive_etag,\n self.direct_get(node, part))\n\n # check meta\n meta = client.head_object(self.url, self.token,\n self.container_name,\n self.object_name)\n for key in headers_post:\n self.assertTrue(key in meta)\n self.assertEqual(meta[key], headers_post[key])", "metadata": "root.TestReconstructorPropDurable._check_node", "header": "['class', 'TestReconstructorPropDurable', '(', 'ECProbeTest', ')', ':', '___EOS___']", "index": 79 } ]
[ { "span": "self.assertTrue(key in meta)", "start_line": 109, "start_column": 12, "end_line": 109, "end_column": 40 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Recon", "struct", "or", "Prop", "Dur", "able_", "(_", "EC", "Probe", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "check", "\\u", "node_", "(_", "self_", ",_", "node_", ",_", "part_", ",_", "etag_", ",_", "header", "s", "\\u", "post_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "fragment", " ", "archive", " ", "etag_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fragment", "\\u", "archive", "\\u", "etag_", "=_", "self_", "._", "direct", "\\u", "get_", "(_", "node_", ",_", "part_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remove", " ", "the", " ", ".", "durab", "le", " ", "from", " ", "the", " ", "selecte", "d", " ", "node_", "\\u\\u\\uNL\\u\\u\\u_", "part", "\\u", "dir_", "=_", "self_", "._", "storage", "\\u", "dir_", "(_", "'", "object", "'_", ",_", "node_", ",_", "part_", "=_", "part_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dirs_", ",_", "subdirs_", ",_", "files_", "in_", "os_", "._", "walk_", "(_", "part", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "fname_", "in_", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "fname_", "._", "endswith_", "(_", "'.", "durab", "le", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "durab", "le_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dirs_", ",_", "fname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "remove_", "(_", "durab", "le_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "os_", "._", "path_", "._", "join_", "(_", "part", "\\u", "dir_", ",_", "'", "hashe", "s", ".", "pkl", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "OSE", "rror_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", "._", "errno_", "!=_", "errno_", "._", "ENOENT_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fire", " ", "up", " ", "reconstruct", "or", " ", "to", " ", "propagate", " ", "the", " ", ".", "durab", "le_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "reconstruct", "or_", "._", "once_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fragment", " ", "is", " ", "still", " ", "exact", "ly", " ", "as", " ", "it", " ", "was", " ", "bef", "ore", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "fragment", "\\u", "archive", "\\u", "etag_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "direct", "\\u", "get_", "(_", "node_", ",_", "part_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "meta_", "\\u\\u\\uNL\\u\\u\\u_", "meta_", "=_", "client_", "._", "head", "\\u", "object_", "(_", "self_", "._", "url_", ",_", "self_", "._", "token_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "container", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "object\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", "in_", "header", "s", "\\u", "post_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "key_", "in_", "meta_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "meta_", "[_", "key_", "]_", ",_", "header", "s", "\\u", "post_", "[_", "key_", "]_", ")_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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, 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 ]
Except block handles 'BaseException'
antiboredom/videogrep/videogrep/tools/hypernym_count.py
[ { "content": "import sys\nfrom pattern.en import wordnet, parse, tag\n\n\n\ntext = sys.stdin.read()\n\nhypernyms = {}\nfor word, pos in tag(text):\n synsets = wordnet.synsets(word)\n if len(synsets) > 0:\n try:\n hypernym = synsets[0].hypernyms()[0].senses[0]\n if hypernym in hypernyms:\n hypernyms[hypernym] += 1\n else:\n hypernyms[hypernym] = 1\n except:\n next\n\nfor hypernym in sorted(hypernyms, key=hypernyms.get, reverse=True):\n count = hypernyms[hypernym]\n print hypernym + \": \" + str(count)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 30, "start_column": 8, "end_line": 30, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pattern_", "._", "en_", "import_", "word", "net_", ",_", "parse_", ",_", "tag_", "\\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_", "text_", "=_", "sys_", "._", "stdin_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "hyper", "nym", "s_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "word_", ",_", "pos_", "in_", "tag_", "(_", "text_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "synset", "s_", "=_", "word", "net_", "._", "synset", "s_", "(_", "word_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "synset", "s_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hyper", "nym", "_", "=_", "synset", "s_", "[_", "0_", "]_", "._", "hyper", "nym", "s_", "(_", ")_", "[_", "0_", "]_", "._", "sense", "s_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hyper", "nym", "_", "in_", "hyper", "nym", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hyper", "nym", "s_", "[_", "hyper", "nym", "_", "]_", "+=_", "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 ", " _", "hyper", "nym", "s_", "[_", "hyper", "nym", "_", "]_", "=_", "1_", "\\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 ", " _", "next_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "hyper", "nym", "_", "in_", "sorted_", "(_", "hyper", "nym", "s_", ",_", "key_", "=_", "hyper", "nym", "s_", "._", "get_", ",_", "reverse_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "count_", "=_", "hyper", "nym", "s_", "[_", "hyper", "nym", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "hyper", "nym", "_", "+_", "\":", " ", "\"_", "+_", "str_", "(_", "count_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
saeschdivara/ArangoPy/arangodb/tests.py
[ { "content": "import unittest\n\nfrom arangodb.tests.api.document import DocumentTestCase\nfrom arangodb.tests.api.collection import CollectionTestCase\nfrom arangodb.tests.api.database import DatabaseTestCase\nfrom arangodb.tests.endpoint import EndpointTestCase\nfrom arangodb.tests.index import IndexTestCase\nfrom arangodb.tests.orm.fields.boolean_field import BooleanFieldTestCase\nfrom arangodb.tests.orm.fields.char_field import CharFieldTestCase\nfrom arangodb.tests.orm.fields.choice import ChoiceFieldTestCase\nfrom arangodb.tests.orm.fields.date_field import DateFieldTestCase\nfrom arangodb.tests.orm.fields.datetime_field import DatetimeFieldTestCase\nfrom arangodb.tests.orm.fields.dict_field import DictFieldTestCase\nfrom arangodb.tests.orm.fields.foreignkey import ForeignkeyFieldTestCase\nfrom arangodb.tests.orm.fields.list_field import ListFieldTestCase\nfrom arangodb.tests.orm.fields.manytomany import ManyToManyFieldTestCase\nfrom arangodb.tests.orm.fields.number import NumberFieldTestCase\nfrom arangodb.tests.orm.fields.uuid_field import UuidFieldTestCase\nfrom arangodb.tests.orm.manager_with_index import CollectionModelManagerForIndexTestCase\nfrom arangodb.tests.orm.model import CollectionModelTestCase\nfrom arangodb.tests.orm.model_foreignkey import CollectionModelForeignKeyFieldTestCase\nfrom arangodb.tests.orm.model_manager import CollectionModelManagerTestCase\nfrom arangodb.tests.query.advanced import TraveserTestCase\nfrom arangodb.tests.query.aql import AqlQueryTestCase\nfrom arangodb.tests.query.basic import SimpleQueryTestCase\nfrom arangodb.tests.query.escaping import AqlEscapingTestCase\nfrom arangodb.tests.query.index import SimpleIndexQueryTestCase\nfrom arangodb.tests.transaction import TransactionTestCase\nfrom arangodb.tests.user import UserTestCase\n\n\nif __name__ == '__main__':\n unittest.main()", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from arangodb.tests.api.document import DocumentTestCase", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 56 }, { "span": "from arangodb.tests.api.collection import CollectionTestCase", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 60 }, { "span": "from arangodb.tests.api.database import DatabaseTestCase", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 56 }, { "span": "from arangodb.tests.endpoint import EndpointTestCase", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 52 }, { "span": "from arangodb.tests.index import IndexTestCase", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 46 }, { "span": "from arangodb.tests.orm.fields.boolean_field import BooleanFieldTestCase", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 72 }, { "span": "from arangodb.tests.orm.fields.char_field import CharFieldTestCase", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 66 }, { "span": "from arangodb.tests.orm.fields.choice import ChoiceFieldTestCase", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 64 }, { "span": "from arangodb.tests.orm.fields.date_field import DateFieldTestCase", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 66 }, { "span": "from arangodb.tests.orm.fields.datetime_field import DatetimeFieldTestCase", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 74 }, { "span": "from arangodb.tests.orm.fields.dict_field import DictFieldTestCase", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 66 }, { "span": "from arangodb.tests.orm.fields.foreignkey import ForeignkeyFieldTestCase", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 72 }, { "span": "from arangodb.tests.orm.fields.list_field import ListFieldTestCase", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 66 }, { "span": "from arangodb.tests.orm.fields.manytomany import ManyToManyFieldTestCase", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 72 }, { "span": "from arangodb.tests.orm.fields.number import NumberFieldTestCase", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 64 }, { "span": "from arangodb.tests.orm.fields.uuid_field import UuidFieldTestCase", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 66 }, { "span": "from arangodb.tests.orm.manager_with_index import CollectionModelManagerForIndexTestCase", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 88 }, { "span": "from arangodb.tests.orm.model import CollectionModelTestCase", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 60 }, { "span": "from arangodb.tests.orm.model_foreignkey import CollectionModelForeignKeyFieldTestCase", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 86 }, { "span": "from arangodb.tests.orm.model_manager import CollectionModelManagerTestCase", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 75 }, { "span": "from arangodb.tests.query.advanced import TraveserTestCase", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 58 }, { "span": "from arangodb.tests.query.aql import AqlQueryTestCase", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 53 }, { "span": "from arangodb.tests.query.basic import SimpleQueryTestCase", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 58 }, { "span": "from arangodb.tests.query.escaping import AqlEscapingTestCase", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 61 }, { "span": "from arangodb.tests.query.index import SimpleIndexQueryTestCase", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 63 }, { "span": "from arangodb.tests.transaction import TransactionTestCase", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 58 }, { "span": "from arangodb.tests.user import UserTestCase", "start_line": 28, "start_column": 0, "end_line": 28, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "api_", "._", "document_", "import_", "Document", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "api_", "._", "collection_", "import_", "Collecti", "on", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "api_", "._", "database_", "import_", "Databa", "se", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "endpoint_", "import_", "End", "point", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "index_", "import_", "Index", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "boolean", "\\u", "field_", "import_", "Boo", "lean", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "char", "\\u", "field_", "import_", "Char", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "choice_", "import_", "Choi", "ce", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "date", "\\u", "field_", "import_", "Date", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "datetime", "\\u", "field_", "import_", "Date", "time", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "dict", "\\u", "field_", "import_", "Dict", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "foreign", "key_", "import_", "Fore", "ign", "key", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "list", "\\u", "field_", "import_", "List", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "many", "toma", "ny_", "import_", "Many", "To", "Many", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "number_", "import_", "Number", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "fields_", "._", "uuid", "\\u", "field_", "import_", "Uu", "id", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "manage", "r", "\\u", "with", "\\u", "index_", "import_", "Collecti", "on", "Model", "Manager", "For", "Index", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "model_", "import_", "Collecti", "on", "Model", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "model", "\\u", "foreign", "key_", "import_", "Collecti", "on", "Model", "Fore", "ign", "Key", "Field", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "orm_", "._", "model", "\\u", "manager_", "import_", "Collecti", "on", "Model", "Manager", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "query_", "._", "advanced", "_", "import_", "Tra", "ves", "er", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "query_", "._", "aq", "l_", "import_", "Aq", "l", "Query", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "query_", "._", "basic_", "import_", "Simple", "Query", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "query_", "._", "esca", "ping_", "import_", "Aq", "l", "Esc", "api", "ng", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "query_", "._", "index_", "import_", "Simple", "Index", "Query", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "transaction_", "import_", "Transa", "ction", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aran", "god", "b_", "._", "tests_", "._", "user_", "import_", "User", "Test", "Case_", "\\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 ", " _", "unittest_", "._", "main_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 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, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
numba/numba/numba/tests/__init__.py
[ { "content": "from numba import unittest_support as unittest\n\nimport gc\nfrom os.path import dirname, join\nimport multiprocessing\nimport sys\nimport time\nimport warnings\n\nfrom unittest.suite import TestSuite\nfrom numba.testing import load_testsuite\nfrom numba.testing import ddt # for backward compatibility\n\n\ntry:\n import faulthandler\nexcept ImportError:\n faulthandler = None\nelse:\n try:\n # May fail in IPython Notebook with UnsupportedOperation\n faulthandler.enable()\n except BaseException as e:\n msg = \"Failed to enable faulthandler due to:\\n{err}\"\n warnings.warn(msg.format(err=e))\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except BaseException as e:", "start_line": 22, "start_column": 4, "end_line": 22, "end_column": 30 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "numba_", "import_", "unittest", "\\u", "support_", "as_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "gc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "._", "path_", "import_", "dirname_", ",_", "join_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "multiprocessing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "unittest_", "._", "suite_", "import_", "Test", "Suite_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numba_", "._", "testing_", "import_", "load", "\\u", "testsuite_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numba_", "._", "testing_", "import_", "ddt_", "#", " ", "for", " ", "back", "ward", " ", "compatibility", "_", "\\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 ", " _", "import_", "fault", "handler_", "\\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 ", " _", "fault", "handler_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ma", "y", " ", "fail", " ", "in", " ", "IP", "yth", "on", " ", "Notebook", " ", "with", " ", "Unsu", "ppo", "rted", "Operation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fault", "handler_", "._", "enable_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Base", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "\"", "Fail", "ed", " ", "to", " ", "enable", " ", "fault", "handler", " ", "due", " ", "to", ":\\\\", "n", "{", "err", "}\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "warnings_", "._", "warn_", "(_", "msg_", "._", "format_", "(_", "err_", "=_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unreachable code
fp7-ofelia/ocf/ofam/src/src/foam/api/admin.py
[ { "content": " def gapi_CreateSliver(self, slice_urn, credentials, rspec, users, force_approval=False, options=None):\t\n #GENI API imports\n from foam.geni.db import GeniDB, UnknownSlice, UnknownNode\n import foam.geni.approval\n import foam.geni.ofeliaapproval\n import sfa\n user_info = users\n try:\n if True:\n #self.recordAction(\"createsliver\", credentials, slice_urn)\n try:\n self._log.debug(\"Parsed user cert with URN (%(urn)s) and email (%(email)s)\" % users)\n except Exception, e:\n self._log.exception(\"UNFILTERED EXCEPTION\")\n user_info[\"urn\"] = None\n user_info[\"email\"] = None\n sliver = foam.geni.lib.createSliver(slice_urn, credentials, rspec, user_info)\n style = ConfigDB.getConfigItemByKey(\"geni.approval.approve-on-creation\").getValue()\n if style == foam.geni.approval.NEVER:\n approve = False\n elif style == foam.geni.approval.ALWAYS:\n approve = True\n else:\n approve = foam.geni.ofeliaapproval.of_analyzeForApproval(sliver)\n if approve or force_approval:\n pid = foam.task.approveSliver(sliver.getURN(), AUTO_SLIVER_PRIORITY)\n self._log.debug(\"task.py launched for approve-sliver (PID: %d)\" % pid)\t\n data = GeniDB.getSliverData(sliver.getURN(), True)\n foam.task.emailCreateSliver(data)\n return self.successResult(GeniDB.getManifest(sliver.getURN()))\n return\t\t\n except foam.geni.lib.RspecParseError, e:\n self._log.info(str(e))\n e._foam_logged = True\n raise e\n except foam.geni.lib.RspecValidationError, e:\n self._log.info(str(e))\n e._foam_logged = True\n raise e\n except foam.geni.lib.DuplicateSliver, ds:\n self._log.info(\"Attempt to create multiple slivers for slice [%s]\" % (ds.slice_urn))\n ds._foam_logged = True\n raise ds\n except foam.geni.lib.UnknownComponentManagerID, ucm:\n raise Fault(\"UnknownComponentManager\", \"Component Manager ID specified in %s does not match this aggregate.\" % (ucm.cid))\n except (foam.geni.lib.UnmanagedComponent, UnknownNode), uc:\n self._log.info(\"Attempt to request unknown component %s\" % (uc.cid))\n f = Fault(\"UnmanagedComponent\", \"DPID in component %s is unknown to this aggregate.\" % (uc.cid))\n f._foam_logged = True\n raise f\n except Exception, e:\n self._log.exception(\"Exception\")\n raise e", "metadata": "root.AdminAPIv1.gapi_CreateSliver", "header": "['class', 'AdminAPIv1', '(', 'Dispatcher', ')', ':', '___EOS___']", "index": 663 }, { "content": " def gapi_DeleteSliver(self, slice_urn, credentials, options=None):\n #GENI API imports\n from foam.geni.db import GeniDB, UnknownSlice, UnknownNode\n import foam.geni.approval\n import foam.geni.ofeliaapproval\n import sfa\n try:\n if True:\n #self.recordAction(\"deletesliver\", credentials, slice_urn)\n if GeniDB.getSliverURN(slice_urn) is None:\n raise Fault(\"DeleteSliver\", \"Sliver for slice URN (%s) does not exist\" % (slice_urn))\n return self.errorResult(12, \"\") #not sure if this is needed\n sliver_urn = GeniDB.getSliverURN(slice_urn)\n data = GeniDB.getSliverData(sliver_urn, True)\n foam.geni.lib.deleteSliver(sliver_urn = sliver_urn)\n foam.task.emailGAPIDeleteSliver(data)\n return self.successResult(True)\n return self.successResult(False)\t\n except UnknownSlice, x:\n self._log.info(\"Attempt to delete unknown sliver for slice URN %s\" % (slice_urn))\n x._foam_logged = True\n raise x \n except Exception, e:\n self._log.exception(\"Exception\")\n raise e", "metadata": "root.AdminAPIv1.gapi_DeleteSliver", "header": "['class', 'AdminAPIv1', '(', 'Dispatcher', ')', ':', '___EOS___']", "index": 717 } ]
[ { "span": "return\t", "start_line": 693, "start_column": 6, "end_line": 693, "end_column": 12 }, { "span": "return self.errorResult(12, \"\") ", "start_line": 728, "start_column": 10, "end_line": 728, "end_column": 41 }, { "span": "return self.successResult(False)\t", "start_line": 734, "start_column": 6, "end_line": 734, "end_column": 38 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Admi", "n", "API", "v1_", "(_", "Dispatcher_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gap", "i", "\\u", "Creat", "e", "Sli", "ver_", "(_", "self_", ",_", "slice", "\\u", "urn_", ",_", "credentials_", ",_", "rsp", "ec_", ",_", "users_", ",_", "force", "\\u", "approval", "_", "=_", "False_", ",_", "options_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "GEN", "I", " ", "API", " ", "imports_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "foa", "m_", "._", "geni", "_", "._", "db_", "import_", "Gen", "i", "DB_", ",_", "Un", "know", "n", "Slice_", ",_", "Un", "know", "n", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "foa", "m_", "._", "geni", "_", "._", "approval", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "foa", "m_", "._", "geni", "_", "._", "of", "eli", "aa", "ppro", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sfa", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "info_", "=_", "users_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "record", "Action", "(\"", "create", "sli", "ver", "\",", " ", "cred", "ential", "s", ",", " ", "slice", "\\u", "urn", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "debug_", "(_", "\"", "Pars", "ed", " ", "user", " ", "cert", " ", "with", " ", "URN", " ", "(%", "(", "urn", ")", "s", ")", " ", "and", " ", "email", " ", "(%", "(", "email", ")", "s", ")\"_", "%_", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "exception_", "(_", "\"", "UN", "FILTER", "ED", " ", "EXCEPTION", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "info_", "[_", "\"", "urn", "\"_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "info_", "[_", "\"", "email", "\"_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sli", "ver_", "=_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "create", "Sli", "ver_", "(_", "slice", "\\u", "urn_", ",_", "credentials_", ",_", "rsp", "ec_", ",_", "user", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "style_", "=_", "Config", "DB_", "._", "get", "Config", "Item", "By", "Key_", "(_", "\"", "geni", ".", "approval", ".", "approve", "-", "on", "-", "creati", "on", "\"_", ")_", "._", "get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "style_", "==_", "foa", "m_", "._", "geni", "_", "._", "approval", "_", "._", "NE", "VER_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "approve", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "style_", "==_", "foa", "m_", "._", "geni", "_", "._", "approval", "_", "._", "ALWAYS", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "approve", "_", "=_", "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 ", " _", "approve", "_", "=_", "foa", "m_", "._", "geni", "_", "._", "of", "eli", "aa", "ppro", "val_", "._", "of", "\\u", "analyze", "For", "Approval", "_", "(_", "sli", "ver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "approve", "_", "or_", "force", "\\u", "approval", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pid_", "=_", "foa", "m_", "._", "task_", "._", "approve", "Sli", "ver_", "(_", "sli", "ver_", "._", "get", "URN", "_", "(_", ")_", ",_", "AUTO", "\\u", "SLI", "VER", "\\u", "PRIORITY", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "log_", "._", "debug_", "(_", "\"", "task", ".", "py", " ", "launched", " ", "for", " ", "approve", "-", "sli", "ver", " ", "(", "PID", ":", " ", "%", "d", ")\"_", "%_", "pid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "=_", "Gen", "i", "DB_", "._", "get", "Sli", "ver", "Data_", "(_", "sli", "ver_", "._", "get", "URN", "_", "(_", ")_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "foa", "m_", "._", "task_", "._", "email", "Creat", "e", "Sli", "ver_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "success", "Result_", "(_", "Gen", "i", "DB_", "._", "get", "Manifest", "_", "(_", "sli", "ver_", "._", "get", "URN", "_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "Rs", "pec", "Pars", "e", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "info_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "._", "\\u", "foa", "m", "\\u", "logged", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "Rs", "pec", "Validat", "ion", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "info_", "(_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "._", "\\u", "foa", "m", "\\u", "logged", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "Duplicate", "Sli", "ver_", ",_", "ds_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "info_", "(_", "\"", "Atte", "mpt", " ", "to", " ", "create", " ", "multiple", " ", "sli", "vers", " ", "for", " ", "slice", " ", "[", "%", "s", "]\"_", "%_", "(_", "ds_", "._", "slice", "\\u", "urn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ds_", "._", "\\u", "foa", "m", "\\u", "logged", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "Un", "know", "n", "Compo", "nent", "Manager", "ID_", ",_", "uc", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Fault_", "(_", "\"", "Un", "know", "n", "Compo", "nent", "Manager", "\"_", ",_", "\"", "Compo", "nent", " ", "Manager", " ", "ID", " ", "specified", " ", "in", " ", "%", "s", " ", "doe", "s", " ", "not", " ", "match", " ", "this", " ", "aggre", "gate", ".\"_", "%_", "(_", "uc", "m_", "._", "cid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "Unma", "nage", "d", "Component_", ",_", "Un", "know", "n", "Node_", ")_", ",_", "uc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "info_", "(_", "\"", "Atte", "mpt", " ", "to", " ", "request", " ", "unknown", " ", "component", " ", "%", "s", "\"_", "%_", "(_", "uc_", "._", "cid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "Fault_", "(_", "\"", "Unma", "nage", "d", "Compo", "nent", "\"_", ",_", "\"", "DP", "ID", " ", "in", " ", "component", " ", "%", "s", " ", "is", " ", "unknown", " ", "to", " ", "this", " ", "aggre", "gate", ".\"_", "%_", "(_", "uc_", "._", "cid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "\\u", "foa", "m", "\\u", "logged", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "f_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "exception_", "(_", "\"", "Except", "ion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Admi", "n", "API", "v1_", "(_", "Dispatcher_", ")_", ":_", "\\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_", "gap", "i", "\\u", "Delete", "Sli", "ver_", "(_", "self_", ",_", "slice", "\\u", "urn_", ",_", "credentials_", ",_", "options_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "GEN", "I", " ", "API", " ", "imports_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "foa", "m_", "._", "geni", "_", "._", "db_", "import_", "Gen", "i", "DB_", ",_", "Un", "know", "n", "Slice_", ",_", "Un", "know", "n", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "foa", "m_", "._", "geni", "_", "._", "approval", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "foa", "m_", "._", "geni", "_", "._", "of", "eli", "aa", "ppro", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sfa", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "record", "Action", "(\"", "delete", "sli", "ver", "\",", " ", "cred", "ential", "s", ",", " ", "slice", "\\u", "urn", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "Gen", "i", "DB_", "._", "get", "Sli", "ver", "URN", "_", "(_", "slice", "\\u", "urn_", ")_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Fault_", "(_", "\"", "Delete", "Sli", "ver", "\"_", ",_", "\"", "Sli", "ver", " ", "for", " ", "slice", " ", "URN", " ", "(%", "s", ")", " ", "doe", "s", " ", "not", " ", "exist", "\"_", "%_", "(_", "slice", "\\u", "urn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "error", "Result_", "(_", "12_", ",_", "\"\"_", ")_", "#", "not", " ", "sure", " ", "if", " ", "this", " ", "is", " ", "needed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sli", "ver", "\\u", "urn_", "=_", "Gen", "i", "DB_", "._", "get", "Sli", "ver", "URN", "_", "(_", "slice", "\\u", "urn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "Gen", "i", "DB_", "._", "get", "Sli", "ver", "Data_", "(_", "sli", "ver", "\\u", "urn_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "foa", "m_", "._", "geni", "_", "._", "lib_", "._", "delete", "Sli", "ver_", "(_", "sli", "ver", "\\u", "urn_", "=_", "sli", "ver", "\\u", "urn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "foa", "m_", "._", "task_", "._", "email", "GAP", "ID", "ele", "te", "Sli", "ver_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "success", "Result_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "success", "Result_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Un", "know", "n", "Slice_", ",_", "x_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "info_", "(_", "\"", "Atte", "mpt", " ", "to", " ", "delete", " ", "unknown", " ", "sli", "ver", " ", "for", " ", "slice", " ", "URN", " ", "%", "s", "\"_", "%_", "(_", "slice", "\\u", "urn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "._", "\\u", "foa", "m", "\\u", "logged", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "log_", "._", "exception_", "(_", "\"", "Except", "ion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
Alir3z4/django-databrowse/django_databrowse/datastructures.py
[ { "content": " def urls(self):\n \"Returns a list of (value, URL) tuples.\"\n # First, check the urls() method for each plugin.\n plugin_urls = []\n for plugin_name, plugin in \\\n self.model.model_databrowse().plugins.items():\n urls = plugin.urls(plugin_name, self)\n if urls is not None:\n #plugin_urls.append(urls)\n values = self.values()\n return zip(self.values(), urls)\n if self.field.rel:\n m = EasyModel(self.model.site, self.field.rel.to)\n if self.field.rel.to in self.model.model_list:\n lst = []\n for value in self.values():\n if value is None:\n continue\n url = mark_safe('%s%s/%s/objects/%s/' %\n (self.model.site.root_url,\n m.model._meta.app_label,\n m.model._meta.module_name,\n iri_to_uri(value._get_pk_val())))\n lst.append((smart_unicode(value), url))\n else:\n lst = [(value, None) for value in self.values()]\n elif self.field.choices:\n lst = []\n for value in self.values():\n url = mark_safe('%s%s/%s/fields/%s/%s/' %\n (self.model.site.root_url,\n self.model.model._meta.app_label,\n self.model.model._meta.module_name,\n self.field.name,\n iri_to_uri(self.raw_value)))\n lst.append((value, url))\n elif isinstance(self.field, models.URLField):\n val = self.values()[0]\n lst = [(val, iri_to_uri(val))]\n else:\n lst = [(self.values()[0], None)]\n return lst", "metadata": "root.EasyInstanceField.urls", "header": "['class', 'EasyInstanceField', '(', 'object', ')', ':', '___EOS___']", "index": 223 } ]
[ { "span": "plugin_urls ", "start_line": 226, "start_column": 8, "end_line": 226, "end_column": 19 }, { "span": "values ", "start_line": 232, "start_column": 16, "end_line": 232, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Eas", "y", "Insta", "nce", "Field_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "urls_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Return", "s", " ", "a", " ", "list", " ", "of", " ", "(", "value", ",", " ", "URL", ")", " ", "tuple", "s", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fi", "rst", ",", " ", "check", " ", "the", " ", "urls", "()", " ", "method", " ", "for", " ", "each", " ", "plugin", "._", "\\u\\u\\uNL\\u\\u\\u_", "plugin", "\\u", "urls_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "plugin", "\\u", "name_", ",_", "plugin_", "in_", "self_", "._", "model_", "._", "model", "\\u", "datab", "rowse", "_", "(_", ")_", "._", "plugins_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urls_", "=_", "plugin_", "._", "urls_", "(_", "plugin", "\\u", "name_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "urls_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "plugin", "\\u", "urls", ".", "append", "(", "urls", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "self_", "._", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "zip_", "(_", "self_", "._", "values_", "(_", ")_", ",_", "urls_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "field_", "._", "rel_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "Eas", "y", "Model_", "(_", "self_", "._", "model_", "._", "site_", ",_", "self_", "._", "field_", "._", "rel_", "._", "to_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "field_", "._", "rel_", "._", "to_", "in_", "self_", "._", "model_", "._", "model", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lst_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "self_", "._", "values_", "(_", ")_", ":_", "\\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 ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "url_", "=_", "mark", "\\u", "safe_", "(_", "'%", "s", "%", "s", "/", "%", "s", "/", "object", "s", "/", "%", "s", "/'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "self_", "._", "model_", "._", "site_", "._", "root", "\\u", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "model_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "model_", "._", "\\u", "meta_", "._", "module", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "iri", "\\u", "to", "\\u", "uri_", "(_", "value_", "._", "\\u", "get", "\\u", "pk", "\\u", "val_", "(_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lst_", "._", "append_", "(_", "(_", "smart", "\\u", "unicode_", "(_", "value_", ")_", ",_", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lst_", "=_", "[_", "(_", "value_", ",_", "None_", ")_", "for_", "value_", "in_", "self_", "._", "values_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "field_", "._", "choices_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lst_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "self_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "mark", "\\u", "safe_", "(_", "'%", "s", "%", "s", "/", "%", "s", "/", "fields", "/", "%", "s", "/", "%", "s", "/'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "self_", "._", "model_", "._", "site_", "._", "root", "\\u", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "model_", "._", "model_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "model_", "._", "model_", "._", "\\u", "meta_", "._", "module", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "field_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "iri", "\\u", "to", "\\u", "uri_", "(_", "self_", "._", "raw", "\\u", "value_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lst_", "._", "append_", "(_", "(_", "value_", ",_", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "self_", "._", "field_", ",_", "models_", "._", "URL", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "val_", "=_", "self_", "._", "values_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lst_", "=_", "[_", "(_", "val_", ",_", "iri", "\\u", "to", "\\u", "uri_", "(_", "val_", ")_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uIND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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 ]
Missing call to `__init__` during object initialization
CollabQ/CollabQ/.google_appengine/google/appengine/api/validation.py
[ { "content": " def __init__(self, default=None):\n \"\"\"Constructor.\n\n Args:\n default: Default assignment is made during initialization and will\n not pass through validation.\n \"\"\"\n self.default = default", "metadata": "root.Validator.__init__", "header": "['class', 'Validator', '(', 'object', ')', ':', '___EOS___']", "index": 351 }, { "content": "class Optional(Validator):\n \"\"\"Definition of optional attributes.\n\n Optional values are attributes which can be set to None or left\n unset. All values in a basic Validated class are set to None\n at initialization. Failure to assign to non-optional values\n will result in a validation error when calling CheckInitialized.\n \"\"\"\n\n", "metadata": "root.Optional", "header": "['module', '___EOS___']", "index": 554 }, { "content": " def __init__(self, validator, default=None):\n \"\"\"Initializer.\n\n This constructor will make a few guesses about the value passed in\n as the validator:\n\n - If the validator argument is a type, it automatically creates a Type\n validator around it.\n\n - If the validator argument is a list or tuple, it automatically\n creates an Options validator around it.\n\n Args:\n validator: Optional validation condition.\n\n Raises:\n AttributeDefinitionError if validator is not callable.\n \"\"\"\n self.validator = AsValidator(validator)\n self.expected_type = self.validator.expected_type\n self.default = default", "metadata": "root.Optional.__init__", "header": "['class', 'Optional', '(', 'Validator', ')', ':', '___EOS___']", "index": 563 } ]
[ { "span": "class Optional(Validator):", "start_line": 554, "start_column": 0, "end_line": 554, "end_column": 26 } ]
[ { "span": "def __init__(self, default=None):", "start_line": 351, "start_column": 2, "end_line": 351, "end_column": 35 }, { "span": "def __init__(self, validator, default=None):", "start_line": 563, "start_column": 2, "end_line": 563, "end_column": 46 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Validator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "default_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Constructor", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "default", ":", " ", "Default", " ", "assign", "ment", " ", "is", " ", "made", " ", "dur", "ing", " ", "initialization", " ", "and", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "not", " ", "pass", " ", "through", " ", "validation", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "default_", "=_", "default_", "\\u\\u\\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_", "Optional_", "(_", "Validator_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Definit", "ion", " ", "of", " ", "option", "al", " ", "attribute", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Optio", "nal", " ", "values", " ", "are", " ", "attribute", "s", " ", "whi", "ch", " ", "can", " ", "be", " ", "set", " ", "to", " ", "Non", "e", " ", "or", " ", "left", "\\", "10", ";", " ", " ", "unse", "t", ".", " ", " ", "All", " ", "values", " ", "in", " ", "a", " ", "basic", " ", "Validate", "d", " ", "class", " ", "are", " ", "set", " ", "to", " ", "Non", "e", "\\", "10", ";", " ", " ", "at", " ", "initialization", ".", " ", " ", "Fail", "ure", " ", "to", " ", "assign", " ", "to", " ", "non", "-", "option", "al", " ", "values", "\\", "10", ";", " ", " ", "will", " ", "result", " ", "in", " ", "a", " ", "validation", " ", "error", " ", "whe", "n", " ", "calling", " ", "Check", "Initialized", ".", "\\", "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_", "[SEP]_", "class_", "Optional_", "(_", "Validator_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "validator_", ",_", "default_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Initializer", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "construct", "or", " ", "will", " ", "make", " ", "a", " ", "few", " ", "guesses", " ", "abo", "ut", " ", "the", " ", "value", " ", "pass", "ed", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "as", " ", "the", " ", "validator", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", "-", " ", "If", " ", "the", " ", "validator", " ", "argu", "ment", " ", "is", " ", "a", " ", "type", ",", " ", "it", " ", "automati", "call", "y", " ", "create", "s", " ", "a", " ", "Type", "\\", "10", ";", " ", " ", " ", " ", "validator", " ", "aro", "und", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "-", " ", "If", " ", "the", " ", "validator", " ", "argu", "ment", " ", "is", " ", "a", " ", "list", " ", "or", " ", "tuple", ",", " ", "it", " ", "automati", "call", "y", "\\", "10", ";", " ", " ", " ", " ", "create", "s", " ", "an", " ", "Optio", "ns", " ", "validator", " ", "aro", "und", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", "validator", ":", " ", "Optio", "nal", " ", "validation", " ", "condition", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Rai", "ses", ":", "\\", "10", ";", " ", " ", "Attribute", "Definit", "ion", "Error", " ", "if", " ", "validator", " ", "is", " ", "not", " ", "calla", "ble", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "validator_", "=_", "As", "Validator_", "(_", "validator_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "expected", "\\u", "type_", "=_", "self_", "._", "validator_", "._", "expected", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "default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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 ]
Unused local variable
mattloper/opendr/occlusion_test.py
[ { "content": " def test_occlusion(self):\n if visualize:\n import matplotlib.pyplot as plt\n plt.ion()\n\n # Create renderer\n import chumpy as ch\n import numpy as np\n from opendr.renderer import TexturedRenderer, ColoredRenderer\n #rn = TexturedRenderer()\n rn = ColoredRenderer()\n\n # Assign attributes to renderer\n from util_tests import get_earthmesh\n m = get_earthmesh(trans=ch.array([0,0,4]), rotation=ch.zeros(3))\n rn.texture_image = m.texture_image\n rn.ft = m.ft\n rn.vt = m.vt\n m.v[:,2] = np.mean(m.v[:,2])\n\n # red is front and zero\n # green is back and 1\n t0 = ch.array([1,0,.1])\n t1 = ch.array([-1,0,.1])\n v0 = ch.array(m.v) + t0\n\n if False:\n v1 = ch.array(m.v*.4 + np.array([0,0,3.8])) + t1\n else:\n v1 = ch.array(m.v) + t1\n vc0 = v0*0 + np.array([[.4,0,0]])\n vc1 = v1*0 + np.array([[0,.4,0]])\n vc = ch.vstack((vc0, vc1))\n\n v = ch.vstack((v0, v1))\n f = np.vstack((m.f, m.f+len(v0)))\n\n w, h = (320, 240)\n rn.camera = ProjectPoints(v=v, rt=ch.zeros(3), t=ch.zeros(3), f=ch.array([w,w])/2., c=ch.array([w,h])/2., k=ch.zeros(5))\n rn.camera.t = ch.array([0,0,-2.5])\n rn.frustum = {'near': 1., 'far': 10., 'width': w, 'height': h}\n m.vc = v.r*0 + np.array([[1,0,0]])\n rn.set(v=v, f=f, vc=vc)\n\n t0[:] = np.array([1.4, 0, .1-.02])\n t1[:] = np.array([-0.6, 0, .1+.02])\n\n target = rn.r\n\n if visualize:\n plt.figure()\n plt.imshow(target)\n plt.title('target')\n\n plt.figure()\n plt.show()\n\n im_orig = rn.r.copy()\n\n from cvwrap import cv2\n\n tr = t0\n eps_emp = .02\n eps_pred = .02\n\n #blur = lambda x : cv2.blur(x, ksize=(5,5))\n blur = lambda x : x\n for tr in [t0, t1]:\n if tr is t0:\n sum_limits = np.array([2.1e+2, 6.9e+1, 1.6e+2])\n else:\n sum_limits = [1., 5., 4.]\n\n if visualize:\n plt.figure()\n for i in range(3):\n dr_pred = np.array(rn.dr_wrt(tr[i]).todense()).reshape(rn.shape) * eps_pred\n dr_pred = blur(dr_pred)\n\n # central differences\n tr[i] = tr[i].r + eps_emp/2.\n rn_greater = rn.r.copy()\n tr[i] = tr[i].r - eps_emp/1.\n rn_lesser = rn.r.copy()\n tr[i] = tr[i].r + eps_emp/2.\n\n dr_emp = blur((rn_greater - rn_lesser) * eps_pred / eps_emp)\n\n dr_pred_shown = np.clip(dr_pred, -.5, .5) + .5\n dr_emp_shown = np.clip(dr_emp, -.5, .5) + .5\n\n if visualize:\n plt.subplot(3,3,i+1)\n plt.imshow(dr_pred_shown)\n plt.title('pred')\n plt.axis('off')\n\n plt.subplot(3,3,3+i+1)\n plt.imshow(dr_emp_shown)\n plt.title('empirical')\n plt.axis('off')\n\n plt.subplot(3,3,6+i+1)\n\n diff = np.abs(dr_emp - dr_pred)\n if visualize:\n plt.imshow(diff)\n diff = diff.ravel()\n if visualize:\n plt.title('diff (sum: %.2e)' % (np.sum(diff)))\n plt.axis('off')\n\n # print 'dr pred sum: %.2e' % (np.sum(np.abs(dr_pred.ravel())),)\n # print 'dr emp sum: %.2e' % (np.sum(np.abs(dr_emp.ravel())),)\n\n #import pdb; pdb.set_trace()\n self.assertTrue(np.sum(diff) < sum_limits[i])", "metadata": "root.TestOcclusion.test_occlusion", "header": "['class', 'TestOcclusion', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 11 } ]
[ { "span": "im_orig ", "start_line": 68, "start_column": 8, "end_line": 68, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Oc", "clu", "sion_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "occ", "lus", "ion_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "visualize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "matplotlib_", "._", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ion_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "renderer_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "chu", "mpy", "_", "as_", "ch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "opend", "r_", "._", "renderer_", "import_", "Text", "ure", "d", "Renderer_", ",_", "Color", "ed", "Renderer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "rn", " ", "=", " ", "Text", "ure", "d", "Render", "er", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "rn_", "=_", "Color", "ed", "Renderer_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Assign", " ", "attribute", "s", " ", "to", " ", "renderer_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "util", "\\u", "tests_", "import_", "get", "\\u", "earth", "mesh_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "get", "\\u", "earth", "mesh_", "(_", "trans_", "=_", "ch_", "._", "array_", "(_", "[_", "0_", ",_", "0_", ",_", "4_", "]_", ")_", ",_", "rotation_", "=_", "ch_", "._", "zeros_", "(_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "textu", "re", "\\u", "image_", "=_", "m_", "._", "textu", "re", "\\u", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "ft_", "=_", "m_", "._", "ft_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "vt_", "=_", "m_", "._", "vt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "v_", "[_", ":_", ",_", "2_", "]_", "=_", "np_", "._", "mean_", "(_", "m_", "._", "v_", "[_", ":_", ",_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "red", " ", "is", " ", "front", " ", "and", " ", "zero_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "green", " ", "is", " ", "back", " ", "and", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "t0_", "=_", "ch_", "._", "array_", "(_", "[_", "1_", ",_", "0_", ",_", ".1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "=_", "ch_", "._", "array_", "(_", "[_", "-_", "1_", ",_", "0_", ",_", ".1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v0_", "=_", "ch_", "._", "array_", "(_", "m_", "._", "v_", ")_", "+_", "t0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v1_", "=_", "ch_", "._", "array_", "(_", "m_", "._", "v_", "*_", ".4_", "+_", "np_", "._", "array_", "(_", "[_", "0_", ",_", "0_", ",_", "3.8", "_", "]_", ")_", ")_", "+_", "t1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v1_", "=_", "ch_", "._", "array_", "(_", "m_", "._", "v_", ")_", "+_", "t1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vc", "0_", "=_", "v0_", "*_", "0_", "+_", "np_", "._", "array_", "(_", "[_", "[_", ".4_", ",_", "0_", ",_", "0_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vc", "1_", "=_", "v1_", "*_", "0_", "+_", "np_", "._", "array_", "(_", "[_", "[_", "0_", ",_", ".4_", ",_", "0_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vc_", "=_", "ch_", "._", "vstack_", "(_", "(_", "vc", "0_", ",_", "vc", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "v_", "=_", "ch_", "._", "vstack_", "(_", "(_", "v0_", ",_", "v1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "np_", "._", "vstack_", "(_", "(_", "m_", "._", "f_", ",_", "m_", "._", "f_", "+_", "len_", "(_", "v0_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "w_", ",_", "h_", "=_", "(_", "320_", ",_", "240_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "camera_", "=_", "Project", "Points_", "(_", "v_", "=_", "v_", ",_", "rt_", "=_", "ch_", "._", "zeros_", "(_", "3_", ")_", ",_", "t_", "=_", "ch_", "._", "zeros_", "(_", "3_", ")_", ",_", "f_", "=_", "ch_", "._", "array_", "(_", "[_", "w_", ",_", "w_", "]_", ")_", "/_", "2._", ",_", "c_", "=_", "ch_", "._", "array_", "(_", "[_", "w_", ",_", "h_", "]_", ")_", "/_", "2._", ",_", "k_", "=_", "ch_", "._", "zeros_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "camera_", "._", "t_", "=_", "ch_", "._", "array_", "(_", "[_", "0_", ",_", "0_", ",_", "-_", "2.5_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "fru", "stu", "m_", "=_", "{_", "'", "near", "'_", ":_", "1._", ",_", "'", "far", "'_", ":_", "10._", ",_", "'", "widt", "h", "'_", ":_", "w_", ",_", "'", "height", "'_", ":_", "h_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "vc_", "=_", "v_", "._", "r_", "*_", "0_", "+_", "np_", "._", "array_", "(_", "[_", "[_", "1_", ",_", "0_", ",_", "0_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn_", "._", "set_", "(_", "v_", "=_", "v_", ",_", "f_", "=_", "f_", ",_", "vc_", "=_", "vc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t0_", "[_", ":_", "]_", "=_", "np_", "._", "array_", "(_", "[_", "1.4_", ",_", "0_", ",_", ".1_", "-_", ".02", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "[_", ":_", "]_", "=_", "np_", "._", "array_", "(_", "[_", "-_", "0.6_", ",_", "0_", ",_", ".1_", "+_", ".02", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "rn_", "._", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "visualize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plt_", "._", "figure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "imshow_", "(_", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "'", "target", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "figure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "im", "\\u", "orig_", "=_", "rn_", "._", "r_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "cv", "wrap_", "import_", "cv2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tr_", "=_", "t0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eps", "\\u", "emp_", "=_", ".02", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eps", "\\u", "pred_", "=_", ".02", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "blur", " ", "=", " ", "lambda", " ", "x", " ", ":", " ", "cv", "2", ".", "blur", "(", "x", ",", " ", "ksi", "ze", "=(", "5", ",", "5", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "blur", "_", "=_", "lambda_", "x_", ":_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "tr_", "in_", "[_", "t0_", ",_", "t1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "tr_", "is_", "t0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sum", "\\u", "limits_", "=_", "np_", "._", "array_", "(_", "[_", "2.1", "e", "+", "2_", ",_", "6.9", "e", "+", "1_", ",_", "1.6", "e", "+", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sum", "\\u", "limits_", "=_", "[_", "1._", ",_", "5._", ",_", "4._", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "visualize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plt_", "._", "figure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dr", "\\u", "pred_", "=_", "np_", "._", "array_", "(_", "rn_", "._", "dr", "\\u", "wrt", "_", "(_", "tr_", "[_", "i_", "]_", ")_", "._", "tod", "ense", "_", "(_", ")_", ")_", "._", "reshape_", "(_", "rn_", "._", "shape_", ")_", "*_", "eps", "\\u", "pred_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dr", "\\u", "pred_", "=_", "blur", "_", "(_", "dr", "\\u", "pred_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "central", " ", "difference", "s_", "\\u\\u\\uNL\\u\\u\\u_", "tr_", "[_", "i_", "]_", "=_", "tr_", "[_", "i_", "]_", "._", "r_", "+_", "eps", "\\u", "emp_", "/_", "2._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn", "\\u", "greater_", "=_", "rn_", "._", "r_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "[_", "i_", "]_", "=_", "tr_", "[_", "i_", "]_", "._", "r_", "-_", "eps", "\\u", "emp_", "/_", "1._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rn", "\\u", "less", "er_", "=_", "rn_", "._", "r_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "[_", "i_", "]_", "=_", "tr_", "[_", "i_", "]_", "._", "r_", "+_", "eps", "\\u", "emp_", "/_", "2._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dr", "\\u", "emp_", "=_", "blur", "_", "(_", "(_", "rn", "\\u", "greater_", "-_", "rn", "\\u", "less", "er_", ")_", "*_", "eps", "\\u", "pred_", "/_", "eps", "\\u", "emp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dr", "\\u", "pred", "\\u", "shown", "_", "=_", "np_", "._", "clip_", "(_", "dr", "\\u", "pred_", ",_", "-_", ".5_", ",_", ".5_", ")_", "+_", ".5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dr", "\\u", "emp", "\\u", "shown", "_", "=_", "np_", "._", "clip_", "(_", "dr", "\\u", "emp_", ",_", "-_", ".5_", ",_", ".5_", ")_", "+_", ".5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "visualize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "plt_", "._", "subplot_", "(_", "3_", ",_", "3_", ",_", "i_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "imshow_", "(_", "dr", "\\u", "pred", "\\u", "shown", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "'", "pred", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "axis_", "(_", "'", "off", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "subplot_", "(_", "3_", ",_", "3_", ",_", "3_", "+_", "i_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "imshow_", "(_", "dr", "\\u", "emp", "\\u", "shown", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "'", "empir", "ical", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "axis_", "(_", "'", "off", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "subplot_", "(_", "3_", ",_", "3_", ",_", "6_", "+_", "i_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "diff_", "=_", "np_", "._", "abs_", "(_", "dr", "\\u", "emp_", "-_", "dr", "\\u", "pred_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "visualize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "plt_", "._", "imshow_", "(_", "diff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "diff_", "=_", "diff_", "._", "ravel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "visualize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "plt_", "._", "title_", "(_", "'", "diff", " ", "(", "sum", ":", " ", "%", ".2", "e", ")'_", "%_", "(_", "np_", "._", "sum_", "(_", "diff_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "axis_", "(_", "'", "off", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "'", "dr", " ", "pred", " ", "sum", ":", " ", "%", ".2", "e", "'", " ", "%", " ", "(", "np", ".", "sum", "(", "np", ".", "abs", "(", "dr", "\\u", "pred", ".", "rave", "l", "())", "),", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "'", "dr", " ", "emp", " ", "sum", ":", " ", "%", ".2", "e", "'", " ", "%", " ", "(", "np", ".", "sum", "(", "np", ".", "abs", "(", "dr", "\\u", "emp", ".", "rave", "l", "())", "),", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "import", " ", "pdb", ";", " ", "pdb", ".", "set\\u", "trace", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "np_", "._", "sum_", "(_", "diff_", ")_", "<_", "sum", "\\u", "limits_", "[_", "i_", "]_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
dtmilano/AndroidViewClient/examples/sample-ui-dialog_activity-button.py
[ { "content": "#! /usr/bin/env python\n'''\nCopyright (C) 2012 Diego Torres Milano\nCreated on Aug 31, 2012\n\n@author: diego\n'''\n\n\nimport re\nimport sys\nimport os\n\n# This must be imported before MonkeyRunner and MonkeyDevice,\n# otherwise the import fails.\n# PyDev sets PYTHONPATH, use it\ntry:\n for p in os.environ['PYTHONPATH'].split(':'):\n if not p in sys.path:\n sys.path.append(p)\nexcept:\n pass\n\ntry:\n sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))\nexcept:\n pass\nfrom com.dtmilano.android.viewclient import ViewClient, View\n\n\nvc = ViewClient(*ViewClient.connectToDeviceOrExit())\n\nbutton = vc.findViewWithTextOrRaise('Show Dialog')\nprint \"button: \", button.getClass(), button.getId(), button.getCoords()\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 7 }, { "span": "except:", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", " ", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", "Copy", "right", " ", "(", "C", ")", " ", "2012", " ", " ", "Die", "go", " ", "Tor", "res", " ", "Mil", "ano", "\\", "10", ";", "Creat", "ed", " ", "on", " ", "Au", "g", " ", "3", "1", ",", " ", "2012", "\\", "10", ";", "\\", "10", ";", "@", "author", ":", " ", "die", "go", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "must", " ", "be", " ", "import", "ed", " ", "bef", "ore", " ", "Mon", "key", "Run", "ner", " ", "and", " ", "Mon", "key", "Dev", "ice", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "other", "wis", "e", " ", "the", " ", "import", " ", "fail", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Py", "Dev", " ", "sets", " ", "PYTHON", "PATH", ",", " ", "use", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "p_", "in_", "os_", "._", "environ_", "[_", "'", "PYTHON", "PATH", "'_", "]_", "._", "split_", "(_", "':'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "p_", "in_", "sys_", "._", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "path_", "._", "append_", "(_", "p_", ")_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "path_", "._", "append_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "environ_", "[_", "'", "ANDROID", "\\u", "VIEW", "\\u", "CLIENT", "\\u", "HOM", "E", "'_", "]_", ",_", "'", "src", "'_", ")_", ")_", "\\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_", "from_", "com_", "._", "dtm", "ila", "no_", "._", "android", "_", "._", "view", "client_", "import_", "View", "Client_", ",_", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vc_", "=_", "View", "Client_", "(_", "*_", "View", "Client_", "._", "connect", "To", "Dev", "ice", "Or", "Exit_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "button_", "=_", "vc_", "._", "find", "View", "With", "Text", "Or", "Raise_", "(_", "'", "Show", " ", "Dialog", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "button", ":", " ", "\"_", ",_", "button_", "._", "get", "Class_", "(_", ")_", ",_", "button_", "._", "get", "Id_", "(_", ")_", ",_", "button_", "._", "get", "Coords_", "(_", ")_" ]
[ 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, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
ggventurini/python-deltasigma/deltasigma/_simulateDSM_python.py
[ { "content": "def simulateDSM(u, arg2, nlev=2, x0=0.):\n \"\"\"Simulate a Delta Sigma modulator\n\n **Syntax:**\n\n * [v, xn, xmax, y] = simulateDSM(u, ABCD, nlev=2, x0=0)\n * [v, xn, xmax, y] = simulateDSM(u, ntf, nlev=2, x0=0)\n\n Compute the output of a general delta-sigma modulator with input u,\n a structure described by ABCD, an initial state x0 (default zero) and\n a quantizer with a number of levels specified by nlev.\n Multiple quantizers are implied by making nlev an array,\n and multiple inputs are implied by the number of rows in u.\n\n Alternatively, the modulator may be described by an NTF.\n The NTF is zpk object. (And the STF is assumed to be 1.)\n The structure that is simulated is the block-diagonal structure used by\n ``zpk2ss()``.\n\n **Example:**\n\n Simulate a 5th-order binary modulator with a half-scale sine-wave input and\n plot its output in the time and frequency domains.::\n\n import numpy as np\n from deltasigma import *\n OSR = 32\n H = synthesizeNTF(5, OSR, 1)\n N = 8192 \n fB = np.ceil(N/(2*OSR))\n f = 85\n u = 0.5*np.sin(2*np.pi*f/N*np.arange(N))\n v = simulateDSM(u, H)[0]\n\n Graphical display of the results:\n\n .. plot::\n\n import numpy as np\n import pylab as plt\n from numpy.fft import fft\n from deltasigma import *\n OSR = 32\n H = synthesizeNTF(5, OSR, 1)\n N = 8192 \n fB = np.ceil(N/(2*OSR))\n f = 85\n u = 0.5*np.sin(2*np.pi*f/N*np.arange(N))\n v = simulateDSM(u, H)[0]\n plt.figure(figsize=(10, 7))\n plt.subplot(2, 1, 1)\n t = np.arange(85)\n # the equivalent of MATLAB 'stairs' is step in matplotlib\n plt.step(t, u[t], 'g', label='u(n)')\n plt.hold(True)\n plt.step(t, v[t], 'b', label='v(n)')\n plt.axis([0, 85, -1.2, 1.2]);\n plt.ylabel('u, v');\n plt.xlabel('sample')\n plt.legend()\n plt.subplot(2, 1, 2)\n spec = fft(v*ds_hann(N))/(N/4)\n plt.plot(np.linspace(0, 0.5, N/2 + 1), dbv(spec[:N/2 + 1]))\n plt.axis([0, 0.5, -120, 0])\n plt.grid(True)\n plt.ylabel('dBFS/NBW')\n snr = calculateSNR(spec[:fB], f)\n s = 'SNR = %4.1fdB' % snr\n plt.text(0.25, -90, s)\n s = 'NBW = %7.5f' % (1.5/N)\n plt.text(0.25, -110, s)\n plt.xlabel(\"frequency $1 \\\\\\\\rightarrow f_s$\")\n\n Click on \"Source\" above to see the source code.\n \"\"\"\n\n #fprintf(1,'Warning: You are running the non-mex version of simulateDSM.\\n');\n #fprintf(1,'Please compile the mex version with \"mex simulateDSM.c\"\\n');\n\n nlev = carray(nlev)\n u = np.array(u) if not hasattr(u, 'ndim') else u\n if not max(u.shape) == np.prod(u.shape):\n warn(\"Multiple input delta sigma structures have had little testing.\")\n if u.ndim == 1:\n u = u.reshape((1, -1))\n nu = u.shape[0]\n nq = 1 if np.isscalar(nlev) else nlev.shape[0]\n # extract poles and zeros\n if (hasattr(arg2, 'inputs') and not arg2.inputs == 1) or \\\n (hasattr(arg2, 'outputs') and not arg2.outputs == 1):\n raise TypeError(\"The supplied TF isn't a SISO transfer function.\")\n if isinstance(arg2, np.ndarray):\n ABCD = np.asarray(arg2, dtype=np.float64)\n if ABCD.shape[1] != ABCD.shape[0] + nu:\n raise ValueError('The ABCD argument does not have proper dimensions.')\n form = 1\n else:\n zeros, poles, k = _get_zpk(arg2)\n form = 2\n #raise TypeError('%s: Unknown transfer function %s' % (__name__, str(arg2)))\n \n # need to set order and form now.\n order = carray(zeros).shape[0] if form == 2 else ABCD.shape[0] - nq\n \n if not isinstance(x0, collections.Iterable):\n x0 = x0*np.ones((order,), dtype=np.float64)\n else:\n x0 = np.array(x0).reshape((-1,))\n \n if form == 1:\n A = ABCD[:order, :order]\n B = ABCD[:order, order:order+nu+nq]\n C = ABCD[order:order+nq, :order]\n D1 = ABCD[order:order+nq, order:order+nu]\n else:\n A, B2, C, D2 = zpk2ss(poles, zeros, -1) # A realization of 1/H\n # Transform the realization so that C = [1 0 0 ...]\n C, D2 = np.real_if_close(C), np.real_if_close(D2)\n Sinv = orth(np.hstack((np.transpose(C), np.eye(order)))) / norm(C)\n S = inv(Sinv)\n C = np.dot(C, Sinv)\n if C[0, 0] < 0:\n S = -S\n Sinv = -Sinv\n A = np.dot(np.dot(S, A), Sinv) \n B2 = np.dot(S, B2) \n C = np.hstack((np.ones((1, 1)), np.zeros((1, order-1)))) # C=C*Sinv; \n D2 = np.zeros((0,))\n # !!!! Assume stf=1\n B1 = -B2\n D1 = 1\n B = np.hstack((B1, B2))\n\n N = u.shape[1]\n v = np.empty((nq, N), dtype=np.float64)\n y = np.empty((nq, N), dtype=np.float64) # to store the quantizer input\n xn = np.empty((order, N), dtype=np.float64) # to store the state information\n xmax = np.abs(x0) # to keep track of the state maxima\n\n for i in range(N):\n # y0 needs to be cast to real because ds_quantize needs real\n # inputs. If quantization were defined for complex numbers,\n # this cast could be removed\n y0 = np.real(np.dot(C, x0) + np.dot(D1, u[:, i]))\n y[:, i] = y0\n v[:, i] = ds_quantize(y0, nlev)\n x0 = np.dot(A, x0) + np.dot(B, np.concatenate((u[:, i], v[:, i])))\n xn[:, i] = np.real_if_close(x0.T)\n xmax = np.max(np.hstack((np.abs(x0).reshape((-1, 1)), xmax.reshape((-1, 1)))),\n axis=1, keepdims=True)\n\n return v.squeeze(), xn.squeeze(), xmax, y.squeeze()", "metadata": "root.simulateDSM", "header": "['module', '___EOS___']", "index": 30 } ]
[ { "span": "D2 ", "start_line": 157, "start_column": 8, "end_line": 157, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "simulat", "e", "DS", "M_", "(_", "u_", ",_", "arg2_", ",_", "nle", "v_", "=_", "2_", ",_", "x0_", "=_", "0._", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Simulate", " ", "a", " ", "Del", "ta", " ", "Sigm", "a", " ", "modula", "tor", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Syntax", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", "*", " ", "[", "v", ",", " ", "xn", ",", " ", "xma", "x", ",", " ", "y", "]", " ", "=", " ", "simulat", "e", "DS", "M", "(", "u", ",", " ", "ABC", "D", ",", " ", "nle", "v", "=", "2", ",", " ", "x0", "=", "0", ")", "\\", "10", ";", " ", "*", " ", "[", "v", ",", " ", "xn", ",", " ", "xma", "x", ",", " ", "y", "]", " ", "=", " ", "simulat", "e", "DS", "M", "(", "u", ",", " ", "ntf", ",", " ", "nle", "v", "=", "2", ",", " ", "x0", "=", "0", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Compute", " ", "the", " ", "output", " ", "of", " ", "a", " ", "genera", "l", " ", "delta", "-", "sigma", " ", "modula", "tor", " ", "with", " ", "input", " ", "u", ",", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "structure", " ", "descri", "bed", " ", "by", " ", "ABC", "D", ",", " ", "an", " ", "initial", " ", "state", " ", "x0", " ", "(", "default", " ", "zero", ")", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "quantize", "r", " ", "with", " ", "a", " ", "number", " ", "of", " ", "level", "s", " ", "specified", " ", "by", " ", "nle", "v", ".", "\\", "10", ";", " ", " ", " ", " ", "Multipl", "e", " ", "quantize", "rs", " ", "are", " ", "impli", "ed", " ", "by", " ", "mak", "ing", " ", "nle", "v", " ", "an", " ", "array", ",", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "multiple", " ", "inputs", " ", "are", " ", "impli", "ed", " ", "by", " ", "the", " ", "number", " ", "of", " ", "rows", " ", "in", " ", "u", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Alternative", "ly", ",", " ", "the", " ", "modula", "tor", " ", "may", " ", "be", " ", "descri", "bed", " ", "by", " ", "an", " ", "NT", "F", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "NT", "F", " ", "is", " ", "zp", "k", " ", "object", ".", " ", "(", "And", " ", "the", " ", "ST", "F", " ", "is", " ", "assume", "d", " ", "to", " ", "be", " ", "1", ".)", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "structure", " ", "tha", "t", " ", "is", " ", "simulat", "ed", " ", "is", " ", "the", " ", "block", "-", "diagonal", " ", "structure", " ", "used", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "``", "zp", "k2", "ss", "()``", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Simulate", " ", "a", " ", "5", "th", "-", "order", " ", "binar", "y", " ", "modula", "tor", " ", "with", " ", "a", " ", "half", "-", "scale", " ", "sine", "-", "wave", " ", "input", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "plot", " ", "its", " ", "output", " ", "in", " ", "the", " ", "time", " ", "and", " ", "freque", "nc", "y", " ", "domains", ".:", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "import", " ", "nump", "y", " ", "as", " ", "np", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "deltas", "igm", "a", " ", "import", " ", "*", "\\", "10", ";", " ", " ", " ", " ", "OS", "R", " ", "=", " ", "32", "\\", "10", ";", " ", " ", " ", " ", "H", " ", "=", " ", "synthesi", "ze", "NT", "F", "(", "5", ",", " ", "OS", "R", ",", " ", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "N", " ", "=", " ", "819", "2", " ", "\\", "10", ";", " ", " ", " ", " ", "f", "B", " ", "=", " ", "np", ".", "ceil", "(", "N", "/(", "2", "*", "OS", "R", "))\\", "10", ";", " ", " ", " ", " ", "f", " ", "=", " ", "85", "\\", "10", ";", " ", " ", " ", " ", "u", " ", "=", " ", "0.", "5", "*", "np", ".", "sin", "(", "2", "*", "np", ".", "pi", "*", "f", "/", "N", "*", "np", ".", "aran", "ge", "(", "N", "))\\", "10", ";", " ", " ", " ", " ", "v", " ", "=", " ", "simulat", "e", "DS", "M", "(", "u", ",", " ", "H", ")[", "0", "]", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Graphic", "al", " ", "display", " ", "of", " ", "the", " ", "results", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "plot", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "import", " ", "nump", "y", " ", "as", " ", "np", "\\", "10", ";", " ", " ", " ", " ", "import", " ", "pyla", "b", " ", "as", " ", "plt", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "nump", "y", ".", "fft", " ", "import", " ", "fft", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "deltas", "igm", "a", " ", "import", " ", "*", "\\", "10", ";", " ", " ", " ", " ", "OS", "R", " ", "=", " ", "32", "\\", "10", ";", " ", " ", " ", " ", "H", " ", "=", " ", "synthesi", "ze", "NT", "F", "(", "5", ",", " ", "OS", "R", ",", " ", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "N", " ", "=", " ", "819", "2", " ", "\\", "10", ";", " ", " ", " ", " ", "f", "B", " ", "=", " ", "np", ".", "ceil", "(", "N", "/(", "2", "*", "OS", "R", "))\\", "10", ";", " ", " ", " ", " ", "f", " ", "=", " ", "85", "\\", "10", ";", " ", " ", " ", " ", "u", " ", "=", " ", "0.", "5", "*", "np", ".", "sin", "(", "2", "*", "np", ".", "pi", "*", "f", "/", "N", "*", "np", ".", "aran", "ge", "(", "N", "))\\", "10", ";", " ", " ", " ", " ", "v", " ", "=", " ", "simulat", "e", "DS", "M", "(", "u", ",", " ", "H", ")[", "0", "]", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "figure", "(", "figs", "ize", "=(", "10", ",", " ", "7", "))\\", "10", ";", " ", " ", " ", " ", "plt", ".", "subplot", "(", "2", ",", " ", "1", ",", " ", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "t", " ", "=", " ", "np", ".", "aran", "ge", "(", "85", ")", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "the", " ", "equivalent", " ", "of", " ", "MAT", "LAB", " ", "'", "stair", "s", "'", " ", "is", " ", "step", " ", "in", " ", "mat", "plotlib", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "step", "(", "t", ",", " ", "u", "[", "t", "],", " ", "'", "g", "',", " ", "label", "='", "u", "(", "n", ")'", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "hold", "(", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "step", "(", "t", ",", " ", "v", "[", "t", "],", " ", "'", "b", "',", " ", "label", "='", "v", "(", "n", ")'", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "axis", "([", "0", ",", " ", "85", ",", " ", "-1", ".2", ",", " ", "1.2", "])", ";", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "ylabel", "('", "u", ",", " ", "v", "');", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "xlabel", "('", "sample", "')", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "legend", "()", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "subplot", "(", "2", ",", " ", "1", ",", " ", "2", ")", "\\", "10", ";", " ", " ", " ", " ", "spec", " ", "=", " ", "fft", "(", "v", "*", "ds", "\\u", "hann", "(", "N", "))/(", "N", "/", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "plot", "(", "np", ".", "lins", "pace", "(", "0", ",", " ", "0.", "5", ",", " ", "N", "/", "2", " ", "+", " ", "1", "),", " ", "db", "v", "(", "spec", "[:", "N", "/", "2", " ", "+", " ", "1", "]))", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "axis", "([", "0", ",", " ", "0.", "5", ",", " ", "-1", "20", ",", " ", "0", "])", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "grid", "(", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "ylabel", "('", "d", "BF", "S", "/", "NB", "W", "')", "\\", "10", ";", " ", " ", " ", " ", "snr", " ", "=", " ", "calcul", "ate", "SNR", "(", "spec", "[:", "f", "B", "],", " ", "f", ")", "\\", "10", ";", " ", " ", " ", " ", "s", " ", "=", " ", "'", "SNR", " ", "=", " ", "%", "4.1", "fd", "B", "'", " ", "%", " ", "snr", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "text", "(", "0.25", ",", " ", "-", "90", ",", " ", "s", ")", "\\", "10", ";", " ", " ", " ", " ", "s", " ", "=", " ", " ", "'", "NB", "W", " ", "=", " ", "%", "7.5", "f", "'", " ", "%", " ", "(", "1.5", "/", "N", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "text", "(", "0.25", ",", " ", "-1", "10", ",", " ", "s", ")", "\\", "10", ";", " ", " ", " ", " ", "plt", ".", "xlabel", "(\"", "freque", "nc", "y", " ", "$", "1", " ", "\\\\\\\\\\\\\\\\", "right", "arrow", " ", "f", "\\u", "s", "$", "\")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Click", " ", "on", " ", "\"", "Sou", "rce", "\"", " ", "above", " ", "to", " ", "see", " ", "the", " ", "source", " ", "code", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "fpr", "intf", "(", "1", ",'", "Warn", "ing", ":", " ", "You", " ", "are", " ", "runn", "ing", " ", "the", " ", "non", "-", "me", "x", " ", "version", " ", "of", " ", "simulat", "e", "DS", "M", ".\\\\", "n", "');", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "fpr", "intf", "(", "1", ",'", "Ple", "ase", " ", "compile", " ", "the", " ", "me", "x", " ", "version", " ", "with", " ", "\"", "me", "x", " ", "simulat", "e", "DS", "M", ".", "c", "\"\\\\", "n", "');", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nle", "v_", "=_", "carr", "ay_", "(_", "nle", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "np_", "._", "array_", "(_", "u_", ")_", "if_", "not_", "hasattr_", "(_", "u_", ",_", "'", "ndim", "'_", ")_", "else_", "u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "max_", "(_", "u_", "._", "shape_", ")_", "==_", "np_", "._", "prod_", "(_", "u_", "._", "shape_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warn_", "(_", "\"", "Multipl", "e", " ", "input", " ", "delta", " ", "sigma", " ", "structure", "s", " ", "have", " ", "had", " ", "litt", "le", " ", "testi", "ng", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "u_", "._", "ndim_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "u_", "=_", "u_", "._", "reshape_", "(_", "(_", "1_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "nu_", "=_", "u_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nq", "_", "=_", "1_", "if_", "np_", "._", "iss", "cala", "r_", "(_", "nle", "v_", ")_", "else_", "nle", "v_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "extract", " ", "pole", "s", " ", "and", " ", "zeros_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "hasattr_", "(_", "arg2_", ",_", "'", "inputs", "'_", ")_", "and_", "not_", "arg2_", "._", "inputs_", "==_", "1_", ")_", "or_", "(_", "hasattr_", "(_", "arg2_", ",_", "'", "output", "s", "'_", ")_", "and_", "not_", "arg2_", "._", "outputs_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "\"", "The", " ", "supplie", "d", " ", "TF", " ", "isn", "'", "t", " ", "a", " ", "SIS", "O", " ", "transfer", " ", "function", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "arg2_", ",_", "np_", "._", "ndarray_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ABC", "D_", "=_", "np_", "._", "asarray_", "(_", "arg2_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ABC", "D_", "._", "shape_", "[_", "1_", "]_", "!=_", "ABC", "D_", "._", "shape_", "[_", "0_", "]_", "+_", "nu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "The", " ", "ABC", "D", " ", "argu", "ment", " ", "doe", "s", " ", "not", " ", "have", " ", "proper", " ", "dimension", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "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 ", " _", "zeros_", ",_", "pole", "s_", ",_", "k_", "=_", "\\u", "get", "\\u", "zp", "k_", "(_", "arg2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "raise", " ", "Type", "Error", "('", "%", "s", ":", " ", "Un", "know", "n", " ", "transfer", " ", "function", " ", "%", "s", "'", " ", "%", " ", "(\\u", "\\u", "name", "\\u\\u", ",", " ", "str", "(", "arg", "2", ")))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "need", " ", "to", " ", "set", " ", "order", " ", "and", " ", "form", " ", "now", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "order_", "=_", "carr", "ay_", "(_", "zeros_", ")_", "._", "shape_", "[_", "0_", "]_", "if_", "form_", "==_", "2_", "else_", "ABC", "D_", "._", "shape_", "[_", "0_", "]_", "-_", "nq", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "x0_", ",_", "collections_", "._", "Iterable_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x0_", "=_", "x0_", "*_", "np_", "._", "ones_", "(_", "(_", "order_", ",_", ")_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x0_", "=_", "np_", "._", "array_", "(_", "x0_", ")_", "._", "reshape_", "(_", "(_", "-_", "1_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "form_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "A_", "=_", "ABC", "D_", "[_", ":_", "order_", ",_", ":_", "order_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B_", "=_", "ABC", "D_", "[_", ":_", "order_", ",_", "order_", ":_", "order_", "+_", "nu_", "+_", "nq", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "ABC", "D_", "[_", "order_", ":_", "order_", "+_", "nq", "_", ",_", ":_", "order_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "D1_", "=_", "ABC", "D_", "[_", "order_", ":_", "order_", "+_", "nq", "_", ",_", "order_", ":_", "order_", "+_", "nu_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "A_", ",_", "B2_", ",_", "C_", ",_", "D2_", "=_", "zp", "k2", "ss_", "(_", "pole", "s_", ",_", "zeros_", ",_", "-_", "1_", ")_", "#", " ", "A", " ", "realiza", "tion", " ", "of", " ", "1", "/", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Transform", " ", "the", " ", "realiza", "tion", " ", "so", " ", "tha", "t", " ", "C", " ", "=", " ", "[", "1", " ", "0", " ", "0", " ", "...]", "_", "\\u\\u\\uNL\\u\\u\\u_", "C_", ",_", "D2_", "=_", "np_", "._", "real", "\\u", "if", "\\u", "close_", "(_", "C_", ")_", ",_", "np_", "._", "real", "\\u", "if", "\\u", "close_", "(_", "D2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Sin", "v_", "=_", "orth", "_", "(_", "np_", "._", "hstack_", "(_", "(_", "np_", "._", "transpose_", "(_", "C_", ")_", ",_", "np_", "._", "eye_", "(_", "order_", ")_", ")_", ")_", ")_", "/_", "norm_", "(_", "C_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "S_", "=_", "inv_", "(_", "Sin", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "np_", "._", "dot_", "(_", "C_", ",_", "Sin", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "C_", "[_", "0_", ",_", "0_", "]_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "S_", "=_", "-_", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Sin", "v_", "=_", "-_", "Sin", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "A_", "=_", "np_", "._", "dot_", "(_", "np_", "._", "dot_", "(_", "S_", ",_", "A_", ")_", ",_", "Sin", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B2_", "=_", "np_", "._", "dot_", "(_", "S_", ",_", "B2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "np_", "._", "hstack_", "(_", "(_", "np_", "._", "ones_", "(_", "(_", "1_", ",_", "1_", ")_", ")_", ",_", "np_", "._", "zeros_", "(_", "(_", "1_", ",_", "order_", "-_", "1_", ")_", ")_", ")_", ")_", "#", " ", "C", "=", "C", "*", "Sin", "v", ";", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "D2_", "=_", "np_", "._", "zeros_", "(_", "(_", "0_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "!!!", "!", " ", "Assume", " ", "stf", "=", "1_", "\\u\\u\\uNL\\u\\u\\u_", "B1_", "=_", "-_", "B2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "D1_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B_", "=_", "np_", "._", "hstack_", "(_", "(_", "B1_", ",_", "B2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "N_", "=_", "u_", "._", "shape_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "np_", "._", "empty_", "(_", "(_", "nq", "_", ",_", "N_", ")_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "np_", "._", "empty_", "(_", "(_", "nq", "_", ",_", "N_", ")_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", "#", " ", "to", " ", "store", " ", "the", " ", "quantize", "r", " ", "input_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xn_", "=_", "np_", "._", "empty_", "(_", "(_", "order_", ",_", "N_", ")_", ",_", "dtype_", "=_", "np_", "._", "float64_", ")_", "#", " ", "to", " ", "store", " ", "the", " ", "state", " ", "information_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xmax_", "=_", "np_", "._", "abs_", "(_", "x0_", ")_", "#", " ", "to", " ", "keep", " ", "track", " ", "of", " ", "the", " ", "state", " ", "maxim", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "N_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "y", "0", " ", "need", "s", " ", "to", " ", "be", " ", "cast", " ", "to", " ", "real", " ", "bec", "aus", "e", " ", "ds", "\\u", "quantize", " ", "need", "s", " ", "real_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "inputs", ".", " ", "If", " ", "quanti", "zatio", "n", " ", "wer", "e", " ", "defin", "ed", " ", "for", " ", "complex", " ", "numbers", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "cast", " ", "coul", "d", " ", "be", " ", "removed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y0_", "=_", "np_", "._", "real_", "(_", "np_", "._", "dot_", "(_", "C_", ",_", "x0_", ")_", "+_", "np_", "._", "dot_", "(_", "D1_", ",_", "u_", "[_", ":_", ",_", "i_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "[_", ":_", ",_", "i_", "]_", "=_", "y0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "[_", ":_", ",_", "i_", "]_", "=_", "ds", "\\u", "quantize", "_", "(_", "y0_", ",_", "nle", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x0_", "=_", "np_", "._", "dot_", "(_", "A_", ",_", "x0_", ")_", "+_", "np_", "._", "dot_", "(_", "B_", ",_", "np_", "._", "concatenate_", "(_", "(_", "u_", "[_", ":_", ",_", "i_", "]_", ",_", "v_", "[_", ":_", ",_", "i_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xn_", "[_", ":_", ",_", "i_", "]_", "=_", "np_", "._", "real", "\\u", "if", "\\u", "close_", "(_", "x0_", "._", "T_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xmax_", "=_", "np_", "._", "max_", "(_", "np_", "._", "hstack_", "(_", "(_", "np_", "._", "abs_", "(_", "x0_", ")_", "._", "reshape_", "(_", "(_", "-_", "1_", ",_", "1_", ")_", ")_", ",_", "xmax_", "._", "reshape_", "(_", "(_", "-_", "1_", ",_", "1_", ")_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "axis_", "=_", "1_", ",_", "keepdims_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "v_", "._", "squeeze_", "(_", ")_", ",_", "xn_", "._", "squeeze_", "(_", ")_", ",_", "xmax_", ",_", "y_", "._", "squeeze_", "(_", ")_", "\\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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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 ]
Variable defined multiple times
sympy/sympy/sympy/polys/ring_series.py
[ { "content": "def rs_pow(p1, n, x, prec):\n \"\"\"\n Return ``p1**n`` modulo ``O(x**prec)``\n\n Examples\n ========\n\n >>> from sympy.polys.domains import QQ\n >>> from sympy.polys.rings import ring\n >>> from sympy.polys.ring_series import rs_pow\n >>> R, x = ring('x', QQ)\n >>> p = x + 1\n >>> rs_pow(p, 4, x, 3)\n 6*x**2 + 4*x + 1\n \"\"\"\n R = p1.ring\n p = R.zero\n if isinstance(n, Rational):\n np = int(n.p)\n nq = int(n.q)\n if nq != 1:\n res = rs_nth_root(p1, nq, x, prec)\n if np != 1:\n res = rs_pow(res, np, x, prec)\n else:\n res = rs_pow(p1, np, x, prec)\n return res\n\n n = as_int(n)\n if n == 0:\n if p1:\n return R(1)\n else:\n raise ValueError('0**0 is undefined')\n if n < 0:\n p1 = rs_pow(p1, -n, x, prec)\n return rs_series_inversion(p1, x, prec)\n if n == 1:\n return rs_trunc(p1, x, prec)\n if n == 2:\n return rs_square(p1, x, prec)\n if n == 3:\n p2 = rs_square(p1, x, prec)\n return rs_mul(p1, p2, x, prec)\n p = R(1)\n while 1:\n if n & 1:\n p = rs_mul(p1, p, x, prec)\n n -= 1\n if not n:\n break\n p1 = rs_square(p1, x, prec)\n n = n // 2\n return p", "metadata": "root.rs_pow", "header": "['module', '___EOS___']", "index": 302 }, { "content": "def _get_constant_term(p, x):\n \"\"\"Return constant term in p with respect to x\n\n Note that it is not simply `p[R.zero_monom]` as there might be multiple\n generators in the ring R. We want the `x`-free term which can contain other\n generators.\n \"\"\"\n R = p.ring\n zm = R.zero_monom\n i = R.gens.index(x)\n zm = R.zero_monom\n a = [0]*R.ngens\n a[i] = 1\n miv = tuple(a)\n c = 0\n for expv in p:\n if monomial_min(expv, miv) == zm:\n c += R({expv: p[expv]})\n return c", "metadata": "root._get_constant_term", "header": "['module', '___EOS___']", "index": 451 }, { "content": "def rs_series_from_list(p, c, x, prec, concur=1):\n \"\"\"\n Return a series `sum c[n]*p**n` modulo `O(x**prec)`.\n\n It reduces the number of multiplications by summing concurrently.\n\n `ax = [1, p, p**2, .., p**(J - 1)]`\n `s = sum(c[i]*ax[i]` for i in `range(r, (r + 1)*J))*p**((K - 1)*J)`\n with `K >= (n + 1)/J`\n\n Examples\n ========\n\n >>> from sympy.polys.domains import QQ\n >>> from sympy.polys.rings import ring\n >>> from sympy.polys.ring_series import rs_series_from_list, rs_trunc\n >>> R, x = ring('x', QQ)\n >>> p = x**2 + x + 1\n >>> c = [1, 2, 3]\n >>> rs_series_from_list(p, c, x, 4)\n 6*x**3 + 11*x**2 + 8*x + 6\n >>> rs_trunc(1 + 2*p + 3*p**2, x, 4)\n 6*x**3 + 11*x**2 + 8*x + 6\n >>> pc = R.from_list(list(reversed(c)))\n >>> rs_trunc(pc.compose(x, p), x, 4)\n 6*x**3 + 11*x**2 + 8*x + 6\n\n See Also\n ========\n\n sympy.polys.ring.compose\n\n \"\"\"\n R = p.ring\n n = len(c)\n if not concur:\n q = R(1)\n s = c[0]*q\n for i in range(1, n):\n q = rs_mul(q, p, x, prec)\n s += c[i]*q\n return s\n J = int(math.sqrt(n) + 1)\n K, r = divmod(n, J)\n if r:\n K += 1\n ax = [R(1)]\n b = 1\n q = R(1)\n if len(p) < 20:\n for i in range(1, J):\n q = rs_mul(q, p, x, prec)\n ax.append(q)\n else:\n for i in range(1, J):\n if i % 2 == 0:\n q = rs_square(ax[i//2], x, prec)\n else:\n q = rs_mul(q, p, x, prec)\n ax.append(q)\n # optimize using rs_square\n pj = rs_mul(ax[-1], p, x, prec)\n b = R(1)\n s = R(0)\n for k in range(K - 1):\n r = J*k\n s1 = c[r]\n for j in range(1, J):\n s1 += c[r + j]*ax[j]\n s1 = rs_mul(s1, b, x, prec)\n s += s1\n b = rs_mul(b, pj, x, prec)\n if not b:\n break\n k = K - 1\n r = J*k\n if r < n:\n s1 = c[r]*R(1)\n for j in range(1, J):\n if r + j >= n:\n break\n s1 += c[r + j]*ax[j]\n s1 = rs_mul(s1, b, x, prec)\n s += s1\n return s", "metadata": "root.rs_series_from_list", "header": "['module', '___EOS___']", "index": 641 }, { "content": "def rs_nth_root(p, n, x, prec):\n \"\"\"\n Multivariate series expansion of the nth root of ``p``.\n\n Parameters\n ----------\n n : `p**(1/n)` is returned.\n x : :class:`PolyElement`\n prec : Order of the expanded series.\n\n Notes\n =====\n\n The result of this function is dependent on the ring over which the\n polynomial has been defined. If the answer involves a root of a constant,\n make sure that the polynomial is over a real field. It can not yet handle\n roots of symbols.\n\n Examples\n ========\n\n >>> from sympy.polys.domains import QQ, RR\n >>> from sympy.polys.rings import ring\n >>> from sympy.polys.ring_series import rs_nth_root\n >>> R, x, y = ring('x, y', QQ)\n >>> rs_nth_root(1 + x + x*y, -3, x, 3)\n 2/9*x**2*y**2 + 4/9*x**2*y + 2/9*x**2 - 1/3*x*y - 1/3*x + 1\n >>> R, x, y = ring('x, y', RR)\n >>> rs_nth_root(3 + x + x*y, 3, x, 2)\n 0.160249952256379*x*y + 0.160249952256379*x + 1.44224957030741\n \"\"\"\n p0 = p\n n0 = n\n if n == 0:\n if p == 0:\n raise ValueError('0**0 expression')\n else:\n return p.ring(1)\n if n == 1:\n return rs_trunc(p, x, prec)\n R = p.ring\n zm = R.zero_monom\n index = R.gens.index(x)\n m = min(p, key=lambda k: k[index])[index]\n p = mul_xin(p, index, -m)\n prec -= m\n\n if _has_constant_term(p - 1, x):\n zm = R.zero_monom\n c = p[zm]\n if R.domain is EX:\n c_expr = c.as_expr()\n const = c_expr**QQ(1, n)\n elif isinstance(c, PolyElement):\n try:\n c_expr = c.as_expr()\n const = R(c_expr**(QQ(1, n)))\n except ValueError:\n raise DomainError(\"The given series can't be expanded in \"\n \"this domain.\")\n else:\n try: # RealElement doesn't support\n const = R(c**Rational(1, n)) # exponentiation with mpq object\n except ValueError: # as exponent\n raise DomainError(\"The given series can't be expanded in \"\n \"this domain.\")\n res = rs_nth_root(p/c, n, x, prec)*const\n else:\n res = _nth_root1(p, n, x, prec)\n if m:\n m = QQ(m, n)\n res = mul_xin(res, index, m)\n return res", "metadata": "root.rs_nth_root", "header": "['module', '___EOS___']", "index": 912 }, { "content": "def rs_exp(p, x, prec):\n \"\"\"\n Exponentiation of a series modulo ``O(x**prec)``\n\n Examples\n ========\n\n >>> from sympy.polys.domains import QQ\n >>> from sympy.polys.rings import ring\n >>> from sympy.polys.ring_series import rs_exp\n >>> R, x = ring('x', QQ)\n >>> rs_exp(x**2, x, 7)\n 1/6*x**6 + 1/2*x**4 + x**2 + 1\n \"\"\"\n if rs_is_puiseux(p, x):\n return rs_puiseux(rs_exp, p, x, prec)\n R = p.ring\n c = _get_constant_term(p, x)\n if c:\n if R.domain is EX:\n c_expr = c.as_expr()\n const = exp(c_expr)\n elif isinstance(c, PolyElement):\n try:\n c_expr = c.as_expr()\n const = R(exp(c_expr))\n except ValueError:\n R = R.add_gens([exp(c_expr)])\n p = p.set_ring(R)\n x = x.set_ring(R)\n c = c.set_ring(R)\n const = R(exp(c_expr))\n else:\n try:\n const = R(exp(c))\n except ValueError:\n raise DomainError(\"The given series can't be expanded in \"\n \"this domain.\")\n p1 = p - c\n\n # Makes use of sympy fuctions to evaluate the values of the cos/sin\n # of the constant term.\n return const*rs_exp(p1, x, prec)\n\n if len(p) > 20:\n return _exp1(p, x, prec)\n one = R(1)\n n = 1\n k = 1\n c = []\n for k in range(prec):\n c.append(one/n)\n k += 1\n n *= k\n\n r = rs_series_from_list(p, c, x, prec)\n return r", "metadata": "root.rs_exp", "header": "['module', '___EOS___']", "index": 1090 }, { "content": "def rs_cos(p, x, prec):\n \"\"\"\n Cosine of a series\n\n Return the series expansion of the cos of ``p``, about 0.\n\n Examples\n ========\n\n >>> from sympy.polys.domains import QQ\n >>> from sympy.polys.rings import ring\n >>> from sympy.polys.ring_series import rs_cos\n >>> R, x, y = ring('x, y', QQ)\n >>> rs_cos(x + x*y, x, 4)\n -1/2*x**2*y**2 - x**2*y - 1/2*x**2 + 1\n >>> rs_cos(x + x*y, x, 4)/x**QQ(7, 5)\n -1/2*x**(3/5)*y**2 - x**(3/5)*y - 1/2*x**(3/5) + x**(-7/5)\n\n See Also\n ========\n\n cos\n \"\"\"\n if rs_is_puiseux(p, x):\n return rs_puiseux(rs_cos, p, x, prec)\n R = p.ring\n c = _get_constant_term(p, x)\n if c:\n if R.domain is EX:\n c_expr = c.as_expr()\n t1, t2 = sin(c_expr), cos(c_expr)\n elif isinstance(c, PolyElement):\n try:\n c_expr = c.as_expr()\n t1, t2 = R(sin(c_expr)), R(cos(c_expr))\n except ValueError:\n R = R.add_gens([sin(c_expr), cos(c_expr)])\n p = p.set_ring(R)\n x = x.set_ring(R)\n c = c.set_ring(R)\n else:\n try:\n t1, t2 = R(sin(c)), R(cos(c))\n except ValueError:\n raise DomainError(\"The given series can't be expanded in \"\n \"this domain.\")\n p1 = p - c\n\n # Makes use of sympy cos, sin fuctions to evaluate the values of the\n # cos/sin of the constant term.\n p_cos = rs_cos(p1, x, prec)\n p_sin = rs_sin(p1, x, prec)\n R = R.compose(p_cos.ring).compose(p_sin.ring)\n p_cos.set_ring(R)\n p_sin.set_ring(R)\n t1, t2 = R(sin(c_expr)), R(cos(c_expr))\n return p_cos*t2 - p_sin*t1\n\n # Series is calculated in terms of tan as its evaluation is fast.\n if len(p) > 20 and R.ngens == 1:\n t = rs_tan(p/2, x, prec)\n t2 = rs_square(t, x, prec)\n p1 = rs_series_inversion(1+t2, x, prec)\n return rs_mul(p1, 1 - t2, x, prec)\n one = R(1)\n n = 1\n c = []\n for k in range(2, prec + 2, 2):\n c.append(one/n)\n c.append(0)\n n *= -k*(k - 1)\n return rs_series_from_list(p, c, x, prec)", "metadata": "root.rs_cos", "header": "['module', '___EOS___']", "index": 1450 } ]
[ { "span": "p ", "start_line": 318, "start_column": 4, "end_line": 318, "end_column": 5 }, { "span": "zm ", "start_line": 459, "start_column": 4, "end_line": 459, "end_column": 6 }, { "span": "b ", "start_line": 688, "start_column": 4, "end_line": 688, "end_column": 5 }, { "span": "zm ", "start_line": 953, "start_column": 4, "end_line": 953, "end_column": 6 }, { "span": "k ", "start_line": 1138, "start_column": 4, "end_line": 1138, "end_column": 5 }, { "span": "t1,", "start_line": 1480, "start_column": 12, "end_line": 1480, "end_column": 14 }, { "span": "t2 ", "start_line": 1480, "start_column": 16, "end_line": 1480, "end_column": 18 }, { "span": "t1,", "start_line": 1484, "start_column": 16, "end_line": 1484, "end_column": 18 }, { "span": "t2 ", "start_line": 1484, "start_column": 20, "end_line": 1484, "end_column": 22 }, { "span": "t1,", "start_line": 1492, "start_column": 16, "end_line": 1492, "end_column": 18 }, { "span": "t2 ", "start_line": 1492, "start_column": 20, "end_line": 1492, "end_column": 22 } ]
[ { "span": "zm ", "start_line": 461, "start_column": 4, "end_line": 461, "end_column": 6 }, { "span": "zm ", "start_line": 960, "start_column": 8, "end_line": 960, "end_column": 10 }, { "span": "t1,", "start_line": 1505, "start_column": 8, "end_line": 1505, "end_column": 10 }, { "span": "t2 ", "start_line": 1505, "start_column": 12, "end_line": 1505, "end_column": 14 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rs", "\\u", "pow_", "(_", "p1_", ",_", "n_", ",_", "x_", ",_", "prec_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "``", "p1", "**", "n", "``", " ", "modulo", " ", "``", "O", "(", "x", "**", "prec", ")`", "`", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "domains", " ", "import", " ", "QQ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "rings", " ", "import", " ", "ring", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "ring", "\\u", "series", " ", "import", " ", "rs", "\\u", "pow", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "R", ",", " ", "x", " ", "=", " ", "ring", "('", "x", "',", " ", "QQ", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "p", " ", "=", " ", "x", " ", "+", " ", "1", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "pow", "(", "p", ",", " ", "4", ",", " ", "x", ",", " ", "3", ")", "\\", "10", ";", " ", " ", " ", " ", "6", "*", "x", "**", "2", " ", "+", " ", "4", "*", "x", " ", "+", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "=_", "p1_", "._", "ring_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "R_", "._", "zero_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "n_", ",_", "Rational", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "np_", "=_", "int_", "(_", "n_", "._", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nq", "_", "=_", "int_", "(_", "n_", "._", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "nq", "_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "rs", "\\u", "nth", "\\u", "root_", "(_", "p1_", ",_", "nq", "_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "np_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "rs", "\\u", "pow_", "(_", "res_", ",_", "np_", ",_", "x_", ",_", "prec_", ")_", "\\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 ", " _", "res_", "=_", "rs", "\\u", "pow_", "(_", "p1_", ",_", "np_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "n_", "=_", "as", "\\u", "int_", "(_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "n_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "p1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "0", "**", "0", " ", "is", " ", "undefined", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "n_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p1_", "=_", "rs", "\\u", "pow_", "(_", "p1_", ",_", "-_", "n_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "rs", "\\u", "series", "\\u", "inversion", "_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "n_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "rs", "\\u", "trunc", "_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "n_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "rs", "\\u", "square_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "n_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p2_", "=_", "rs", "\\u", "square_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "rs", "\\u", "mul_", "(_", "p1_", ",_", "p2_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p_", "=_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "n_", "&_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "rs", "\\u", "mul_", "(_", "p1_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "n_", ":_", "\\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_", "p1_", "=_", "rs", "\\u", "square_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "=_", "n_", "//_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "p_", "\\u\\u\\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", "get", "\\u", "constant", "\\u", "term_", "(_", "p_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "constant", " ", "term", " ", "in", " ", "p", " ", "with", " ", "respec", "t", " ", "to", " ", "x", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", " ", "tha", "t", " ", "it", " ", "is", " ", "not", " ", "simp", "ly", " ", "`", "p", "[", "R", ".", "zero", "\\u", "monom", "]`", " ", "as", " ", "there", " ", "mig", "ht", " ", "be", " ", "multiple", "\\", "10", ";", " ", " ", " ", " ", "generat", "ors", " ", "in", " ", "the", " ", "ring", " ", "R", ".", " ", "We", " ", "want", " ", "the", " ", "`", "x", "`-", "free", " ", "term", " ", "whi", "ch", " ", "can", " ", "contain", " ", "other", "\\", "10", ";", " ", " ", " ", " ", "generat", "ors", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "=_", "p_", "._", "ring_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zm", "_", "=_", "R_", "._", "zero", "\\u", "monom", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "R_", "._", "gens_", "._", "index_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zm", "_", "=_", "R_", "._", "zero", "\\u", "monom", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "[_", "0_", "]_", "*_", "R_", "._", "ngen", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "[_", "i_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mi", "v_", "=_", "tuple_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "exp", "v_", "in_", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "monom", "ial", "\\u", "min_", "(_", "exp", "v_", ",_", "mi", "v_", ")_", "==_", "zm", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "+=_", "R_", "(_", "{_", "exp", "v_", ":_", "p_", "[_", "exp", "v_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "c_", "\\u\\u\\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_", "rs", "\\u", "series", "\\u", "from", "\\u", "list_", "(_", "p_", ",_", "c_", ",_", "x_", ",_", "prec_", ",_", "conc", "ur_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "a", " ", "series", " ", "`", "sum", " ", "c", "[", "n", "]*", "p", "**", "n", "`", " ", "modulo", " ", "`", "O", "(", "x", "**", "prec", ")`", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "It", " ", "reduce", "s", " ", "the", " ", "number", " ", "of", " ", "multiplication", "s", " ", "by", " ", "summ", "ing", " ", "concurrent", "ly", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "`", "ax", " ", "=", " ", "[", "1", ",", " ", "p", ",", " ", "p", "**", "2", ",", " ", "..", ",", " ", "p", "**", "(", "J", " ", "-", " ", "1", ")]", "`", "\\", "10", ";", " ", " ", " ", " ", "`", "s", " ", "=", " ", "sum", "(", "c", "[", "i", "]*", "ax", "[", "i", "]`", " ", "for", " ", "i", " ", "in", " ", "`", "range", "(", "r", ",", " ", "(", "r", " ", "+", " ", "1", ")*", "J", "))", "*", "p", "**", "((", "K", " ", "-", " ", "1", ")*", "J", ")`", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "`", "K", " ", ">=", " ", "(", "n", " ", "+", " ", "1", ")/", "J", "`", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "domains", " ", "import", " ", "QQ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "rings", " ", "import", " ", "ring", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "ring", "\\u", "series", " ", "import", " ", "rs", "\\u", "series", "\\u", "from", "\\u", "list", ",", " ", "rs", "\\u", "trunc", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "R", ",", " ", "x", " ", "=", " ", "ring", "('", "x", "',", " ", "QQ", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "p", " ", "=", " ", "x", "**", "2", " ", "+", " ", "x", " ", "+", " ", "1", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "c", " ", "=", " ", "[", "1", ",", " ", "2", ",", " ", "3", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "series", "\\u", "from", "\\u", "list", "(", "p", ",", " ", "c", ",", " ", "x", ",", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "6", "*", "x", "**", "3", " ", "+", " ", "11", "*", "x", "**", "2", " ", "+", " ", "8", "*", "x", " ", "+", " ", "6", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "trunc", "(", "1", " ", "+", " ", "2", "*", "p", " ", "+", " ", "3", "*", "p", "**", "2", ",", " ", "x", ",", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "6", "*", "x", "**", "3", " ", "+", " ", "11", "*", "x", "**", "2", " ", "+", " ", "8", "*", "x", " ", "+", " ", "6", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "pc", " ", "=", " ", "R", ".", "from", "\\u", "list", "(", "list", "(", "reverse", "d", "(", "c", ")))", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "trunc", "(", "pc", ".", "compose", "(", "x", ",", " ", "p", "),", " ", "x", ",", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "6", "*", "x", "**", "3", " ", "+", " ", "11", "*", "x", "**", "2", " ", "+", " ", "8", "*", "x", " ", "+", " ", "6", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "See", " ", "Al", "so", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "symp", "y", ".", "polys", ".", "ring", ".", "compose", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "=_", "p_", "._", "ring_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "=_", "len_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "conc", "ur_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "c_", "[_", "0_", "]_", "*_", "q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "1_", ",_", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "rs", "\\u", "mul_", "(_", "q_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "+=_", "c_", "[_", "i_", "]_", "*_", "q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "J_", "=_", "int_", "(_", "math_", "._", "sqrt_", "(_", "n_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "K_", ",_", "r_", "=_", "divmod_", "(_", "n_", ",_", "J_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "K_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ax_", "=_", "[_", "R_", "(_", "1_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "p_", ")_", "<_", "20_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "range_", "(_", "1_", ",_", "J_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "rs", "\\u", "mul_", "(_", "q_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "append_", "(_", "q_", ")_", "\\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 ", " _", "for_", "i_", "in_", "range_", "(_", "1_", ",_", "J_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "%_", "2_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "rs", "\\u", "square_", "(_", "ax_", "[_", "i_", "//_", "2_", "]_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "rs", "\\u", "mul_", "(_", "q_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ax_", "._", "append_", "(_", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "optimize", " ", "usi", "ng", " ", "rs", "\\u", "square_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pj_", "=_", "rs", "\\u", "mul_", "(_", "ax_", "[_", "-_", "1_", "]_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "R_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "range_", "(_", "K_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "J_", "*_", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s1_", "=_", "c_", "[_", "r_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "range_", "(_", "1_", ",_", "J_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s1_", "+=_", "c_", "[_", "r_", "+_", "j_", "]_", "*_", "ax_", "[_", "j_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "s1_", "=_", "rs", "\\u", "mul_", "(_", "s1_", ",_", "b_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "+=_", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "rs", "\\u", "mul_", "(_", "b_", ",_", "pj_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "b_", ":_", "\\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_", "k_", "=_", "K_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "J_", "*_", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", "<_", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s1_", "=_", "c_", "[_", "r_", "]_", "*_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "range_", "(_", "1_", ",_", "J_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "r_", "+_", "j_", ">=_", "n_", ":_", "\\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_", "s1_", "+=_", "c_", "[_", "r_", "+_", "j_", "]_", "*_", "ax_", "[_", "j_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "s1_", "=_", "rs", "\\u", "mul_", "(_", "s1_", ",_", "b_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "+=_", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rs", "\\u", "nth", "\\u", "root_", "(_", "p_", ",_", "n_", ",_", "x_", ",_", "prec_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Multi", "varia", "te", " ", "series", " ", "expansion", " ", "of", " ", "the", " ", "nth", " ", "root", " ", "of", " ", "``", "p", "``.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "n", " ", ":", " ", "`", "p", "**", "(", "1", "/", "n", ")`", " ", "is", " ", "return", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "x", " ", ":", " ", ":", "class", ":`", "Poly", "Element", "`", "\\", "10", ";", " ", " ", " ", " ", "prec", " ", ":", " ", "Order", " ", "of", " ", "the", " ", "expand", "ed", " ", "series", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "es", "\\", "10", ";", " ", " ", " ", " ", "=====", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "result", " ", "of", " ", "this", " ", "function", " ", "is", " ", "dependent", " ", "on", " ", "the", " ", "ring", " ", "over", " ", "whi", "ch", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "polynomial", " ", "has", " ", "bee", "n", " ", "defin", "ed", ".", " ", "If", " ", "the", " ", "answer", " ", "involv", "es", " ", "a", " ", "root", " ", "of", " ", "a", " ", "constant", ",", "\\", "10", ";", " ", " ", " ", " ", "make", " ", "sure", " ", "tha", "t", " ", "the", " ", "polynomial", " ", "is", " ", "over", " ", "a", " ", "real", " ", "field", ".", " ", "It", " ", "can", " ", "not", " ", "ye", "t", " ", "handle", "\\", "10", ";", " ", " ", " ", " ", "root", "s", " ", "of", " ", "symbols", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "domains", " ", "import", " ", "QQ", ",", " ", "RR", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "rings", " ", "import", " ", "ring", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "ring", "\\u", "series", " ", "import", " ", "rs", "\\u", "nth", "\\u", "root", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "R", ",", " ", "x", ",", " ", "y", " ", "=", " ", "ring", "('", "x", ",", " ", "y", "',", " ", "QQ", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "nth", "\\u", "root", "(", "1", " ", "+", " ", "x", " ", "+", " ", "x", "*", "y", ",", " ", "-", "3", ",", " ", "x", ",", " ", "3", ")", "\\", "10", ";", " ", " ", " ", " ", "2", "/", "9", "*", "x", "**", "2", "*", "y", "**", "2", " ", "+", " ", "4", "/", "9", "*", "x", "**", "2", "*", "y", " ", "+", " ", "2", "/", "9", "*", "x", "**", "2", " ", "-", " ", "1", "/", "3", "*", "x", "*", "y", " ", "-", " ", "1", "/", "3", "*", "x", " ", "+", " ", "1", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "R", ",", " ", "x", ",", " ", "y", " ", "=", " ", "ring", "('", "x", ",", " ", "y", "',", " ", "RR", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "nth", "\\u", "root", "(", "3", " ", "+", " ", "x", " ", "+", " ", "x", "*", "y", ",", " ", "3", ",", " ", "x", ",", " ", "2", ")", "\\", "10", ";", " ", " ", " ", " ", "0.16", "024", "995", "225", "6379", "*", "x", "*", "y", " ", "+", " ", "0.16", "024", "995", "225", "6379", "*", "x", " ", "+", " ", "1.4", "422", "495", "703", "074", "1", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p0_", "=_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n0_", "=_", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "n_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "p_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "0", "**", "0", " ", "express", "ion", "'_", ")_", "\\u\\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_", "p_", "._", "ring_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "n_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "rs", "\\u", "trunc", "_", "(_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "=_", "p_", "._", "ring_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zm", "_", "=_", "R_", "._", "zero", "\\u", "monom", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "=_", "R_", "._", "gens_", "._", "index_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "min_", "(_", "p_", ",_", "key_", "=_", "lambda_", "k_", ":_", "k_", "[_", "index_", "]_", ")_", "[_", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "mul", "\\u", "xin", "_", "(_", "p_", ",_", "index_", ",_", "-_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prec_", "-=_", "m_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u", "has", "\\u", "constant", "\\u", "term_", "(_", "p_", "-_", "1_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zm", "_", "=_", "R_", "._", "zero", "\\u", "monom", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "p_", "[_", "zm", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "R_", "._", "domain_", "is_", "EX_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c\\u", "expr_", "=_", "c_", "._", "as", "\\u", "expr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "const_", "=_", "c\\u", "expr_", "**_", "QQ", "_", "(_", "1_", ",_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "c_", ",_", "Poly", "Element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c\\u", "expr_", "=_", "c_", "._", "as", "\\u", "expr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "const_", "=_", "R_", "(_", "c\\u", "expr_", "**_", "(_", "QQ", "_", "(_", "1_", ",_", "n_", ")_", ")_", ")_", "\\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 ", " _", "raise_", "Doma", "in", "Error_", "(_", "\"", "The", " ", "give", "n", " ", "series", " ", "can", "'", "t", " ", "be", " ", "expand", "ed", " ", "in", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "this", " ", "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 ", " _", "try_", ":_", "#", " ", "Real", "Element", " ", "doe", "sn", "'", "t", " ", "support_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "const_", "=_", "R_", "(_", "c_", "**_", "Rational", "_", "(_", "1_", ",_", "n_", ")_", ")_", "#", " ", "expon", "enti", "ation", " ", "with", " ", "mp", "q", " ", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "#", " ", "as", " ", "exponent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Doma", "in", "Error_", "(_", "\"", "The", " ", "give", "n", " ", "series", " ", "can", "'", "t", " ", "be", " ", "expand", "ed", " ", "in", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "this", " ", "domain", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "res_", "=_", "rs", "\\u", "nth", "\\u", "root_", "(_", "p_", "/_", "c_", ",_", "n_", ",_", "x_", ",_", "prec_", ")_", "*_", "const_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "\\u", "nth", "\\u", "root", "1_", "(_", "p_", ",_", "n_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "QQ", "_", "(_", "m_", ",_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "mul", "\\u", "xin", "_", "(_", "res_", ",_", "index_", ",_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rs", "\\u", "exp_", "(_", "p_", ",_", "x_", ",_", "prec_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Expo", "nent", "iation", " ", "of", " ", "a", " ", "series", " ", "modulo", " ", "``", "O", "(", "x", "**", "prec", ")`", "`", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "domains", " ", "import", " ", "QQ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "rings", " ", "import", " ", "ring", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "ring", "\\u", "series", " ", "import", " ", "rs", "\\u", "exp", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "R", ",", " ", "x", " ", "=", " ", "ring", "('", "x", "',", " ", "QQ", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "exp", "(", "x", "**", "2", ",", " ", "x", ",", " ", "7", ")", "\\", "10", ";", " ", " ", " ", " ", "1", "/", "6", "*", "x", "**", "6", " ", "+", " ", "1", "/", "2", "*", "x", "**", "4", " ", "+", " ", "x", "**", "2", " ", "+", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rs", "\\u", "is", "\\u", "pu", "ise", "ux_", "(_", "p_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "rs", "\\u", "pu", "ise", "ux_", "(_", "rs", "\\u", "exp_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "=_", "p_", "._", "ring_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "\\u", "get", "\\u", "constant", "\\u", "term_", "(_", "p_", ",_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "R_", "._", "domain_", "is_", "EX_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c\\u", "expr_", "=_", "c_", "._", "as", "\\u", "expr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "const_", "=_", "exp_", "(_", "c\\u", "expr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "c_", ",_", "Poly", "Element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c\\u", "expr_", "=_", "c_", "._", "as", "\\u", "expr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "const_", "=_", "R_", "(_", "exp_", "(_", "c\\u", "expr_", ")_", ")_", "\\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 ", " _", "R_", "=_", "R_", "._", "add", "\\u", "gens_", "(_", "[_", "exp_", "(_", "c\\u", "expr_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "p_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "x_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "c_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "const_", "=_", "R_", "(_", "exp_", "(_", "c\\u", "expr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "const_", "=_", "R_", "(_", "exp_", "(_", "c_", ")_", ")_", "\\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 ", " _", "raise_", "Doma", "in", "Error_", "(_", "\"", "The", " ", "give", "n", " ", "series", " ", "can", "'", "t", " ", "be", " ", "expand", "ed", " ", "in", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "this", " ", "domain", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p1_", "=_", "p_", "-_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", "s", " ", "use", " ", "of", " ", "symp", "y", " ", "fu", "ctions", " ", "to", " ", "evaluate", " ", "the", " ", "values", " ", "of", " ", "the", " ", "cos", "/", "sin_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "the", " ", "constant", " ", "term", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "const_", "*_", "rs", "\\u", "exp_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "p_", ")_", ">_", "20_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u", "exp", "1_", "(_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "one_", "=_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "range_", "(_", "prec_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "._", "append_", "(_", "one_", "/_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "*=_", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "=_", "rs", "\\u", "series", "\\u", "from", "\\u", "list_", "(_", "p_", ",_", "c_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rs", "\\u", "cos_", "(_", "p_", ",_", "x_", ",_", "prec_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Cos", "ine", " ", "of", " ", "a", " ", "series", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "the", " ", "series", " ", "expansion", " ", "of", " ", "the", " ", "cos", " ", "of", " ", "``", "p", "``", ",", " ", "abo", "ut", " ", "0.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "domains", " ", "import", " ", "QQ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "rings", " ", "import", " ", "ring", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "symp", "y", ".", "polys", ".", "ring", "\\u", "series", " ", "import", " ", "rs", "\\u", "cos", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "R", ",", " ", "x", ",", " ", "y", " ", "=", " ", "ring", "('", "x", ",", " ", "y", "',", " ", "QQ", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "cos", "(", "x", " ", "+", " ", "x", "*", "y", ",", " ", "x", ",", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "-1", "/", "2", "*", "x", "**", "2", "*", "y", "**", "2", " ", "-", " ", "x", "**", "2", "*", "y", " ", "-", " ", "1", "/", "2", "*", "x", "**", "2", " ", "+", " ", "1", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "rs", "\\u", "cos", "(", "x", " ", "+", " ", "x", "*", "y", ",", " ", "x", ",", " ", "4", ")/", "x", "**", "QQ", "(", "7", ",", " ", "5", ")", "\\", "10", ";", " ", " ", " ", " ", "-1", "/", "2", "*", "x", "**", "(", "3", "/", "5", ")*", "y", "**", "2", " ", "-", " ", "x", "**", "(", "3", "/", "5", ")*", "y", " ", "-", " ", "1", "/", "2", "*", "x", "**", "(", "3", "/", "5", ")", " ", "+", " ", "x", "**", "(-", "7", "/", "5", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "See", " ", "Al", "so", "\\", "10", ";", " ", " ", " ", " ", "=======", "=", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "cos", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rs", "\\u", "is", "\\u", "pu", "ise", "ux_", "(_", "p_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "rs", "\\u", "pu", "ise", "ux_", "(_", "rs", "\\u", "cos_", ",_", "p_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "=_", "p_", "._", "ring_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "\\u", "get", "\\u", "constant", "\\u", "term_", "(_", "p_", ",_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "R_", "._", "domain_", "is_", "EX_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c\\u", "expr_", "=_", "c_", "._", "as", "\\u", "expr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", ",_", "t2_", "=_", "sin_", "(_", "c\\u", "expr_", ")_", ",_", "cos_", "(_", "c\\u", "expr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "c_", ",_", "Poly", "Element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c\\u", "expr_", "=_", "c_", "._", "as", "\\u", "expr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", ",_", "t2_", "=_", "R_", "(_", "sin_", "(_", "c\\u", "expr_", ")_", ")_", ",_", "R_", "(_", "cos_", "(_", "c\\u", "expr_", ")_", ")_", "\\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 ", " _", "R_", "=_", "R_", "._", "add", "\\u", "gens_", "(_", "[_", "sin_", "(_", "c\\u", "expr_", ")_", ",_", "cos_", "(_", "c\\u", "expr_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "p_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "x_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "c_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t1_", ",_", "t2_", "=_", "R_", "(_", "sin_", "(_", "c_", ")_", ")_", ",_", "R_", "(_", "cos_", "(_", "c_", ")_", ")_", "\\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 ", " _", "raise_", "Doma", "in", "Error_", "(_", "\"", "The", " ", "give", "n", " ", "series", " ", "can", "'", "t", " ", "be", " ", "expand", "ed", " ", "in", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "this", " ", "domain", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p1_", "=_", "p_", "-_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", "s", " ", "use", " ", "of", " ", "symp", "y", " ", "cos", ",", " ", "sin", " ", "fu", "ctions", " ", "to", " ", "evaluate", " ", "the", " ", "values", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cos", "/", "sin", " ", "of", " ", "the", " ", "constant", " ", "term", "._", "\\u\\u\\uNL\\u\\u\\u_", "p", "\\u", "cos_", "=_", "rs", "\\u", "cos_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "sin_", "=_", "rs", "\\u", "sin_", "(_", "p1_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "=_", "R_", "._", "compose_", "(_", "p", "\\u", "cos_", "._", "ring_", ")_", "._", "compose_", "(_", "p", "\\u", "sin_", "._", "ring_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "cos_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "sin_", "._", "set\\u", "ring_", "(_", "R_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", ",_", "t2_", "=_", "R_", "(_", "sin_", "(_", "c\\u", "expr_", ")_", ")_", ",_", "R_", "(_", "cos_", "(_", "c\\u", "expr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "p", "\\u", "cos_", "*_", "t2_", "-_", "p", "\\u", "sin_", "*_", "t1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Serie", "s", " ", "is", " ", "calculated", " ", "in", " ", "term", "s", " ", "of", " ", "tan", " ", "as", " ", "its", " ", "evaluat", "ion", " ", "is", " ", "fast", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "p_", ")_", ">_", "20_", "and_", "R_", "._", "ngen", "s_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "rs", "\\u", "tan_", "(_", "p_", "/_", "2_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t2_", "=_", "rs", "\\u", "square_", "(_", "t_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p1_", "=_", "rs", "\\u", "series", "\\u", "inversion", "_", "(_", "1_", "+_", "t2_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "rs", "\\u", "mul_", "(_", "p1_", ",_", "1_", "-_", "t2_", ",_", "x_", ",_", "prec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "one_", "=_", "R_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "range_", "(_", "2_", ",_", "prec_", "+_", "2_", ",_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "._", "append_", "(_", "one_", "/_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "append_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "*=_", "-_", "k_", "*_", "(_", "k_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rs", "\\u", "series", "\\u", "from", "\\u", "list_", "(_", "p_", ",_", "c_", ",_", "x_", ",_", "prec_", ")_", "\\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,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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 ]
Comparison using is when operands support `__eq__`
tdevelioglu/python-f5/f5/util.py
[ { "content": "def multisetter(func):\n @wraps(func)\n def wrapper(self, values):\n if not isinstance(values, list):\n values=[values] * len(self)\n else:\n if len(values) is not len(self):\n raise ValueError('value must be of same length as list')\n func(self, values)\n return wrapper", "metadata": "root.multisetter", "header": "['module', '___EOS___']", "index": 78 } ]
[ { "span": "len(values) is not len(self):", "start_line": 84, "start_column": 15, "end_line": 84, "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_", "def_", "multis", "ette", "r_", "(_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "wraps_", "(_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wrapper_", "(_", "self_", ",_", "values_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "values_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "[_", "values_", "]_", "*_", "len_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "values_", ")_", "is_", "not_", "len_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "value", " ", "must", " ", "be", " ", "of", " ", "same", " ", "length", " ", "as", " ", "list", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "func_", "(_", "self_", ",_", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "wrapper_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
sirrice/dbtruck/dbtruck/dbtruck.py
[ { "content": "import sys\nimport csv\nimport datetime\nimport math\nimport os\nimport logging\nimport re\nimport time\nimport pdb\nmoduledir = os.path.abspath(os.path.dirname(__file__)) \nsys.path.append( moduledir )\n\nfrom collections import *\nfrom dateutil.parser import parse as dateparse\n\nfrom infertypes import *\nfrom parsers.parsers import *\nfrom util import get_logger, to_utf\n\n\n_log = get_logger()\n\n\n\n\n\n\n \n\n \n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def file_iterators(fnames, parser=None, **kwargs):\n if not parser:\n parser = DBTruckParser('/tmp/', '/tmp/')\n\n if isinstance(fnames, basestring):\n fnames = [fnames]\n\n print fnames\n iterfs = parser.get_reader(fnames)\n iterfs = [iterf for iterf in iterfs]\n for iterf in iterfs:\n iterf.infer_metadata()\n return iterfs", "metadata": "root.file_iterators", "header": "['module', '___EOS___']", "index": 23 }, { "content": "def import_datafiles(fnames, new, tablename, errfile, exportmethodsklass, parser=None, **kwargs):\n \"\"\"\n Parse \n\n Args:\n fnames: file names of files to parse and import\n new: drop table(s) before importing? \n tablename: prefix of table to import into\n errfile:\n exportmethodsklass: static class containing export methods\n \"\"\"\n _log.info(\"kwargs: %s\", kwargs)\n\n iterfs = file_iterators(fnames, parser=parser, **kwargs)\n\n new_errfile = False\n if not errfile:\n errfile = file('/dev/null', 'a')\n new_errfile = True\n\n try:\n for idx, iterf in enumerate(iterfs):\n try:\n exportmethods = exportmethodsklass(tablename, errfile, **kwargs)\n\n newtable = new and idx == 0\n exportmethods.setup_table(iterf.types, iterf.header, iterf.add_id_col, newtable)\n import_iterator(iterf, exportmethods)\n\n idx += 1 # this is so failed tables can be reused\n except Exception as e:\n _log.warn(traceback.format_exc())\n\n if new_errfile:\n errfile.close()\n except:\n _log.warn(traceback.format_exc())", "metadata": "root.import_datafiles", "header": "['module', '___EOS___']", "index": 38 }, { "content": "def transform_and_validate(types, row):\n row = map(str2sqlval, zip(types, row))\n return row\n # The following code turned out to be too expensive to run\n # val = map(validate_type, zip(types, row))\n # if reduce(lambda a,b: a and b, val):\n # return row\n # return None", "metadata": "root.transform_and_validate", "header": "['module', '___EOS___']", "index": 77 }, { "content": "def import_iterator(iterf, dbmethods):\n \"\"\"\n \"\"\"\n # this function could dynamically increase or decrease the block\n rowiter = iterf()\n types = iterf.types\n blocksize = 100000\n buf = []\n\n if iterf.header_inferred:\n rowiter.next()\n\n rowidx = dbmethods.get_max_id() or 0\n\n for row in rowiter:\n rowidx += 1\n\n row = transform_and_validate(types, row)\n\n if iterf.add_id_col:\n row.append(str(rowidx))\n\n if row is not None and len(row) == len(iterf.types):\n buf.append(row)\n elif row is not None and len(row) != len(iterf.types):\n print >>dbmethods.errfile, ','.join(map(to_utf, row))\n\n if len(buf) > 0 and len(buf) % blocksize == 0:\n try:\n _log.info(\"flushing %s rows\", len(buf))\n success = dbmethods.import_block(buf, iterf)\n except Exception as e:\n _log.warn(traceback.format_exc())\n buf = []\n\n if len(buf) > 0:\n try:\n success = dbmethods.import_block(buf, iterf)\n _log.info( \"loaded\\t%s\\t%d\", success, rowidx )\n except Exception as e:\n _log.warn(traceback.format_exc())", "metadata": "root.import_iterator", "header": "['module', '___EOS___']", "index": 87 } ]
[ { "span": "import csv", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 10 }, { "span": "import datetime", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 15 }, { "span": "import math", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 11 }, { "span": "import logging", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 14 }, { "span": "import re", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 9 }, { "span": "import time", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 11 }, { "span": "import pdb", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 10 }, { "span": "from dateutil.parser import parse as dateparse", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 46 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "csv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\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_", "pdb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "module", "dir_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "module", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "collections_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dateutil_", "._", "parser_", "import_", "parse_", "as_", "date", "parse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "infer", "types_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "parsers_", "._", "parsers_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "util_", "import_", "get", "\\u", "logger_", ",_", "to", "\\u", "utf", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "log_", "=_", "get", "\\u", "logger_", "(_", ")_", "\\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\\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_", "file", "\\u", "iterators", "_", "(_", "fnames_", ",_", "parser_", "=_", "None_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "parser_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "DB", "Tru", "ck", "Parser_", "(_", "'/", "tmp", "/'_", ",_", "'/", "tmp", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "fnames_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fnames_", "=_", "[_", "fnames_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "fnames_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iter", "fs_", "=_", "parser_", "._", "get", "\\u", "reader_", "(_", "fnames_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iter", "fs_", "=_", "[_", "iter", "f_", "for_", "iter", "f_", "in_", "iter", "fs_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "iter", "f_", "in_", "iter", "fs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "iter", "f_", "._", "infer", "\\u", "metadata_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "iter", "fs_", "\\u\\u\\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_", "import", "\\u", "datafile", "s_", "(_", "fnames_", ",_", "new_", ",_", "tablename_", ",_", "err", "file_", ",_", "export", "method", "skl", "ass_", ",_", "parser_", "=_", "None_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Pars", "e", " ", "\\", "10", ";", "\\", "10", ";", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "fname", "s", ":", " ", "file", " ", "names", " ", "of", " ", "files", " ", "to", " ", "parse", " ", "and", " ", "import", "\\", "10", ";", " ", " ", " ", " ", "new", ":", " ", "drop", " ", "table", "(", "s", ")", " ", "bef", "ore", " ", "import", "ing", "?", " ", "\\", "10", ";", " ", " ", " ", " ", "tablename", ":", " ", "prefix", " ", "of", " ", "table", " ", "to", " ", "import", " ", "int", "o", "\\", "10", ";", " ", " ", " ", " ", "err", "file", ":", "\\", "10", ";", " ", " ", " ", " ", "export", "method", "skl", "ass", ":", " ", "static", " ", "class", " ", "contain", "ing", " ", "export", " ", "method", "s", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "log_", "._", "info_", "(_", "\"", "kwarg", "s", ":", " ", "%", "s", "\"_", ",_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "iter", "fs_", "=_", "file", "\\u", "iterators", "_", "(_", "fnames_", ",_", "parser_", "=_", "parser_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "err", "file_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "err", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "file_", "=_", "file_", "(_", "'/", "dev", "/", "null", "'_", ",_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "err", "file_", "=_", "True_", "\\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 ", " _", "for_", "idx_", ",_", "iter", "f_", "in_", "enumerate_", "(_", "iter", "fs_", ")_", ":_", "\\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 ", " _", "export", "methods_", "=_", "export", "method", "skl", "ass_", "(_", "tablename_", ",_", "err", "file_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "newt", "able_", "=_", "new_", "and_", "idx_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "export", "methods_", "._", "setup", "\\u", "table_", "(_", "iter", "f_", "._", "types_", ",_", "iter", "f_", "._", "header_", ",_", "iter", "f_", "._", "add", "\\u", "id", "\\u", "col_", ",_", "newt", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import", "\\u", "iterator_", "(_", "iter", "f_", ",_", "export", "methods_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "idx_", "+=_", "1_", "#", " ", "this", " ", "is", " ", "so", " ", "fail", "ed", " ", "tables", " ", "can", " ", "be", " ", "reus", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "warn_", "(_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", "\\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_", "new", "\\u", "err", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "file_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "warn_", "(_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", "\\u\\u\\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_", "transform", "\\u", "and", "\\u", "validate_", "(_", "types_", ",_", "row_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "=_", "map_", "(_", "str2", "sql", "val_", ",_", "zip_", "(_", "types_", ",_", "row_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "row_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "follow", "ing", " ", "code", " ", "turn", "ed", " ", "out", " ", "to", " ", "be", " ", "too", " ", "expen", "sive", " ", "to", " ", "run_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "val", " ", "=", " ", "map", "(", "validat", "e\\u", "type", ",", " ", "zip", "(", "types", ",", " ", "row", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "reduce", "(", "lambda", " ", "a", ",", "b", ":", " ", "a", " ", "and", " ", "b", ",", " ", "val", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "return", " ", "row_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "return", " ", "None_", "\\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_", "import", "\\u", "iterator_", "(_", "iter", "f_", ",_", "dbm", "ethod", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "function", " ", "coul", "d", " ", "dynami", "call", "y", " ", "increase", " ", "or", " ", "decrease", " ", "the", " ", "block_", "\\u\\u\\uNL\\u\\u\\u_", "row", "iter_", "=_", "iter", "f_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "types_", "=_", "iter", "f_", "._", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blocksize_", "=_", "100000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "buf_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "iter", "f_", "._", "header", "\\u", "inferred", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row", "iter_", "._", "next_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rowid", "x_", "=_", "dbm", "ethod", "s_", "._", "get", "\\u", "max", "\\u", "id_", "(_", ")_", "or_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "row_", "in_", "row", "iter_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rowid", "x_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "row_", "=_", "transform", "\\u", "and", "\\u", "validate_", "(_", "types_", ",_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "iter", "f_", "._", "add", "\\u", "id", "\\u", "col_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "._", "append_", "(_", "str_", "(_", "rowid", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "row_", "is_", "not_", "None_", "and_", "len_", "(_", "row_", ")_", "==_", "len_", "(_", "iter", "f_", "._", "types_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "buf_", "._", "append_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "row_", "is_", "not_", "None_", "and_", "len_", "(_", "row_", ")_", "!=_", "len_", "(_", "iter", "f_", "._", "types_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "dbm", "ethod", "s_", "._", "err", "file_", ",_", "','_", "._", "join_", "(_", "map_", "(_", "to", "\\u", "utf", "_", ",_", "row_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "buf_", ")_", ">_", "0_", "and_", "len_", "(_", "buf_", ")_", "%_", "blocksize_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "info_", "(_", "\"", "flush", "ing", " ", "%", "s", " ", "rows", "\"_", ",_", "len_", "(_", "buf_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "dbm", "ethod", "s_", "._", "import", "\\u", "block_", "(_", "buf_", ",_", "iter", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "warn_", "(_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "buf_", "=_", "[_", "]_", "\\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_", "(_", "buf_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "success_", "=_", "dbm", "ethod", "s_", "._", "import", "\\u", "block_", "(_", "buf_", ",_", "iter", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "log_", "._", "info_", "(_", "\"", "load", "ed", "\\\\", "t", "%", "s", "\\\\", "t", "%", "d", "\"_", ",_", "success_", ",_", "rowid", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "warn_", "(_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 2, 2, 2, 0, 1, 2, 0, 1, 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, 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, 4, 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 ]
First argument to super() is not enclosing class
cloudera/hue/desktop/core/ext-py/openpyxl-2.3.0-b2/openpyxl/compat/singleton.py
[ { "content": " def __init__(self, *args, **kw):\n super(Singleton, self).__init__(*args, **kw)\n self.__cache = weakref.WeakValueDictionary()", "metadata": "root.Cached.__init__", "header": "['class', 'Cached', '(', 'type', ')', ':', '___EOS___']", "index": 30 }, { "content": " def __call__(self, *args):\n if args in self.__cache:\n return self.__cache[args]\n\n obj = super(Singleton, self).__call__(*args)\n self.__cache[args] = obj\n return obj", "metadata": "root.Cached.__call__", "header": "['class', 'Cached', '(', 'type', ')', ':', '___EOS___']", "index": 34 } ]
[ { "span": "super(Singleton, self).", "start_line": 31, "start_column": 8, "end_line": 31, "end_column": 30 }, { "span": "super(Singleton, self).", "start_line": 38, "start_column": 14, "end_line": 38, "end_column": 36 } ]
[]
1
true
[ "[CLS]_", "First_", "argument_", "to_", "super_", "(_", ")_", "is_", "not_", "encl", "osin", "g_", "class_", "[SEP]_", "class_", "Cache", "d_", "(_", "type_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Singleton_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "*_", "args_", ",_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "cache_", "=_", "weakref_", "._", "Wea", "k", "Value", "Dictionary_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cache", "d_", "(_", "type_", ")_", ":_", "\\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_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "args_", "in_", "self_", "._", "\\u\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "cache_", "[_", "args_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "obj_", "=_", "super_", "(_", "Singleton_", ",_", "self_", ")_", "._", "\\u\\u", "call\\u\\u_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "cache_", "[_", "args_", "]_", "=_", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "obj_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
openworm/PyOpenWorm/tests/NeuronTest.py
[ { "content": "from __future__ import print_function\nimport sys\nsys.path.insert(0,\".\")\nimport unittest\nimport neuroml\nimport neuroml.writers as writers\nimport PyOpenWorm\nfrom PyOpenWorm import *\nimport networkx\nimport rdflib\nimport rdflib as R\nimport pint as Q\nimport os\nimport subprocess as SP\nimport subprocess\nimport tempfile\nimport doctest\n\nfrom glob import glob\n\nfrom GraphDBInit import *\n\nfrom DataTestTemplate import _DataTest\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class NeuronTest(_DataTest):\n\n\n\n\n\n\n\n", "metadata": "root.NeuronTest", "header": "['module', '___EOS___']", "index": 24 }, { "content": " @classmethod\n def setUpClass(cls):\n import logging\n #logging.basicConfig(level=logging.DEBUG)", "metadata": "root.NeuronTest.setUpClass", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 25 }, { "content": " def setUp(self):\n _DataTest.setUp(self)\n self.neur = lambda x : Neuron(name=x)", "metadata": "root.NeuronTest.setUp", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 30 }, { "content": " def test_Cell(self):\n do = self.neur('BDUL')\n self.assertTrue(isinstance(do,Cell))", "metadata": "root.NeuronTest.test_Cell", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 34 }, { "content": " def test_receptors(self):\n n = self.neur('AVAL')\n n.receptor('GLR-2')\n n.save()\n self.assertIn('GLR-2', list(self.neur('AVAL').receptors()))", "metadata": "root.NeuronTest.test_receptors", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 38 }, { "content": " def test_same_name_same_id(self):\n \"\"\"\n Test that two Neuron objects with the same name have the same identifier()\n Saves us from having too many inserts of the same object.\n \"\"\"\n c = Neuron(name=\"boots\")\n c1 = Neuron(name=\"boots\")\n self.assertEqual(c.identifier(),c1.identifier())", "metadata": "root.NeuronTest.test_same_name_same_id", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 44 }, { "content": " def test_type(self):\n n = self.neur('AVAL')\n n.type('interneuron')\n n.save()\n self.assertEqual('interneuron', self.neur('AVAL').type.one())", "metadata": "root.NeuronTest.test_type", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 53 }, { "content": " def test_name(self):\n \"\"\" Test that the name property is set when the neuron is initialized with it \"\"\"\n self.assertEqual('AVAL', self.neur('AVAL').name())\n self.assertEqual('AVAR', self.neur('AVAR').name())", "metadata": "root.NeuronTest.test_name", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 59 }, { "content": " def test_neighbor(self):\n n = self.neur('AVAL')\n n.neighbor(self.neur('PVCL'), syntype='send')\n neighbors = list(n.neighbor())\n self.assertIn(self.neur('PVCL'), neighbors)\n g = R.Graph()\n for t in n.triples():\n g.add(t)\n n.save()\n self.assertIn(self.neur('PVCL'), list(self.neur('AVAL').neighbor()))", "metadata": "root.NeuronTest.test_neighbor", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 64 }, { "content": " def test_init_from_lineage_name(self):\n c = Neuron(lineageName=\"AB plapaaaap\",name=\"ADAL\")\n c.save()\n c = Neuron(lineageName=\"AB plapaaaap\")\n self.assertEqual(c.name(), 'ADAL')", "metadata": "root.NeuronTest.test_init_from_lineage_name", "header": "['class', 'NeuronTest', '(', '_DataTest', ')', ':', '___EOS___']", "index": 75 } ]
[ { "span": "import unittest", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 15 }, { "span": "import neuroml", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 14 }, { "span": "import neuroml.writers as writers", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 33 }, { "span": "import PyOpenWorm", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 17 }, { "span": "import networkx", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 15 }, { "span": "import rdflib", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 13 }, { "span": "import pint as Q", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 16 }, { "span": "import os", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 9 }, { "span": "import subprocess as SP", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 23 }, { "span": "import subprocess", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 17 }, { "span": "import tempfile", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 15 }, { "span": "import doctest", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 14 }, { "span": "from glob import glob", "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_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "insert_", "(_", "0_", ",_", "\".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "neuro", "ml_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "neuro", "ml_", "._", "writers_", "as_", "writers_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Py", "Open", "Wor", "m_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Py", "Open", "Wor", "m_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "networkx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "rdflib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "rdflib_", "as_", "R_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pint", "_", "as_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "as_", "SP_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "doctest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "glob_", "import_", "glob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "Graph", "DB", "Init_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "Data", "Test", "Template_", "import_", "\\u", "Data", "Test_", "\\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_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\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_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\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 ", " _", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "ing", ".", "basic", "Config", "(", "level", "=", "logg", "ing", ".", "DEBU", "G", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "Data", "Test_", "._", "set", "Up_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "neu", "r_", "=_", "lambda_", "x_", ":_", "Neuron_", "(_", "name_", "=_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Cell_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "do_", "=_", "self_", "._", "neu", "r_", "(_", "'", "BD", "UL", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "do_", ",_", "Cell_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "receptor", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "._", "receptor", "_", "(_", "'", "GL", "R", "-", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "'", "GL", "R", "-", "2", "'_", ",_", "list_", "(_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "._", "receptor", "s_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "same", "\\u", "name", "\\u", "same", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "tha", "t", " ", "two", " ", "Neuron", " ", "object", "s", " ", "with", " ", "the", " ", "same", " ", "name", " ", "have", " ", "the", " ", "same", " ", "identifi", "er", "()", "\\", "10", ";", " ", " ", " ", " ", "Save", "s", " ", "us", " ", "from", " ", "hav", "ing", " ", "too", " ", "many", " ", "inserts", " ", "of", " ", "the", " ", "same", " ", "object", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Neuron_", "(_", "name_", "=_", "\"", "boots", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c1_", "=_", "Neuron_", "(_", "name_", "=_", "\"", "boots", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "identifier_", "(_", ")_", ",_", "c1_", "._", "identifier_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "type_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "._", "type_", "(_", "'", "interne", "uro", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "interne", "uro", "n", "'_", ",_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "._", "type_", "._", "one_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Test", " ", "tha", "t", " ", "the", " ", "name", " ", "property", " ", "is", " ", "set", " ", "whe", "n", " ", "the", " ", "neuro", "n", " ", "is", " ", "initialize", "d", " ", "with", " ", "it", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "AVA", "L", "'_", ",_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "._", "name_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "AVA", "R", "'_", ",_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "R", "'_", ")_", "._", "name_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "neighbor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "._", "neighbor_", "(_", "self_", "._", "neu", "r_", "(_", "'", "PV", "CL", "'_", ")_", ",_", "syn", "type_", "=_", "'", "send", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "neighbors_", "=_", "list_", "(_", "n_", "._", "neighbor_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "self_", "._", "neu", "r_", "(_", "'", "PV", "CL", "'_", ")_", ",_", "neighbors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "R_", "._", "Graph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", "in_", "n_", "._", "triples_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "g_", "._", "add_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "n_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "self_", "._", "neu", "r_", "(_", "'", "PV", "CL", "'_", ")_", ",_", "list_", "(_", "self_", "._", "neu", "r_", "(_", "'", "AVA", "L", "'_", ")_", "._", "neighbor_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Neuron", "Test_", "(_", "\\u", "Data", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "init", "\\u", "from", "\\u", "lineage", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "Neuron_", "(_", "lineage", "Name_", "=_", "\"", "AB", " ", "pla", "pa", "aaa", "p", "\"_", ",_", "name_", "=_", "\"", "ADA", "L", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Neuron_", "(_", "lineage", "Name_", "=_", "\"", "AB", " ", "pla", "pa", "aaa", "p", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "name_", "(_", ")_", ",_", "'", "ADA", "L", "'_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Testing equality to None
nextml/NEXT/next/utils/utils.py
[ { "content": "def getDocUID(exp_uid,alg_uid=None):\n \"\"\"\n Each instance of an app (with an (app_id,exp_uid) pair) and an algorithm (with an (app_id,exp_uid,alg_id,alg_uid) tuple)\n gets its own namespace. This method defines that namespace given the exp_uid, or (exp_uid,alg_uid)\n\n Usage::\\n\n print utils.getDocUID(exp_uid)\n >>> 'eee9d58c61d580029113ba593446d23a'\n\n print utils.getDocUID(exp_uid,alg_uid)\n >>> 'eee9d58c61d580029113ba593446d23a-f081d374abac6c009f5a74877f8b9f3c'\n \"\"\"\n if alg_uid==None:\n return exp_uid\n else:\n return exp_uid + \"-\" + alg_uid", "metadata": "root.getDocUID", "header": "['module', '___EOS___']", "index": 229 } ]
[ { "span": "alg_uid==None:", "start_line": 241, "start_column": 5, "end_line": 241, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "Doc", "UID_", "(_", "exp", "\\u", "uid_", ",_", "alg", "\\u", "uid_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Ea", "ch", " ", "instance", " ", "of", " ", "an", " ", "app", " ", "(", "with", " ", "an", " ", "(", "app", "\\u", "id", ",", "exp", "\\u", "uid", ")", " ", "pair", ")", " ", "and", " ", "an", " ", "algo", "rit", "hm", " ", "(", "with", " ", "an", " ", "(", "app", "\\u", "id", ",", "exp", "\\u", "uid", ",", "alg", "\\u", "id", ",", "alg", "\\u", "uid", ")", " ", "tuple", ")", "\\", "10", ";", " ", " ", "gets", " ", "its", " ", "own", " ", "namespace", ".", " ", "Thi", "s", " ", "method", " ", "defin", "es", " ", "tha", "t", " ", "namespace", " ", "give", "n", " ", "the", " ", "exp", "\\u", "uid", ",", " ", "or", " ", "(", "exp", "\\u", "uid", ",", "alg", "\\u", "uid", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", "Us", "age", "::", "\\\\", "n", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "util", "s", ".", "get", "Doc", "UI", "D", "(", "exp", "\\u", "uid", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "'", "eee", "9", "d5", "8c", "6", "1d", "580", "029", "113", "ba", "593", "446", "d2", "3a", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "util", "s", ".", "get", "Doc", "UI", "D", "(", "exp", "\\u", "uid", ",", "alg", "\\u", "uid", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "'", "eee", "9", "d5", "8c", "6", "1d", "580", "029", "113", "ba", "593", "446", "d2", "3a", "-", "f0", "8", "1d", "374", "aba", "c6", "c0", "09", "f5", "a7", "487", "7f", "8b", "9", "f3", "c", "'", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "alg", "\\u", "uid_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "exp", "\\u", "uid_", "\\u\\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_", "exp", "\\u", "uid_", "+_", "\"-\"_", "+_", "alg", "\\u", "uid_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
fusionbox/django-widgy/widgy/views/api.py
[ { "content": "\"\"\"\nResource views that can be included to enable a REST style API\nfor Widgy nodes and Content objects.\n\"\"\"\nfrom functools import partial\n\nfrom django.http import Http404\nfrom django.core.exceptions import ValidationError, PermissionDenied\nfrom django.core.urlresolvers import reverse\nfrom django.shortcuts import get_object_or_404\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.views.generic import DetailView\nfrom django.views.generic.detail import SingleObjectMixin\nfrom django.db.models import ProtectedError\nfrom django.utils.translation import ugettext as _\n\ntry:\n from django.apps import apps\n get_model = apps.get_model\n del apps\nexcept ImportError:\n # Django < 1.8\n from django.db.models import get_model\n\nfrom argonauts.views import RestView\n\nfrom widgy.models import Node\nfrom widgy.exceptions import InvalidTreeMovement\nfrom widgy.utils import extract_id\nfrom widgy.views.base import WidgyViewMixin, AuthorizedMixin\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": "class WidgyView(WidgyViewMixin, RestView):\n pass", "metadata": "root.WidgyView", "header": "['module', '___EOS___']", "index": 32 }, { "content": "class ContentView(WidgyView):\n \"\"\"\n General purpose resource for :class:`widgy.models.Content` objects.\n\n **Supported Methods**:\n :get: Fetch a :class:`widgy.models.Content` object.\n :put: Make changes to a :class:`widgy.models.Content` object.\n\n .. todo::\n change ``put`` method to be more generic.\n \"\"\"\n\n\n", "metadata": "root.ContentView", "header": "['module', '___EOS___']", "index": 36 }, { "content": " def dispatch(self, request, app_label, object_name, object_pk):\n return super(ContentView, self).dispatch(request, app_label, object_name, object_pk)", "metadata": "root.ContentView.dispatch", "header": "['class', 'ContentView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 47 }, { "content": " def get_object(self, app_label, object_name, object_pk):\n \"\"\"\n Resolves ``app_label``, ``object_name``, and ``object_pk`` to a\n :class:`widgy.models.Content` instance.\n \"\"\"\n return (\n ContentType.objects.get(model=object_name, app_label=app_label)\n .get_object_for_this_type(pk=object_pk)\n )", "metadata": "root.ContentView.get_object", "header": "['class', 'ContentView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 50 }, { "content": " def get(self, request, app_label, object_name, object_pk):\n obj = self.get_object(app_label, object_name, object_pk)\n return self.render_to_response(obj.to_json(self.site))", "metadata": "root.ContentView.get", "header": "['class', 'ContentView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 60 }, { "content": " def put(self, request, app_label, object_name, object_pk):\n obj = self.get_object(app_label, object_name, object_pk)\n if not self.site.has_change_permission(request, obj):\n raise PermissionDenied(_(\"You don't have permission to edit this widget.\"))\n\n data = self.data()['attributes']\n form = obj.get_form(request, data=data)\n if not form.is_valid():\n raise ValidationError(form.errors)\n form.save()\n return self.render_to_response(form.instance.to_json(self.site),\n status=200)", "metadata": "root.ContentView.put", "header": "['class', 'ContentView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 64 }, { "content": "class NodeView(WidgyView):\n \"\"\"\n General purpose resource for updating, deleting, and repositioning\n :class:`widgy.models.Node` objects.\n\n **Supported Methods**:\n :post: Create a new :class:`widgy.models.Node` object. This method\n requires that ``__class__`` is passed in the JSON request as a\n parameter. ``__class__`` is expected to be a ``.`` separated\n string of ``app_label.model_classname``.\n :delete: Delete a :class:`widgy.models.Node` object.\n :put: Make changes to a :class:`widgy.models.Node` object. This method\n also supports repositioning a node to the the left of new sibling by\n supplying a ``right_id`` in the request.\n\n \"\"\"\n\n\n\n\n", "metadata": "root.NodeView", "header": "['module', '___EOS___']", "index": 78 }, { "content": " def render_as_node(self, obj, *args, **kwargs):\n obj = {'node': obj}\n\n compatibility_node_url = self.request.GET.get('include_compatibility_for', None)\n if compatibility_node_url:\n node = get_object_or_404(Node, pk=extract_id(compatibility_node_url))\n obj['compatibility'] = ShelfView.get_compatibility_data(self.site, self.request, node)\n\n return self.render_to_response(obj, *args, **kwargs)", "metadata": "root.NodeView.render_as_node", "header": "['class', 'NodeView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 94 }, { "content": " def get(self, request, node_pk):\n node = get_object_or_404(Node, pk=node_pk)\n node.prefetch_tree()\n return self.render_as_node(node.to_json(self.site))", "metadata": "root.NodeView.get", "header": "['class', 'NodeView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 104 }, { "content": " def post(self, request, node_pk=None):\n data = self.data()\n app_label, model = data['__class__'].split('.')\n try:\n content_class = get_model(app_label, model)\n except LookupError:\n raise Http404\n\n try:\n right = get_object_or_404(Node, pk=extract_id(data['right_id']))\n parent = right.get_parent()\n create_content = right.content.add_sibling\n except Http404:\n parent = get_object_or_404(Node, pk=extract_id(data['parent_id']))\n create_content = parent.content.add_child\n\n if not self.site.has_add_permission(request, parent.content, content_class):\n raise PermissionDenied(_(\"You don't have permission to add this widget.\"))\n\n content = create_content(self.site, content_class)\n\n return self.render_as_node(content.node.to_json(self.site),\n status=201)", "metadata": "root.NodeView.post", "header": "['class', 'NodeView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 109 }, { "content": " def put(self, request, node_pk):\n \"\"\"\n If you put with a right_id, then your node will be placed immediately\n to the right of the node corresponding with the right_id.\n\n If you put with a parent_id, then your node will be placed as the\n first-child of the node corresponding with the parent_id.\n\n .. todo::\n put this in the model\n \"\"\"\n node = get_object_or_404(Node, pk=node_pk)\n data = self.data()\n\n if not self.site.has_change_permission(request, node.content):\n raise PermissionDenied(_(\"You don't have permission to move this widget.\"))\n if not node.content.draggable:\n raise InvalidTreeMovement({'message': \"You can't move me\"})\n\n try:\n right = Node.objects.get(pk=extract_id(data['right_id']))\n node.content.reposition(self.site, right=right.content)\n except Node.DoesNotExist:\n try:\n parent = Node.objects.get(pk=extract_id(data['parent_id']))\n node.content.reposition(self.site, parent=parent.content)\n except Node.DoesNotExist:\n raise Http404\n\n # We have to refetch before returning because treebeard doesn't\n # update the in-memory instance, only the database, see\n # <https://tabo.pe/projects/django-treebeard/docs/tip/caveats.html#raw-queries>\n node = Node.objects.get(pk=node.pk)\n node.prefetch_tree()\n\n return self.render_as_node(node.to_json(self.site), status=200)", "metadata": "root.NodeView.put", "header": "['class', 'NodeView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 133 }, { "content": " def delete(self, request, node_pk):\n node = get_object_or_404(Node, pk=node_pk)\n\n if not self.site.has_delete_permission(request, node.content):\n raise PermissionDenied(_(\"You don't have permission to delete this widget.\"))\n if not node.content.deletable:\n raise InvalidTreeMovement({'message': \"You can't delete me\"})\n\n try:\n node.content.delete()\n return self.render_as_node(None)\n except ProtectedError as e:\n raise ValidationError({'message': e.args[0]})", "metadata": "root.NodeView.delete", "header": "['class', 'NodeView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 170 }, { "content": " def options(self, request, node_pk=None):\n response = super(NodeView, self).options(request, node_pk)\n\n if not node_pk:\n response['Allow'] = 'POST'\n\n return response", "metadata": "root.NodeView.options", "header": "['class', 'NodeView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 184 }, { "content": "class ShelfView(WidgyView):\n \"\"\"\n For a given node, returns a mapping of node urls to lists of content\n classes that can be their children.::\n\n {\n node_url: [content classes]\n node_url: [content classes]\n }\n\n Used on the frontend to populate the shelf.\n \"\"\"\n\n\n", "metadata": "root.ShelfView", "header": "['module', '___EOS___']", "index": 193 }, { "content": " @staticmethod\n def serialize_content_classes(site, obj):\n \"\"\"\n The built-in json encoder doesn't support class_to_json, so\n we'll do it manually.\n \"\"\"\n res = {}\n for node, classes in obj.items():\n res[node.get_api_url(site)] = [i.class_to_json(site) for i in classes]\n return res", "metadata": "root.ShelfView.serialize_content_classes", "header": "['class', 'ShelfView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 206 }, { "content": " @staticmethod\n def get_compatibility_data(site, request, root_node):\n root_node.maybe_prefetch_tree()\n parent = root_node.content\n content_classes = site.get_all_content_classes()\n content_classes = [c for c in content_classes\n if site.has_add_permission(request, parent, c)]\n content_classes = root_node.filter_child_classes_recursive(site, content_classes)\n return ShelfView.serialize_content_classes(site, content_classes)", "metadata": "root.ShelfView.get_compatibility_data", "header": "['class', 'ShelfView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 217 }, { "content": " def get(self, request, node_pk):\n node = get_object_or_404(Node, pk=node_pk)\n return self.render_to_response(self.get_compatibility_data(self.site, request, node))", "metadata": "root.ShelfView.get", "header": "['class', 'ShelfView', '(', 'WidgyView', ')', ':', '___EOS___']", "index": 227 }, { "content": "class NodeSingleObjectMixin(SingleObjectMixin):\n model = Node\n pk_url_kwarg = 'node_pk'", "metadata": "root.NodeSingleObjectMixin", "header": "['module', '___EOS___']", "index": 232 }, { "content": "class NodeEditView(NodeSingleObjectMixin, AuthorizedMixin, DetailView):\n \"\"\"\n The only TemplateView in widgy: The interface for popped out node editing.\n \"\"\"\n\n template_name = 'widgy/views/edit_node.html'\n", "metadata": "root.NodeEditView", "header": "['module', '___EOS___']", "index": 237 }, { "content": " def get_context_data(self, **kwargs):\n if not self.site.has_change_permission(self.request, self.object):\n raise PermissionDenied(_(\"You don't have permission to edit this widget.\"))\n kwargs = super(NodeEditView, self).get_context_data(**kwargs)\n self.object.prefetch_tree()\n kwargs.update(\n html_id='node_%s' % (self.object.pk),\n node_dict=self.object.to_json(self.site),\n api_url=reverse(self.site.node_view),\n site=self.site,\n )\n return kwargs", "metadata": "root.NodeEditView.get_context_data", "header": "['class', 'NodeEditView', '(', 'NodeSingleObjectMixin', ',', 'AuthorizedMixin', ',', 'DetailView', ')', ':', '___EOS___']", "index": 244 }, { "content": "class NodeTemplatesView(NodeSingleObjectMixin, WidgyView):\n \"\"\"\n Gets the dynamic [needing request] templates for a node.\n \"\"\"", "metadata": "root.NodeTemplatesView", "header": "['module', '___EOS___']", "index": 258 }, { "content": " def get(self, request, *args, **kwargs):\n node = self.object = self.get_object()\n if not self.site.has_change_permission(request, node.content):\n raise PermissionDenied(_(\"You don't have permission to edit this widget.\"))\n return self.render_to_response(node.content.get_templates(request))", "metadata": "root.NodeTemplatesView.get", "header": "['class', 'NodeTemplatesView', '(', 'NodeSingleObjectMixin', ',', 'WidgyView', ')', ':', '___EOS___']", "index": 262 }, { "content": "class NodeParentsView(NodeSingleObjectMixin, WidgyView):\n \"\"\"\n Given a node, where in its tree can it be moved?\n \"\"\"\n", "metadata": "root.NodeParentsView", "header": "['module', '___EOS___']", "index": 269 }, { "content": " def get(self, request, *args, **kwargs):\n node = self.object = self.get_object()\n if not self.site.has_change_permission(request, node.content):\n raise PermissionDenied(_(\"You don't have permission to move this widget.\"))\n node.prefetch_tree()\n possible_parents = node.possible_parents(self.site, node.get_root())\n return self.render_to_response([i.get_api_url(self.site) for i in possible_parents])", "metadata": "root.NodeParentsView.get", "header": "['class', 'NodeParentsView', '(', 'NodeSingleObjectMixin', ',', 'WidgyView', ')', ':', '___EOS___']", "index": 274 } ]
[ { "span": "from functools import partial", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 29 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Reso", "urc", "e", " ", "views", " ", "tha", "t", " ", "can", " ", "be", " ", "include", "d", " ", "to", " ", "enable", " ", "a", " ", "REST", " ", "style", " ", "API", "\\", "10", ";", "for", " ", "Wid", "gy", " ", "nodes", " ", "and", " ", "Conten", "t", " ", "object", "s", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "functools_", "import_", "partial_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Validat", "ion", "Error_", ",_", "Permi", "ssion", "Denied_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "shortcuts_", "import_", "get", "\\u", "object\\u", "or", "\\u", "404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "._", "models_", "import_", "Conten", "t", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "views_", "._", "generic_", "import_", "Det", "ail", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "views_", "._", "generic_", "._", "detail_", "import_", "Sing", "le", "Object", "Mixin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "Protect", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "translation_", "import_", "ugettext_", "as_", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "apps_", "import_", "apps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "get", "\\u", "model_", "=_", "apps_", "._", "get", "\\u", "model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "apps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Dj", "ang", "o", " ", "<", " ", "1.8_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "db_", "._", "models_", "import_", "get", "\\u", "model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "argo", "naut", "s_", "._", "views_", "import_", "Rest", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "wid", "gy_", "._", "models_", "import_", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wid", "gy_", "._", "exceptions_", "import_", "Inva", "lid", "Tree", "Move", "ment_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wid", "gy_", "._", "utils_", "import_", "extract", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wid", "gy_", "._", "views_", "._", "base_", "import_", "Wid", "gy", "View", "Mixin_", ",_", "Authorized", "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\\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_", "class_", "Wid", "gy", "View_", "(_", "Wid", "gy", "View", "Mixin_", ",_", "Rest", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Conten", "t", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "General", " ", "purpose", " ", "resource", " ", "for", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Conten", "t", "`", " ", "object", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Supp", "orte", "d", " ", "Meth", "ods", "**", ":", "\\", "10", ";", " ", " ", " ", " ", ":", "get", ":", " ", "Fe", "tch", " ", "a", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Conten", "t", "`", " ", "object", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "put", ":", " ", "Make", " ", "change", "s", " ", "to", " ", "a", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Conten", "t", "`", " ", "object", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", " ", " ", " ", " ", "change", " ", "``", "put", "``", " ", "method", " ", "to", " ", "be", " ", "more", " ", "gener", "ic", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Conten", "t", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "dispatch_", "(_", "self_", ",_", "request_", ",_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Conten", "t", "View_", ",_", "self_", ")_", "._", "dispatch_", "(_", "request_", ",_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Conten", "t", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "object_", "(_", "self_", ",_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Resolv", "es", " ", "``", "app", "\\u", "label", "``", ",", " ", "``", "object\\u", "name", "``", ",", " ", "and", " ", "``", "object\\u", "pk", "``", " ", "to", " ", "a", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Conten", "t", "`", " ", "instance", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Conten", "t", "Type_", "._", "objects_", "._", "get_", "(_", "model_", "=_", "object\\u", "name_", ",_", "app", "\\u", "label_", "=_", "app", "\\u", "label_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "get", "\\u", "object\\u", "for", "\\u", "this", "\\u", "type_", "(_", "pk_", "=_", "object\\u", "pk_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Conten", "t", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "request_", ",_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "self_", "._", "get", "\\u", "object_", "(_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "to", "\\u", "response_", "(_", "obj_", "._", "to", "\\u", "json_", "(_", "self_", "._", "site_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Conten", "t", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "put_", "(_", "self_", ",_", "request_", ",_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "self_", "._", "get", "\\u", "object_", "(_", "app", "\\u", "label_", ",_", "object\\u", "name_", ",_", "object\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "change", "\\u", "permission_", "(_", "request_", ",_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "edit", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "=_", "self_", "._", "data_", "(_", ")_", "[_", "'", "attribute", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "obj_", "._", "get", "\\u", "form_", "(_", "request_", ",_", "data_", "=_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Validat", "ion", "Error_", "(_", "form_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "to", "\\u", "response_", "(_", "form_", "._", "instance_", "._", "to", "\\u", "json_", "(_", "self_", "._", "site_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "General", " ", "purpose", " ", "resource", " ", "for", " ", "updat", "ing", ",", " ", "delet", "ing", ",", " ", "and", " ", "repos", "ition", "ing", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Node", "`", " ", "object", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Supp", "orte", "d", " ", "Meth", "ods", "**", ":", "\\", "10", ";", " ", " ", " ", " ", ":", "post", ":", " ", "Creat", "e", " ", "a", " ", "new", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Node", "`", " ", "object", ".", " ", " ", "Thi", "s", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "require", "s", " ", "tha", "t", " ", "``", "\\u\\u", "class", "\\u\\u``", " ", "is", " ", "pass", "ed", " ", "in", " ", "the", " ", "JSO", "N", " ", "request", " ", "as", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "parameter", ".", " ", " ", "``", "\\u\\u", "class", "\\u\\u``", " ", "is", " ", "expected", " ", "to", " ", "be", " ", "a", " ", "``.", "``", " ", "separate", "d", "\\", "10", ";", " ", " ", " ", " ", "string", " ", "of", " ", "``", "app", "\\u", "label", ".", "model", "\\u", "class", "name", "``.", "\\", "10", ";", " ", " ", " ", " ", ":", "delete", ":", " ", "Delete", " ", "a", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Node", "`", " ", "object", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "put", ":", " ", "Make", " ", "change", "s", " ", "to", " ", "a", " ", ":", "class", ":`", "wid", "gy", ".", "model", "s", ".", "Node", "`", " ", "object", ".", " ", " ", "Thi", "s", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "als", "o", " ", "support", "s", " ", "repos", "ition", "ing", " ", "a", " ", "node", " ", "to", " ", "the", " ", "the", " ", "left", " ", "of", " ", "new", " ", "sib", "ling", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "supply", "ing", " ", "a", " ", "``", "right", "\\u", "id", "``", " ", "in", " ", "the", " ", "request", ".", "\\", "10", ";", "\\", "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_", "[SEP]_", "class_", "Node", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "render", "\\u", "as", "\\u", "node_", "(_", "self_", ",_", "obj_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "{_", "'", "node", "'_", ":_", "obj_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "compatibility", "\\u", "node", "\\u", "url_", "=_", "self_", "._", "request_", "._", "GET_", "._", "get_", "(_", "'", "include", "\\u", "compatibility", "\\u", "for", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "compatibility", "\\u", "node", "\\u", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "extract", "\\u", "id_", "(_", "compatibility", "\\u", "node", "\\u", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "[_", "'", "compatibility", "'_", "]_", "=_", "Shel", "f", "View_", "._", "get", "\\u", "compatibility", "\\u", "data_", "(_", "self_", "._", "site_", ",_", "self_", "._", "request_", ",_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "to", "\\u", "response_", "(_", "obj_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "request_", ",_", "node", "\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "node", "\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "._", "prefetch", "\\u", "tree_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "as", "\\u", "node_", "(_", "node_", "._", "to", "\\u", "json_", "(_", "self_", "._", "site_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "request_", ",_", "node", "\\u", "pk_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "self_", "._", "data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "\\u", "label_", ",_", "model_", "=_", "data_", "[_", "'\\u", "\\u", "class", "\\u\\u'_", "]_", "._", "split_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content", "\\u", "class_", "=_", "get", "\\u", "model_", "(_", "app", "\\u", "label_", ",_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Look", "up", "Error_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "right_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "extract", "\\u", "id_", "(_", "data_", "[_", "'", "right", "\\u", "id", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "=_", "right_", "._", "get", "\\u", "parent_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "\\u", "content_", "=_", "right_", "._", "content_", "._", "add", "\\u", "sibling_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Http404_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "extract", "\\u", "id_", "(_", "data_", "[_", "'", "parent", "\\u", "id", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "\\u", "content_", "=_", "parent_", "._", "content_", "._", "add", "\\u", "child_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "add", "\\u", "permission_", "(_", "request_", ",_", "parent_", "._", "content_", ",_", "content", "\\u", "class_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "add", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "content_", "=_", "create", "\\u", "content_", "(_", "self_", "._", "site_", ",_", "content", "\\u", "class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "as", "\\u", "node_", "(_", "content_", "._", "node_", "._", "to", "\\u", "json_", "(_", "self_", "._", "site_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "put_", "(_", "self_", ",_", "request_", ",_", "node", "\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "you", " ", "put", " ", "with", " ", "a", " ", "right", "\\u", "id", ",", " ", "then", " ", "your", " ", "node", " ", "will", " ", "be", " ", "place", "d", " ", "immediate", "ly", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "right", " ", "of", " ", "the", " ", "node", " ", "correspond", "ing", " ", "with", " ", "the", " ", "right", "\\u", "id", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "you", " ", "put", " ", "with", " ", "a", " ", "parent", "\\u", "id", ",", " ", "then", " ", "your", " ", "node", " ", "will", " ", "be", " ", "place", "d", " ", "as", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "first", "-", "child", " ", "of", " ", "the", " ", "node", " ", "correspond", "ing", " ", "with", " ", "the", " ", "parent", "\\u", "id", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", " ", " ", " ", " ", "put", " ", "this", " ", "in", " ", "the", " ", "model", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "node", "\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "self_", "._", "data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "change", "\\u", "permission_", "(_", "request_", ",_", "node_", "._", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "move", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "node_", "._", "content_", "._", "dragg", "able_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Inva", "lid", "Tree", "Move", "ment_", "(_", "{_", "'", "message", "'_", ":_", "\"", "You", " ", "can", "'", "t", " ", "move", " ", "me", "\"_", "}_", ")_", "\\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 ", " _", "right_", "=_", "Node_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "extract", "\\u", "id_", "(_", "data_", "[_", "'", "right", "\\u", "id", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "._", "content_", "._", "repos", "ition", "_", "(_", "self_", "._", "site_", ",_", "right_", "=_", "right_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Node_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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 ", " _", "parent_", "=_", "Node_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "extract", "\\u", "id_", "(_", "data_", "[_", "'", "parent", "\\u", "id", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "._", "content_", "._", "repos", "ition", "_", "(_", "self_", "._", "site_", ",_", "parent_", "=_", "parent_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Node_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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_", "#", " ", "We", " ", "have", " ", "to", " ", "ref", "etch", " ", "bef", "ore", " ", "return", "ing", " ", "bec", "aus", "e", " ", "tree", "bear", "d", " ", "doe", "sn", "'", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "the", " ", "in", "-", "memory", " ", "instance", ",", " ", "only", " ", "the", " ", "databa", "se", ",", " ", "see", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "https", "://", "tab", "o", ".", "pe", "/", "project", "s", "/", "django", "-", "tree", "bear", "d", "/", "docs", "/", "tip", "/", "cave", "ats", ".", "html", "#", "raw", "-", "querie", "s", ">_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "node_", "=_", "Node_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "node_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "._", "prefetch", "\\u", "tree_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "as", "\\u", "node_", "(_", "node_", "._", "to", "\\u", "json_", "(_", "self_", "._", "site_", ")_", ",_", "status_", "=_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ",_", "request_", ",_", "node", "\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "node", "\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "delete", "\\u", "permission_", "(_", "request_", ",_", "node_", "._", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "delete", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "node_", "._", "content_", "._", "delet", "able_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Inva", "lid", "Tree", "Move", "ment_", "(_", "{_", "'", "message", "'_", ":_", "\"", "You", " ", "can", "'", "t", " ", "delete", " ", "me", "\"_", "}_", ")_", "\\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 ", " _", "node_", "._", "content_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "as", "\\u", "node_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Protect", "ed", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Validat", "ion", "Error_", "(_", "{_", "'", "message", "'_", ":_", "e_", "._", "args_", "[_", "0_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "View_", "(_", "Wid", "gy", "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_", "options_", "(_", "self_", ",_", "request_", ",_", "node", "\\u", "pk_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "super_", "(_", "Node", "View_", ",_", "self_", ")_", "._", "options_", "(_", "request_", ",_", "node", "\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "node", "\\u", "pk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "[_", "'", "All", "ow", "'_", "]_", "=_", "'", "POST", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "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_", "Shel", "f", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "a", " ", "give", "n", " ", "node", ",", " ", "return", "s", " ", "a", " ", "mapping", " ", "of", " ", "node", " ", "urls", " ", "to", " ", "lists", " ", "of", " ", "content", "\\", "10", ";", " ", " ", " ", " ", "classe", "s", " ", "tha", "t", " ", "can", " ", "be", " ", "thei", "r", " ", "child", "ren", ".:", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "node", "\\u", "url", ":", " ", "[", "content", " ", "classe", "s", "]", "\\", "10", ";", " ", " ", " ", " ", "node", "\\u", "url", ":", " ", "[", "content", " ", "classe", "s", "]", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Us", "ed", " ", "on", " ", "the", " ", "front", "end", " ", "to", " ", "populate", " ", "the", " ", "shelf", ".", "\\", "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_", "[SEP]_", "class_", "Shel", "f", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "serialize", "\\u", "content", "\\u", "classes_", "(_", "site_", ",_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "bui", "lt", "-", "in", " ", "json", " ", "encode", "r", " ", "doe", "sn", "'", "t", " ", "support", " ", "class", "\\u", "to", "\\u", "json", ",", " ", "so", "\\", "10", ";", " ", " ", " ", " ", "we", "'", "ll", " ", "do", " ", "it", " ", "manu", "ally", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node_", ",_", "classes_", "in_", "obj_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "[_", "node_", "._", "get", "\\u", "api", "\\u", "url_", "(_", "site_", ")_", "]_", "=_", "[_", "i_", "._", "class", "\\u", "to", "\\u", "json_", "(_", "site_", ")_", "for_", "i_", "in_", "classes_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Shel", "f", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\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_", "get", "\\u", "compatibility", "\\u", "data_", "(_", "site_", ",_", "request_", ",_", "root", "\\u", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "root", "\\u", "node_", "._", "may", "be", "\\u", "prefetch", "\\u", "tree_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "=_", "root", "\\u", "node_", "._", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "classes_", "=_", "site_", "._", "get", "\\u", "all", "\\u", "content", "\\u", "classes_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "classes_", "=_", "[_", "c_", "for_", "c_", "in_", "content", "\\u", "classes_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "site_", "._", "has", "\\u", "add", "\\u", "permission_", "(_", "request_", ",_", "parent_", ",_", "c_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "classes_", "=_", "root", "\\u", "node_", "._", "filter", "\\u", "child", "\\u", "classe", "s", "\\u", "recursive_", "(_", "site_", ",_", "content", "\\u", "classes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Shel", "f", "View_", "._", "serialize", "\\u", "content", "\\u", "classes_", "(_", "site_", ",_", "content", "\\u", "classes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Shel", "f", "View_", "(_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "request_", ",_", "node", "\\u", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Node_", ",_", "pk_", "=_", "node", "\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "to", "\\u", "response_", "(_", "self_", "._", "get", "\\u", "compatibility", "\\u", "data_", "(_", "self_", "._", "site_", ",_", "request_", ",_", "node_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Sing", "le", "Object", "Mixin_", "(_", "Sing", "le", "Object", "Mixin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pk", "\\u", "url", "\\u", "kwarg_", "=_", "'", "node", "\\u", "pk", "'_", "\\u\\u\\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_", "Node", "Edit", "View_", "(_", "Node", "Sing", "le", "Object", "Mixin_", ",_", "Authorized", "Mixin_", ",_", "Det", "ail", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "only", " ", "Templa", "te", "View", " ", "in", " ", "wid", "gy", ":", " ", "The", " ", "interface", " ", "for", " ", "popp", "ed", " ", "out", " ", "node", " ", "editin", "g", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "name_", "=_", "'", "wid", "gy", "/", "views", "/", "edit", "\\u", "node", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Edit", "View_", "(_", "Node", "Sing", "le", "Object", "Mixin_", ",_", "Authorized", "Mixin_", ",_", "Det", "ail", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "context", "\\u", "data_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "change", "\\u", "permission_", "(_", "self_", "._", "request_", ",_", "self_", "._", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "edit", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kwargs_", "=_", "super_", "(_", "Node", "Edit", "View_", ",_", "self_", ")_", "._", "get", "\\u", "context", "\\u", "data_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "object_", "._", "prefetch", "\\u", "tree_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kwargs_", "._", "update_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "html", "\\u", "id_", "=_", "'", "node", "\\u", "%", "s", "'_", "%_", "(_", "self_", "._", "object_", "._", "pk_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node", "\\u", "dict_", "=_", "self_", "._", "object_", "._", "to", "\\u", "json_", "(_", "self_", "._", "site_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "url_", "=_", "reverse_", "(_", "self_", "._", "site_", "._", "node", "\\u", "view_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "site_", "=_", "self_", "._", "site_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "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_", "Node", "Templa", "tes", "View_", "(_", "Node", "Sing", "le", "Object", "Mixin_", ",_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", "s", " ", "the", " ", "dynami", "c", " ", "[", "need", "ing", " ", "request", "]", " ", "template", "s", " ", "for", " ", "a", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Templa", "tes", "View_", "(_", "Node", "Sing", "le", "Object", "Mixin_", ",_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "self_", "._", "object_", "=_", "self_", "._", "get", "\\u", "object_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "change", "\\u", "permission_", "(_", "request_", ",_", "node_", "._", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "edit", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "to", "\\u", "response_", "(_", "node_", "._", "content_", "._", "get", "\\u", "templates_", "(_", "request_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Parent", "s", "View_", "(_", "Node", "Sing", "le", "Object", "Mixin_", ",_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Give", "n", " ", "a", " ", "node", ",", " ", "where", " ", "in", " ", "its", " ", "tree", " ", "can", " ", "it", " ", "be", " ", "moved", "?", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Parent", "s", "View_", "(_", "Node", "Sing", "le", "Object", "Mixin_", ",_", "Wid", "gy", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get_", "(_", "self_", ",_", "request_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "self_", "._", "object_", "=_", "self_", "._", "get", "\\u", "object_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "site_", "._", "has", "\\u", "change", "\\u", "permission_", "(_", "request_", ",_", "node_", "._", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Permi", "ssion", "Denied_", "(_", "\\u_", "(_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "permissi", "on", " ", "to", " ", "move", " ", "this", " ", "widget", ".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "node_", "._", "prefetch", "\\u", "tree_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "possib", "le", "\\u", "parents_", "=_", "node_", "._", "possib", "le", "\\u", "parents_", "(_", "self_", "._", "site_", ",_", "node_", "._", "get", "\\u", "root_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "render", "\\u", "to", "\\u", "response_", "(_", "[_", "i_", "._", "get", "\\u", "api", "\\u", "url_", "(_", "self_", "._", "site_", ")_", "for_", "i_", "in_", "possib", "le", "\\u", "parents_", "]_", ")_" ]
[ 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, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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 ]
Unused import
saga-project/BigJob/bigjob/__init__.py
[ { "content": "import os\nimport sys\nimport logging\nimport traceback\nversion = \"latest\"\n\n#from pkg_resources import Requirement, resource_filename\n\n#READ config\n\ntry:\n import ConfigParser\n _CONFIG_FILE=\"bigjob.conf\"\n _conf_file = os.path.dirname(os.path.abspath( __file__ )) + \"/../\" + _CONFIG_FILE\n if not os.path.exists(_conf_file):\n _conf_file = os.path.join(sys.prefix, _CONFIG_FILE)\n \n \n #print \"using conf file: \" + str(_conf_file)\n\n _config = ConfigParser.ConfigParser()\n _config.read(_conf_file)\n default_dict = _config.defaults()\n \n ####################################################\n # logging\n logging_level = logging.FATAL\n BIGJOB_VERBOSE=None\n try: \n BIGJOB_VERBOSE = int(os.getenv('BIGJOB_VERBOSE'))\n #print(\"BIGJOB_VERBOSE: %d\"%BIGJOB_VERBOSE)\n except Exception:\n pass \n \n if BIGJOB_VERBOSE==None: # use logging level defined in config file\n #print \"Read log level from bigjob.conf\"\n level = default_dict[\"logging.level\"]\n #print(\"Logging level: %s\"%level) \n if level.startswith(\"logging.\"):\n logging_level = eval(level) \n else:\n # 4 = DEBUG + INFO + WARNING + ERROR\n if BIGJOB_VERBOSE >= 4:\n print \"set to DEBUG\"\n logging_level = logging.DEBUG\n # 3 = INFO + WARNING + ERROR\n elif BIGJOB_VERBOSE == 3:\n logging_level = logging.INFO\n # 2 = WARNING + ERROR \n elif BIGJOB_VERBOSE == 2:\n logging_level = logging.WARNING\n # 1 = ERROR ONLY\n elif BIGJOB_VERBOSE == 1:\n logging_level = logging.ERROR\n \n \n #print(\"Set logging level: %s\"%(logging_level))\n logging.basicConfig(datefmt='%m/%d/%Y %I:%M:%S %p',\n format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n logger = logging.getLogger(name='bigjob')\n \n #logger.basicConfig(datefmt='%m/%d/%Y %I:%M:%S %p',\n # format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')\n logger.setLevel(logging_level)\n \n paramiko_logger = logging.getLogger(name=\"paramiko.transport\")\n paramiko_logger.setLevel(logging.ERROR)\n #logging.basicConfig(level=logging_level) \n \nexcept:\n print(\"bigjob.conf could not be read\") \n exc_type, exc_value, exc_traceback = sys.exc_info()\n traceback.print_exc(limit=1, file=sys.stdout)\n \nimport socket\ntry:\n fn = os.path.join(os.path.dirname(os.path.abspath(__file__)), \"..\", 'VERSION')\n if not os.path.exists(fn):\n fn = os.path.join(sys.prefix, 'VERSION')\n #print \"Open Version file: \" + str(fn)\n version = open(fn).read().strip()\n logger.info(\"Loading BigJob version: \" + version + \" on \" + socket.gethostname())\nexcept IOError:\n pass\n\n\n\n# define external-facing API\nfrom bigjob.bigjob_manager import bigjob \nfrom bigjob.bigjob_manager import subjob\ntry:\n from bigjob.bigjob_manager import description\nexcept:\n pass\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from bigjob.bigjob_manager import bigjob ", "start_line": 88, "start_column": 0, "end_line": 88, "end_column": 40 }, { "span": "from bigjob.bigjob_manager import subjob", "start_line": 89, "start_column": 0, "end_line": 89, "end_column": 40 }, { "span": "from bigjob.bigjob_manager import description", "start_line": 91, "start_column": 4, "end_line": 91, "end_column": 49 } ]
[]
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_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "\"", "late", "st", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "from", " ", "pkg", "\\u", "resource", "s", " ", "import", " ", "Requirement", ",", " ", "resource", "\\u", "filename_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "READ", " ", "config_", "\\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 ", " _", "import_", "Config", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "CONFIG", "\\u", "FILE_", "=_", "\"", "big", "job", ".", "conf", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "conf", "\\u", "file_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "+_", "\"/.", "./", "\"_", "+_", "\\u", "CONFIG", "\\u", "FILE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "\\u", "conf", "\\u", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "conf", "\\u", "file_", "=_", "os_", "._", "path_", "._", "join_", "(_", "sys_", "._", "prefix_", ",_", "\\u", "CONFIG", "\\u", "FILE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "\"", "usi", "ng", " ", "conf", " ", "file", ":", " ", "\"", " ", "+", " ", "str", "(\\u", "conf", "\\u", "file", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "config_", "=_", "Config", "Parser_", "._", "Config", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "config_", "._", "read_", "(_", "\\u", "conf", "\\u", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "dict_", "=_", "\\u", "config_", "._", "defaults_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "logging_", "\\u\\u\\uNL\\u\\u\\u_", "logg", "ing", "\\u", "level_", "=_", "logging_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BIG", "JOB", "\\u", "VERBOSE_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "BIG", "JOB", "\\u", "VERBOSE_", "=_", "int_", "(_", "os_", "._", "getenv_", "(_", "'", "BIG", "JOB", "\\u", "VERBOS", "E", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(\"", "BIG", "JOB", "\\u", "VERBOS", "E", ":", " ", "%", "d", "\"%", "BIG", "JOB", "\\u", "VERBOS", "E", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "BIG", "JOB", "\\u", "VERBOSE_", "==_", "None_", ":_", "#", " ", "use", " ", "logg", "ing", " ", "level", " ", "defin", "ed", " ", "in", " ", "config", " ", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "\"", "Read", " ", "log", " ", "level", " ", "from", " ", "big", "job", ".", "conf", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "level_", "=_", "default", "\\u", "dict_", "[_", "\"", "logg", "ing", ".", "level", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(\"", "Log", "ging", " ", "level", ":", " ", "%", "s", "\"%", "level", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "if_", "level_", "._", "startswith_", "(_", "\"", "logg", "ing", ".\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logg", "ing", "\\u", "level_", "=_", "eval_", "(_", "level_", ")_", "\\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_", "#", " ", "4", " ", "=", " ", "DEBU", "G", " ", "+", " ", "INFO", " ", "+", " ", "WARN", "ING", " ", "+", " ", "ERROR_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "BIG", "JOB", "\\u", "VERBOSE_", ">=_", "4_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "set", " ", "to", " ", "DEBU", "G", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logg", "ing", "\\u", "level_", "=_", "logging_", "._", "DEBUG_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "3", " ", "=", " ", "INFO", " ", "+", " ", "WARN", "ING", " ", "+", " ", "ERROR_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "BIG", "JOB", "\\u", "VERBOSE_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logg", "ing", "\\u", "level_", "=_", "logging_", "._", "INFO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "2", " ", "=", " ", "WARN", "ING", " ", "+", " ", "ERROR", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "BIG", "JOB", "\\u", "VERBOSE_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logg", "ing", "\\u", "level_", "=_", "logging_", "._", "WARNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "1", " ", "=", " ", "ERROR", " ", "ONLY_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "BIG", "JOB", "\\u", "VERBOSE_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logg", "ing", "\\u", "level_", "=_", "logging_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "Set", " ", "logg", "ing", " ", "level", ":", " ", "%", "s", "\"%", "(", "logg", "ing", "\\u", "level", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logging_", "._", "basic", "Config_", "(_", "datefmt_", "=_", "'%", "m", "/", "%", "d", "/", "%", "Y", " ", "%", "I", ":", "%", "M", ":", "%", "S", " ", "%", "p", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "format_", "=_", "'%", "(", "asc", "time", ")", "s", " ", "-", " ", "%", "(", "name", ")", "s", " ", "-", " ", "%", "(", "level", "name", ")", "s", " ", "-", " ", "%", "(", "message", ")", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "name_", "=_", "'", "big", "job", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "logg", "er", ".", "basic", "Config", "(", "datef", "mt", "='", "%", "m", "/", "%", "d", "/", "%", "Y", " ", "%", "I", ":", "%", "M", ":", "%", "S", " ", "%", "p", "',", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "format", "='", "%", "(", "asc", "time", ")", "s", " ", "-", " ", "%", "(", "name", ")", "s", " ", "-", " ", "%", "(", "level", "name", ")", "s", " ", "-", " ", "%", "(", "message", ")", "s", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "set", "Level_", "(_", "logg", "ing", "\\u", "level_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "param", "iko", "\\u", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "name_", "=_", "\"", "param", "iko", ".", "transport", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param", "iko", "\\u", "logger_", "._", "set", "Level_", "(_", "logging_", "._", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "ing", ".", "basic", "Config", "(", "level", "=", "logg", "ing", "\\u", "level", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "big", "job", ".", "conf", " ", "coul", "d", " ", "not", " ", "be", " ", "read", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exc", "\\u", "type_", ",_", "exc", "\\u", "value_", ",_", "exc", "\\u", "traceback_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", "limit_", "=_", "1_", ",_", "file_", "=_", "sys_", "._", "stdout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fn_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ",_", "\"..\"_", ",_", "'", "VERSI", "ON", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fn_", "=_", "os_", "._", "path_", "._", "join_", "(_", "sys_", "._", "prefix_", ",_", "'", "VERSI", "ON", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "\"", "Open", " ", "Version", " ", "file", ":", " ", "\"", " ", "+", " ", "str", "(", "fn", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", "=_", "open_", "(_", "fn_", ")_", "._", "read_", "(_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "Load", "ing", " ", "Big", "Jo", "b", " ", "version", ":", " ", "\"_", "+_", "version_", "+_", "\"", " ", "on", " ", "\"_", "+_", "socket_", "._", "gethostname_", "(_", ")_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defin", "e", " ", "external", "-", "facing", " ", "API_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "big", "job_", "._", "big", "job", "\\u", "manager_", "import_", "big", "job_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "big", "job_", "._", "big", "job", "\\u", "manager_", "import_", "subj", "ob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "big", "job_", "._", "big", "job", "\\u", "manager_", "import_", "description_", "\\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\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Imprecise assert
rholder/retrying/test_retrying.py
[ { "content": " def test_random_sleep(self):\n r = Retrying(wait_random_min=1000, wait_random_max=2000)\n times = set()\n times.add(r.wait(1, 6546))\n times.add(r.wait(1, 6546))\n times.add(r.wait(1, 6546))\n times.add(r.wait(1, 6546))\n\n # this is kind of non-deterministic...\n self.assertTrue(len(times) > 1)\n for t in times:\n self.assertTrue(t >= 1000)\n self.assertTrue(t <= 2000)", "metadata": "root.TestWaitConditions.test_random_sleep", "header": "['class', 'TestWaitConditions', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 66 }, { "content": " def test_random_sleep_without_min(self):\n r = Retrying(wait_random_max=2000)\n times = set()\n times.add(r.wait(1, 6546))\n times.add(r.wait(1, 6546))\n times.add(r.wait(1, 6546))\n times.add(r.wait(1, 6546))\n\n # this is kind of non-deterministic...\n self.assertTrue(len(times) > 1)\n for t in times:\n self.assertTrue(t >= 0)\n self.assertTrue(t <= 2000)", "metadata": "root.TestWaitConditions.test_random_sleep_without_min", "header": "['class', 'TestWaitConditions', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 80 }, { "content": " def test_with_wait(self):\n start = current_time_ms()\n result = _retryable_test_with_wait(NoneReturnUntilAfterCount(5))\n t = current_time_ms() - start\n self.assertTrue(t >= 250)\n self.assertTrue(result)", "metadata": "root.TestDecoratorWrapper.test_with_wait", "header": "['class', 'TestDecoratorWrapper', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 316 }, { "content": " def test_with_stop_on_return_value(self):\n try:\n _retryable_test_with_stop(NoneReturnUntilAfterCount(5))\n self.fail(\"Expected RetryError after 3 attempts\")\n except RetryError as re:\n self.assertFalse(re.last_attempt.has_exception)\n self.assertEqual(3, re.last_attempt.attempt_number)\n self.assertTrue(re.last_attempt.value is None)\n print(re)", "metadata": "root.TestDecoratorWrapper.test_with_stop_on_return_value", "header": "['class', 'TestDecoratorWrapper', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 323 }, { "content": " def test_retry_if_exception_of_type(self):\n self.assertTrue(_retryable_test_with_exception_type_io(NoIOErrorAfterCount(5)))\n\n try:\n _retryable_test_with_exception_type_io(NoNameErrorAfterCount(5))\n self.fail(\"Expected NameError\")\n except NameError as n:\n self.assertTrue(isinstance(n, NameError))\n print(n)\n\n try:\n _retryable_test_with_exception_type_io_attempt_limit_wrap(NoIOErrorAfterCount(5))\n self.fail(\"Expected RetryError\")\n except RetryError as re:\n self.assertEqual(3, re.last_attempt.attempt_number)\n self.assertTrue(re.last_attempt.has_exception)\n self.assertTrue(re.last_attempt.value[0] is not None)\n self.assertTrue(isinstance(re.last_attempt.value[1], IOError))\n self.assertTrue(re.last_attempt.value[2] is not None)\n print(re)\n\n self.assertTrue(_retryable_test_with_exception_type_custom(NoCustomErrorAfterCount(5)))\n\n try:\n _retryable_test_with_exception_type_custom(NoNameErrorAfterCount(5))\n self.fail(\"Expected NameError\")\n except NameError as n:\n self.assertTrue(isinstance(n, NameError))\n print(n)\n\n try:\n _retryable_test_with_exception_type_custom_attempt_limit_wrap(NoCustomErrorAfterCount(5))\n self.fail(\"Expected RetryError\")\n except RetryError as re:\n self.assertEqual(3, re.last_attempt.attempt_number)\n self.assertTrue(re.last_attempt.has_exception)\n self.assertTrue(re.last_attempt.value[0] is not None)\n self.assertTrue(isinstance(re.last_attempt.value[1], CustomError))\n self.assertTrue(re.last_attempt.value[2] is not None)\n print(re)", "metadata": "root.TestDecoratorWrapper.test_retry_if_exception_of_type", "header": "['class', 'TestDecoratorWrapper', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 341 }, { "content": " def test_wrapped_exception(self):\n\n # base exception cases\n self.assertTrue(_retryable_test_with_exception_type_io_wrap(NoIOErrorAfterCount(5)))\n\n try:\n _retryable_test_with_exception_type_io_wrap(NoNameErrorAfterCount(5))\n self.fail(\"Expected RetryError\")\n except RetryError as re:\n self.assertTrue(isinstance(re.last_attempt.value[1], NameError))\n print(re)\n\n try:\n _retryable_test_with_exception_type_io_attempt_limit_wrap(NoIOErrorAfterCount(5))\n self.fail(\"Expected RetryError\")\n except RetryError as re:\n self.assertEqual(3, re.last_attempt.attempt_number)\n self.assertTrue(re.last_attempt.has_exception)\n self.assertTrue(re.last_attempt.value[0] is not None)\n self.assertTrue(isinstance(re.last_attempt.value[1], IOError))\n self.assertTrue(re.last_attempt.value[2] is not None)\n print(re)\n\n # custom error cases\n self.assertTrue(_retryable_test_with_exception_type_custom_wrap(NoCustomErrorAfterCount(5)))\n\n try:\n _retryable_test_with_exception_type_custom_wrap(NoNameErrorAfterCount(5))\n self.fail(\"Expected RetryError\")\n except RetryError as re:\n self.assertTrue(re.last_attempt.value[0] is not None)\n self.assertTrue(isinstance(re.last_attempt.value[1], NameError))\n self.assertTrue(re.last_attempt.value[2] is not None)\n print(re)\n\n try:\n _retryable_test_with_exception_type_custom_attempt_limit_wrap(NoCustomErrorAfterCount(5))\n self.fail(\"Expected RetryError\")\n except RetryError as re:\n self.assertEqual(3, re.last_attempt.attempt_number)\n self.assertTrue(re.last_attempt.has_exception)\n self.assertTrue(re.last_attempt.value[0] is not None)\n self.assertTrue(isinstance(re.last_attempt.value[1], CustomError))\n self.assertTrue(re.last_attempt.value[2] is not None)\n\n self.assertTrue(\"This is a Custom exception class\" in str(re.last_attempt.value[1]))\n print(re)", "metadata": "root.TestDecoratorWrapper.test_wrapped_exception", "header": "['class', 'TestDecoratorWrapper', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 382 } ]
[ { "span": "self.assertTrue(len(times) > 1)", "start_line": 75, "start_column": 8, "end_line": 75, "end_column": 39 }, { "span": "self.assertTrue(t >= 1000)", "start_line": 77, "start_column": 12, "end_line": 77, "end_column": 38 }, { "span": "self.assertTrue(t <= 2000)", "start_line": 78, "start_column": 12, "end_line": 78, "end_column": 38 }, { "span": "self.assertTrue(len(times) > 1)", "start_line": 89, "start_column": 8, "end_line": 89, "end_column": 39 }, { "span": "self.assertTrue(t >= 0)", "start_line": 91, "start_column": 12, "end_line": 91, "end_column": 35 }, { "span": "self.assertTrue(t <= 2000)", "start_line": 92, "start_column": 12, "end_line": 92, "end_column": 38 }, { "span": "self.assertTrue(t >= 250)", "start_line": 320, "start_column": 8, "end_line": 320, "end_column": 33 }, { "span": "self.assertTrue(re.last_attempt.value is None)", "start_line": 330, "start_column": 12, "end_line": 330, "end_column": 58 }, { "span": "self.assertTrue(re.last_attempt.value[0] is not None)", "start_line": 357, "start_column": 12, "end_line": 357, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[2] is not None)", "start_line": 359, "start_column": 12, "end_line": 359, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[0] is not None)", "start_line": 377, "start_column": 12, "end_line": 377, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[2] is not None)", "start_line": 379, "start_column": 12, "end_line": 379, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[0] is not None)", "start_line": 400, "start_column": 12, "end_line": 400, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[2] is not None)", "start_line": 402, "start_column": 12, "end_line": 402, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[0] is not None)", "start_line": 412, "start_column": 12, "end_line": 412, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[2] is not None)", "start_line": 414, "start_column": 12, "end_line": 414, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[0] is not None)", "start_line": 423, "start_column": 12, "end_line": 423, "end_column": 65 }, { "span": "self.assertTrue(re.last_attempt.value[2] is not None)", "start_line": 425, "start_column": 12, "end_line": 425, "end_column": 65 }, { "span": "self.assertTrue(\"This is a Custom exception class\" in str(re.last_attempt.value[1]))", "start_line": 427, "start_column": 12, "end_line": 427, "end_column": 96 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Wait", "Conditions", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "random", "\\u", "sleep_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "Retr", "ying", "_", "(_", "wait", "\\u", "random", "\\u", "min_", "=_", "1000_", ",_", "wait", "\\u", "random", "\\u", "max_", "=_", "2000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "kind", " ", "of", " ", "non", "-", "deterministic", "..._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "times_", ")_", ">_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", "in_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "t_", ">=_", "1000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "t_", "<=_", "2000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Wait", "Conditions", "_", "(_", "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", "random", "\\u", "sleep", "\\u", "with", "out", "\\u", "min_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "Retr", "ying", "_", "(_", "wait", "\\u", "random", "\\u", "max_", "=_", "2000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "._", "add_", "(_", "r_", "._", "wait_", "(_", "1_", ",_", "654", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "kind", " ", "of", " ", "non", "-", "deterministic", "..._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "times_", ")_", ">_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", "in_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "t_", ">=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "t_", "<=_", "2000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Decorat", "or", "Wrapper_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "with", "\\u", "wait_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "current", "\\u", "time", "\\u", "ms_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "wait_", "(_", "Non", "e", "Return", "Unti", "l", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "current", "\\u", "time", "\\u", "ms_", "(_", ")_", "-_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "t_", ">=_", "250_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Decorat", "or", "Wrapper_", "(_", "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", "stop", "\\u", "on", "\\u", "return", "\\u", "value_", "(_", "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 ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "stop_", "(_", "Non", "e", "Return", "Unti", "l", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", " ", "after", " ", "3", " ", "atte", "mpt", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "has", "\\u", "exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "3_", ",_", "re_", "._", "last", "\\u", "attempt_", "._", "atte", "mpt", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Decorat", "or", "Wrapper_", "(_", "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", "retr", "y", "\\u", "if", "\\u", "exception", "\\u", "of", "\\u", "type_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "io_", "(_", "No", "IO", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", ")_", "\\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 ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "io_", "(_", "No", "Name", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Name", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", "as_", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "n_", ",_", "Name", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "io", "\\u", "atte", "mpt", "\\u", "limit", "\\u", "wrap_", "(_", "No", "IO", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "3_", ",_", "re_", "._", "last", "\\u", "attempt_", "._", "atte", "mpt", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "has", "\\u", "exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "0_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ",_", "IO", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "2_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "custom_", "(_", "No", "Custom", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", ")_", "\\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 ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "custom_", "(_", "No", "Name", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Name", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", "as_", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "n_", ",_", "Name", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "custom", "\\u", "atte", "mpt", "\\u", "limit", "\\u", "wrap_", "(_", "No", "Custom", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "3_", ",_", "re_", "._", "last", "\\u", "attempt_", "._", "atte", "mpt", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "has", "\\u", "exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "0_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ",_", "Custom", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "2_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Decorat", "or", "Wrapper_", "(_", "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", "wrapp", "ed", "\\u", "exception_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "base", " ", "exception", " ", "cases_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "io", "\\u", "wrap_", "(_", "No", "IO", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", ")_", "\\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 ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "io", "\\u", "wrap_", "(_", "No", "Name", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ",_", "Name", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "io", "\\u", "atte", "mpt", "\\u", "limit", "\\u", "wrap_", "(_", "No", "IO", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "3_", ",_", "re_", "._", "last", "\\u", "attempt_", "._", "atte", "mpt", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "has", "\\u", "exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "0_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ",_", "IO", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "2_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "custom", " ", "error", " ", "cases_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "custom", "\\u", "wrap_", "(_", "No", "Custom", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", ")_", "\\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 ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "custom", "\\u", "wrap_", "(_", "No", "Name", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "0_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ",_", "Name", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "2_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "retr", "yab", "le", "\\u", "test\\u", "with", "\\u", "exception", "\\u", "type", "\\u", "custom", "\\u", "atte", "mpt", "\\u", "limit", "\\u", "wrap_", "(_", "No", "Custom", "Error", "Af", "ter", "Count_", "(_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expect", "ed", " ", "Retr", "y", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Retr", "y", "Error_", "as_", "re_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "3_", ",_", "re_", "._", "last", "\\u", "attempt_", "._", "atte", "mpt", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "has", "\\u", "exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "0_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ",_", "Custom", "Error_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "2_", "]_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "Thi", "s", " ", "is", " ", "a", " ", "Custom", " ", "exception", " ", "class", "\"_", "in_", "str_", "(_", "re_", "._", "last", "\\u", "attempt_", "._", "value_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "re_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 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, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2 ]
Unused local variable
Julian/PyVi/pyvi/window.py
[ { "content": " def insert(self, window, first_line, *lines):\n row, column = cursor = self.cursors[window]\n left, right = self[row][:column], self[row][column:]\n added = len(lines)\n\n if lines:\n last_line = lines[-1]\n column = len(last_line)\n else:\n last_line = first_line\n column += len(first_line)\n\n self[row] = left + first_line\n self[row + 1: row + 1] = lines\n self[row + added] += right\n\n for other in self.cursors.itervalues():\n if other.row > row:\n other._row += added\n\n cursor.coords = row + added, column", "metadata": "root.Buffer.insert", "header": "['class', 'Buffer', '(', 'object', ')', ':', '___EOS___']", "index": 163 } ]
[ { "span": "last_line ", "start_line": 172, "start_column": 12, "end_line": 172, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Buffer_", "(_", "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_", "insert_", "(_", "self_", ",_", "window_", ",_", "first", "\\u", "line_", ",_", "*_", "lines_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", ",_", "column_", "=_", "cursor_", "=_", "self_", "._", "cursors", "_", "[_", "window_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "left_", ",_", "right_", "=_", "self_", "[_", "row_", "]_", "[_", ":_", "column_", "]_", ",_", "self_", "[_", "row_", "]_", "[_", "column_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "added_", "=_", "len_", "(_", "lines_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "\\u", "line_", "=_", "lines_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "column_", "=_", "len_", "(_", "last", "\\u", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "\\u", "line_", "=_", "first", "\\u", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "column_", "+=_", "len_", "(_", "first", "\\u", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "[_", "row_", "]_", "=_", "left_", "+_", "first", "\\u", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "[_", "row_", "+_", "1_", ":_", "row_", "+_", "1_", "]_", "=_", "lines_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "[_", "row_", "+_", "added_", "]_", "+=_", "right_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "other_", "in_", "self_", "._", "cursors", "_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "other_", "._", "row_", ">_", "row_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "other_", "._", "\\u", "row_", "+=_", "added_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cursor_", "._", "coords_", "=_", "row_", "+_", "added_", ",_", "column_", "\\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, 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 ]
Imprecise assert
adafruit/io-client-python/tests/test_client.py
[ { "content": " def test_feeds_returns_all_feeds(self):\n io = self.get_client()\n io.send('TestFeed', 1) # Make sure TestFeed exists.\n feeds = io.feeds()\n self.assertGreaterEqual(len(feeds), 1)\n names = set(map(lambda x: x.name, feeds))\n self.assertTrue('TestFeed' in names)", "metadata": "root.TestClient.test_feeds_returns_all_feeds", "header": "['class', 'TestClient', '(', 'base', '.', 'IOTestCase', ')', ':', '___NEWLINE___', '___NL___', \"# If your IP isn't put on the list of non-throttled IPs, uncomment the\", '___NL___', '# function below to waste time between tests to prevent throttling.', '___NL___', '#def tearDown(self):', '___NL___', '# time.sleep(30.0)', '___NL___', '___EOS___']", "index": 141 }, { "content": " def test_groups_returns_all_groups(self):\n io = self.get_client()\n groups = io.groups()\n self.assertGreaterEqual(len(groups), 1)\n names = set(map(lambda x: x.name, groups))\n self.assertTrue('GroupTest' in names)", "metadata": "root.TestClient.test_groups_returns_all_groups", "header": "['class', 'TestClient', '(', 'base', '.', 'IOTestCase', ')', ':', '___NEWLINE___', '___NL___', \"# If your IP isn't put on the list of non-throttled IPs, uncomment the\", '___NL___', '# function below to waste time between tests to prevent throttling.', '___NL___', '#def tearDown(self):', '___NL___', '# time.sleep(30.0)', '___NL___', '___EOS___']", "index": 218 } ]
[ { "span": "self.assertTrue('TestFeed' in names)", "start_line": 147, "start_column": 8, "end_line": 147, "end_column": 44 }, { "span": "self.assertTrue('GroupTest' in names)", "start_line": 223, "start_column": 8, "end_line": 223, "end_column": 45 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Client_", "(_", "base_", "._", "IO", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "your", " ", "IP", " ", "isn", "'", "t", " ", "put", " ", "on", " ", "the", " ", "list", " ", "of", " ", "non", "-", "throttle", "d", " ", "IP", "s", ",", " ", "uncomm", "ent", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "function", " ", "belo", "w", " ", "to", " ", "wast", "e", " ", "time", " ", "bet", "ween", " ", "tests", " ", "to", " ", "prevent", " ", "thro", "ttl", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "def", " ", "tear", "Down", "(", "self", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "time", ".", "sleep", "(", "30.", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "feed", "s", "\\u", "return", "s", "\\u", "all", "\\u", "feeds_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "io_", "=_", "self_", "._", "get", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "io_", "._", "send_", "(_", "'", "Test", "Feed", "'_", ",_", "1_", ")_", "#", " ", "Make", " ", "sure", " ", "Test", "Feed", " ", "exist", "s", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feeds_", "=_", "io_", "._", "feeds_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Great", "er", "Equal_", "(_", "len_", "(_", "feeds_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "names_", "=_", "set_", "(_", "map_", "(_", "lambda_", "x_", ":_", "x_", "._", "name_", ",_", "feeds_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "Test", "Feed", "'_", "in_", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Client_", "(_", "base_", "._", "IO", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "your", " ", "IP", " ", "isn", "'", "t", " ", "put", " ", "on", " ", "the", " ", "list", " ", "of", " ", "non", "-", "throttle", "d", " ", "IP", "s", ",", " ", "uncomm", "ent", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "function", " ", "belo", "w", " ", "to", " ", "wast", "e", " ", "time", " ", "bet", "ween", " ", "tests", " ", "to", " ", "prevent", " ", "thro", "ttl", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "def", " ", "tear", "Down", "(", "self", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "time", ".", "sleep", "(", "30.", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "group", "s", "\\u", "return", "s", "\\u", "all", "\\u", "groups_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "io_", "=_", "self_", "._", "get", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "groups_", "=_", "io_", "._", "groups_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Great", "er", "Equal_", "(_", "len_", "(_", "groups_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "names_", "=_", "set_", "(_", "map_", "(_", "lambda_", "x_", ":_", "x_", "._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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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Wrong number of arguments in a class instantiation
9miao/Firefly/firefly/dbentrust/dbutils.py
[ { "content": "class SQLQuery(object):\n \"\"\"\n You can pass this sort of thing as a clause in any db function.\n Otherwise, you can pass a dictionary to the keyword argument `vars`\n and the function will call reparam for you.\n\n Internally, consists of `items`, which is a list of strings and\n SQLParams, which get concatenated to produce the actual query.\n \"\"\"\n __slots__ = [\"items\"]\n\n # tested in sqlquote's docstring\n\n\n\n\n\n \n \n \n \n join = staticmethod(join)\n \n \n \n", "metadata": "root.SQLQuery", "header": "['module', '___EOS___']", "index": 286 }, { "content": " def __init__(self, items=None):\n r\"\"\"Creates a new SQLQuery.\n \n >>> SQLQuery(\"x\")\n <sql: 'x'>\n >>> q = SQLQuery(['SELECT * FROM ', 'test', ' WHERE x=', SQLParam(1)])\n >>> q\n <sql: 'SELECT * FROM test WHERE x=1'>\n >>> q.query(), q.values()\n ('SELECT * FROM test WHERE x=%s', [1])\n >>> SQLQuery(SQLParam(1))\n <sql: '1'>\n \"\"\"\n if items is None:\n self.items = []\n elif isinstance(items, list):\n self.items = items\n elif isinstance(items, SQLParam):\n self.items = [items]\n elif isinstance(items, SQLQuery):\n self.items = list(items.items)\n else:\n self.items = [items]\n \n # Take care of SQLLiterals\n for i, item in enumerate(self.items):\n if isinstance(item, SQLParam) and isinstance(item.value, SQLLiteral):\n self.items[i] = item.value.v", "metadata": "root.SQLQuery.__init__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 298 }, { "content": " def append(self, value):\n self.items.append(value)", "metadata": "root.SQLQuery.append", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 327 }, { "content": " def __add__(self, other):\n if isinstance(other, basestring):\n items = [other]\n elif isinstance(other, SQLQuery):\n items = other.items\n else:\n return NotImplemented\n return SQLQuery(self.items + items)", "metadata": "root.SQLQuery.__add__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 330 }, { "content": " def __radd__(self, other):\n if isinstance(other, basestring):\n items = [other]\n else:\n return NotImplemented\n \n return SQLQuery(items + self.items)", "metadata": "root.SQLQuery.__radd__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 339 }, { "content": " def __iadd__(self, other):\n if isinstance(other, (basestring, SQLParam)):\n self.items.append(other)\n elif isinstance(other, SQLQuery):\n self.items.extend(other.items)\n else:\n return NotImplemented\n return self", "metadata": "root.SQLQuery.__iadd__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 347 }, { "content": " def __len__(self):\n return len(self.query())", "metadata": "root.SQLQuery.__len__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 356 }, { "content": " def query(self, paramstyle=None):\n \"\"\"\n Returns the query part of the sql query.\n >>> q = SQLQuery([\"SELECT * FROM test WHERE name=\", SQLParam('joe')])\n >>> q.query()\n 'SELECT * FROM test WHERE name=%s'\n >>> q.query(paramstyle='qmark')\n 'SELECT * FROM test WHERE name=?'\n \"\"\"\n s = []\n for x in self.items:\n if isinstance(x, SQLParam):\n x = x.get_marker(paramstyle)\n s.append(safestr(x))\n else:\n x = safestr(x)\n # automatically escape % characters in the query\n # For backward compatability, ignore escaping when the query looks already escaped\n if paramstyle in ['format', 'pyformat']:\n if '%' in x and '%%' not in x:\n x = x.replace('%', '%%')\n s.append(x)\n return \"\".join(s)", "metadata": "root.SQLQuery.query", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 359 }, { "content": " def values(self):\n \"\"\"\n Returns the values of the parameters used in the sql query.\n >>> q = SQLQuery([\"SELECT * FROM test WHERE name=\", SQLParam('joe')])\n >>> q.values()\n ['joe']\n \"\"\"\n return [i.value for i in self.items if isinstance(i, SQLParam)]", "metadata": "root.SQLQuery.values", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 383 }, { "content": " def join(items, sep=' ', prefix=None, suffix=None, target=None):\n \"\"\"\n Joins multiple queries.\n \n >>> SQLQuery.join(['a', 'b'], ', ')\n <sql: 'a, b'>\n\n Optinally, prefix and suffix arguments can be provided.\n\n >>> SQLQuery.join(['a', 'b'], ', ', prefix='(', suffix=')')\n <sql: '(a, b)'>\n\n If target argument is provided, the items are appended to target instead of creating a new SQLQuery.\n \"\"\"\n if target is None:\n target = SQLQuery()\n\n target_items = target.items\n\n if prefix:\n target_items.append(prefix)\n\n for i, item in enumerate(items):\n if i != 0:\n target_items.append(sep)\n if isinstance(item, SQLQuery):\n target_items.extend(item.items)\n else:\n target_items.append(item)\n\n if suffix:\n target_items.append(suffix)\n return target", "metadata": "root.SQLQuery.join", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 392 }, { "content": " def _str(self):\n try:\n return self.query() % tuple([sqlify(x) for x in self.values()]) \n except (ValueError, TypeError):\n return self.query()", "metadata": "root.SQLQuery._str", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 428 }, { "content": " def __str__(self):\n return safestr(self._str())", "metadata": "root.SQLQuery.__str__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 434 }, { "content": " def __unicode__(self):\n return safeunicode(self._str())", "metadata": "root.SQLQuery.__unicode__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 437 }, { "content": " def __repr__(self):\n return '<sql: %s>' % repr(str(self))", "metadata": "root.SQLQuery.__repr__", "header": "['class', 'SQLQuery', '(', 'object', ')', ':', '___EOS___']", "index": 440 }, { "content": " def gen_clause(self, sql, val, svars): \n if isinstance(val, (int, long)):\n if sql == 'WHERE':\n nout = 'id = ' + sqlquote(val)\n else:\n nout = SQLQuery(val)\n \n elif isinstance(val, (list, tuple)) and len(val) == 2:\n nout = SQLQuery(val[0], val[1]) # backwards-compatibility\n elif isinstance(val, SQLQuery):\n nout = val\n else:\n nout = reparam(val, svars)\n\n def xjoin(a, b):\n if a and b: return a + ' ' + b\n else: return a or b\n\n return xjoin(sql, nout)", "metadata": "root.SQLProducer.gen_clause", "header": "['class', 'SQLProducer', ':', '___EOS___']", "index": 497 }, { "content": " def _where(self, where, svars): \n if isinstance(where, (int, long)):\n where = \"id = \" + sqlparam(where)\n elif isinstance(where, (list, tuple)) and len(where) == 2:\n where = SQLQuery(where[0], where[1])\n elif isinstance(where, SQLQuery):\n pass\n else:\n where = reparam(where, svars) \n return where", "metadata": "root.SQLProducer._where", "header": "['class', 'SQLProducer', ':', '___EOS___']", "index": 517 } ]
[ { "span": "SQLQuery(val[0], val[1]) ", "start_line": 505, "start_column": 19, "end_line": 505, "end_column": 43 }, { "span": "SQLQuery(where[0], where[1])", "start_line": 521, "start_column": 20, "end_line": 521, "end_column": 48 } ]
[ { "span": "def __init__(self, items=None):", "start_line": 298, "start_column": 4, "end_line": 298, "end_column": 35 } ]
1
false
[ "[CLS]_", "Wro", "ng_", "number_", "of_", "arguments_", "in_", "a_", "class_", "instantiation", "_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "You", " ", "can", " ", "pass", " ", "this", " ", "sort", " ", "of", " ", "thing", " ", "as", " ", "a", " ", "clause", " ", "in", " ", "any", " ", "db", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "Ot", "her", "wis", "e", ",", " ", "you", " ", "can", " ", "pass", " ", "a", " ", "dictionar", "y", " ", "to", " ", "the", " ", "keyw", "ord", " ", "argu", "ment", " ", "`", "vars", "`", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "the", " ", "function", " ", "will", " ", "call", " ", "repar", "am", " ", "for", " ", "you", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Intern", "ally", ",", " ", "consi", "sts", " ", "of", " ", "`", "items", "`", ",", " ", "whi", "ch", " ", "is", " ", "a", " ", "list", " ", "of", " ", "string", "s", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "SQL", "Param", "s", ",", " ", "whi", "ch", " ", "get", " ", "concatenated", " ", "to", " ", "produce", " ", "the", " ", "actual", " ", "query", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "slots\\u\\u_", "=_", "[_", "\"", "items", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tested", " ", "in", " ", "sql", "quote", "'", "s", " ", "docstring_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "join_", "=_", "staticmethod_", "(_", "join_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "items_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r", "\"\"\"", "Creat", "es", " ", "a", " ", "new", " ", "SQL", "Query", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "SQL", "Query", "(\"", "x", "\")", "\\", "10", ";", " ", " ", " ", " ", "<", "sql", ":", " ", "'", "x", "'>", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", " ", "=", " ", "SQL", "Query", "([", "'", "SELECT", " ", "*", " ", "FROM", " ", "',", " ", "'", "test", "',", " ", "'", " ", "WHE", "RE", " ", "x", "='", ",", " ", "SQL", "Param", "(", "1", ")])", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", "\\", "10", ";", " ", " ", " ", " ", "<", "sql", ":", " ", "'", "SELECT", " ", "*", " ", "FROM", " ", "test", " ", "WHE", "RE", " ", "x", "=", "1", "'>", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", ".", "query", "()", ",", " ", "q", ".", "values", "()", "\\", "10", ";", " ", " ", " ", " ", "('", "SELECT", " ", "*", " ", "FROM", " ", "test", " ", "WHE", "RE", " ", "x", "=", "%", "s", "',", " ", "[", "1", "])", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "SQL", "Query", "(", "SQL", "Param", "(", "1", "))\\", "10", ";", " ", " ", " ", " ", "<", "sql", ":", " ", "'", "1", "'>", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "items_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "items_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "=_", "items_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "items_", ",_", "SQL", "Param_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "=_", "[_", "items_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "items_", ",_", "SQL", "Query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "=_", "list_", "(_", "items_", "._", "items_", ")_", "\\u\\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_", "._", "items_", "=_", "[_", "items_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tak", "e", " ", "care", " ", "of", " ", "SQL", "Lite", "ral", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", ",_", "item_", "in_", "enumerate_", "(_", "self_", "._", "items_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "item_", ",_", "SQL", "Param_", ")_", "and_", "isinstance_", "(_", "item_", "._", "value_", ",_", "SQL", "Literal_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "[_", "i_", "]_", "=_", "item_", "._", "value_", "._", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "append_", "(_", "self_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\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 ", " _", "if_", "isinstance_", "(_", "other_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "items_", "=_", "[_", "other_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "other_", ",_", "SQL", "Query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "items_", "=_", "other_", "._", "items_", "\\u\\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_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "SQL", "Query_", "(_", "self_", "._", "items_", "+_", "items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "rad", "d\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "other_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "items_", "=_", "[_", "other_", "]_", "\\u\\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_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "SQL", "Query_", "(_", "items_", "+_", "self_", "._", "items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iad", "d\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "other_", ",_", "(_", "basestring_", ",_", "SQL", "Param_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "._", "append_", "(_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "other_", ",_", "SQL", "Query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "items_", "._", "extend_", "(_", "other_", "._", "items_", ")_", "\\u\\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_", "Not", "Implemented_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "len\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "query_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "query_", "(_", "self_", ",_", "params", "tyle_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "query", " ", "part", " ", "of", " ", "the", " ", "sql", " ", "query", ".", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", " ", "=", " ", "SQL", "Query", "([", "\"", "SELECT", " ", "*", " ", "FROM", " ", "test", " ", "WHE", "RE", " ", "name", "=\"", ",", " ", "SQL", "Param", "('", "jo", "e", "')]", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", ".", "query", "()", "\\", "10", ";", " ", " ", " ", " ", "'", "SELECT", " ", "*", " ", "FROM", " ", "test", " ", "WHE", "RE", " ", "name", "=", "%", "s", "'", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", ".", "query", "(", "params", "tyl", "e", "='", "qma", "rk", "')", "\\", "10", ";", " ", " ", " ", " ", "'", "SELECT", " ", "*", " ", "FROM", " ", "test", " ", "WHE", "RE", " ", "name", "=?", "'", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "self_", "._", "items_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "x_", ",_", "SQL", "Param_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "x_", "._", "get", "\\u", "marker_", "(_", "params", "tyle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "append_", "(_", "safe", "str_", "(_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "safe", "str_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "automati", "call", "y", " ", "escape", " ", "%", " ", "character", "s", " ", "in", " ", "the", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "back", "ward", " ", "compa", "tabi", "lit", "y", ",", " ", "ignore", " ", "esca", "ping", " ", "whe", "n", " ", "the", " ", "query", " ", "look", "s", " ", "alr", "ead", "y", " ", "escaped", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params", "tyle_", "in_", "[_", "'", "format", "'_", ",_", "'", "pyf", "ormat", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "'%'_", "in_", "x_", "and_", "'%%", "'_", "not_", "in_", "x_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "x_", "=_", "x_", "._", "replace_", "(_", "'%'_", ",_", "'%%", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "s_", "._", "append_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"\"_", "._", "join_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "values_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "values", " ", "of", " ", "the", " ", "parameter", "s", " ", "used", " ", "in", " ", "the", " ", "sql", " ", "query", ".", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", " ", "=", " ", "SQL", "Query", "([", "\"", "SELECT", " ", "*", " ", "FROM", " ", "test", " ", "WHE", "RE", " ", "name", "=\"", ",", " ", "SQL", "Param", "('", "jo", "e", "')]", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "q", ".", "values", "()", "\\", "10", ";", " ", " ", " ", " ", "['", "jo", "e", "']", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "i_", "._", "value_", "for_", "i_", "in_", "self_", "._", "items_", "if_", "isinstance_", "(_", "i_", ",_", "SQL", "Param_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "join_", "(_", "items_", ",_", "sep_", "=_", "'", " ", "'_", ",_", "prefix_", "=_", "None_", ",_", "suffix_", "=_", "None_", ",_", "target_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Join", "s", " ", "multiple", " ", "querie", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "SQL", "Query", ".", "join", "([", "'", "a", "',", " ", "'", "b", "']", ",", " ", "',", " ", "')", "\\", "10", ";", " ", " ", " ", " ", "<", "sql", ":", " ", "'", "a", ",", " ", "b", "'>", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Opt", "inal", "ly", ",", " ", "prefix", " ", "and", " ", "suff", "ix", " ", "argu", "ment", "s", " ", "can", " ", "be", " ", "provided", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "SQL", "Query", ".", "join", "([", "'", "a", "',", " ", "'", "b", "']", ",", " ", "',", " ", "',", " ", "prefix", "='", "('", ",", " ", "suff", "ix", "='", ")'", ")", "\\", "10", ";", " ", " ", " ", " ", "<", "sql", ":", " ", "'(", "a", ",", " ", "b", ")'", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "target", " ", "argu", "ment", " ", "is", " ", "provided", ",", " ", "the", " ", "items", " ", "are", " ", "append", "ed", " ", "to", " ", "target", " ", "inst", "ead", " ", "of", " ", "creati", "ng", " ", "a", " ", "new", " ", "SQL", "Query", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "target_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target_", "=_", "SQL", "Query_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "target", "\\u", "items_", "=_", "target_", "._", "items_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "prefix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "items_", "._", "append_", "(_", "prefix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", ",_", "item_", "in_", "enumerate_", "(_", "items_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "items_", "._", "append_", "(_", "sep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "item_", ",_", "SQL", "Query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "items_", "._", "extend_", "(_", "item_", "._", "items_", ")_", "\\u\\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", "\\u", "items_", "._", "append_", "(_", "item_", ")_", "\\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_", "suffix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "items_", "._", "append_", "(_", "suffix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "target_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "str_", "(_", "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_", "._", "query_", "(_", ")_", "%_", "tuple_", "(_", "[_", "sql", "ify_", "(_", "x_", ")_", "for_", "x_", "in_", "self_", "._", "values_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Value", "Error_", ",_", "Type", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "query_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "str\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "safe", "str_", "(_", "self_", "._", "\\u", "str_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "object_", ")_", ":_", "\\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_", "safe", "unicode_", "(_", "self_", "._", "\\u", "str_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Query_", "(_", "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_", "'<", "sql", ":", " ", "%", "s", ">'_", "%_", "repr_", "(_", "str_", "(_", "self_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Producer_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gen", "\\u", "clause_", "(_", "self_", ",_", "sql_", ",_", "val_", ",_", "sv", "ars_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "val_", ",_", "(_", "int_", ",_", "long_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sql_", "==_", "'", "WHE", "RE", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nou", "t_", "=_", "'", "id", " ", "=", " ", "'_", "+_", "sql", "quote_", "(_", "val_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nou", "t_", "=_", "SQL", "Query_", "(_", "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_", "elif_", "isinstance_", "(_", "val_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", "and_", "len_", "(_", "val_", ")_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nou", "t_", "=_", "SQL", "Query_", "(_", "val_", "[_", "0_", "]_", ",_", "val_", "[_", "1_", "]_", ")_", "#", " ", "back", "ward", "s", "-", "compatibility", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "val_", ",_", "SQL", "Query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nou", "t_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nou", "t_", "=_", "repar", "am_", "(_", "val_", ",_", "sv", "ars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "xj", "oin", "_", "(_", "a_", ",_", "b_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "a_", "and_", "b_", ":_", "return_", "a_", "+_", "'", " ", "'_", "+_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "return_", "a_", "or_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "xj", "oin", "_", "(_", "sql_", ",_", "nou", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SQL", "Producer_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "where_", "(_", "self_", ",_", "where_", ",_", "sv", "ars_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "where_", ",_", "(_", "int_", ",_", "long_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "where_", "=_", "\"", "id", " ", "=", " ", "\"_", "+_", "sql", "param_", "(_", "where_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "where_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", "and_", "len_", "(_", "where_", ")_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "where_", "=_", "SQL", "Query_", "(_", "where_", "[_", "0_", "]_", ",_", "where_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "where_", ",_", "SQL", "Query_", ")_", ":_", "\\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 ", " _", "where_", "=_", "repar", "am_", "(_", "where_", ",_", "sv", "ars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "where_", "\\u\\u\\uNEWLINE\\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, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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 ]
Except block handles 'BaseException'
gregbayer/logcatcher/tornado/catch_logs.py
[ { "content": "\nimport tornado.httpserver\nimport tornado.ioloop\nimport tornado.web\n\nimport sys\nfrom scribe import scribe\nfrom thrift.transport import TTransport, TSocket\nfrom thrift.protocol import TBinaryProtocol\n\nimport logging\nimport hmac\nimport hashlib\nimport base64\nimport urllib\nimport socket\nimport traceback\nimport simplejson\nimport re\n\n'''\nLog Catcher: receives put request and sends them to scribe.\n\nExample endpoint:\nhttp://<your_server_dns_name_or_ip>:8080/put_logs?category=application1&message=this%20is%20a%20test&hash=RWPzriPjiX202eF3LbCb0xB5zIw=\n'''\n\nLOGGING_SHARED_SECRET = \"<your logging secret key>\"\nSERVER_HOSTNAME = \"none\"\ntry:\n SERVER_HOSTNAME = socket.gethostbyname(socket.gethostname())\nexcept:\n pass\nlogging.basicConfig(level=logging.WARN)\n\n\nscribe_transport = None\nscribe_client = None\n\nSCRIBE_HOST = '127.0.0.1'\nSCRIBE_PORT = 1463\n\n# Init scribe\nsocket = TSocket.TSocket(host=SCRIBE_HOST, port=int(SCRIBE_PORT))\nscribe_transport = TTransport.TFramedTransport(socket)\nprotocol = TBinaryProtocol.TBinaryProtocol(trans=scribe_transport, strictRead=False, strictWrite=False)\nscribe_client = scribe.Client(iprot=protocol, oprot=protocol)\n\n\n\n\n########################\n# Register Handlers\n########################\n\n\n\n######################## \n# Scribe\n########################\n\n\n\n\n\n\napplication = tornado.web.Application([\n (r\"/put_logs\", LogCatcherHandler),\n (r\"/index.html\", HeartbeatHandler),\n ])\n\nif __name__ == \"__main__\":\n http_server = tornado.httpserver.HTTPServer(application)\n http_server.listen(8080)\n tornado.ioloop.IOLoop.instance().start()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def get_params_and_process_message(self):\n try:\n# logging.info(\"get_params_and_call_scribe()\")\n try:\n self.category = self.get_argument('category')\n except:\n message = None\n try: message = self.get_argument('message').encode(\"utf-8\")\n except: pass\n logging.error(\"Category argument missing. Message was: \" + str(message))\n \n self.message = self.get_argument('message').encode(\"utf-8\")\n self.hash = self.get_argument('hash').replace(' ', '+')\n \n if not self.category or not self.message or not self.hash:\n self.write(\"Error: Must contain category and message and hash.<br>\\n\")\n logging.error(\"Must contain category and message and hash.\")\n return\n \n message_for_hash = self.message\n \n # Calc valid hash\n digest = hmac.new(LOGGING_SHARED_SECRET, message_for_hash, hashlib.sha1).digest()\n calculated_hash = base64.encodestring(digest)\n \n # Test if hash matches\n hash_matches = (self.hash[:28] == calculated_hash[:28])\n \n if hash_matches:\n self.write(\"hash matched, logging to scribe.<br>\\n\")\n# logging.info(\"hash matched, logging to scribe.\")\n forward_message(self.category, self.message)\n else:\n self.write(\"nothing was logged.<br>\\n\")\n# logging.warn(\"last char: \" + str(ord(self.message[len(self.message)-1])))\n logging.warn(\"calculated hash = \" + str(calculated_hash))\n logging.warn(\" provided hash = \" + str(self.hash))\n logging.warn(\"hash_matches: \" + str(hash_matches))\n try:\n logging.warn(\"nothing was logged. message[0:500]: \" + self.message[:500])\n except:\n logging.warn(\"nothing was logged.\")\n except:\n logging.error(\"Error processing request.\")\n traceback.print_exc()", "metadata": "root.LogCatcherHandler.get_params_and_process_message", "header": "['class', 'LogCatcherHandler', '(', 'tornado', '.', 'web', '.', 'RequestHandler', ')', ':', '___EOS___']", "index": 60 }, { "content": "def send_records_to_scribe(category, message):\n try:\n global scribe_transport\n global scribe_client\n \n if not scribe_transport or not scribe_client:\n # Re-init scribe\n logging.warn(\"Had to re-init scribe\")\n socket = TSocket.TSocket(host=SCRIBE_HOST, port=int(SCRIBE_PORT))\n scribe_transport = TTransport.TFramedTransport(socket)\n protocol = TBinaryProtocol.TBinaryProtocol(trans=scribe_transport, strictRead=False, strictWrite=False)\n scribe_client = scribe.Client(iprot=protocol, oprot=protocol)\n \n scribe_transport.open()\n \n lines = message.split(\"\\n\")\n log_entries = []\n for line in lines:\n log_entry = scribe.LogEntry(category=category, message=line)\n log_entries.append(log_entry)\n \n result = scribe_client.Log(messages=log_entries)\n \n scribe_transport.close()\n \n if result == scribe.ResultCode.OK:\n pass\n elif result == scribe.ResultCode.TRY_LATER:\n logging.error(\"TRY_LATER. Result: \" + str(result))\n else:\n logging.error(\"Unknown error code.\" + str(result))\n except:\n logging.error(\"Error sending records to scribe.\")\n traceback.print_exc()", "metadata": "root.send_records_to_scribe", "header": "['module', '___EOS___']", "index": 120 } ]
[ { "span": "except:", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 7 }, { "span": "except:", "start_line": 65, "start_column": 12, "end_line": 65, "end_column": 19 }, { "span": "except: ", "start_line": 68, "start_column": 16, "end_line": 68, "end_column": 23 }, { "span": "except:", "start_line": 100, "start_column": 16, "end_line": 100, "end_column": 23 }, { "span": "except:", "start_line": 102, "start_column": 8, "end_line": 102, "end_column": 15 }, { "span": "except:", "start_line": 151, "start_column": 4, "end_line": 151, "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_", "import_", "tornado_", "._", "https", "erver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tornado_", "._", "ioloop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tornado_", "._", "web_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "scri", "be_", "import_", "scri", "be_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "thrift", "_", "._", "transport_", "import_", "TT", "rans", "port_", ",_", "TS", "ocket", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "thrift", "_", "._", "protocol_", "import_", "TB", "inary", "Protocol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hmac_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "simplejson_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", "Log", " ", "Catch", "er", ":", " ", "receive", "s", " ", "put", " ", "request", " ", "and", " ", "send", "s", " ", "them", " ", "to", " ", "scri", "be", ".", "\\", "10", ";", "\\", "10", ";", "Exam", "ple", " ", "endpoint", ":", "\\", "10", ";", "http", "://", "<", "your", "\\u", "server", "\\u", "dns", "\\u", "name", "\\u", "or", "\\u", "ip", ">:", "808", "0", "/", "put", "\\u", "logs", "?", "category", "=", "applica", "tion", "1", "&", "message", "=", "this", "%", "20", "is", "%", "20", "a", "%", "20", "test", "&", "hash", "=", "RW", "P", "zr", "i", "Pj", "i", "X", "202", "e", "F3", "Lb", "Cb", "0xB", "5", "z", "I", "w", "=", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "LOGGING", "\\u", "SHARED", "\\u", "SECRET_", "=_", "\"<", "your", " ", "logg", "ing", " ", "secret", " ", "key", ">\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SERVER", "\\u", "HOSTNAME", "_", "=_", "\"", "none", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SERVER", "\\u", "HOSTNAME", "_", "=_", "socket_", "._", "gethostbyname", "_", "(_", "socket_", "._", "gethostname_", "(_", ")_", ")_", "\\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_", "logging_", "._", "basic", "Config_", "(_", "level_", "=_", "logging_", "._", "WARN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "scri", "be", "\\u", "transport_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scri", "be", "\\u", "client_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SCR", "IB", "E", "\\u", "HOST_", "=_", "'", "127", ".0", ".0", ".1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SCR", "IB", "E", "\\u", "PORT_", "=_", "146", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ini", "t", " ", "scri", "be_", "\\u\\u\\uNL\\u\\u\\u_", "socket_", "=_", "TS", "ocket", "_", "._", "TS", "ocket", "_", "(_", "host_", "=_", "SCR", "IB", "E", "\\u", "HOST_", ",_", "port_", "=_", "int_", "(_", "SCR", "IB", "E", "\\u", "PORT_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scri", "be", "\\u", "transport_", "=_", "TT", "rans", "port_", "._", "TF", "rame", "d", "Transport_", "(_", "socket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "protocol_", "=_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Protocol_", "(_", "trans_", "=_", "scri", "be", "\\u", "transport_", ",_", "strict", "Read_", "=_", "False_", ",_", "strict", "Write_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scri", "be", "\\u", "client_", "=_", "scri", "be_", "._", "Client_", "(_", "iprot_", "=_", "protocol_", ",_", "oprot_", "=_", "protocol_", ")_", "\\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_", "#", " ", "Register", " ", "Handlers_", "\\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_", "#", " ", "Scr", "ibe", "_", "\\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\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "application_", "=_", "tornado_", "._", "web_", "._", "Application_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "r", "\"/", "put", "\\u", "logs", "\"_", ",_", "Log", "Catch", "er", "Handler_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "r", "\"/", "index", ".", "html", "\"_", ",_", "Heart", "beat", "Handler_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "http", "\\u", "server_", "=_", "tornado_", "._", "https", "erver_", "._", "HTTP", "Server_", "(_", "application_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http", "\\u", "server_", "._", "listen_", "(_", "8080_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tornado_", "._", "ioloop_", "._", "IO", "Loop_", "._", "instance_", "(_", ")_", "._", "start_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Log", "Catch", "er", "Handler_", "(_", "tornado_", "._", "web_", "._", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "params", "\\u", "and", "\\u", "process", "\\u", "message_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "logg", "ing", ".", "info", "(\"", "get", "\\u", "params", "\\u", "and", "\\u", "call", "\\u", "scri", "be", "()\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "category_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "'", "category", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "message_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "'", "message", "'_", ")_", "._", "encode_", "(_", "\"", "utf", "-", "8", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "error_", "(_", "\"", "Cate", "gory", " ", "argu", "ment", " ", "missi", "ng", ".", " ", "Messag", "e", " ", "was", ":", " ", "\"_", "+_", "str_", "(_", "message_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "message_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "'", "message", "'_", ")_", "._", "encode_", "(_", "\"", "utf", "-", "8", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "hash_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "'", "hash", "'_", ")_", "._", "replace_", "(_", "'", " ", "'_", ",_", "'+'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "category_", "or_", "not_", "self_", "._", "message_", "or_", "not_", "self_", "._", "hash_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "write_", "(_", "\"", "Error", ":", " ", "Mus", "t", " ", "contain", " ", "category", " ", "and", " ", "message", " ", "and", " ", "hash", ".", "<", "br", ">\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "error_", "(_", "\"", "Mus", "t", " ", "contain", " ", "category", " ", "and", " ", "message", " ", "and", " ", "hash", ".\"_", ")_", "\\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_", "message", "\\u", "for", "\\u", "hash_", "=_", "self_", "._", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Calc", " ", "valid", " ", "hash_", "\\u\\u\\uNL\\u\\u\\u_", "digest_", "=_", "hmac_", "._", "new_", "(_", "LOGGING", "\\u", "SHARED", "\\u", "SECRET_", ",_", "message", "\\u", "for", "\\u", "hash_", ",_", "hashlib_", "._", "sha1_", ")_", "._", "digest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calculated", "\\u", "hash_", "=_", "base64_", "._", "encodes", "tring_", "(_", "digest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "if", " ", "hash", " ", "matches_", "\\u\\u\\uNL\\u\\u\\u_", "hash", "\\u", "matches_", "=_", "(_", "self_", "._", "hash_", "[_", ":_", "28_", "]_", "==_", "calculated", "\\u", "hash_", "[_", ":_", "28_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hash", "\\u", "matches_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "write_", "(_", "\"", "hash", " ", "matche", "d", ",", " ", "logg", "ing", " ", "to", " ", "scri", "be", ".", "<", "br", ">\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "logg", "ing", ".", "info", "(\"", "hash", " ", "matche", "d", ",", " ", "logg", "ing", " ", "to", " ", "scri", "be", ".\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "forward", "\\u", "message_", "(_", "self_", "._", "category_", ",_", "self_", "._", "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 ", " _", "self_", "._", "write_", "(_", "\"", "not", "hing", " ", "was", " ", "logged", ".", "<", "br", ">\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "logg", "ing", ".", "warn", "(\"", "last", " ", "char", ":", " ", "\"", " ", "+", " ", "str", "(", "ord", "(", "self", ".", "message", "[", "len", "(", "self", ".", "message", ")-", "1", "]))", ")_", "\\u\\u\\uNL\\u\\u\\u_", "logging_", "._", "warn_", "(_", "\"", "calculated", " ", "hash", " ", "=", " ", "\"_", "+_", "str_", "(_", "calculated", "\\u", "hash_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "warn_", "(_", "\"", " ", " ", "provided", " ", "hash", " ", "=", " ", "\"_", "+_", "str_", "(_", "self_", "._", "hash_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "warn_", "(_", "\"", "hash", "\\u", "matche", "s", ":", " ", "\"_", "+_", "str_", "(_", "hash", "\\u", "matches_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logging_", "._", "warn_", "(_", "\"", "not", "hing", " ", "was", " ", "logged", ".", " ", "message", "[", "0", ":", "500", "]:", " ", "\"_", "+_", "self_", "._", "message_", "[_", ":_", "500_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logging_", "._", "warn_", "(_", "\"", "not", "hing", " ", "was", " ", "logged", ".\"_", ")_", "\\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 ", " _", "logging_", "._", "error_", "(_", "\"", "Error", " ", "process", "ing", " ", "request", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send", "\\u", "record", "s", "\\u", "to", "\\u", "scri", "be_", "(_", "category_", ",_", "message_", ")_", ":_", "\\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 ", " _", "global_", "scri", "be", "\\u", "transport_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global_", "scri", "be", "\\u", "client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "scri", "be", "\\u", "transport_", "or_", "not_", "scri", "be", "\\u", "client_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Re", "-", "init", " ", "scri", "be_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "warn_", "(_", "\"", "Had", " ", "to", " ", "re", "-", "init", " ", "scri", "be", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socket_", "=_", "TS", "ocket", "_", "._", "TS", "ocket", "_", "(_", "host_", "=_", "SCR", "IB", "E", "\\u", "HOST_", ",_", "port_", "=_", "int_", "(_", "SCR", "IB", "E", "\\u", "PORT_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scri", "be", "\\u", "transport_", "=_", "TT", "rans", "port_", "._", "TF", "rame", "d", "Transport_", "(_", "socket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "protocol_", "=_", "TB", "inary", "Protocol_", "._", "TB", "inary", "Protocol_", "(_", "trans_", "=_", "scri", "be", "\\u", "transport_", ",_", "strict", "Read_", "=_", "False_", ",_", "strict", "Write_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scri", "be", "\\u", "client_", "=_", "scri", "be_", "._", "Client_", "(_", "iprot_", "=_", "protocol_", ",_", "oprot_", "=_", "protocol_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "scri", "be", "\\u", "transport_", "._", "open_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lines_", "=_", "message_", "._", "split_", "(_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log", "\\u", "entries_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log", "\\u", "entry_", "=_", "scri", "be_", "._", "Log", "Entry_", "(_", "category_", "=_", "category_", ",_", "message_", "=_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log", "\\u", "entries_", "._", "append_", "(_", "log", "\\u", "entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "scri", "be", "\\u", "client_", "._", "Log_", "(_", "messages_", "=_", "log", "\\u", "entries_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "scri", "be", "\\u", "transport_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "result_", "==_", "scri", "be_", "._", "Result", "Code_", "._", "OK_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "result_", "==_", "scri", "be_", "._", "Result", "Code_", "._", "TR", "Y", "\\u", "LATE", "R_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "error_", "(_", "\"", "TR", "Y", "\\u", "LATE", "R", ".", " ", "Result", ":", " ", "\"_", "+_", "str_", "(_", "result_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "error_", "(_", "\"", "Un", "know", "n", " ", "error", " ", "code", ".\"_", "+_", "str_", "(_", "result_", ")_", ")_", "\\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 ", " _", "logging_", "._", "error_", "(_", "\"", "Error", " ", "sendin", "g", " ", "record", "s", " ", "to", " ", "scri", "be", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "\\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,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 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
lebedov/scikit-cuda/tests/test_special.py
[ { "content": "#!/usr/bin/env python\n\n\"\"\"\nUnit tests for scikits.cuda.linalg\n\"\"\"\n\n\nfrom unittest import main, makeSuite, TestCase, TestSuite\n\nimport pycuda.autoinit\nimport pycuda.gpuarray as gpuarray\nimport numpy as np\nimport scipy as sp\nimport scipy.special\n\nimport skcuda.linalg as linalg\nimport skcuda.misc as misc\nimport skcuda.special as special\n\n\n\nif __name__ == '__main__':\n main(defaultTest = 'suite')\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class test_special(TestCase):\n\n\n\n\n\n", "metadata": "root.test_special", "header": "['module', '___EOS___']", "index": 19 }, { "content": " def setUp(self):\n np.random.seed(0)\n linalg.init()", "metadata": "root.test_special.setUp", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 20 }, { "content": " def test_sici_float32(self):\n x = np.array([[1, 2], [3, 4]], np.float32)\n x_gpu = gpuarray.to_gpu(x)\n (si_gpu, ci_gpu) = special.sici(x_gpu)\n (si, ci) = scipy.special.sici(x)\n assert np.allclose(si, si_gpu.get())\n assert np.allclose(ci, ci_gpu.get())", "metadata": "root.test_special.test_sici_float32", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 24 }, { "content": " def test_sici_float64(self):\n x = np.array([[1, 2], [3, 4]], np.float64)\n x_gpu = gpuarray.to_gpu(x)\n (si_gpu, ci_gpu) = special.sici(x_gpu)\n (si, ci) = scipy.special.sici(x)\n assert np.allclose(si, si_gpu.get())\n assert np.allclose(ci, ci_gpu.get())", "metadata": "root.test_special.test_sici_float64", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 32 }, { "content": " def test_exp1_complex64(self):\n z = np.asarray(np.random.rand(4, 4) + 1j*np.random.rand(4, 4), np.complex64)\n z_gpu = gpuarray.to_gpu(z)\n e_gpu = special.exp1(z_gpu)\n assert np.allclose(sp.special.exp1(z), e_gpu.get()) ", "metadata": "root.test_special.test_exp1_complex64", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 40 }, { "content": " def test_exp1_complex128(self):\n z = np.asarray(np.random.rand(4, 4) + 1j*np.random.rand(4, 4), np.complex128)\n z_gpu = gpuarray.to_gpu(z)\n e_gpu = special.exp1(z_gpu)\n assert np.allclose(sp.special.exp1(z), e_gpu.get()) ", "metadata": "root.test_special.test_exp1_complex128", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 46 }, { "content": " def test_expi_complex64(self):\n z = np.asarray(np.random.rand(4, 4) + 1j*np.random.rand(4, 4), np.complex64)\n z_gpu = gpuarray.to_gpu(z)\n e_gpu = special.expi(z_gpu)\n assert np.allclose(sp.special.expi(z), e_gpu.get()) ", "metadata": "root.test_special.test_expi_complex64", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 52 }, { "content": " def test_expi_complex128(self):\n z = np.asarray(np.random.rand(4, 4) + 1j*np.random.rand(4, 4), np.complex128)\n z_gpu = gpuarray.to_gpu(z)\n e_gpu = special.expi(z_gpu)\n assert np.allclose(sp.special.expi(z), e_gpu.get()) ", "metadata": "root.test_special.test_expi_complex128", "header": "['class', 'test_special', '(', 'TestCase', ')', ':', '___EOS___']", "index": 58 }, { "content": "def suite():\n s = TestSuite()\n s.addTest(test_special('test_sici_float32'))\n s.addTest(test_special('test_exp1_complex64'))\n s.addTest(test_special('test_expi_complex64'))\n if misc.get_compute_capability(pycuda.autoinit.device) >= 1.3:\n s.addTest(test_special('test_sici_float64'))\n s.addTest(test_special('test_exp1_complex128'))\n s.addTest(test_special('test_expi_complex128'))\n return s", "metadata": "root.suite", "header": "['module', '___EOS___']", "index": 64 } ]
[ { "span": "from unittest import main, makeSuite, TestCase, TestSuite", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 57 } ]
[]
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", ";", "Unit", " ", "tests", " ", "for", " ", "scikit", "s", ".", "cud", "a", ".", "linalg", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "unittest_", "import_", "main_", ",_", "make", "Suite_", ",_", "Test", "Case_", ",_", "Test", "Suite_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pyc", "uda", "_", "._", "autoi", "nit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyc", "uda", "_", "._", "gpu", "array_", "as_", "gpu", "array_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "scipy_", "as_", "sp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "scipy_", "._", "special_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sk", "cuda_", "._", "linalg_", "as_", "linalg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sk", "cuda_", "._", "misc_", "as_", "misc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sk", "cuda_", "._", "special_", "as_", "special_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", "default", "Test_", "=_", "'", "suit", "e", "'_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "test\\u", "special_", "(_", "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_", "test\\u", "special_", "(_", "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 ", " _", "np_", "._", "random_", "._", "seed_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "linalg_", "._", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "test\\u", "special_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "sic", "i", "\\u", "float32_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "np_", "._", "array_", "(_", "[_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "3_", ",_", "4_", "]_", "]_", ",_", "np_", "._", "float32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "\\u", "gpu_", "=_", "gpu", "array_", "._", "to", "\\u", "gpu_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "si", "\\u", "gpu_", ",_", "ci", "\\u", "gpu_", ")_", "=_", "special_", "._", "sic", "i_", "(_", "x", "\\u", "gpu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "si_", ",_", "ci_", ")_", "=_", "scipy_", "._", "special_", "._", "sic", "i_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "si_", ",_", "si", "\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "ci_", ",_", "ci", "\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "test\\u", "special_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "sic", "i", "\\u", "float64_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "np_", "._", "array_", "(_", "[_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "3_", ",_", "4_", "]_", "]_", ",_", "np_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "\\u", "gpu_", "=_", "gpu", "array_", "._", "to", "\\u", "gpu_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "si", "\\u", "gpu_", ",_", "ci", "\\u", "gpu_", ")_", "=_", "special_", "._", "sic", "i_", "(_", "x", "\\u", "gpu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "si_", ",_", "ci_", ")_", "=_", "scipy_", "._", "special_", "._", "sic", "i_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "si_", ",_", "si", "\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "ci_", ",_", "ci", "\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "test\\u", "special_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exp", "1", "\\u", "complex", "64_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "np_", "._", "asarray_", "(_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", "+_", "1j_", "*_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", ",_", "np_", "._", "complex", "64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z", "\\u", "gpu_", "=_", "gpu", "array_", "._", "to", "\\u", "gpu_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "gpu_", "=_", "special_", "._", "exp", "1_", "(_", "z", "\\u", "gpu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "sp_", "._", "special_", "._", "exp", "1_", "(_", "z_", ")_", ",_", "e\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "test\\u", "special_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exp", "1", "\\u", "complex", "128_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "np_", "._", "asarray_", "(_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", "+_", "1j_", "*_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", ",_", "np_", "._", "complex", "128_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z", "\\u", "gpu_", "=_", "gpu", "array_", "._", "to", "\\u", "gpu_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "gpu_", "=_", "special_", "._", "exp", "1_", "(_", "z", "\\u", "gpu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "sp_", "._", "special_", "._", "exp", "1_", "(_", "z_", ")_", ",_", "e\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "test\\u", "special_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exp", "i", "\\u", "complex", "64_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "np_", "._", "asarray_", "(_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", "+_", "1j_", "*_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", ",_", "np_", "._", "complex", "64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z", "\\u", "gpu_", "=_", "gpu", "array_", "._", "to", "\\u", "gpu_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "gpu_", "=_", "special_", "._", "exp", "i_", "(_", "z", "\\u", "gpu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "sp_", "._", "special_", "._", "exp", "i_", "(_", "z_", ")_", ",_", "e\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "test\\u", "special_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exp", "i", "\\u", "complex", "128_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "np_", "._", "asarray_", "(_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", "+_", "1j_", "*_", "np_", "._", "random_", "._", "rand_", "(_", "4_", ",_", "4_", ")_", ",_", "np_", "._", "complex", "128_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z", "\\u", "gpu_", "=_", "gpu", "array_", "._", "to", "\\u", "gpu_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "gpu_", "=_", "special_", "._", "exp", "i_", "(_", "z", "\\u", "gpu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "np_", "._", "allclose_", "(_", "sp_", "._", "special_", "._", "exp", "i_", "(_", "z_", ")_", ",_", "e\\u", "gpu_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\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_", "suite_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Test", "Suite_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "Test_", "(_", "test\\u", "special_", "(_", "'", "test\\u", "sic", "i", "\\u", "float", "32", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "Test_", "(_", "test\\u", "special_", "(_", "'", "test\\u", "exp", "1", "\\u", "complex", "64", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "Test_", "(_", "test\\u", "special_", "(_", "'", "test\\u", "exp", "i", "\\u", "complex", "64", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "misc_", "._", "get", "\\u", "compute", "\\u", "capability_", "(_", "pyc", "uda", "_", "._", "autoi", "nit_", "._", "device_", ")_", ">=_", "1.3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "add", "Test_", "(_", "test\\u", "special_", "(_", "'", "test\\u", "sic", "i", "\\u", "float", "64", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "Test_", "(_", "test\\u", "special_", "(_", "'", "test\\u", "exp", "1", "\\u", "complex", "128", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "Test_", "(_", "test\\u", "special_", "(_", "'", "test\\u", "exp", "i", "\\u", "complex", "128", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "s_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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,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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
amarandon/smeuhsocial/apps/artist/urls.py
[ { "content": "from django.conf.urls import patterns, url\nfrom django.contrib.auth.decorators import login_required\n\nurlpatterns = patterns(\"\",\n # all items\n url(r\"^$\", \"artist.views.index\", name=\"artist_index\"),\n url(r\"^(?P<name>.+)/$\", \"artist.views.artist\", name=\"artist_tracks\"), \n)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from django.contrib.auth.decorators import login_required", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 57 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "conf_", "._", "urls_", "import_", "patterns_", ",_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "decorators_", "import_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "urlpatterns_", "=_", "patterns_", "(_", "\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "items_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "(_", "r", "\"", "^", "$\"_", ",_", "\"", "artist", ".", "views", ".", "index", "\"_", ",_", "name_", "=_", "\"", "artist", "\\u", "index", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "(_", "r", "\"", "^", "(?", "P", "<", "name", ">.+)", "/$", "\"_", ",_", "\"", "artist", ".", "views", ".", "artist", "\"_", ",_", "name_", "=_", "\"", "artist", "\\u", "tracks", "\"_", ")_", ",_", "\\u\\u\\uNL\\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, 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 ]
Except block handles 'BaseException'
XiaoMi/minos/owl/monitor/management/commands/count_rows.py
[ { "content": " def count_rows(self, cluster_name, table_name):\n logger.info(\"Count the rows of \" + table_name + \" in \" + cluster_name)\n\n try:\n # deploy shell hbase sdtst-miliao org.apache.hadoop.hbase.coprocessor.example.CoprocessorRowcounter _acl_ --speed=3000\n deploy_command = settings.DEPLOY_COMMAND\n command_list = [deploy_command, \"shell\", \"hbase\"] + [cluster_name] + [\"org.apache.hadoop.hbase.coprocessor.example.CoprocessorRowcounter\"] + [table_name] + [\"--speed=3000\"]\n\n rowcounter_process = subprocess.Popen(command_list, stdout=subprocess.PIPE)\n rowcounter_result = rowcounter_process.communicate()\n rowcounter_status = rowcounter_process.wait()\n\n # e.g. \"_acl_ 2014-4-18 3\"\n pattern = table_name + \" \\\\d+\\\\-\\\\d+\\\\-\\\\d+ (\\\\d+)\"; \n compiled_pattern = re.compile(pattern)\n re_result = compiled_pattern.search(rowcounter_result[0])\n return re_result.group(1)\n except:\n logger.error(\"Error to count rows, make sure kinit to run CoprocessorRowcounter and set DEPLOY_COMMAND\")\n return -1", "metadata": "root.Command.count_rows", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 72 } ]
[ { "span": "except:", "start_line": 89, "start_column": 4, "end_line": 89, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "count", "\\u", "rows_", "(_", "self_", ",_", "cluster", "\\u", "name_", ",_", "table", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "Count", " ", "the", " ", "rows", " ", "of", " ", "\"_", "+_", "table", "\\u", "name_", "+_", "\"", " ", "in", " ", "\"_", "+_", "cluster", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "deploy", " ", "shell", " ", "hbase", " ", "sd", "tst", "-", "mili", "ao", " ", "org", ".", "apa", "che", ".", "hadoop", ".", "hbase", ".", "cop", "rocess", "or", ".", "example", ".", "Cop", "rocess", "or", "Row", "counter", " ", "\\u", "acl", "\\u", " ", "--", "speed", "=", "3000_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "deploy", "\\u", "command_", "=_", "settings_", "._", "DEPLOY", "\\u", "COMMAND_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "\\u", "list_", "=_", "[_", "deploy", "\\u", "command_", ",_", "\"", "shell", "\"_", ",_", "\"", "hbase", "\"_", "]_", "+_", "[_", "cluster", "\\u", "name_", "]_", "+_", "[_", "\"", "org", ".", "apa", "che", ".", "hadoop", ".", "hbase", ".", "cop", "rocess", "or", ".", "example", ".", "Cop", "rocess", "or", "Row", "counter", "\"_", "]_", "+_", "[_", "table", "\\u", "name_", "]_", "+_", "[_", "\"--", "speed", "=", "3000", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rowco", "unter", "\\u", "process_", "=_", "subprocess_", "._", "Popen_", "(_", "command", "\\u", "list_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rowco", "unter", "\\u", "result_", "=_", "rowco", "unter", "\\u", "process_", "._", "communicate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rowco", "unter", "\\u", "status_", "=_", "rowco", "unter", "\\u", "process_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "e", ".", "g", ".", " ", "\"\\u", "acl", "\\u", " ", "2014", "-", "4", "-1", "8", " ", "3", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "pattern_", "=_", "table", "\\u", "name_", "+_", "\"", " ", "\\\\\\\\", "d", "+\\\\", "\\\\-\\", "\\\\", "\\", "d", "+\\\\", "\\\\-\\", "\\\\", "\\", "d", "+", " ", "(\\\\\\\\", "d", "+)\"_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compile", "d\\u", "pattern_", "=_", "re_", "._", "compile_", "(_", "pattern_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "re", "\\u", "result_", "=_", "compile", "d\\u", "pattern_", "._", "search_", "(_", "rowco", "unter", "\\u", "result_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "re", "\\u", "result_", "._", "group_", "(_", "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 ", " _", "logger_", "._", "error_", "(_", "\"", "Error", " ", "to", " ", "count", " ", "rows", ",", " ", "make", " ", "sure", " ", "kin", "it", " ", "to", " ", "run", " ", "Cop", "rocess", "or", "Row", "counter", " ", "and", " ", "set", " ", "DEPLOY", "\\u", "COMMA", "ND", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "-_", "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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
hwaf/hwaf/py-hwaftools/orch/features/feature_vcs.py
[ { "content": "#!/usr/bin/env python\n'''A \"tarball\"-like feature to which pulls from a VCS instead. It\nprovides the \"seturl\" and \"unpack\" steps. There is no \"download\" step\nlike \"tarball\" as the checkout/clone is direct to the source\ndirectory.\n\n'''\nimport os.path as osp\nfrom waflib.TaskGen import feature\nimport waflib.Logs as msg\n\nfrom orch.util import urlopen, get_unpacker\nfrom orch.wafutil import exec_command\n\nimport orch.features\norch.features.register_defaults(\n 'vcs', \n source_urlfile = '{urlfile_dir}/{package}-{version}.url',\n source_unpacked = '{package}-{version}',\n source_unpacked_path = '{source_dir}/{source_unpacked}',\n unpacked_target = 'README',\n source_unpacked_target = '{source_unpacked_path}/{unpacked_target}',\n\n vcs_flavor = 'git', # git,hg,svn,cvs \n vcs_tag = '',\n vcs_module = '', # used by cvs\n)\n\n\n\n\n\n\n\n\n \n\n\n \n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def single_cmd_rule(func):\n def rule(tgen):\n def task_func(task):\n cmd = func(tgen)\n return exec_command(task, cmd)\n tgen.step('unpack',\n rule = task_func,\n source = tgen.worch.source_urlfile,\n target = tgen.worch.source_unpacked_target)\n return rule", "metadata": "root.single_cmd_rule", "header": "['module', '___EOS___']", "index": 28 }, { "content": "@single_cmd_rule\ndef do_cvs(tgen):\n tag = tgen.worch.get('vcs_tag', '')\n if tag:\n tag = '-r ' + tag\n module = tgen.worch.get('vcs_module', '')\n if not module:\n module = tgen.worch.package\n pat = 'cvs -d {source_url} checkout {vcs_tag_opt} -d {source_unpacked} {module}'\n return tgen.worch.format(pat, vcs_tag_opt=tag, module=module)", "metadata": "root.do_cvs", "header": "['module', '___EOS___']", "index": 39 }, { "content": "@single_cmd_rule\ndef do_svn(tgen):\n if tgen.worch.get('vcs_tag'):\n err = tgen.worch.format('SVN has no concept of tags, can not honor: \"{vcs_tag}\"')\n msg.error(err)\n raise ValueError(err)\n pat = \"svn checkout {source_url} {source_unpacked}\"\n return tgen.worch.format(pat)", "metadata": "root.do_svn", "header": "['module', '___EOS___']", "index": 50 }, { "content": "@single_cmd_rule\ndef do_hg(tgen):\n tag = tgen.worch.get('vcs_tag', '')\n if tag:\n tag = '-b ' + tag\n pat = \"hg clone {vcs_tag_opt} {source_url} {source_unpacked}\"\n return tgen.worch.format(pat, vcs_tag_opt=tag)", "metadata": "root.do_hg", "header": "['module', '___EOS___']", "index": 60 }, { "content": "def do_git(tgen):\n\n git_dir = tgen.make_node(tgen.worch.format('{download_dir}/{package}.git'))\n\n if osp.exists(git_dir.abspath()):\n clone_or_update = 'git --git-dir={git_dir} fetch --all --tags'\n else:\n clone_or_update = 'git clone --bare {source_url} {git_dir}'\n clone_or_update = tgen.worch.format(clone_or_update , git_dir=git_dir.abspath())\n tgen.step('download',\n rule = clone_or_update,\n source = tgen.worch.source_urlfile,\n target = git_dir)\n\n checkout = 'git --git-dir={git_dir} archive'\n checkout += ' --format=tar --prefix={package}-{version}/ '\n checkout += ' ' + getattr(tgen.worch, 'vcs_tag', 'HEAD') # git tag, branch or hash\n checkout += ' | tar -xvf -'\n checkout = tgen.worch.format(checkout, git_dir=git_dir.abspath())\n tgen.step('unpack',\n rule = checkout,\n source = tgen.control_node('download'),\n target = tgen.worch.source_unpacked_target)", "metadata": "root.do_git", "header": "['module', '___EOS___']", "index": 70 }, { "content": "@feature('vcs')\ndef feature_vcs(tgen):\n\n tgen.step('seturl', \n rule = \"echo '%s' > %s\" % (tgen.worch.source_url, tgen.worch.source_urlfile),\n update_outputs = True,\n target = tgen.worch.source_urlfile)\n\n flavor = tgen.worch.vcs_flavor\n doer = eval('do_%s' % flavor)\n doer(tgen)\n return", "metadata": "root.feature_vcs", "header": "['module', '___EOS___']", "index": 96 } ]
[ { "span": "from orch.util import urlopen, get_unpacker", "start_line": 11, "start_column": 0, "end_line": 11, "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_", "'''", "A", " ", "\"", "tarball", "\"-", "like", " ", "feature", " ", "to", " ", "whi", "ch", " ", "pull", "s", " ", "from", " ", "a", " ", "VCS", " ", "inst", "ead", ".", " ", " ", "It", "\\", "10", ";", "provide", "s", " ", "the", " ", "\"", "set", "url", "\"", " ", "and", " ", "\"", "unpack", "\"", " ", "step", "s", ".", " ", " ", "There", " ", "is", " ", "no", " ", "\"", "download", "\"", " ", "step", "\\", "10", ";", "like", " ", "\"", "tarball", "\"", " ", "as", " ", "the", " ", "check", "out", "/", "clone", " ", "is", " ", "direct", " ", "to", " ", "the", " ", "source", "\\", "10", ";", "director", "y", ".", "\\", "10", ";", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "as_", "osp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "waf", "lib_", "._", "Task", "Gen_", "import_", "feature_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "waf", "lib_", "._", "Logs_", "as_", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "orch", "_", "._", "util_", "import_", "urlopen_", ",_", "get", "\\u", "unpack", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "orch", "_", "._", "waf", "util_", "import_", "exec", "\\u", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "orch", "_", "._", "features_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orch", "_", "._", "features_", "._", "register", "\\u", "defaults_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "vcs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "urlf", "ile_", "=_", "'{", "urlf", "ile", "\\u", "dir", "}/", "{", "package", "}-", "{", "version", "}.", "url", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "unpacked", "_", "=_", "'{", "package", "}-", "{", "version", "}'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "unpacked", "\\u", "path_", "=_", "'{", "source", "\\u", "dir", "}/", "{", "source", "\\u", "unpacked", "}'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unpacked", "\\u", "target_", "=_", "'", "READ", "ME", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "unpacked", "\\u", "target_", "=_", "'{", "source", "\\u", "unpacked", "\\u", "path", "}/", "{", "unpacked", "\\u", "target", "}'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vcs", "\\u", "flavor_", "=_", "'", "git", "'_", ",_", "#", " ", "git", ",", "hg", ",", "svn", ",", "cvs", " _", "\\u\\u\\uNL\\u\\u\\u_", "vcs", "\\u", "tag_", "=_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vcs", "\\u", "module_", "=_", "''_", ",_", "#", " ", "used", " ", "by", " ", "cvs", "_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "single", "\\u", "cmd", "\\u", "rule_", "(_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "rule_", "(_", "tge", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "task", "\\u", "func_", "(_", "task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "func_", "(_", "tge", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "exec", "\\u", "command_", "(_", "task_", ",_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tge", "n_", "._", "step_", "(_", "'", "unpack", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "rule_", "=_", "task", "\\u", "func_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "urlf", "ile_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "unpacked", "\\u", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rule_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "single", "\\u", "cmd", "\\u", "rule_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "do", "\\u", "cvs", "_", "(_", "tge", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tag_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "get_", "(_", "'", "vcs", "\\u", "tag", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tag_", "=_", "'-", "r", " ", "'_", "+_", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "module_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "get_", "(_", "'", "vcs", "\\u", "module", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "module_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "package_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pat_", "=_", "'", "cvs", " ", "-", "d", " ", "{", "source", "\\u", "url", "}", " ", "check", "out", " ", "{", "vcs", "\\u", "tag", "\\u", "opt", "}", " ", "-", "d", " ", "{", "source", "\\u", "unpacked", "}", " ", "{", "module", "}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "pat_", ",_", "vcs", "\\u", "tag", "\\u", "opt_", "=_", "tag_", ",_", "module_", "=_", "module_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "single", "\\u", "cmd", "\\u", "rule_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "do", "\\u", "svn_", "(_", "tge", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "tge", "n_", "._", "wor", "ch_", "._", "get_", "(_", "'", "vcs", "\\u", "tag", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "'", "SV", "N", " ", "has", " ", "no", " ", "concept", " ", "of", " ", "tags", ",", " ", "can", " ", "not", " ", "honor", ":", " ", "\"{", "vcs", "\\u", "tag", "}\"'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "._", "error_", "(_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Value", "Error_", "(_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pat_", "=_", "\"", "svn", " ", "check", "out", " ", "{", "source", "\\u", "url", "}", " ", "{", "source", "\\u", "unpacked", "}\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "pat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "single", "\\u", "cmd", "\\u", "rule_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "do", "\\u", "hg_", "(_", "tge", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tag_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "get_", "(_", "'", "vcs", "\\u", "tag", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tag_", "=_", "'-", "b", " ", "'_", "+_", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pat_", "=_", "\"", "hg", " ", "clone", " ", "{", "vcs", "\\u", "tag", "\\u", "opt", "}", " ", "{", "source", "\\u", "url", "}", " ", "{", "source", "\\u", "unpacked", "}\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "pat_", ",_", "vcs", "\\u", "tag", "\\u", "opt_", "=_", "tag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "git_", "(_", "tge", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "git", "\\u", "dir_", "=_", "tge", "n_", "._", "make", "\\u", "node_", "(_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "'{", "download", "\\u", "dir", "}/", "{", "package", "}.", "git", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "osp_", "._", "exists_", "(_", "git", "\\u", "dir_", "._", "abspath_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clone", "\\u", "or", "\\u", "update_", "=_", "'", "git", " ", "--", "git", "-", "dir", "={", "git", "\\u", "dir", "}", " ", "fetch", " ", "--", "all", " ", "--", "tags", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clone", "\\u", "or", "\\u", "update_", "=_", "'", "git", " ", "clone", " ", "--", "bare", " ", "{", "source", "\\u", "url", "}", " ", "{", "git", "\\u", "dir", "}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "clone", "\\u", "or", "\\u", "update_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "clone", "\\u", "or", "\\u", "update_", ",_", "git", "\\u", "dir_", "=_", "git", "\\u", "dir_", "._", "abspath_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tge", "n_", "._", "step_", "(_", "'", "download", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "rule_", "=_", "clone", "\\u", "or", "\\u", "update_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "urlf", "ile_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "git", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "checkout_", "=_", "'", "git", " ", "--", "git", "-", "dir", "={", "git", "\\u", "dir", "}", " ", "archive", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checkout_", "+=_", "'", " ", "--", "format", "=", "tar", " ", "--", "prefix", "={", "package", "}-", "{", "version", "}/", " ", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checkout_", "+=_", "'", " ", "'_", "+_", "getattr_", "(_", "tge", "n_", "._", "wor", "ch_", ",_", "'", "vcs", "\\u", "tag", "'_", ",_", "'", "HEAD", "'_", ")_", "#", " ", "git", " ", "tag", ",", " ", "branch", " ", "or", " ", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checkout_", "+=_", "'", " ", "|", " ", "tar", " ", "-", "xv", "f", " ", "-'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checkout_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "format_", "(_", "checkout_", ",_", "git", "\\u", "dir_", "=_", "git", "\\u", "dir_", "._", "abspath_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tge", "n_", "._", "step_", "(_", "'", "unpack", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "rule_", "=_", "checkout_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "source_", "=_", "tge", "n_", "._", "control", "\\u", "node_", "(_", "'", "download", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "unpacked", "\\u", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "feature_", "(_", "'", "vcs", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "feature", "\\u", "vcs_", "(_", "tge", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tge", "n_", "._", "step_", "(_", "'", "set", "url", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "rule_", "=_", "\"", "echo", " ", "'%", "s", "'", " ", ">", " ", "%", "s", "\"_", "%_", "(_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "url_", ",_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "urlf", "ile_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "update", "\\u", "outputs_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "source", "\\u", "urlf", "ile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "flavor_", "=_", "tge", "n_", "._", "wor", "ch_", "._", "vcs", "\\u", "flavor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doe", "r_", "=_", "eval_", "(_", "'", "do", "\\u", "%", "s", "'_", "%_", "flavor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doe", "r_", "(_", "tge", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_" ]
[ 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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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
pixelogik/NearPy/nearpy/engine.py
[ { "content": " def candidate_count(self, v):\n \"\"\"\n Returns candidate count for nearest neighbour search for specified vector.\n The candidate count is the count of vectors taken from all buckets the\n specified vector is projected onto.\n\n Use this method to check if your hashes are configured good. High candidate\n counts makes querying slow.\n\n For example if you always want to retrieve 20 neighbours but the candidate\n count is 1000 or something you have to change the hash so that each bucket\n has less entries (increase projection count for example).\n \"\"\"\n # Collect candidates from all buckets from all hashes\n candidates = self._get_candidates()\n return len(candidates)", "metadata": "root.Engine.candidate_count", "header": "['class', 'Engine', '(', 'object', ')', ':', '___EOS___']", "index": 99 }, { "content": " def _get_candidates(self, v):\n \"\"\" Collect candidates from all buckets from all hashes \"\"\"\n candidates = []\n for lshash in self.lshashes:\n for bucket_key in lshash.hash_vector(v, querying=True):\n bucket_content = self.storage.get_bucket(lshash.hash_name,\n bucket_key)\n #print 'Bucket %s size %d' % (bucket_key, len(bucket_content))\n candidates.extend(bucket_content)\n return candidates", "metadata": "root.Engine._get_candidates", "header": "['class', 'Engine', '(', 'object', ')', ':', '___EOS___']", "index": 144 } ]
[ { "span": "self._get_candidates()", "start_line": 113, "start_column": 21, "end_line": 113, "end_column": 43 } ]
[ { "span": "def _get_candidates(self, v):", "start_line": 144, "start_column": 4, "end_line": 144, "end_column": 33 } ]
1
false
[ "[CLS]_", "Wro", "ng_", "number_", "of_", "arguments_", "in_", "a_", "call_", "[SEP]_", "class_", "Engine_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "candidate", "\\u", "count_", "(_", "self_", ",_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "candidate", " ", "count", " ", "for", " ", "near", "est", " ", "neighbour", " ", "search", " ", "for", " ", "specified", " ", "vector", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "candidate", " ", "count", " ", "is", " ", "the", " ", "count", " ", "of", " ", "vector", "s", " ", "take", "n", " ", "from", " ", "all", " ", "bucket", "s", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "specified", " ", "vector", " ", "is", " ", "projected", " ", "onto", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Us", "e", " ", "this", " ", "method", " ", "to", " ", "check", " ", "if", " ", "your", " ", "hashe", "s", " ", "are", " ", "configur", "ed", " ", "good", ".", " ", "Hig", "h", " ", "candidate", "\\", "10", ";", " ", " ", " ", " ", "count", "s", " ", "make", "s", " ", "query", "ing", " ", "slow", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "example", " ", "if", " ", "you", " ", "alw", "ay", "s", " ", "want", " ", "to", " ", "retrieve", " ", "20", " ", "neighbour", "s", " ", "but", " ", "the", " ", "candidate", "\\", "10", ";", " ", " ", " ", " ", "count", " ", "is", " ", "1000", " ", "or", " ", "somet", "hing", " ", "you", " ", "have", " ", "to", " ", "change", " ", "the", " ", "hash", " ", "so", " ", "tha", "t", " ", "each", " ", "bucket", "\\", "10", ";", " ", " ", " ", " ", "has", " ", "less", " ", "entri", "es", " ", "(", "increase", " ", "projecti", "on", " ", "count", " ", "for", " ", "example", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Collect", " ", "candidate", "s", " ", "from", " ", "all", " ", "bucket", "s", " ", "from", " ", "all", " ", "hashes_", "\\u\\u\\uNL\\u\\u\\u_", "candidates_", "=_", "self_", "._", "\\u", "get", "\\u", "candidates_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "len_", "(_", "candidates_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Engine_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "candidates_", "(_", "self_", ",_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Collect", " ", "candidate", "s", " ", "from", " ", "all", " ", "bucket", "s", " ", "from", " ", "all", " ", "hashe", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "candidates_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "lsh", "ash_", "in_", "self_", "._", "lsh", "ash", "es_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "bucket", "\\u", "key_", "in_", "lsh", "ash_", "._", "hash", "\\u", "vector_", "(_", "v_", ",_", "query", "ing_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bucket", "\\u", "content_", "=_", "self_", "._", "storage_", "._", "get", "\\u", "bucket_", "(_", "lsh", "ash_", "._", "hash", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "bucket", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "'", "Buck", "et", " ", "%", "s", " ", "size", " ", "%", "d", "'", " ", "%", " ", "(", "bucket", "\\u", "key", ",", " ", "len", "(", "bucket", "\\u", "content", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "candidates_", "._", "extend_", "(_", "bucket", "\\u", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "candidates_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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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 ]
Except block handles 'BaseException'
cloudera/hue/desktop/core/ext-py/Mako-0.8.1/mako/compat.py
[ { "content": "import sys\nimport time\n\npy3k = sys.version_info >= (3, 0)\npy33 = sys.version_info >= (3, 3)\npy26 = sys.version_info >= (2, 6)\npy25 = sys.version_info >= (2, 5)\njython = sys.platform.startswith('java')\nwin32 = sys.platform.startswith('win')\npypy = hasattr(sys, 'pypy_version_info')\n\nif py3k:\n from io import StringIO\n import builtins as compat_builtins\n from urllib.parse import quote_plus, unquote_plus\n from html.entities import codepoint2name, name2codepoint\n string_types = str,\n binary_type = bytes\n text_type = str\n\n\n\nelse:\n import __builtin__ as compat_builtins\n try:\n from cStringIO import StringIO\n except:\n from StringIO import StringIO\n from urllib import quote_plus, unquote_plus\n from htmlentitydefs import codepoint2name, name2codepoint\n string_types = basestring,\n binary_type = str\n text_type = unicode\n\n\n\n\nif py33:\n from importlib import machinery\nelse:\n import imp\n\n\n\ntry:\n import threading\n if py3k:\n import _thread as thread\n else:\n import thread\nexcept ImportError:\n import dummy_threading as threading\n if py3k:\n import _dummy_thread as thread\n else:\n import dummy_thread as thread\n\nif win32 or jython:\n time_func = time.clock\nelse:\n time_func = time.time\n\ntry:\n from functools import partial\nexcept:\n\nif not py25:\n\nelse:\n all = all\n\n\ntry:\n from inspect import CO_VARKEYWORDS, CO_VARARGS\nexcept ImportError:\n import inspect\n\nif py3k:\nelse:\n callable = callable\n\n\n################################################\n# cross-compatible metaclass implementation\n# Copyright (c) 2010-2012 Benjamin Peterson\n################################################\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 30, "start_column": 4, "end_line": 30, "end_column": 11 }, { "span": "except:", "start_line": 82, "start_column": 0, "end_line": 82, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\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_", "py3", "k_", "=_", "sys_", "._", "version", "\\u", "info_", ">=_", "(_", "3_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "py3", "3_", "=_", "sys_", "._", "version", "\\u", "info_", ">=_", "(_", "3_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "py2", "6_", "=_", "sys_", "._", "version", "\\u", "info_", ">=_", "(_", "2_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "py2", "5_", "=_", "sys_", "._", "version", "\\u", "info_", ">=_", "(_", "2_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jy", "tho", "n_", "=_", "sys_", "._", "platform_", "._", "startswith_", "(_", "'", "java", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "win32", "_", "=_", "sys_", "._", "platform_", "._", "startswith_", "(_", "'", "win", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pypy", "_", "=_", "hasattr_", "(_", "sys_", ",_", "'", "pypy", "\\u", "version", "\\u", "info", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "py3", "k_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "io_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "builtins_", "as_", "compa", "t", "\\u", "builtins_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urllib_", "._", "parse_", "import_", "quote", "\\u", "plus_", ",_", "unqu", "ote", "\\u", "plus_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "html_", "._", "entities_", "import_", "codepoint", "2n", "ame_", ",_", "name2", "codepoint", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "\\u", "types_", "=_", "str_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "binar", "y", "\\u", "type_", "=_", "bytes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "\\u", "type_", "=_", "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\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "\\u\\u", "builtin\\u\\u_", "as_", "compa", "t", "\\u", "builtins_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "c", "String", "IO_", "import_", "String", "IO_", "\\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_", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "urllib_", "import_", "quote", "\\u", "plus_", ",_", "unqu", "ote", "\\u", "plus_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "html", "entity", "defs_", "import_", "codepoint", "2n", "ame_", ",_", "name2", "codepoint", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "\\u", "types_", "=_", "basestring_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "binar", "y", "\\u", "type_", "=_", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "\\u", "type_", "=_", "unicode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "py3", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "importlib_", "import_", "machine", "ry_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "imp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "py3", "k_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "\\u", "thread_", "as_", "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 ", " _", "import_", "thread_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "dummy", "\\u", "threading_", "as_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "py3", "k_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "\\u", "dummy", "\\u", "thread_", "as_", "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 ", " _", "import_", "dummy", "\\u", "thread_", "as_", "thread_", "\\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_", "win32", "_", "or_", "jy", "tho", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time", "\\u", "func_", "=_", "time_", "._", "clock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time", "\\u", "func_", "=_", "time_", "._", "time_", "\\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_", "functools_", "import_", "partial_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\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\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "py2", "5_", ":_", "\\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\\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 ", " _", "all_", "=_", "all_", "\\u\\u\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "inspect_", "import_", "CO", "\\u", "VAR", "KEYWORDS", "_", ",_", "CO", "\\u", "VAR", "ARGS_", "\\u\\u\\uNEWLINE\\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_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "inspect_", "\\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\\u\\uDEDENT\\u\\u\\u_", "if_", "py3", "k_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callable_", "=_", "callable_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cross", "-", "compatible", " ", "metaclass", " ", "implementation_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2010", "-", "2012", " ", "Ben", "jam", "in", " ", "Peter", "son_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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 ]
Unused local variable
benoitc/dj-webmachine/webmachine/auth/oauth.py
[ { "content": " def fetch_request_token(self, oauth_request):\n \"\"\"Processes a request_token request and returns the\n request token on success.\n \"\"\"\n try:\n # Get the request token for authorization.\n token = self._get_token(oauth_request, TOKEN_REQUEST)\n except oauth2.Error:\n # No token required for the initial token request.\n timestamp = self._get_timestamp(oauth_request)\n version = self._get_version(oauth_request)\n consumer = self._get_consumer(oauth_request)\n try:\n callback = self.get_callback(oauth_request)\n except oauth2.Error:\n callback = None # 1.0, no callback specified.\n\n #hack\n\n self._check_signature(oauth_request, consumer, None)\n # Fetch a new token.\n token = self.datastore.fetch_request_token(consumer,\n callback, timestamp)\n return token", "metadata": "root.OAuthServer.fetch_request_token", "header": "['class', 'OAuthServer', '(', 'oauth2', '.', 'Server', ')', ':', '___EOS___']", "index": 41 }, { "content": " def fetch_access_token(self, oauth_request):\n \"\"\"Processes an access_token request and returns the\n access token on success.\n \"\"\"\n timestamp = self._get_timestamp(oauth_request)\n version = self._get_version(oauth_request)\n consumer = self._get_consumer(oauth_request)\n try:\n verifier = self._get_verifier(oauth_request)\n except oauth2.Error:\n verifier = None\n # Get the request token.\n token = self._get_token(oauth_request, TOKEN_REQUEST)\n self._check_signature(oauth_request, consumer, token)\n new_token = self.datastore.fetch_access_token(consumer, token,\n verifier, timestamp)\n return new_token", "metadata": "root.OAuthServer.fetch_access_token", "header": "['class', 'OAuthServer', '(', 'oauth2', '.', 'Server', ')', ':', '___EOS___']", "index": 66 } ]
[ { "span": "version ", "start_line": 51, "start_column": 12, "end_line": 51, "end_column": 19 }, { "span": "version ", "start_line": 71, "start_column": 8, "end_line": 71, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "OA", "uth", "Server_", "(_", "oauth2", "_", "._", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fetch", "\\u", "request", "\\u", "token_", "(_", "self_", ",_", "oauth", "\\u", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Processe", "s", " ", "a", " ", "request", "\\u", "token", " ", "request", " ", "and", " ", "return", "s", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "token", " ", "on", " ", "success", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "request", " ", "token", " ", "for", " ", "authoriz", "ation", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "token_", "=_", "self_", "._", "\\u", "get", "\\u", "token_", "(_", "oauth", "\\u", "request_", ",_", "TOKEN", "\\u", "REQUEST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "oauth2", "_", "._", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "token", " ", "require", "d", " ", "for", " ", "the", " ", "initial", " ", "token", " ", "request", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timestamp_", "=_", "self_", "._", "\\u", "get", "\\u", "timestamp_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "self_", "._", "\\u", "get", "\\u", "version_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "consumer_", "=_", "self_", "._", "\\u", "get", "\\u", "consumer_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "=_", "self_", "._", "get", "\\u", "callback_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "oauth2", "_", "._", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "=_", "None_", "#", " ", "1.0", ",", " ", "no", " ", "callback", " ", "specified", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "hack", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "check", "\\u", "signature_", "(_", "oauth", "\\u", "request_", ",_", "consumer_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fe", "tch", " ", "a", " ", "new", " ", "token", "._", "\\u\\u\\uNL\\u\\u\\u_", "token_", "=_", "self_", "._", "datastore_", "._", "fetch", "\\u", "request", "\\u", "token_", "(_", "consumer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "callback_", ",_", "timestamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "OA", "uth", "Server_", "(_", "oauth2", "_", "._", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fetch", "\\u", "access", "\\u", "token_", "(_", "self_", ",_", "oauth", "\\u", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Processe", "s", " ", "an", " ", "access", "\\u", "token", " ", "request", " ", "and", " ", "return", "s", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "access", " ", "token", " ", "on", " ", "success", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timestamp_", "=_", "self_", "._", "\\u", "get", "\\u", "timestamp_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "self_", "._", "\\u", "get", "\\u", "version_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "consumer_", "=_", "self_", "._", "\\u", "get", "\\u", "consumer_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "verifier_", "=_", "self_", "._", "\\u", "get", "\\u", "verifier_", "(_", "oauth", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "oauth2", "_", "._", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "verifier_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "request", " ", "token", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "token_", "=_", "self_", "._", "\\u", "get", "\\u", "token_", "(_", "oauth", "\\u", "request_", ",_", "TOKEN", "\\u", "REQUEST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "check", "\\u", "signature_", "(_", "oauth", "\\u", "request_", ",_", "consumer_", ",_", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "token_", "=_", "self_", "._", "datastore_", "._", "fetch", "\\u", "access", "\\u", "token_", "(_", "consumer_", ",_", "token_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "verifier_", ",_", "timestamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "new", "\\u", "token_", "\\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, 0, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
bkonkle/django-reporter/reporter/management/commands/report.py
[ { "content": "import os\nimport datetime\nimport sys\nfrom optparse import make_option\n\nfrom django.core.management.base import BaseCommand, CommandError\nfrom django.utils.importlib import import_module\n\nimport reporter\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Command(BaseCommand):\n help = ('Runs reports, which are registered in reports.py files within'\n 'installed apps. Valid frequencies are \"daily\", \"weekly\", and '\n '\"monthly\". By default, the reports are emailed to the report\\'s '\n 'default recipients. This can be overridden through options. '\n 'Additional arguments after the report name will be passed to '\n 'the report.')\n \n args = 'FREQUENCY REPORT_NAME [REPORT ARGS]'\n \n option_list = BaseCommand.option_list + (\n make_option(\n '-V', '--view',\n action='store_true',\n dest='view',\n help=('Send the data to stdout instead of emailing or saving to a'\n ' file.')\n ),\n make_option(\n '-f', '--filename',\n action='store',\n dest='filename',\n metavar='FILE',\n help=('Instead of emailing the results, save them to the provided'\n ' filename.')\n ),\n make_option(\n '-r', '--recipients',\n action='store',\n dest='recipients',\n metavar='RECIPIENTS',\n help=('Override the default recipients for the report. Seperate '\n 'each email address with a comma. Do not use spaces.')\n ),\n make_option(\n '-l', '--list-all',\n action='store_true',\n dest='list_all',\n help='List all available reports, and then exit.'\n ),\n make_option(\n '-d', '--date',\n action='store',\n dest='date',\n metavar='YYYY-MM-DD',\n help='Provide a date to run the report for.'\n ),\n )\n ", "metadata": "root.Command", "header": "['module', '___EOS___']", "index": 10 }, { "content": " def handle(self, *args, **options):\n # Autodiscover all reports by scanning INSTALLED_APPS for reports.py\n # files.\n reporter.autodiscover()\n \n if options.get('list_all', False):\n # List all reports, printing their docstrings\n print \"Listing all available reports:\"\n available_reports = reporter.get_all()\n frequencies = ['daily', 'weekly', 'monthly']\n for frq in frequencies:\n reports_found = []\n for report_name, report in available_reports.items():\n if frq in report.frequencies:\n reports_found.append(' %s - %s' %\n (report_name,\n report.__doc__.strip()))\n if reports_found:\n print '\\n%s:' % frq.capitalize()\n for report in reports_found:\n print report\n print ('\\nFor more information on how to run reports, use this '\n 'command with the -h option.')\n exit(0)\n \n # Make sure the right number of arguments was provided\n if len(args) < 2:\n raise CommandError('Please provide both a frequency and a '\n 'report name.')\n if not args[0] in ('daily', 'weekly', 'monthly'):\n raise CommandError('Please provide a valid frequency.')\n \n frequency = args[0]\n name = args[1]\n report_args = None\n if len(args) > 2:\n report_args = args[2:]\n date = options.get('date', None)\n if date:\n date = datetime.datetime.strptime(date, '%Y-%m-%d')\n date = datetime.date(date.year, date.month, date.day)\n filename = options.get('filename', None)\n view = options.get('view', False)\n recipients = options.get('recipients', None)\n if recipients:\n recipients = recipients.split(',')\n \n try:\n report_class = reporter.get_report(name)\n report = report_class(frequency, date, view, filename, recipients,\n report_args)\n except (reporter.NotRegistered, reporter.NotAvailable), e:\n raise CommandError(e)\n report.run_report()", "metadata": "root.Command.handle", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 59 } ]
[ { "span": "import os", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 9 }, { "span": "import sys", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 10 }, { "span": "from django.utils.importlib import import_module", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 48 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "optparse_", "import_", "make", "\\u", "option_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "management_", "._", "base_", "import_", "Base", "Command_", ",_", "Command", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "importlib_", "import_", "import", "\\u", "module_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "reporter_", "\\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_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "help_", "=_", "(_", "'", "Run", "s", " ", "report", "s", ",", " ", "whi", "ch", " ", "are", " ", "register", "ed", " ", "in", " ", "report", "s", ".", "py", " ", "files", " ", "within", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "install", "ed", " ", "apps", ".", " ", "Valid", " ", "freque", "ncie", "s", " ", "are", " ", "\"", "daily", "\",", " ", "\"", "week", "ly", "\",", " ", "and", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "month", "ly", "\".", " ", "By", " ", "default", ",", " ", "the", " ", "report", "s", " ", "are", " ", "email", "ed", " ", "to", " ", "the", " ", "report", "\\\\'", "s", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "default", " ", "recip", "ients", ".", " ", "Thi", "s", " ", "can", " ", "be", " ", "overrid", "den", " ", "through", " ", "options", ".", " ", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Addition", "al", " ", "argu", "ment", "s", " ", "after", " ", "the", " ", "report", " ", "name", " ", "will", " ", "be", " ", "pass", "ed", " ", "to", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "the", " ", "report", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "'", "FREQUENCY", " ", "REPORT", "\\u", "NAME", " ", "[", "REPORT", " ", "ARG", "S", "]'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "option", "\\u", "list_", "=_", "Base", "Command_", "._", "option", "\\u", "list_", "+_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "V", "'_", ",_", "'--", "view", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "view", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "(_", "'", "Sen", "d", " ", "the", " ", "data", " ", "to", " ", "stdout", " ", "inst", "ead", " ", "of", " ", "email", "ing", " ", "or", " ", "saving", " ", "to", " ", "a", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", "file", ".'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "f", "'_", ",_", "'--", "filename", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "filename", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "FILE", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "(_", "'", "Ins", "tea", "d", " ", "of", " ", "email", "ing", " ", "the", " ", "results", ",", " ", "save", " ", "them", " ", "to", " ", "the", " ", "provided", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", "filename", ".'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "r", "'_", ",_", "'--", "recip", "ients", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "recip", "ients", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "RECIP", "IENT", "S", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "(_", "'", "Override", " ", "the", " ", "default", " ", "recip", "ients", " ", "for", " ", "the", " ", "report", ".", " ", "Se", "perat", "e", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "each", " ", "email", " ", "address", " ", "with", " ", "a", " ", "comma", ".", " ", "Do", " ", "not", " ", "use", " ", "space", "s", ".'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "l", "'_", ",_", "'--", "list", "-", "all", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "list", "\\u", "all", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "List", " ", "all", " ", "avail", "able", " ", "report", "s", ",", " ", "and", " ", "then", " ", "exit", ".'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "d", "'_", ",_", "'--", "date", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "date", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "'", "YYY", "Y", "-", "MM", "-", "DD", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Prov", "ide", " ", "a", " ", "date", " ", "to", " ", "run", " ", "the", " ", "report", " ", "for", ".'_", "\\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_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "handle_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "options_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Auto", "discove", "r", " ", "all", " ", "report", "s", " ", "by", " ", "scanning", " ", "INSTALLE", "D", "\\u", "APP", "S", " ", "for", " ", "report", "s", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "files", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reporter_", "._", "autodiscover", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "._", "get_", "(_", "'", "list", "\\u", "all", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "List", " ", "all", " ", "report", "s", ",", " ", "printin", "g", " ", "thei", "r", " ", "docstrings", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Listi", "ng", " ", "all", " ", "avail", "able", " ", "report", "s", ":\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avail", "able", "\\u", "reports_", "=_", "reporter_", "._", "get", "\\u", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frequencies_", "=_", "[_", "'", "daily", "'_", ",_", "'", "week", "ly", "'_", ",_", "'", "month", "ly", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fr", "q_", "in_", "frequencies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "report", "s", "\\u", "found_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "report", "\\u", "name_", ",_", "report_", "in_", "avail", "able", "\\u", "reports_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "fr", "q_", "in_", "report_", "._", "frequencies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "report", "s", "\\u", "found_", "._", "append_", "(_", "'", " ", " ", " ", " ", "%", "s", " ", "-", " ", "%", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "report", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "report_", "._", "\\u\\u", "doc\\u\\u_", "._", "strip_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "report", "s", "\\u", "found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "'\\\\", "n", "%", "s", ":'_", "%_", "fr", "q_", "._", "capitalize_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "report_", "in_", "report", "s", "\\u", "found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", "report_", "\\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_", "(_", "'\\\\", "n", "For", " ", "more", " ", "informati", "on", " ", "on", " ", "how", " ", "to", " ", "run", " ", "report", "s", ",", " ", "use", " ", "this", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "command", " ", "with", " ", "the", " ", "-", "h", " ", "option", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "right", " ", "number", " ", "of", " ", "argu", "ment", "s", " ", "was", " ", "provided", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "args_", ")_", "<_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Command", "Error_", "(_", "'", "Ple", "ase", " ", "provide", " ", "bot", "h", " ", "a", " ", "freque", "nc", "y", " ", "and", " ", "a", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "report", " ", "name", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "args_", "[_", "0_", "]_", "in_", "(_", "'", "daily", "'_", ",_", "'", "week", "ly", "'_", ",_", "'", "month", "ly", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Command", "Error_", "(_", "'", "Ple", "ase", " ", "provide", " ", "a", " ", "valid", " ", "freque", "nc", "y", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "frequency_", "=_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "args_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "report", "\\u", "args_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "args_", ")_", ">_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "report", "\\u", "args_", "=_", "args_", "[_", "2_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "date_", "=_", "options_", "._", "get_", "(_", "'", "date", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "date_", "=_", "datetime_", "._", "datetime_", "._", "strptime_", "(_", "date_", ",_", "'%", "Y", "-%", "m", "-%", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "datetime_", "._", "date_", "(_", "date_", "._", "year_", ",_", "date_", "._", "month_", ",_", "date_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "filename_", "=_", "options_", "._", "get_", "(_", "'", "filename", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "view_", "=_", "options_", "._", "get_", "(_", "'", "view", "'_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "recipients_", "=_", "options_", "._", "get_", "(_", "'", "recip", "ients", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "recipients_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "recipients_", "=_", "recipients_", "._", "split_", "(_", "','_", ")_", "\\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 ", " _", "report", "\\u", "class_", "=_", "reporter_", "._", "get", "\\u", "report_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "report_", "=_", "report", "\\u", "class_", "(_", "frequency_", ",_", "date_", ",_", "view_", ",_", "filename_", ",_", "recipients_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "report", "\\u", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "reporter_", "._", "Not", "Register", "ed_", ",_", "reporter_", "._", "Not", "Available_", ")_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Command", "Error_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "report_", "._", "run", "\\u", "report_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
Esri/solutions-geoprocessing-toolbox/data_management/toolboxes/scripts/CalculateFieldDeltaTime.py
[ { "content": "#--------ESRI 2010-------------------------------------\n#-------------------------------------------------------------------------------\n# Copyright 2010-2014 Esri\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# Calculate Field DeltaTime\n# This script will calculate the time spent around a point\n# in a GPS track series as half the timespan between the 2\n# points either side and will add that time in seconds to\n# a numeric field, the name of which is passed as a parameter.\n# Each track (as identified in the Track ID Field) will be\n# treated separately\n# INPUTS:\n#\tGPS Track Points (FEATURECLASS)\n#\tDateTime Field (FIELD)\n#\tField in which to store time spent (FIELD)\n#\tTrack ID Field (FIELD)\n# OUTPUTS:\n#\tGPS Track Points - derived (FEATURECLASS)\n#\n# Date: June 30, 2010\n#------------------------------------------------------\n\nimport arcpy\nimport datetime\nimport sys\nimport time\n\ntry:\n\t#set features and cursors so that they are deletable in\n\t#'finally' block should the script fail prior to their creation\n\tnextfeat, srch_cursor = None, None\n\tupdatefeat, updt_cursor = None, None\n\n\tinPoints = arcpy.GetParameterAsText(0)\n\tinDateField = arcpy.GetParameterAsText(1)\n\tinDeltaTimeField = arcpy.GetParameterAsText(2)\n\tinTrackIDField = arcpy.GetParameterAsText(3)\n\n\tfields = inDateField + ';' + inDeltaTimeField\n\tif inTrackIDField :\n\t\tfields += ';' + inTrackIDField\n\t\t\n\t# WARNING: Workaround encountered using this script in Pro\t\n\t# WARNING 2: SearchCursor now also requires fields at Arcpy Pro\t\n\tif (sys.version_info.major < 3) : \n\t\tsrch_cursor = arcpy.SearchCursor(inPoints, \"\", None, fields, inDateField + \" A\")\n\telse : \n\t\tsrch_cursor = arcpy.gp.SearchCursor(inPoints, \"\", None, fields, inDateField + \" A\")\n\t\n\tnextfeat = next(srch_cursor)\n\tnextfeat = next(srch_cursor) # this cursor looks at the point after the one being updated\n\t\n\t# WARNING: Workaround encountered using this script in Pro\n\tif (sys.version_info.major < 3) : \n\t\tupdt_cursor = arcpy.UpdateCursor(inPoints, \"\", None, fields, inDateField + \" A\")\n\telse :\n\t\tupdt_cursor = arcpy.gp.UpdateCursor(inPoints, \"\", None, fields, inDateField + \" A\")\n\t\n\tupdatefeat = next(updt_cursor)\n\n\tlastdt = None\n\tlastid, thisid, nextid = None, None, None\n\n\ttry : \n\t\n\t\twhile updatefeat:\n\t\t\tthisdt = updatefeat.getValue(inDateField)\n\t\t\tif inTrackIDField:\n\t\t\t\tthisid = updatefeat.getValue(inTrackIDField)\n\t\t\t\tif thisid != lastid:\n\t\t\t\t\tlastdt = None\n\t\t\tif nextfeat:\n\t\t\t\tif inTrackIDField:\n\t\t\t\t\tnextid = nextfeat.getValue(inTrackIDField)\n\t\t\t\tif thisid == nextid:\n\t\t\t\t\tnextdt = nextfeat.getValue(inDateField)\n\t\t\t\telse:\n\t\t\t\t\tnextdt = None\n\t\t\telse:\n\t\t\t\tnextdt = None\n\t\t\tif lastdt:\n\t\t\t\tif nextdt:\n\t\t\t\t\tspan = (nextdt - lastdt)\n\t\t\t\telse:\n\t\t\t\t\tspan = (thisdt - lastdt)\n\t\t\telse:\n\t\t\t\tif nextdt:\n\t\t\t\t\tspan = (nextdt - thisdt)\n\t\t\t\telse:\n\t\t\t\t\tspan = None\n\t\t\tif span:\n\t\t\t\tspan = float(span.seconds) / 2\n\t\t\t\tupdatefeat.setValue(inDeltaTimeField, span)\n\t\t\t\tupdt_cursor.updateRow(updatefeat)\n\n\t\t\tlastid = thisid\n\t\t\tlastdt = thisdt\n\t\t\tupdatefeat = next(updt_cursor)\n\t\t\tif updatefeat:\n\t\t\t\tnextfeat = next(srch_cursor)\n\texcept StopIteration:\n\t\tpass\t# this is expected for iterators that use next()\n\n\tarcpy.SetParameterAsText(4, inPoints)\n\nexcept Exception as err:\n\timport traceback\n\tarcpy.AddError(\n\t\ttraceback.format_exception_only(type(err), err)[0].rstrip())\n\nfinally:\n\tif nextfeat:\n\t\tdel nextfeat\n\tif srch_cursor:\n\t\tdel srch_cursor\n\tif updatefeat:\n\t\tdel updatefeat\n\tif updt_cursor:\n\t\tdel updt_cursor\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import datetime", "start_line": 34, "start_column": 0, "end_line": 34, "end_column": 15 }, { "span": "import time", "start_line": 36, "start_column": 0, "end_line": 36, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#-", "-------", "ESR", "I", " ", "2010", "--------------", "--------------", "---------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2010", "-", "2014", " ", "Es", "ri_", "\\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_", "#", " ", "Calculat", "e", " ", "Field", " ", "Del", "ta", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "script", " ", "will", " ", "calcul", "ate", " ", "the", " ", "time", " ", "spe", "nt", " ", "aro", "und", " ", "a", " ", "point_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "a", " ", "GPS", " ", "track", " ", "series", " ", "as", " ", "half", " ", "the", " ", "timespan", " ", "bet", "ween", " ", "the", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "points", " ", "eit", "her", " ", "side", " ", "and", " ", "will", " ", "add", " ", "tha", "t", " ", "time", " ", "in", " ", "second", "s", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "numeri", "c", " ", "field", ",", " ", "the", " ", "name", " ", "of", " ", "whi", "ch", " ", "is", " ", "pass", "ed", " ", "as", " ", "a", " ", "parameter", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ea", "ch", " ", "track", " ", "(", "as", " ", "identifi", "ed", " ", "in", " ", "the", " ", "Track", " ", "ID", " ", "Field", ")", " ", "will", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "treat", "ed", " ", "separately", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "INPUT", "S", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "GPS", " ", "Track", " ", "Point", "s", " ", "(", "FEATURE", "CLASS", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "Date", "Time", " ", "Field", " ", "(", "FIE", "LD", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "Field", " ", "in", " ", "whi", "ch", " ", "to", " ", "store", " ", "time", " ", "spe", "nt", " ", "(", "FIE", "LD", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "Track", " ", "ID", " ", "Field", " ", "(", "FIE", "LD", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OUTPU", "TS", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "GPS", " ", "Track", " ", "Point", "s", " ", "-", " ", "derive", "d", " ", "(", "FEATURE", "CLASS", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Date", ":", " ", "Jun", "e", " ", "30", ",", " ", "2010_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "-----------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "arcpy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "set", " ", "features", " ", "and", " ", "cursors", " ", "so", " ", "tha", "t", " ", "the", "y", " ", "are", " ", "delet", "able", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#'", "final", "ly", "'", " ", "block", " ", "shou", "ld", " ", "the", " ", "script", " ", "fail", " ", "prior", " ", "to", " ", "thei", "r", " ", "creation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "next", "feat_", ",_", "src", "h", "\\u", "cursor_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "feat_", ",_", "upd", "t", "\\u", "cursor_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "in", "Points_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Date", "Field_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Del", "ta", "Time", "Field_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Track", "IDF", "ield_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fields_", "=_", "in", "Date", "Field_", "+_", "';'_", "+_", "in", "Del", "ta", "Time", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "in", "Track", "IDF", "ield_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "fields_", "+=_", "';'_", "+_", "in", "Track", "IDF", "ield_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WARN", "ING", ":", " ", "Work", "aro", "und", " ", "encounter", "ed", " ", "usi", "ng", " ", "this", " ", "script", " ", "in", " ", "Pro", "\t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WARN", "ING", " ", "2", ":", " ", "Sear", "ch", "Curs", "or", " ", "now", " ", "als", "o", " ", "require", "s", " ", "fields", " ", "at", " ", "Arc", "py", " ", "Pro", "\t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "sys_", "._", "version", "\\u", "info_", "._", "major_", "<_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "src", "h", "\\u", "cursor_", "=_", "arcpy_", "._", "Sear", "ch", "Cursor_", "(_", "in", "Points_", ",_", "\"\"_", ",_", "None_", ",_", "fields_", ",_", "in", "Date", "Field_", "+_", "\"", " ", "A", "\"_", ")_", "\\u\\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_", "src", "h", "\\u", "cursor_", "=_", "arcpy_", "._", "gp_", "._", "Sear", "ch", "Cursor_", "(_", "in", "Points_", ",_", "\"\"_", ",_", "None_", ",_", "fields_", ",_", "in", "Date", "Field_", "+_", "\"", " ", "A", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "next", "feat_", "=_", "next_", "(_", "src", "h", "\\u", "cursor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next", "feat_", "=_", "next_", "(_", "src", "h", "\\u", "cursor_", ")_", "#", " ", "this", " ", "cursor", " ", "look", "s", " ", "at", " ", "the", " ", "point", " ", "after", " ", "the", " ", "one", " ", "bei", "ng", " ", "updated_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WARN", "ING", ":", " ", "Work", "aro", "und", " ", "encounter", "ed", " ", "usi", "ng", " ", "this", " ", "script", " ", "in", " ", "Pro", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "sys_", "._", "version", "\\u", "info_", "._", "major_", "<_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "upd", "t", "\\u", "cursor_", "=_", "arcpy_", "._", "Update", "Cursor_", "(_", "in", "Points_", ",_", "\"\"_", ",_", "None_", ",_", "fields_", ",_", "in", "Date", "Field_", "+_", "\"", " ", "A", "\"_", ")_", "\\u\\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_", "upd", "t", "\\u", "cursor_", "=_", "arcpy_", "._", "gp_", "._", "Update", "Cursor_", "(_", "in", "Points_", ",_", "\"\"_", ",_", "None_", ",_", "fields_", ",_", "in", "Date", "Field_", "+_", "\"", " ", "A", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "update", "feat_", "=_", "next_", "(_", "upd", "t", "\\u", "cursor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "last", "dt_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lasti", "d_", ",_", "this", "id_", ",_", "next", "id_", "=_", "None_", ",_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "while_", "update", "feat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "this", "dt_", "=_", "update", "feat_", "._", "get", "Value_", "(_", "in", "Date", "Field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "in", "Track", "IDF", "ield_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "this", "id_", "=_", "update", "feat_", "._", "get", "Value_", "(_", "in", "Track", "IDF", "ield_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "this", "id_", "!=_", "lasti", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "last", "dt_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "next", "feat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "in", "Track", "IDF", "ield_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "next", "id_", "=_", "next", "feat_", "._", "get", "Value_", "(_", "in", "Track", "IDF", "ield_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "this", "id_", "==_", "next", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "next", "dt_", "=_", "next", "feat_", "._", "get", "Value_", "(_", "in", "Date", "Field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "next", "dt_", "=_", "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\t", "\t\t\t_", "next", "dt_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "last", "dt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "next", "dt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "span_", "=_", "(_", "next", "dt_", "-_", "last", "dt_", ")_", "\\u\\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_", "span_", "=_", "(_", "this", "dt_", "-_", "last", "dt_", ")_", "\\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\t", "\t\t\t_", "if_", "next", "dt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "span_", "=_", "(_", "next", "dt_", "-_", "this", "dt_", ")_", "\\u\\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_", "span_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "span_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "span_", "=_", "float_", "(_", "span_", "._", "seconds_", ")_", "/_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "feat_", "._", "set", "Value_", "(_", "in", "Del", "ta", "Time", "Field_", ",_", "span_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upd", "t", "\\u", "cursor_", "._", "update", "Row_", "(_", "update", "feat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lasti", "d_", "=_", "this", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "dt_", "=_", "this", "dt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "feat_", "=_", "next_", "(_", "upd", "t", "\\u", "cursor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "update", "feat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "next", "feat_", "=_", "next_", "(_", "src", "h", "\\u", "cursor_", ")_", "\\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_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "pass_", "#", " ", "this", " ", "is", " ", "expected", " ", "for", " ", "iterators", " ", "tha", "t", " ", "use", " ", "next", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arcpy_", "._", "Set", "Parameter", "As", "Text_", "(_", "4_", ",_", "in", "Points_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Add", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "traceback_", "._", "format\\u", "exception", "\\u", "only_", "(_", "type_", "(_", "err_", ")_", ",_", "err_", ")_", "[_", "0_", "]_", "._", "rstrip_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "if_", "next", "feat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "del_", "next", "feat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "src", "h", "\\u", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "del_", "src", "h", "\\u", "cursor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "update", "feat_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "del_", "update", "feat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "upd", "t", "\\u", "cursor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "del_", "upd", "t", "\\u", "cursor_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary pass
dikien/Machine-Learning-Newspaper/nytimes/step1_data_wrangling.py
[ { "content": "def trans_json_to_csv(date):\n '''\n if data == 20101010 -> 20101010.csv will be saved with article that were written in 2010.10.10\n :param date: date\n :return: nothing\n '''\n ft = open(\"articles/\"+ date + \".csv\", \"wb+\")\n f = csv.writer(ft, delimiter='\\t')\n payload.update({\"begin_date\" : date, \"end_date\" : date})\n docs_lens = 1\n page = 1\n\n while(docs_lens > 0 and page < 15):\n # when page get around 100, there were some errors.\n try:\n r = requests.get(basic_url, params=payload)\n except:\n r = requests.get(basic_url, params=payload)\n\n # If one day limie query occurs, exit(0)\n if \"X-Mashery-Error-Code\" in r.headers:\n print \"ERR_403_DEVELOPER_OVER_RATE\"\n sys.exit(0)\n\n try:\n contents = r.json()\n for k in contents[\"response\"][\"docs\"]:\n # Don't save \"THE ASSOCIATED PRESS\" and \"REUTERS\" because these are not the goal of this.\n if type(k[\"byline\"]) == dict \\\n and type(k[\"lead_paragraph\"]) == unicode\\\n and k[\"byline\"][\"original\"].replace(\"By \", \"\").encode(\"UTF-8\", errors=\"ignore\") != \"THE ASSOCIATED PRESS\"\\\n and k[\"byline\"][\"original\"].replace(\"By \", \"\").encode(\"UTF-8\", errors=\"ignore\") != \"REUTERS\":\n f.writerow([k[\"byline\"][\"original\"].replace(\"By \", \"\").encode(\"UTF-8\", errors=\"ignore\"), # write \"writer\"\n k[\"lead_paragraph\"].encode(\"UTF-8\", errors=\"ignore\") # write \"lead paragraph\"\n ])\n print \"writer is %s\" % k[\"byline\"][\"original\"].replace(\"By \", \"\")\n time.sleep(0.5)\n # print \"paragraph is %s\" % k[\"lead_paragraph\"]\n\n print \"page number is %s\" % page\n page += 1\n\n docs_lens = len(contents[\"response\"][\"docs\"])\n print \"doc length is %s\" % docs_lens\n payload.update({\"page\" : page})\n\n except Exception as e:\n page += 1\n print \"page number is %s\" % page\n print e\n # print json.dumps(contents, indent=4, sort_keys=True)\n pass\n ft.close()", "metadata": "root.trans_json_to_csv", "header": "['module', '___EOS___']", "index": 16 } ]
[ { "span": "pass", "start_line": 67, "start_column": 12, "end_line": 67, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "trans", "\\u", "json", "\\u", "to", "\\u", "csv_", "(_", "date_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "data", " ", "==", " ", "2010", "1010", " ", "->", " ", "2010", "1010", ".", "csv", " ", "will", " ", "be", " ", "saved", " ", "with", " ", "article", " ", "tha", "t", " ", "wer", "e", " ", "writt", "en", " ", "in", " ", "2010", ".1", "0.10", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "date", ":", " ", "date", "\\", "10", ";", " ", " ", " ", " ", ":", "return", ":", " ", "not", "hing", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ft_", "=_", "open_", "(_", "\"", "article", "s", "/\"_", "+_", "date_", "+_", "\".", "csv", "\"_", ",_", "\"", "wb", "+\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "csv_", "._", "writer_", "(_", "ft_", ",_", "delimiter_", "=_", "'\\\\", "t", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "._", "update_", "(_", "{_", "\"", "begin", "\\u", "date", "\"_", ":_", "date_", ",_", "\"", "end", "\\u", "date", "\"_", ":_", "date_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "docs", "\\u", "lens_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "(_", "docs", "\\u", "lens_", ">_", "0_", "and_", "page_", "<_", "15_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "whe", "n", " ", "page", " ", "get", " ", "aro", "und", " ", "100", ",", " ", "there", " ", "wer", "e", " ", "some", " ", "error", "s", "._", "\\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 ", " _", "r_", "=_", "requests_", "._", "get_", "(_", "basic", "\\u", "url_", ",_", "params_", "=_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "requests_", "._", "get_", "(_", "basic", "\\u", "url_", ",_", "params_", "=_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "one", " ", "day", " ", "lim", "ie", " ", "query", " ", "occur", "s", ",", " ", "exit", "(", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\"", "X", "-", "Mas", "her", "y", "-", "Error", "-", "Code", "\"_", "in_", "r_", "._", "headers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "ERR", "\\u", "403", "\\u", "DEVELO", "PER", "\\u", "OVER", "\\u", "RAT", "E", "\"_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "contents_", "=_", "r_", "._", "json_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "contents_", "[_", "\"", "response", "\"_", "]_", "[_", "\"", "docs", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Don", "'", "t", " ", "save", " ", "\"", "THE", " ", "ASSOC", "IAT", "ED", " ", "PRESS", "\"", " ", "and", " ", "\"", "RE", "UT", "ERS", "\"", " ", "bec", "aus", "e", " ", "these", " ", "are", " ", "not", " ", "the", " ", "goal", " ", "of", " ", "this", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "k_", "[_", "\"", "by", "line", "\"_", "]_", ")_", "==_", "dict_", "and_", "type_", "(_", "k_", "[_", "\"", "lead", "\\u", "paragraph", "\"_", "]_", ")_", "==_", "unicode_", "and_", "k_", "[_", "\"", "by", "line", "\"_", "]_", "[_", "\"", "original", "\"_", "]_", "._", "replace_", "(_", "\"", "By", " ", "\"_", ",_", "\"\"_", ")_", "._", "encode_", "(_", "\"", "UT", "F", "-", "8", "\"_", ",_", "errors_", "=_", "\"", "ignore", "\"_", ")_", "!=_", "\"", "THE", " ", "ASSOC", "IAT", "ED", " ", "PRESS", "\"_", "and_", "k_", "[_", "\"", "by", "line", "\"_", "]_", "[_", "\"", "original", "\"_", "]_", "._", "replace_", "(_", "\"", "By", " ", "\"_", ",_", "\"\"_", ")_", "._", "encode_", "(_", "\"", "UT", "F", "-", "8", "\"_", ",_", "errors_", "=_", "\"", "ignore", "\"_", ")_", "!=_", "\"", "RE", "UT", "ERS", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "writerow_", "(_", "[_", "k_", "[_", "\"", "by", "line", "\"_", "]_", "[_", "\"", "original", "\"_", "]_", "._", "replace_", "(_", "\"", "By", " ", "\"_", ",_", "\"\"_", ")_", "._", "encode_", "(_", "\"", "UT", "F", "-", "8", "\"_", ",_", "errors_", "=_", "\"", "ignore", "\"_", ")_", ",_", "#", " ", "write", " ", "\"", "writer", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "k_", "[_", "\"", "lead", "\\u", "paragraph", "\"_", "]_", "._", "encode_", "(_", "\"", "UT", "F", "-", "8", "\"_", ",_", "errors_", "=_", "\"", "ignore", "\"_", ")_", "#", " ", "write", " ", "\"", "lead", " ", "paragraph", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "writer", " ", "is", " ", "%", "s", "\"_", "%_", "k_", "[_", "\"", "by", "line", "\"_", "]_", "[_", "\"", "original", "\"_", "]_", "._", "replace_", "(_", "\"", "By", " ", "\"_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", " ", "\"", "paragraph", " ", "is", " ", "%", "s", "\"", " ", "%", " ", "k", "[\"", "lead", "\\u", "paragraph", "\"]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "page", " ", "number", " ", "is", " ", "%", "s", "\"_", "%_", "page_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "docs", "\\u", "lens_", "=_", "len_", "(_", "contents_", "[_", "\"", "response", "\"_", "]_", "[_", "\"", "docs", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "doc", " ", "length", " ", "is", " ", "%", "s", "\"_", "%_", "docs", "\\u", "lens_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "._", "update_", "(_", "{_", "\"", "page", "\"_", ":_", "page_", "}_", ")_", "\\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 ", " _", "page_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "page", " ", "number", " ", "is", " ", "%", "s", "\"_", "%_", "page_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", " ", "json", ".", "dump", "s", "(", "content", "s", ",", " ", "indent", "=", "4", ",", " ", "sort", "\\u", "keys", "=", "Tru", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ft_", "._", "close_", "(_", ")_", "\\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, 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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, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
mrknow/filmkodi/plugin.video.specto/resources/lib/libraries/f4mproxy/F4mProxy.py
[ { "content": " def answer_request(self, sendData):\n global g_stopEvent\n global g_downloader\n try:\n\n #Pull apart request path\n request_path=self.path[1:] \n request_path=re.sub(r\"\\?.*\",\"\",request_path)\n #If a request to stop is sent, shut down the proxy\n\n if request_path.lower()==\"stop\":# all special web interfaces here\n sys.exit()\n return\n if request_path.lower()==\"favicon.ico\":\n print 'dont have no icone here, may be in future'\n self.wfile.close()\n return\n\n\n (url,proxy,use_proxy_for_chunks,maxbitrate,simpledownloader, auth,streamtype)=self.decode_url(request_path)\n print 'simpledownloaderxxxxxxxxxxxxxxx',simpledownloader\n if streamtype=='' or streamtype==None or streamtype=='none': streamtype='HDS'\n \n if streamtype=='HDS':\n\n print 'Url received at proxy',url,proxy,use_proxy_for_chunks,maxbitrate\n\n\n #Send file request\n #self.handle_send_request(download_id,file_url, file_name, requested_range,download_mode ,keep_file,connections)\n \n downloader=None\n #downloader=g_downloader\n \n if not downloader or downloader.live==True or not (downloader.init_done and downloader.init_url ==url):\n downloader=F4MDownloader()\n if not downloader.init(self.wfile,url,proxy,use_proxy_for_chunks,g_stopEvent,maxbitrate,auth):\n print 'cannot init'\n return\n g_downloader=downloader\n print 'init...' \n \n enableSeek=False\n requested_range=self.headers.getheader(\"Range\")\n if requested_range==None: requested_range=\"\"\n srange, erange=(None,None)\n \n \n \n if downloader.live==False and len(requested_range)>0 and not requested_range==\"bytes=0-0\": #we have to stream?\n enableSeek=True\n (srange, erange) = self.get_range_request(requested_range, downloader.total_frags)\n \n\n print 'PROXY DATA',downloader.live,enableSeek,requested_range,downloader.total_frags,srange, erange\n enableSeek=False ##disabled for time being, couldn't find better way to handle\n \n framgementToSend=0\n inflate=1815002#(6526684-466/3)#*373/downloader.total_frags# 4142*1024*243/8/40 #1#1024*1024\n if enableSeek:\n #rtype=\"video/x-flv\" #just as default\n self.send_response(206)\n rtype=\"flv-application/octet-stream\" #default type could have gone to the server to get it.\n self.send_header(\"Content-Type\", rtype)\n self.send_header(\"Accept-Ranges\",\"bytes\")\n print 'not LIVE,enable seek',downloader.total_frags\n \n totalsize=downloader.total_frags*inflate\n \n framgementToSend=1#downloader.total_frags\n erange=srange+framgementToSend*inflate\n if erange>=totalsize:\n erange=totalsize-1\n \n # crange=\"bytes \"+str(srange)+\"-\" +str(int(downloader.total_frags-1))+\"/\"+str(downloader.total_frags)#recalculate crange based on srange, portionLen and content_size \n # crange=\"bytes \"+str(srange)+\"-\" +str(int(totalsize-1))+\"/\"+str(totalsize)#recalculate crange based on srange, portionLen and content_size \n crange=\"bytes \"+str(srange)+\"-\" +str(int(erange))+\"/*\"#+str(totalsize)#recalculate crange based on srange, portionLen and content_size \n print srange/inflate,erange/inflate,totalsize/inflate\n self.send_header(\"Content-Length\", str(totalsize))\n self.send_header(\"Content-Range\",crange)\n etag=self.generate_ETag(url)\n self.send_header(\"ETag\",etag)\n print crange\n self.send_header(\"Last-Modified\",\"Wed, 21 Feb 2000 08:43:39 GMT\")\n self.send_header(\"Cache-Control\",\"public, must-revalidate\")\n self.send_header(\"Cache-Control\",\"no-cache\")\n self.send_header(\"Pragma\",\"no-cache\")\n self.send_header(\"features\",\"seekable,stridable\")\n self.send_header(\"client-id\",\"12345\")\n self.send_header(\"Connection\", 'close')\n else:\n self.send_response(200)\n rtype=\"flv-application/octet-stream\" #default type could have gone to the server to get it.\n self.send_header(\"Content-Type\", rtype)\n srange=None\n \n elif streamtype=='SIMPLE' or simpledownloader :\n downloader=interalSimpleDownloader();\n if not downloader.init(self.wfile,url,proxy,g_stopEvent,maxbitrate):\n print 'cannot init'\n return\n srange,framgementToSend=(None,None)\n self.send_response(200)\n rtype=\"flv-application/octet-stream\" #default type could have gone to the server to get it.\n self.send_header(\"Content-Type\", rtype)\n srange=None\n elif streamtype=='HLS' or simpledownloader :\n downloader=HLSDownloader()\n if not downloader.init(self.wfile,url,proxy,use_proxy_for_chunks,g_stopEvent,maxbitrate,auth):\n print 'cannot init'\n return\n \n srange,framgementToSend=(None,None)\n self.send_response(200)\n rtype=\"flv-application/octet-stream\" #default type could have gone to the server to get it.\n self.send_header(\"Content-Type\", rtype)\n srange=None\n \n\n #rtype=\"flv-application/octet-stream\" #default type could have gone to the server to get it. \n #self.send_header(\"Content-Type\", rtype) \n \n self.end_headers()\n if not srange==None:\n srange=srange/inflate\n \n if sendData:\n downloader.keep_sending_video(self.wfile,srange,framgementToSend)\n #runningthread=thread.start_new_thread(downloader.download,(self.wfile,url,proxy,use_proxy_for_chunks,))\n print 'srange,framgementToSend',srange,framgementToSend\n #runningthread=thread.start_new_thread(downloader.keep_sending_video,(self.wfile,srange,framgementToSend,))\n \n xbmc.sleep(500)\n while not downloader.status==\"finished\":\n xbmc.sleep(200);\n\n\n except:\n #Print out a stack trace\n traceback.print_exc()\n g_stopEvent.set()\n self.send_response(404)\n #Close output stream file\n self.wfile.close()\n return\n\n #Close output stream file\n self.wfile.close()\n return ", "metadata": "root.MyHandler.answer_request", "header": "['class', 'MyHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 69 } ]
[ { "span": "self.send_response(206)", "start_line": 130, "start_column": 20, "end_line": 130, "end_column": 43 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "My", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "answer", "\\u", "request_", "(_", "self_", ",_", "send", "Data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "g", "\\u", "stop", "Event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global_", "g", "\\u", "downloader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Pul", "l", " ", "apart", " ", "request", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "\\u", "path_", "=_", "self_", "._", "path_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request", "\\u", "path_", "=_", "re_", "._", "sub_", "(_", "r", "\"\\\\", "?", ".*\"_", ",_", "\"\"_", ",_", "request", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "If", " ", "a", " ", "request", " ", "to", " ", "stop", " ", "is", " ", "sent", ",", " ", "shut", " ", "down", " ", "the", " ", "proxy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request", "\\u", "path_", "._", "lower_", "(_", ")_", "==_", "\"", "stop", "\"_", ":_", "#", " ", "all", " ", "special", " ", "web", " ", "interface", "s", " ", "here_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request", "\\u", "path_", "._", "lower_", "(_", ")_", "==_", "\"", "fav", "icon", ".", "ico", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "don", "t", " ", "have", " ", "no", " ", "icon", "e", " ", "here", ",", " ", "may", " ", "be", " ", "in", " ", "future", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "(_", "url_", ",_", "proxy_", ",_", "use", "\\u", "proxy", "\\u", "for", "\\u", "chunks_", ",_", "max", "bitrate_", ",_", "simple", "downloader_", ",_", "auth_", ",_", "stream", "type_", ")_", "=_", "self_", "._", "decode", "\\u", "url_", "(_", "request", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "simple", "downloader", "xxxxxxxx", "xxxxxx", "x", "'_", ",_", "simple", "downloader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "stream", "type_", "==_", "''_", "or_", "stream", "type_", "==_", "None_", "or_", "stream", "type_", "==_", "'", "none", "'_", ":_", "stream", "type_", "=_", "'", "HD", "S", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "stream", "type_", "==_", "'", "HD", "S", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Ur", "l", " ", "receive", "d", " ", "at", " ", "proxy", "'_", ",_", "url_", ",_", "proxy_", ",_", "use", "\\u", "proxy", "\\u", "for", "\\u", "chunks_", ",_", "max", "bitrate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Sen", "d", " ", "file", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "handle", "\\u", "send", "\\u", "request", "(", "download", "\\u", "id", ",", "file", "\\u", "url", ",", " ", "file", "\\u", "name", ",", " ", "request", "ed", "\\u", "range", ",", "download", "\\u", "mode", " ", ",", "keep", "\\u", "file", ",", "connections", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "downloader_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "downloader", "=", "g", "\\u", "downloader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "downloader_", "or_", "downloader_", "._", "live_", "==_", "True_", "or_", "not_", "(_", "downloader_", "._", "init", "\\u", "done_", "and_", "downloader_", "._", "init", "\\u", "url_", "==_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "downloader_", "=_", "F4", "MD", "own", "loader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "downloader_", "._", "init_", "(_", "self_", "._", "wfile_", ",_", "url_", ",_", "proxy_", ",_", "use", "\\u", "proxy", "\\u", "for", "\\u", "chunks_", ",_", "g", "\\u", "stop", "Event_", ",_", "max", "bitrate_", ",_", "auth_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", "'", "cann", "ot", " ", "init", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "g", "\\u", "downloader_", "=_", "downloader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "init", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "enable", "Seek", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request", "ed", "\\u", "range_", "=_", "self_", "._", "headers_", "._", "getheader_", "(_", "\"", "Range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request", "ed", "\\u", "range_", "==_", "None_", ":_", "request", "ed", "\\u", "range_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sra", "nge_", ",_", "era", "nge_", "=_", "(_", "None_", ",_", "None_", ")_", "\\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_", "downloader_", "._", "live_", "==_", "False_", "and_", "len_", "(_", "request", "ed", "\\u", "range_", ")_", ">_", "0_", "and_", "not_", "request", "ed", "\\u", "range_", "==_", "\"", "bytes", "=", "0", "-0", "\"_", ":_", "#", "we", " ", "have", " ", "to", " ", "stream", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "enable", "Seek", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "sra", "nge_", ",_", "era", "nge_", ")_", "=_", "self_", "._", "get", "\\u", "range", "\\u", "request_", "(_", "request", "ed", "\\u", "range_", ",_", "downloader_", "._", "total", "\\u", "frags", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'", "PROX", "Y", " ", "DATA", "'_", ",_", "downloader_", "._", "live_", ",_", "enable", "Seek", "_", ",_", "request", "ed", "\\u", "range_", ",_", "downloader_", "._", "total", "\\u", "frags", "_", ",_", "sra", "nge_", ",_", "era", "nge_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enable", "Seek", "_", "=_", "False_", "##", "disable", "d", " ", "for", " ", "time", " ", "bei", "ng", ",", " ", "coul", "dn", "'", "t", " ", "find", " ", "bett", "er", " ", "way", " ", "to", " ", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fra", "mg", "ement", "To", "Send_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "infla", "te_", "=_", "181", "500", "2_", "#(", "652", "668", "4", "-", "466", "/", "3", ")#", "*", "373", "/", "downloader", ".", "total", "\\u", "frags", "#", " ", "414", "2", "*", "1024", "*", "243", "/", "8", "/", "40", " ", "#", "1", "#", "1024", "*", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "enable", "Seek", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "rty", "pe", "=\"", "video", "/", "x", "-", "fl", "v", "\"", " ", "#", "just", " ", "as", " ", "default_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "send", "\\u", "response_", "(_", "206_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rtype_", "=_", "\"", "fl", "v", "-", "applica", "tion", "/", "oct", "et", "-", "stream", "\"_", "#", "default", " ", "type", " ", "coul", "d", " ", "have", " ", "gone", " ", "to", " ", "the", " ", "server", " ", "to", " ", "get", " ", "it", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "Type", "\"_", ",_", "rtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Accept", "-", "Range", "s", "\"_", ",_", "\"", "bytes", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "not", " ", "LIVE", ",", "enable", " ", "seek", "'_", ",_", "downloader_", "._", "total", "\\u", "frags", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "totals", "ize_", "=_", "downloader_", "._", "total", "\\u", "frags", "_", "*_", "infla", "te_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fra", "mg", "ement", "To", "Send_", "=_", "1_", "#", "downloader", ".", "total", "\\u", "frags", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "era", "nge_", "=_", "sra", "nge_", "+_", "fra", "mg", "ement", "To", "Send_", "*_", "infla", "te_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "era", "nge_", ">=_", "totals", "ize_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "era", "nge_", "=_", "totals", "ize_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "cra", "nge", "=\"", "bytes", " ", "\"+", "str", "(", "sra", "nge", ")+", "\"-", "\"", " ", "+", "str", "(", "int", "(", "downloader", ".", "total", "\\u", "frags", "-1", "))", "+\"", "/\"", "+", "str", "(", "downloader", ".", "total", "\\u", "frags", ")#", "recalc", "ulate", " ", "cra", "nge", " ", "based", " ", "on", " ", "sra", "nge", ",", " ", "porti", "on", "Len", " ", "and", " ", "content", "\\u", "size", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "cra", "nge", "=\"", "bytes", " ", "\"+", "str", "(", "sra", "nge", ")+", "\"-", "\"", " ", "+", "str", "(", "int", "(", "totals", "ize", "-1", "))", "+\"", "/\"", "+", "str", "(", "totals", "ize", ")#", "recalc", "ulate", " ", "cra", "nge", " ", "based", " ", "on", " ", "sra", "nge", ",", " ", "porti", "on", "Len", " ", "and", " ", "content", "\\u", "size", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cra", "nge_", "=_", "\"", "bytes", " ", "\"_", "+_", "str_", "(_", "sra", "nge_", ")_", "+_", "\"-\"_", "+_", "str_", "(_", "int_", "(_", "era", "nge_", ")_", ")_", "+_", "\"/*", "\"_", "#", "+", "str", "(", "totals", "ize", ")#", "recalc", "ulate", " ", "cra", "nge", " ", "based", " ", "on", " ", "sra", "nge", ",", " ", "porti", "on", "Len", " ", "and", " ", "content", "\\u", "size", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "sra", "nge_", "/_", "infla", "te_", ",_", "era", "nge_", "/_", "infla", "te_", ",_", "totals", "ize_", "/_", "infla", "te_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "Length", "\"_", ",_", "str_", "(_", "totals", "ize_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "Range", "\"_", ",_", "cra", "nge_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "etag_", "=_", "self_", "._", "generat", "e\\u", "ET", "ag_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "ET", "ag", "\"_", ",_", "etag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "cra", "nge_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Las", "t", "-", "Modifie", "d", "\"_", ",_", "\"", "We", "d", ",", " ", "21", " ", "Fe", "b", " ", "2000", " ", "0", "8", ":", "4", "3", ":", "3", "9", " ", "GM", "T", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Cache", "-", "Control", "\"_", ",_", "\"", "public", ",", " ", "must", "-", "rev", "alid", "ate", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Cache", "-", "Control", "\"_", ",_", "\"", "no", "-", "cache", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Pra", "gma", "\"_", ",_", "\"", "no", "-", "cache", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "features", "\"_", ",_", "\"", "seek", "able", ",", "stri", "dable", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "client", "-", "id", "\"_", ",_", "\"", "12345", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Connect", "ion", "\"_", ",_", "'", "close", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rtype_", "=_", "\"", "fl", "v", "-", "applica", "tion", "/", "oct", "et", "-", "stream", "\"_", "#", "default", " ", "type", " ", "coul", "d", " ", "have", " ", "gone", " ", "to", " ", "the", " ", "server", " ", "to", " ", "get", " ", "it", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "Type", "\"_", ",_", "rtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sra", "nge_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "stream", "type_", "==_", "'", "SIMPLE", "'_", "or_", "simple", "downloader_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "downloader_", "=_", "inter", "al", "Simple", "Downloader_", "(_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "downloader_", "._", "init_", "(_", "self_", "._", "wfile_", ",_", "url_", ",_", "proxy_", ",_", "g", "\\u", "stop", "Event_", ",_", "max", "bitrate_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "'", "cann", "ot", " ", "init", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sra", "nge_", ",_", "fra", "mg", "ement", "To", "Send_", "=_", "(_", "None_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rtype_", "=_", "\"", "fl", "v", "-", "applica", "tion", "/", "oct", "et", "-", "stream", "\"_", "#", "default", " ", "type", " ", "coul", "d", " ", "have", " ", "gone", " ", "to", " ", "the", " ", "server", " ", "to", " ", "get", " ", "it", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "Type", "\"_", ",_", "rtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sra", "nge_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "stream", "type_", "==_", "'", "HL", "S", "'_", "or_", "simple", "downloader_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "downloader_", "=_", "HL", "SD", "own", "loader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "downloader_", "._", "init_", "(_", "self_", "._", "wfile_", ",_", "url_", ",_", "proxy_", ",_", "use", "\\u", "proxy", "\\u", "for", "\\u", "chunks_", ",_", "g", "\\u", "stop", "Event_", ",_", "max", "bitrate_", ",_", "auth_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "'", "cann", "ot", " ", "init", "'_", "\\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_", "sra", "nge_", ",_", "fra", "mg", "ement", "To", "Send_", "=_", "(_", "None_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rtype_", "=_", "\"", "fl", "v", "-", "applica", "tion", "/", "oct", "et", "-", "stream", "\"_", "#", "default", " ", "type", " ", "coul", "d", " ", "have", " ", "gone", " ", "to", " ", "the", " ", "server", " ", "to", " ", "get", " ", "it", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "\"", "Conten", "t", "-", "Type", "\"_", ",_", "rtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sra", "nge_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "rty", "pe", "=\"", "fl", "v", "-", "applica", "tion", "/", "oct", "et", "-", "stream", "\"", " ", " ", "#", "default", " ", "type", " ", "coul", "d", " ", "have", " ", "gone", " ", "to", " ", "the", " ", "server", " ", "to", " ", "get", " ", "it", ".", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "send", "\\u", "header", "(\"", "Conten", "t", "-", "Type", "\",", " ", "rty", "pe", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "sra", "nge_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sra", "nge_", "=_", "sra", "nge_", "/_", "infla", "te_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "send", "Data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "downloader_", "._", "keep", "\\u", "sendin", "g", "\\u", "video_", "(_", "self_", "._", "wfile_", ",_", "sra", "nge_", ",_", "fra", "mg", "ement", "To", "Send_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "runn", "ing", "thread", "=", "thread", ".", "start", "\\u", "new", "\\u", "thread", "(", "downloader", ".", "download", ",(", "self", ".", "wf", "ile", ",", "url", ",", "proxy", ",", "use", "\\u", "proxy", "\\u", "for", "\\u", "chunks", ",)", ")_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "sra", "nge", ",", "fra", "mg", "ement", "To", "Sen", "d", "'_", ",_", "sra", "nge_", ",_", "fra", "mg", "ement", "To", "Send_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "runn", "ing", "thread", "=", "thread", ".", "start", "\\u", "new", "\\u", "thread", "(", "downloader", ".", "keep", "\\u", "sendin", "g", "\\u", "video", ",(", "self", ".", "wf", "ile", ",", "sra", "nge", ",", "fra", "mg", "ement", "To", "Sen", "d", ",)", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xbmc_", "._", "sleep_", "(_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not_", "downloader_", "._", "status_", "==_", "\"", "finish", "ed", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "xbmc_", "._", "sleep_", "(_", "200_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Print", " ", "out", " ", "a", " ", "stack", " ", "trace_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "stop", "Event_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "response_", "(_", "404_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Clos", "e", " ", "output", " ", "stream", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "wfile_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Clos", "e", " ", "output", " ", "stream", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "wfile_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
openaps/openaps/openaps/vendors/medtronic.py
[ { "content": " def setup_medtronic (self):\n log = logging.getLogger(decocare.__name__)\n level = getattr(logging, self.device.get('logLevel', 'WARN'))\n address = self.device.get('logAddress', '/dev/log')\n log.setLevel(level)\n for previous in log.handlers[:]:\n log.removeHandler(previous)\n log.addHandler(logging.handlers.SysLogHandler(address=address))\n self.uart = stick.Stick(link.Link(self.scanner( )))\n self.uart.open( )\n serial = self.device.get('serial')\n self.pump = session.Pump(self.uart, serial)\n stats = self.uart.interface_stats( )", "metadata": "root.MedtronicTask.setup_medtronic", "header": "['class', 'MedtronicTask', '(', 'scan', ')', ':', '___EOS___']", "index": 131 } ]
[ { "span": "stats ", "start_line": 143, "start_column": 4, "end_line": 143, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Med", "tron", "ic", "Task_", "(_", "scan_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "setup", "\\u", "med", "tron", "ic_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "deco", "care", "_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level_", "=_", "getattr_", "(_", "logging_", ",_", "self_", "._", "device_", "._", "get_", "(_", "'", "log", "Leve", "l", "'_", ",_", "'", "WARN", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "address_", "=_", "self_", "._", "device_", "._", "get_", "(_", "'", "log", "Address", "'_", ",_", "'/", "dev", "/", "log", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "set", "Level_", "(_", "level_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "previous_", "in_", "log_", "._", "handlers_", "[_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "remove", "Handler_", "(_", "previous_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "add", "Handler_", "(_", "logging_", "._", "handlers_", "._", "Sys", "Log", "Handler_", "(_", "address_", "=_", "address_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "uar", "t_", "=_", "stick", "_", "._", "Stick", "_", "(_", "link_", "._", "Link_", "(_", "self_", "._", "scanner_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "uar", "t_", "._", "open_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "serial_", "=_", "self_", "._", "device_", "._", "get_", "(_", "'", "serial", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pump", "_", "=_", "session_", "._", "Pump", "_", "(_", "self_", "._", "uar", "t_", ",_", "serial_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stats_", "=_", "self_", "._", "uar", "t_", "._", "interface", "\\u", "stats_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
codelikeagirlcny/python-lessons-cny/code-exercises-etc/section_03_(conditionals)/life.py
[ { "content": "# What you can do in life\n# Change the age and gender to change the behavior of this program\n\n# Note the indentation levels and the nesting of different if and elif statements.\n\nage = 10\ngender = 'f'\n\nif age < 2:\n print \"You can eat and poo all day and people will fall all over themselves over how adorable you are\"\n\nelif age == 2:\n print \"You can throw tantrums and it's pretty much expected\"\n\nelif age == 3:\n print \"By this point, you are the master of object permanence.\"\n\nelif 4 <= age <= 6: # is age between 4 and 6?\n print \"This seems like a good time to learn how to read.\"\n\n if age == 4:\n print \"How about some preschool?\"\n elif age == 5:\n print \"Kindergarten is cool -- nap time rocks. Don't forget to share.\"\n elif age == 6:\n print \"First grade. Naptime is a thing of the past. You're probably too stubborn to be upset much by this.\"\n\nelif 7 <= age <= 9: # is age between 7 and 9?\n print \"Grade school goes by so quickly\"\n\nelif 10 <= age <= 11: # is age between 10 and 11?\n print \"Middle school is kind of neat.\"\n\n if age == 10:\n print \"Health class for the first time ...\"\n\n if gender.lower() == 'f':\n print \"... Well, that explains a lot, really.\"\n elif gender.lower() == 'm':\n print \"Wonder what the girls are all talking about?\"\n\n elif age == 11:\n print \"The periodic table is SO COOL\"\n\nelif 12 <= age <= 13: # is age between 12 and 13?\n print \"Junior high, aka welcome to hormone land\"\n print \"PS: sucks to be you\"\n\nelif 14 <= age <= 17: # is age between 14 and 17?\n print \"High school was probably the worst\"\n print \"Why on earth did everyone say it was the best time of their life?\"\n\n if age >= 16:\n print \"But you can drive, so you've got that going for you\"\n\nelif age == 18:\n print \"So you're technically an adult now. But not really.\"\n print \"But you can vote, so you've got that going for you.\"\n print \"PS: you have responsibilities now. sucks to be you\"\n\n if gender.lower() == 'm':\n print \"Better register for the draft.\"\n\nelif 19 <= age <= 20:\n print \"Now's a good time to be in college.\"\n\nelif age == 21:\n print \"Well, you can drink now.\"\n\nelif 22 <= age <= 24:\n print \"Graduating college and spoiling your liver, mostly.\"\n\nelif age == 25:\n print \"You can rent a car now. You know, that's never actually come up for me, but apparently it's a thing ...\"\n\nelse: # In all other cases not covered by the ifs and elifs above\n\n print \"You're an adult. Do what you want.\"\n\n if age > 30 and gender.lower() == 'f': # Note that both of these conditions must be true\n print \"Meddling folks are going to start hectoring you about your love life. Yawn.\"\n\n # Notice how the if statements below are all evaluated independently\n\n if age > 40:\n print \"You're over the hill\"\n\n if age > 50:\n print \"Everything hurts and your children never call.\"\n\n if age > 70:\n print \"You're old enough not to care about anything. You can now do what you like with total impunity.\"", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "print \"You can eat and poo all day and people will fall all over themselves over how adorable you are\"", "start_line": 9, "start_column": 4, "end_line": 9, "end_column": 106 }, { "span": "print \"You can throw tantrums and it's pretty much expected\"", "start_line": 12, "start_column": 4, "end_line": 12, "end_column": 64 }, { "span": "print \"By this point, you are the master of object permanence.\"", "start_line": 15, "start_column": 4, "end_line": 15, "end_column": 67 }, { "span": "print \"How about some preschool?\"", "start_line": 21, "start_column": 8, "end_line": 21, "end_column": 41 }, { "span": "print \"Kindergarten is cool -- nap time rocks. Don't forget to share.\"", "start_line": 23, "start_column": 8, "end_line": 23, "end_column": 79 }, { "span": "print \"First grade. Naptime is a thing of the past. You're probably too stubborn to be upset much by this.\"", "start_line": 25, "start_column": 8, "end_line": 25, "end_column": 116 }, { "span": "elif age == 11:", "start_line": 41, "start_column": 4, "end_line": 41, "end_column": 19 }, { "span": "print \"But you can drive, so you've got that going for you\"", "start_line": 53, "start_column": 8, "end_line": 53, "end_column": 67 }, { "span": "print \"So you're technically an adult now. But not really.\"", "start_line": 56, "start_column": 4, "end_line": 56, "end_column": 63 }, { "span": "print \"Well, you can drink now.\"", "start_line": 67, "start_column": 4, "end_line": 67, "end_column": 36 }, { "span": "print \"You can rent a car now. You know, that's never actually come up for me, but apparently it's a thing ...\"", "start_line": 73, "start_column": 4, "end_line": 73, "end_column": 116 }, { "span": "print \"Meddling folks are going to start hectoring you about your love life. Yawn.\"", "start_line": 80, "start_column": 8, "end_line": 80, "end_column": 92 }, { "span": "print \"You're over the hill\"", "start_line": 85, "start_column": 8, "end_line": 85, "end_column": 36 }, { "span": "print \"Everything hurts and your children never call.\"", "start_line": 88, "start_column": 8, "end_line": 88, "end_column": 62 }, { "span": "print \"You're old enough not to care about anything. You can now do what you like with total impunity.\"", "start_line": 91, "start_column": 8, "end_line": 91, "end_column": 112 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "What", " ", "you", " ", "can", " ", "do", " ", "in", " ", "life_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Change", " ", "the", " ", "age", " ", "and", " ", "gender", " ", "to", " ", "change", " ", "the", " ", "behavior", " ", "of", " ", "this", " ", "program_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Not", "e", " ", "the", " ", "indent", "ation", " ", "level", "s", " ", "and", " ", "the", " ", "nesting", " ", "of", " ", "different", " ", "if", " ", "and", " ", "eli", "f", " ", "statem", "ents", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "age_", "=_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gender_", "=_", "'", "f", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "age_", "<_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "You", " ", "can", " ", "eat", " ", "and", " ", "poo", " ", "all", " ", "day", " ", "and", " ", "people", " ", "will", " ", "fall", " ", "all", " ", "over", " ", "them", "sel", "ves", " ", "over", " ", "how", " ", "ador", "able", " ", "you", " ", "are", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "You", " ", "can", " ", "throw", " ", "tant", "rum", "s", " ", "and", " ", "it", "'", "s", " ", "pretty", " ", "muc", "h", " ", "expected", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "By", " ", "this", " ", "point", ",", " ", "you", " ", "are", " ", "the", " ", "master", " ", "of", " ", "object", " ", "perm", "ane", "nce", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "4_", "<=_", "age_", "<=_", "6_", ":_", "#", " ", "is", " ", "age", " ", "bet", "ween", " ", "4", " ", "and", " ", "6", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Thi", "s", " ", "see", "ms", " ", "like", " ", "a", " ", "good", " ", "time", " ", "to", " ", "learn", " ", "how", " ", "to", " ", "read", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "age_", "==_", "4_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Ho", "w", " ", "abo", "ut", " ", "some", " ", "presc", "hoo", "l", "?\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Kin", "der", "gar", "ten", " ", "is", " ", "cool", " ", "--", " ", "nap", " ", "time", " ", "rock", "s", ".", " ", " ", "Don", "'", "t", " ", "forget", " ", "to", " ", "share", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "6_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Fi", "rst", " ", "grade", ".", " ", " ", "Na", "pti", "me", " ", "is", " ", "a", " ", "thing", " ", "of", " ", "the", " ", "past", ".", " ", "You", "'", "re", " ", "probab", "ly", " ", "too", " ", "stub", "born", " ", "to", " ", "be", " ", "upse", "t", " ", "muc", "h", " ", "by", " ", "this", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "7_", "<=_", "age_", "<=_", "9_", ":_", "#", " ", "is", " ", "age", " ", "bet", "ween", " ", "7", " ", "and", " ", "9", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Grade", " ", "school", " ", "go", "es", " ", "by", " ", "so", " ", "quickl", "y", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "10_", "<=_", "age_", "<=_", "11_", ":_", "#", " ", "is", " ", "age", " ", "bet", "ween", " ", "10", " ", "and", " ", "11", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Mid", "dle", " ", "school", " ", "is", " ", "kind", " ", "of", " ", "nea", "t", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "age_", "==_", "10_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Health", " ", "class", " ", "for", " ", "the", " ", "first", " ", "time", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "gender_", "._", "lower_", "(_", ")_", "==_", "'", "f", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"...", " ", "Wel", "l", ",", " ", "tha", "t", " ", "explain", "s", " ", "a", " ", "lot", ",", " ", "reall", "y", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "gender_", "._", "lower_", "(_", ")_", "==_", "'", "m", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Wo", "nder", " ", "what", " ", "the", " ", "girl", "s", " ", "are", " ", "all", " ", "talk", "ing", " ", "abo", "ut", "?\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "11_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "The", " ", "periodic", " ", "table", " ", "is", " ", "SO", " ", "COO", "L", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "12_", "<=_", "age_", "<=_", "13_", ":_", "#", " ", "is", " ", "age", " ", "bet", "ween", " ", "1", "2", " ", "and", " ", "13", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Jun", "ior", " ", "high", ",", " ", "aka", " ", "welcome", " ", "to", " ", "hor", "mone", " ", "land", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "PS", ":", " ", "suc", "ks", " ", "to", " ", "be", " ", "you", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "14_", "<=_", "age_", "<=_", "17_", ":_", "#", " ", "is", " ", "age", " ", "bet", "ween", " ", "14", " ", "and", " ", "1", "7", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Hig", "h", " ", "school", " ", "was", " ", "probab", "ly", " ", "the", " ", "worst", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Wh", "y", " ", "on", " ", "earth", " ", "did", " ", "everyone", " ", "say", " ", "it", " ", "was", " ", "the", " ", "best", " ", "time", " ", "of", " ", "thei", "r", " ", "life", "?\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "age_", ">=_", "16_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Bu", "t", " ", "you", " ", "can", " ", "drive", ",", " ", "so", " ", "you", "'", "ve", " ", "got", " ", "tha", "t", " ", "goi", "ng", " ", "for", " ", "you", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "18_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "So", " ", "you", "'", "re", " ", "technical", "ly", " ", "an", " ", "adult", " ", "now", ".", " ", "Bu", "t", " ", "not", " ", "reall", "y", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Bu", "t", " ", "you", " ", "can", " ", "vote", ",", " ", "so", " ", "you", "'", "ve", " ", "got", " ", "tha", "t", " ", "goi", "ng", " ", "for", " ", "you", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "PS", ":", " ", "you", " ", "have", " ", "responsib", "ilities", " ", "now", ".", " ", "suc", "ks", " ", "to", " ", "be", " ", "you", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "gender_", "._", "lower_", "(_", ")_", "==_", "'", "m", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Bet", "ter", " ", "register", " ", "for", " ", "the", " ", "draft", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "19_", "<=_", "age_", "<=_", "20_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", "w", "'", "s", " ", "a", " ", "good", " ", "time", " ", "to", " ", "be", " ", "in", " ", "college", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "21_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Wel", "l", ",", " ", "you", " ", "can", " ", "drink", " ", "now", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "22_", "<=_", "age_", "<=_", "24_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Grad", "uat", "ing", " ", "college", " ", "and", " ", "spo", "ilin", "g", " ", "your", " ", "live", "r", ",", " ", "most", "ly", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "age_", "==_", "25_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "You", " ", "can", " ", "rent", " ", "a", " ", "car", " ", "now", ".", " ", " ", "You", " ", "know", ",", " ", "tha", "t", "'", "s", " ", "neve", "r", " ", "actual", "ly", " ", "come", " ", "up", " ", "for", " ", "me", ",", " ", "but", " ", "appare", "ntl", "y", " ", "it", "'", "s", " ", "a", " ", "thing", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", " ", "In", " ", "all", " ", "other", " ", "case", "s", " ", "not", " ", "covered", " ", "by", " ", "the", " ", "ifs", " ", "and", " ", "eli", "fs", " ", "above_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "You", "'", "re", " ", "an", " ", "adult", ".", " ", " ", "Do", " ", "what", " ", "you", " ", "want", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "age_", ">_", "30_", "and_", "gender_", "._", "lower_", "(_", ")_", "==_", "'", "f", "'_", ":_", "#", " ", "Not", "e", " ", "tha", "t", " ", "bot", "h", " ", "of", " ", "these", " ", "condition", "s", " ", "must", " ", "be", " ", "true_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Med", "dli", "ng", " ", "fol", "ks", " ", "are", " ", "goi", "ng", " ", "to", " ", "start", " ", "he", "ctor", "ing", " ", "you", " ", "abo", "ut", " ", "your", " ", "love", " ", "life", ".", " ", " ", "Ya", "wn", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Noti", "ce", " ", "how", " ", "the", " ", "if", " ", "statem", "ents", " ", "belo", "w", " ", "are", " ", "all", " ", "evaluate", "d", " ", "independent", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "age_", ">_", "40_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "You", "'", "re", " ", "over", " ", "the", " ", "hill", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "age_", ">_", "50_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Every", "thing", " ", "hur", "ts", " ", "and", " ", "your", " ", "child", "ren", " ", "neve", "r", " ", "call", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "age_", ">_", "70_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "You", "'", "re", " ", "old", " ", "eno", "ugh", " ", "not", " ", "to", " ", "care", " ", "abo", "ut", " ", "anyt", "hing", ".", " ", " ", "You", " ", "can", " ", "now", " ", "do", " ", "what", " ", "you", " ", "like", " ", "with", " ", "total", " ", "impu", "nit", "y", ".\"_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Except block handles 'BaseException'
scipy/scipy/scipy/linalg/tests/test_fblas.py
[ { "content": " def test_x_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n y = zeros(6,x.dtype)\n try:\n self.blas_func(x,y,n=4,incx=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseAxpy.test_x_bad_size", "header": "['class', 'BaseAxpy', '(', 'object', ')', ':', '___EOS___']", "index": 88 }, { "content": " def test_y_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n y = zeros(6,x.dtype)\n try:\n self.blas_func(x,y,n=3,incy=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseAxpy.test_y_bad_size", "header": "['class', 'BaseAxpy', '(', 'object', ')', ':', '___EOS___']", "index": 98 }, { "content": " def test_x_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n try:\n self.blas_func(2.,x,n=4,incx=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseScal.test_x_bad_size", "header": "['class', 'BaseScal', '(', 'object', ')', ':', '___EOS___']", "index": 154 }, { "content": " def test_x_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n y = zeros(6,x.dtype)\n try:\n self.blas_func(x,y,n=4,incx=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseCopy.test_x_bad_size", "header": "['class', 'BaseCopy', '(', 'object', ')', ':', '___EOS___']", "index": 220 }, { "content": " def test_y_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n y = zeros(6,x.dtype)\n try:\n self.blas_func(x,y,n=3,incy=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseCopy.test_y_bad_size", "header": "['class', 'BaseCopy', '(', 'object', ')', ':', '___EOS___']", "index": 230 }, { "content": " def test_x_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n y = zeros(6,x.dtype)\n try:\n self.blas_func(x,y,n=4,incx=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseSwap.test_x_bad_size", "header": "['class', 'BaseSwap', '(', 'object', ')', ':', '___EOS___']", "index": 316 }, { "content": " def test_y_bad_size(self):\n x = arange(12.,dtype=self.dtype)\n y = zeros(6,x.dtype)\n try:\n self.blas_func(x,y,n=3,incy=5)\n except: # what kind of error should be caught?\n return\n # should catch error and never get here\n assert_(0)", "metadata": "root.BaseSwap.test_y_bad_size", "header": "['class', 'BaseSwap', '(', 'object', ')', ':', '___EOS___']", "index": 326 }, { "content": " def test_x_stride_assert(self):\n # What is the use of this test?\n alpha,beta,a,x,y = self.get_data(x_stride=2)\n try:\n y = self.blas_func(1,a,x,1,y,trans=0,incx=3)\n assert_(0)\n except:\n pass\n try:\n y = self.blas_func(1,a,x,1,y,trans=1,incx=3)\n assert_(0)\n except:\n pass", "metadata": "root.BaseGemv.test_x_stride_assert", "header": "['class', 'BaseGemv', '(', 'object', ')', ':', '___EOS___']", "index": 419 }, { "content": " def test_y_stride_assert(self):\n # What is the use of this test?\n alpha,beta,a,x,y = self.get_data(y_stride=2)\n try:\n y = self.blas_func(1,a,x,1,y,trans=0,incy=3)\n assert_(0)\n except:\n pass\n try:\n y = self.blas_func(1,a,x,1,y,trans=1,incy=3)\n assert_(0)\n except:\n pass", "metadata": "root.BaseGemv.test_y_stride_assert", "header": "['class', 'BaseGemv', '(', 'object', ')', ':', '___EOS___']", "index": 447 } ]
[ { "span": "except: ", "start_line": 93, "start_column": 8, "end_line": 93, "end_column": 15 }, { "span": "except: ", "start_line": 103, "start_column": 8, "end_line": 103, "end_column": 15 }, { "span": "except: ", "start_line": 158, "start_column": 8, "end_line": 158, "end_column": 15 }, { "span": "except: ", "start_line": 225, "start_column": 8, "end_line": 225, "end_column": 15 }, { "span": "except: ", "start_line": 235, "start_column": 8, "end_line": 235, "end_column": 15 }, { "span": "except: ", "start_line": 321, "start_column": 8, "end_line": 321, "end_column": 15 }, { "span": "except: ", "start_line": 331, "start_column": 8, "end_line": 331, "end_column": 15 }, { "span": "except:", "start_line": 425, "start_column": 8, "end_line": 425, "end_column": 15 }, { "span": "except:", "start_line": 430, "start_column": 8, "end_line": 430, "end_column": 15 }, { "span": "except:", "start_line": 453, "start_column": 8, "end_line": 453, "end_column": 15 }, { "span": "except:", "start_line": 458, "start_column": 8, "end_line": 458, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Base", "Ax", "py_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "x", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "zeros_", "(_", "6_", ",_", "x_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "x_", ",_", "y_", ",_", "n_", "=_", "4_", ",_", "inc", "x_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Ax", "py_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "y", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "zeros_", "(_", "6_", ",_", "x_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "x_", ",_", "y_", ",_", "n_", "=_", "3_", ",_", "inc", "y_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Sca", "l_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "x", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "2._", ",_", "x_", ",_", "n_", "=_", "4_", ",_", "inc", "x_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Copy_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "x", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "zeros_", "(_", "6_", ",_", "x_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "x_", ",_", "y_", ",_", "n_", "=_", "4_", ",_", "inc", "x_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Copy_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "y", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "zeros_", "(_", "6_", ",_", "x_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "x_", ",_", "y_", ",_", "n_", "=_", "3_", ",_", "inc", "y_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Swa", "p_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "x", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "zeros_", "(_", "6_", ",_", "x_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "x_", ",_", "y_", ",_", "n_", "=_", "4_", ",_", "inc", "x_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Swa", "p_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "y", "\\u", "bad", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "arange_", "(_", "12.", "_", ",_", "dtype_", "=_", "self_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "zeros_", "(_", "6_", ",_", "x_", "._", "dtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bla", "s", "\\u", "func_", "(_", "x_", ",_", "y_", ",_", "n_", "=_", "3_", ",_", "inc", "y_", "=_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "what", " ", "kind", " ", "of", " ", "error", " ", "shou", "ld", " ", "be", " ", "cau", "ght", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "catch", " ", "error", " ", "and", " ", "neve", "r", " ", "get", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Ge", "mv_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "x", "\\u", "stride", "\\u", "assert_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "What", " ", "is", " ", "the", " ", "use", " ", "of", " ", "this", " ", "test", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alpha_", ",_", "beta_", ",_", "a_", ",_", "x_", ",_", "y_", "=_", "self_", "._", "get", "\\u", "data_", "(_", "x", "\\u", "stride_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y_", "=_", "self_", "._", "bla", "s", "\\u", "func_", "(_", "1_", ",_", "a_", ",_", "x_", ",_", "1_", ",_", "y_", ",_", "trans_", "=_", "0_", ",_", "inc", "x_", "=_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y_", "=_", "self_", "._", "bla", "s", "\\u", "func_", "(_", "1_", ",_", "a_", ",_", "x_", ",_", "1_", ",_", "y_", ",_", "trans_", "=_", "1_", ",_", "inc", "x_", "=_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Ge", "mv_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "y", "\\u", "stride", "\\u", "assert_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "What", " ", "is", " ", "the", " ", "use", " ", "of", " ", "this", " ", "test", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alpha_", ",_", "beta_", ",_", "a_", ",_", "x_", ",_", "y_", "=_", "self_", "._", "get", "\\u", "data_", "(_", "y", "\\u", "stride_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y_", "=_", "self_", "._", "bla", "s", "\\u", "func_", "(_", "1_", ",_", "a_", ",_", "x_", ",_", "1_", ",_", "y_", ",_", "trans_", "=_", "0_", ",_", "inc", "y_", "=_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert\\u_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y_", "=_", "self_", "._", "bla", "s", "\\u", "func_", "(_", "1_", ",_", "a_", ",_", "x_", ",_", "1_", ",_", "y_", ",_", "trans_", "=_", "1_", ",_", "inc", "y_", "=_", "3_", ")_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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, 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, 0, 1, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 1, 2, 2, 2, 2, 2 ]
Unused import
cloudera/hue/desktop/core/ext-py/Django-1.6.10/tests/aggregation_regress/tests.py
[ { "content": "from __future__ import absolute_import, unicode_literals\n\nimport datetime\nimport pickle\nfrom decimal import Decimal\nfrom operator import attrgetter\n\nfrom django.core.exceptions import FieldError\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.db.models import Count, Max, Avg, Sum, StdDev, Variance, F, Q\nfrom django.test import TestCase, Approximate, skipUnlessDBFeature\nfrom django.utils import six\nfrom django.utils.unittest import expectedFailure\n\nfrom .models import (\n Author, Book, Publisher, Clues, Entries, HardbackBook, ItemTag,\n WithManualPK, Alfa, Bravo, Charlie)\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class AggregationTests(TestCase):\n fixtures = [\"aggregation_regress.json\"]\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.AggregationTests", "header": "['module', '___EOS___']", "index": 19 }, { "content": " def assertObjectAttrs(self, obj, **kwargs):\n for attr, value in six.iteritems(kwargs):\n self.assertEqual(getattr(obj, attr), value)", "metadata": "root.AggregationTests.assertObjectAttrs", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 22 }, { "content": " def test_aggregates_in_where_clause(self):\n \"\"\"\n Regression test for #12822: DatabaseError: aggregates not allowed in\n WHERE clause\n\n Tests that the subselect works and returns results equivalent to a\n query with the IDs listed.\n\n Before the corresponding fix for this bug, this test passed in 1.1 and\n failed in 1.2-beta (trunk).\n \"\"\"\n qs = Book.objects.values('contact').annotate(Max('id'))\n qs = qs.order_by('contact').values_list('id__max', flat=True)\n # don't do anything with the queryset (qs) before including it as a\n # subquery\n books = Book.objects.order_by('id')\n qs1 = books.filter(id__in=qs)\n qs2 = books.filter(id__in=list(qs))\n self.assertEqual(list(qs1), list(qs2))", "metadata": "root.AggregationTests.test_aggregates_in_where_clause", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 26 }, { "content": " def test_aggregates_in_where_clause_pre_eval(self):\n \"\"\"\n Regression test for #12822: DatabaseError: aggregates not allowed in\n WHERE clause\n\n Same as the above test, but evaluates the queryset for the subquery\n before it's used as a subquery.\n\n Before the corresponding fix for this bug, this test failed in both\n 1.1 and 1.2-beta (trunk).\n \"\"\"\n qs = Book.objects.values('contact').annotate(Max('id'))\n qs = qs.order_by('contact').values_list('id__max', flat=True)\n # force the queryset (qs) for the subquery to be evaluated in its\n # current state\n list(qs)\n books = Book.objects.order_by('id')\n qs1 = books.filter(id__in=qs)\n qs2 = books.filter(id__in=list(qs))\n self.assertEqual(list(qs1), list(qs2))", "metadata": "root.AggregationTests.test_aggregates_in_where_clause_pre_eval", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 46 }, { "content": " @skipUnlessDBFeature('supports_subqueries_in_group_by')\n def test_annotate_with_extra(self):\n \"\"\"\n Regression test for #11916: Extra params + aggregation creates\n incorrect SQL.\n \"\"\"\n #oracle doesn't support subqueries in group by clause\n shortest_book_sql = \"\"\"\n SELECT name\n FROM aggregation_regress_book b\n WHERE b.publisher_id = aggregation_regress_publisher.id\n ORDER BY b.pages\n LIMIT 1\n \"\"\"\n # tests that this query does not raise a DatabaseError due to the full\n # subselect being (erroneously) added to the GROUP BY parameters\n qs = Publisher.objects.extra(select={\n 'name_of_shortest_book': shortest_book_sql,\n }).annotate(total_books=Count('book'))\n # force execution of the query\n list(qs)", "metadata": "root.AggregationTests.test_annotate_with_extra", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": " def test_aggregate(self):\n # Ordering requests are ignored\n self.assertEqual(\n Author.objects.order_by(\"name\").aggregate(Avg(\"age\")),\n {\"age__avg\": Approximate(37.444, places=1)}\n )\n\n # Implicit ordering is also ignored\n self.assertEqual(\n Book.objects.aggregate(Sum(\"pages\")),\n {\"pages__sum\": 3703},\n )\n\n # Baseline results\n self.assertEqual(\n Book.objects.aggregate(Sum('pages'), Avg('pages')),\n {'pages__sum': 3703, 'pages__avg': Approximate(617.166, places=2)}\n )\n\n # Empty values query doesn't affect grouping or results\n self.assertEqual(\n Book.objects.values().aggregate(Sum('pages'), Avg('pages')),\n {'pages__sum': 3703, 'pages__avg': Approximate(617.166, places=2)}\n )\n\n # Aggregate overrides extra selected column\n self.assertEqual(\n Book.objects.extra(select={'price_per_page' : 'price / pages'}).aggregate(Sum('pages')),\n {'pages__sum': 3703}\n )", "metadata": "root.AggregationTests.test_aggregate", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 89 }, { "content": " def test_annotation(self):\n # Annotations get combined with extra select clauses\n obj = Book.objects.annotate(mean_auth_age=Avg(\"authors__age\")).extra(select={\"manufacture_cost\": \"price * .5\"}).get(pk=2)\n self.assertObjectAttrs(obj,\n contact_id=3,\n id=2,\n isbn='067232959',\n mean_auth_age=45.0,\n name='Sams Teach Yourself Django in 24 Hours',\n pages=528,\n price=Decimal(\"23.09\"),\n pubdate=datetime.date(2008, 3, 3),\n publisher_id=2,\n rating=3.0\n )\n # Different DB backends return different types for the extra select computation\n self.assertTrue(obj.manufacture_cost == 11.545 or obj.manufacture_cost == Decimal('11.545'))\n\n # Order of the annotate/extra in the query doesn't matter\n obj = Book.objects.extra(select={'manufacture_cost' : 'price * .5'}).annotate(mean_auth_age=Avg('authors__age')).get(pk=2)\n self.assertObjectAttrs(obj,\n contact_id=3,\n id=2,\n isbn='067232959',\n mean_auth_age=45.0,\n name='Sams Teach Yourself Django in 24 Hours',\n pages=528,\n price=Decimal(\"23.09\"),\n pubdate=datetime.date(2008, 3, 3),\n publisher_id=2,\n rating=3.0\n )\n # Different DB backends return different types for the extra select computation\n self.assertTrue(obj.manufacture_cost == 11.545 or obj.manufacture_cost == Decimal('11.545'))\n\n # Values queries can be combined with annotate and extra\n obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost' : 'price * .5'}).values().get(pk=2)\n manufacture_cost = obj['manufacture_cost']\n self.assertTrue(manufacture_cost == 11.545 or manufacture_cost == Decimal('11.545'))\n del obj['manufacture_cost']\n self.assertEqual(obj, {\n \"contact_id\": 3,\n \"id\": 2,\n \"isbn\": \"067232959\",\n \"mean_auth_age\": 45.0,\n \"name\": \"Sams Teach Yourself Django in 24 Hours\",\n \"pages\": 528,\n \"price\": Decimal(\"23.09\"),\n \"pubdate\": datetime.date(2008, 3, 3),\n \"publisher_id\": 2,\n \"rating\": 3.0,\n })\n\n # The order of the (empty) values, annotate and extra clauses doesn't\n # matter\n obj = Book.objects.values().annotate(mean_auth_age=Avg('authors__age')).extra(select={'manufacture_cost' : 'price * .5'}).get(pk=2)\n manufacture_cost = obj['manufacture_cost']\n self.assertTrue(manufacture_cost == 11.545 or manufacture_cost == Decimal('11.545'))\n del obj['manufacture_cost']\n self.assertEqual(obj, {\n 'contact_id': 3,\n 'id': 2,\n 'isbn': '067232959',\n 'mean_auth_age': 45.0,\n 'name': 'Sams Teach Yourself Django in 24 Hours',\n 'pages': 528,\n 'price': Decimal(\"23.09\"),\n 'pubdate': datetime.date(2008, 3, 3),\n 'publisher_id': 2,\n 'rating': 3.0\n })\n\n # If the annotation precedes the values clause, it won't be included\n # unless it is explicitly named\n obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page' : 'price / pages'}).values('name').get(pk=1)\n self.assertEqual(obj, {\n \"name\": 'The Definitive Guide to Django: Web Development Done Right',\n })\n\n obj = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page' : 'price / pages'}).values('name','mean_auth_age').get(pk=1)\n self.assertEqual(obj, {\n 'mean_auth_age': 34.5,\n 'name': 'The Definitive Guide to Django: Web Development Done Right',\n })\n\n # If an annotation isn't included in the values, it can still be used\n # in a filter\n qs = Book.objects.annotate(n_authors=Count('authors')).values('name').filter(n_authors__gt=2)\n self.assertQuerysetEqual(\n qs, [\n {\"name\": 'Python Web Development with Django'}\n ],\n lambda b: b,\n )\n\n # The annotations are added to values output if values() precedes\n # annotate()\n obj = Book.objects.values('name').annotate(mean_auth_age=Avg('authors__age')).extra(select={'price_per_page' : 'price / pages'}).get(pk=1)\n self.assertEqual(obj, {\n 'mean_auth_age': 34.5,\n 'name': 'The Definitive Guide to Django: Web Development Done Right',\n })\n\n # Check that all of the objects are getting counted (allow_nulls) and\n # that values respects the amount of objects\n self.assertEqual(\n len(Author.objects.annotate(Avg('friends__age')).values()),\n 9\n )\n\n # Check that consecutive calls to annotate accumulate in the query\n qs = Book.objects.values('price').annotate(oldest=Max('authors__age')).order_by('oldest', 'price').annotate(Max('publisher__num_awards'))\n self.assertQuerysetEqual(\n qs, [\n {'price': Decimal(\"30\"), 'oldest': 35, 'publisher__num_awards__max': 3},\n {'price': Decimal(\"29.69\"), 'oldest': 37, 'publisher__num_awards__max': 7},\n {'price': Decimal(\"23.09\"), 'oldest': 45, 'publisher__num_awards__max': 1},\n {'price': Decimal(\"75\"), 'oldest': 57, 'publisher__num_awards__max': 9},\n {'price': Decimal(\"82.8\"), 'oldest': 57, 'publisher__num_awards__max': 7}\n ],\n lambda b: b,\n )", "metadata": "root.AggregationTests.test_annotation", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 120 }, { "content": " def test_aggrate_annotation(self):\n # Aggregates can be composed over annotations.\n # The return type is derived from the composed aggregate\n vals = Book.objects.all().annotate(num_authors=Count('authors__id')).aggregate(Max('pages'), Max('price'), Sum('num_authors'), Avg('num_authors'))\n self.assertEqual(vals, {\n 'num_authors__sum': 10,\n 'num_authors__avg': Approximate(1.666, places=2),\n 'pages__max': 1132,\n 'price__max': Decimal(\"82.80\")\n })", "metadata": "root.AggregationTests.test_aggrate_annotation", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 243 }, { "content": " def test_field_error(self):\n # Bad field requests in aggregates are caught and reported\n self.assertRaises(\n FieldError,\n lambda: Book.objects.all().aggregate(num_authors=Count('foo'))\n )\n\n self.assertRaises(\n FieldError,\n lambda: Book.objects.all().annotate(num_authors=Count('foo'))\n )\n\n self.assertRaises(\n FieldError,\n lambda: Book.objects.all().annotate(num_authors=Count('authors__id')).aggregate(Max('foo'))\n )", "metadata": "root.AggregationTests.test_field_error", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 254 }, { "content": " def test_more(self):\n # Old-style count aggregations can be mixed with new-style\n self.assertEqual(\n Book.objects.annotate(num_authors=Count('authors')).count(),\n 6\n )\n\n # Non-ordinal, non-computed Aggregates over annotations correctly\n # inherit the annotation's internal type if the annotation is ordinal\n # or computed\n vals = Book.objects.annotate(num_authors=Count('authors')).aggregate(Max('num_authors'))\n self.assertEqual(\n vals,\n {'num_authors__max': 3}\n )\n\n vals = Publisher.objects.annotate(avg_price=Avg('book__price')).aggregate(Max('avg_price'))\n self.assertEqual(\n vals,\n {'avg_price__max': 75.0}\n )\n\n # Aliases are quoted to protected aliases that might be reserved names\n vals = Book.objects.aggregate(number=Max('pages'), select=Max('pages'))\n self.assertEqual(\n vals,\n {'number': 1132, 'select': 1132}\n )\n\n # Regression for #10064: select_related() plays nice with aggregates\n obj = Book.objects.select_related('publisher').annotate(num_authors=Count('authors')).values()[0]\n self.assertEqual(obj, {\n 'contact_id': 8,\n 'id': 5,\n 'isbn': '013790395',\n 'name': 'Artificial Intelligence: A Modern Approach',\n 'num_authors': 2,\n 'pages': 1132,\n 'price': Decimal(\"82.8\"),\n 'pubdate': datetime.date(1995, 1, 15),\n 'publisher_id': 3,\n 'rating': 4.0,\n })\n\n # Regression for #10010: exclude on an aggregate field is correctly\n # negated\n self.assertEqual(\n len(Book.objects.annotate(num_authors=Count('authors'))),\n 6\n )\n self.assertEqual(\n len(Book.objects.annotate(num_authors=Count('authors')).filter(num_authors__gt=2)),\n 1\n )\n self.assertEqual(\n len(Book.objects.annotate(num_authors=Count('authors')).exclude(num_authors__gt=2)),\n 5\n )\n\n self.assertEqual(\n len(Book.objects.annotate(num_authors=Count('authors')).filter(num_authors__lt=3).exclude(num_authors__lt=2)),\n 2\n )\n self.assertEqual(\n len(Book.objects.annotate(num_authors=Count('authors')).exclude(num_authors__lt=2).filter(num_authors__lt=3)),\n 2\n )", "metadata": "root.AggregationTests.test_more", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 271 }, { "content": " def test_aggregate_fexpr(self):\n # Aggregates can be used with F() expressions\n # ... where the F() is pushed into the HAVING clause\n qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_books__lt=F('num_awards')/2).order_by('name').values('name','num_books','num_awards')\n self.assertQuerysetEqual(\n qs, [\n {'num_books': 1, 'name': 'Morgan Kaufmann', 'num_awards': 9},\n {'num_books': 2, 'name': 'Prentice Hall', 'num_awards': 7}\n ],\n lambda p: p,\n )\n\n qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name','num_books','num_awards')\n self.assertQuerysetEqual(\n qs, [\n {'num_books': 2, 'name': 'Apress', 'num_awards': 3},\n {'num_books': 0, 'name': \"Jonno's House of Books\", 'num_awards': 0},\n {'num_books': 1, 'name': 'Sams', 'num_awards': 1}\n ],\n lambda p: p,\n )\n\n # ... and where the F() references an aggregate\n qs = Publisher.objects.annotate(num_books=Count('book')).filter(num_awards__gt=2*F('num_books')).order_by('name').values('name','num_books','num_awards')\n self.assertQuerysetEqual(\n qs, [\n {'num_books': 1, 'name': 'Morgan Kaufmann', 'num_awards': 9},\n {'num_books': 2, 'name': 'Prentice Hall', 'num_awards': 7}\n ],\n lambda p: p,\n )\n\n qs = Publisher.objects.annotate(num_books=Count('book')).exclude(num_books__lt=F('num_awards')/2).order_by('name').values('name','num_books','num_awards')\n self.assertQuerysetEqual(\n qs, [\n {'num_books': 2, 'name': 'Apress', 'num_awards': 3},\n {'num_books': 0, 'name': \"Jonno's House of Books\", 'num_awards': 0},\n {'num_books': 1, 'name': 'Sams', 'num_awards': 1}\n ],\n lambda p: p,\n )", "metadata": "root.AggregationTests.test_aggregate_fexpr", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 339 }, { "content": " def test_db_col_table(self):\n # Tests on fields with non-default table and column names.\n qs = Clues.objects.values('EntryID__Entry').annotate(Appearances=Count('EntryID'), Distinct_Clues=Count('Clue', distinct=True))\n self.assertQuerysetEqual(qs, [])\n\n qs = Entries.objects.annotate(clue_count=Count('clues__ID'))\n self.assertQuerysetEqual(qs, [])", "metadata": "root.AggregationTests.test_db_col_table", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 381 }, { "content": " def test_boolean_conversion(self):\n # Aggregates mixed up ordering of columns for backend's convert_values\n # method. Refs #21126.\n e = Entries.objects.create(Entry='foo')\n c = Clues.objects.create(EntryID=e, Clue='bar')\n qs = Clues.objects.select_related('EntryID').annotate(Count('ID'))\n self.assertQuerysetEqual(\n qs, [c], lambda x: x)\n self.assertEqual(qs[0].EntryID, e)\n self.assertIs(qs[0].EntryID.Exclude, False)", "metadata": "root.AggregationTests.test_boolean_conversion", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 389 }, { "content": " def test_empty(self):\n # Regression for #10089: Check handling of empty result sets with\n # aggregates\n self.assertEqual(\n Book.objects.filter(id__in=[]).count(),\n 0\n )\n\n vals = Book.objects.filter(id__in=[]).aggregate(num_authors=Count('authors'), avg_authors=Avg('authors'), max_authors=Max('authors'), max_price=Max('price'), max_rating=Max('rating'))\n self.assertEqual(\n vals,\n {'max_authors': None, 'max_rating': None, 'num_authors': 0, 'avg_authors': None, 'max_price': None}\n )\n\n qs = Publisher.objects.filter(pk=5).annotate(num_authors=Count('book__authors'), avg_authors=Avg('book__authors'), max_authors=Max('book__authors'), max_price=Max('book__price'), max_rating=Max('book__rating')).values()\n self.assertQuerysetEqual(\n qs, [\n {'max_authors': None, 'name': \"Jonno's House of Books\", 'num_awards': 0, 'max_price': None, 'num_authors': 0, 'max_rating': None, 'id': 5, 'avg_authors': None}\n ],\n lambda p: p\n )", "metadata": "root.AggregationTests.test_empty", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 400 }, { "content": " def test_more_more(self):\n # Regression for #10113 - Fields mentioned in order_by() must be\n # included in the GROUP BY. This only becomes a problem when the\n # order_by introduces a new join.\n self.assertQuerysetEqual(\n Book.objects.annotate(num_authors=Count('authors')).order_by('publisher__name', 'name'), [\n \"Practical Django Projects\",\n \"The Definitive Guide to Django: Web Development Done Right\",\n \"Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp\",\n \"Artificial Intelligence: A Modern Approach\",\n \"Python Web Development with Django\",\n \"Sams Teach Yourself Django in 24 Hours\",\n ],\n lambda b: b.name\n )\n\n # Regression for #10127 - Empty select_related() works with annotate\n qs = Book.objects.filter(rating__lt=4.5).select_related().annotate(Avg('authors__age'))\n self.assertQuerysetEqual(\n qs, [\n ('Artificial Intelligence: A Modern Approach', 51.5, 'Prentice Hall', 'Peter Norvig'),\n ('Practical Django Projects', 29.0, 'Apress', 'James Bennett'),\n ('Python Web Development with Django', Approximate(30.333, places=2), 'Prentice Hall', 'Jeffrey Forcier'),\n ('Sams Teach Yourself Django in 24 Hours', 45.0, 'Sams', 'Brad Dayley')\n ],\n lambda b: (b.name, b.authors__age__avg, b.publisher.name, b.contact.name)\n )\n\n # Regression for #10132 - If the values() clause only mentioned extra\n # (select=) columns, those columns are used for grouping\n qs = Book.objects.extra(select={'pub':'publisher_id'}).values('pub').annotate(Count('id')).order_by('pub')\n self.assertQuerysetEqual(\n qs, [\n {'pub': 1, 'id__count': 2},\n {'pub': 2, 'id__count': 1},\n {'pub': 3, 'id__count': 2},\n {'pub': 4, 'id__count': 1}\n ],\n lambda b: b\n )\n\n qs = Book.objects.extra(select={'pub':'publisher_id', 'foo':'pages'}).values('pub').annotate(Count('id')).order_by('pub')\n self.assertQuerysetEqual(\n qs, [\n {'pub': 1, 'id__count': 2},\n {'pub': 2, 'id__count': 1},\n {'pub': 3, 'id__count': 2},\n {'pub': 4, 'id__count': 1}\n ],\n lambda b: b\n )\n\n # Regression for #10182 - Queries with aggregate calls are correctly\n # realiased when used in a subquery\n ids = Book.objects.filter(pages__gt=100).annotate(n_authors=Count('authors')).filter(n_authors__gt=2).order_by('n_authors')\n self.assertQuerysetEqual(\n Book.objects.filter(id__in=ids), [\n \"Python Web Development with Django\",\n ],\n lambda b: b.name\n )\n\n # Regression for #15709 - Ensure each group_by field only exists once\n # per query\n qs = Book.objects.values('publisher').annotate(max_pages=Max('pages')).order_by()\n grouping, gb_params = qs.query.get_compiler(qs.db).get_grouping([], [])\n self.assertEqual(len(grouping), 1)", "metadata": "root.AggregationTests.test_more_more", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 422 }, { "content": " def test_duplicate_alias(self):\n # Regression for #11256 - duplicating a default alias raises ValueError.\n self.assertRaises(ValueError, Book.objects.all().annotate, Avg('authors__age'), authors__age__avg=Avg('authors__age'))", "metadata": "root.AggregationTests.test_duplicate_alias", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 490 }, { "content": " def test_field_name_conflict(self):\n # Regression for #11256 - providing an aggregate name that conflicts with a field name on the model raises ValueError\n self.assertRaises(ValueError, Author.objects.annotate, age=Avg('friends__age'))", "metadata": "root.AggregationTests.test_field_name_conflict", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 494 }, { "content": " def test_m2m_name_conflict(self):\n # Regression for #11256 - providing an aggregate name that conflicts with an m2m name on the model raises ValueError\n self.assertRaises(ValueError, Author.objects.annotate, friends=Count('friends'))", "metadata": "root.AggregationTests.test_m2m_name_conflict", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 498 }, { "content": " def test_values_queryset_non_conflict(self):\n # Regression for #14707 -- If you're using a values query set, some potential conflicts are avoided.\n\n # age is a field on Author, so it shouldn't be allowed as an aggregate.\n # But age isn't included in the ValuesQuerySet, so it is.\n results = Author.objects.values('name').annotate(age=Count('book_contact_set')).order_by('name')\n self.assertEqual(len(results), 9)\n self.assertEqual(results[0]['name'], 'Adrian Holovaty')\n self.assertEqual(results[0]['age'], 1)\n\n # Same problem, but aggregating over m2m fields\n results = Author.objects.values('name').annotate(age=Avg('friends__age')).order_by('name')\n self.assertEqual(len(results), 9)\n self.assertEqual(results[0]['name'], 'Adrian Holovaty')\n self.assertEqual(results[0]['age'], 32.0)\n\n # Same problem, but colliding with an m2m field\n results = Author.objects.values('name').annotate(friends=Count('friends')).order_by('name')\n self.assertEqual(len(results), 9)\n self.assertEqual(results[0]['name'], 'Adrian Holovaty')\n self.assertEqual(results[0]['friends'], 2)", "metadata": "root.AggregationTests.test_values_queryset_non_conflict", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 502 }, { "content": " def test_reverse_relation_name_conflict(self):\n # Regression for #11256 - providing an aggregate name that conflicts with a reverse-related name on the model raises ValueError\n self.assertRaises(ValueError, Author.objects.annotate, book_contact_set=Avg('friends__age'))", "metadata": "root.AggregationTests.test_reverse_relation_name_conflict", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 524 }, { "content": " def test_pickle(self):\n # Regression for #10197 -- Queries with aggregates can be pickled.\n # First check that pickling is possible at all. No crash = success\n qs = Book.objects.annotate(num_authors=Count('authors'))\n pickle.dumps(qs)\n\n # Then check that the round trip works.\n query = qs.query.get_compiler(qs.db).as_sql()[0]\n qs2 = pickle.loads(pickle.dumps(qs))\n self.assertEqual(\n qs2.query.get_compiler(qs2.db).as_sql()[0],\n query,\n )", "metadata": "root.AggregationTests.test_pickle", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 528 }, { "content": " def test_more_more_more(self):\n # Regression for #10199 - Aggregate calls clone the original query so\n # the original query can still be used\n books = Book.objects.all()\n books.aggregate(Avg(\"authors__age\"))\n self.assertQuerysetEqual(\n books.all(), [\n 'Artificial Intelligence: A Modern Approach',\n 'Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp',\n 'Practical Django Projects',\n 'Python Web Development with Django',\n 'Sams Teach Yourself Django in 24 Hours',\n 'The Definitive Guide to Django: Web Development Done Right'\n ],\n lambda b: b.name\n )\n\n # Regression for #10248 - Annotations work with DateQuerySets\n qs = Book.objects.annotate(num_authors=Count('authors')).filter(num_authors=2).dates('pubdate', 'day')\n self.assertQuerysetEqual(\n qs, [\n datetime.date(1995, 1, 15),\n datetime.date(2007, 12, 6),\n ],\n lambda b: b\n )\n\n # Regression for #10290 - extra selects with parameters can be used for\n # grouping.\n qs = Book.objects.annotate(mean_auth_age=Avg('authors__age')).extra(select={'sheets' : '(pages + %s) / %s'}, select_params=[1, 2]).order_by('sheets').values('sheets')\n self.assertQuerysetEqual(\n qs, [\n 150,\n 175,\n 224,\n 264,\n 473,\n 566\n ],\n lambda b: int(b[\"sheets\"])\n )\n\n # Regression for 10425 - annotations don't get in the way of a count()\n # clause\n self.assertEqual(\n Book.objects.values('publisher').annotate(Count('publisher')).count(),\n 4\n )\n self.assertEqual(\n Book.objects.annotate(Count('publisher')).values('publisher').count(),\n 6\n )\n\n # Note: intentionally no order_by(), that case needs tests, too.\n publishers = Publisher.objects.filter(id__in=[1, 2])\n self.assertEqual(\n sorted(p.name for p in publishers),\n [\n \"Apress\",\n \"Sams\"\n ]\n )\n\n publishers = publishers.annotate(n_books=Count(\"book\"))\n sorted_publishers = sorted(publishers, key=lambda x: x.name)\n self.assertEqual(\n sorted_publishers[0].n_books,\n 2\n )\n self.assertEqual(\n sorted_publishers[1].n_books,\n 1\n )\n\n self.assertEqual(\n sorted(p.name for p in publishers),\n [\n \"Apress\",\n \"Sams\"\n ]\n )\n\n books = Book.objects.filter(publisher__in=publishers)\n self.assertQuerysetEqual(\n books, [\n \"Practical Django Projects\",\n \"Sams Teach Yourself Django in 24 Hours\",\n \"The Definitive Guide to Django: Web Development Done Right\",\n ],\n lambda b: b.name\n )\n self.assertEqual(\n sorted(p.name for p in publishers),\n [\n \"Apress\",\n \"Sams\"\n ]\n )\n\n # Regression for 10666 - inherited fields work with annotations and\n # aggregations\n self.assertEqual(\n HardbackBook.objects.aggregate(n_pages=Sum('book_ptr__pages')),\n {'n_pages': 2078}\n )\n\n self.assertEqual(\n HardbackBook.objects.aggregate(n_pages=Sum('pages')),\n {'n_pages': 2078},\n )\n\n qs = HardbackBook.objects.annotate(n_authors=Count('book_ptr__authors')).values('name', 'n_authors')\n self.assertQuerysetEqual(\n qs, [\n {'n_authors': 2, 'name': 'Artificial Intelligence: A Modern Approach'},\n {'n_authors': 1, 'name': 'Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp'}\n ],\n lambda h: h\n )\n\n qs = HardbackBook.objects.annotate(n_authors=Count('authors')).values('name', 'n_authors')\n self.assertQuerysetEqual(\n qs, [\n {'n_authors': 2, 'name': 'Artificial Intelligence: A Modern Approach'},\n {'n_authors': 1, 'name': 'Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp'}\n ],\n lambda h: h,\n )\n\n # Regression for #10766 - Shouldn't be able to reference an aggregate\n # fields in an aggregate() call.\n self.assertRaises(\n FieldError,\n lambda: Book.objects.annotate(mean_age=Avg('authors__age')).annotate(Avg('mean_age'))\n )", "metadata": "root.AggregationTests.test_more_more_more", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 542 }, { "content": " def test_empty_filter_count(self):\n self.assertEqual(\n Author.objects.filter(id__in=[]).annotate(Count(\"friends\")).count(),\n 0\n )", "metadata": "root.AggregationTests.test_empty_filter_count", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 678 }, { "content": " def test_empty_filter_aggregate(self):\n self.assertEqual(\n Author.objects.filter(id__in=[]).annotate(Count(\"friends\")).aggregate(Count(\"pk\")),\n {\"pk__count\": None}\n )", "metadata": "root.AggregationTests.test_empty_filter_aggregate", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 684 }, { "content": " def test_none_call_before_aggregate(self):\n # Regression for #11789\n self.assertEqual(\n Author.objects.none().aggregate(Avg('age')),\n {'age__avg': None}\n )", "metadata": "root.AggregationTests.test_none_call_before_aggregate", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 690 }, { "content": " def test_annotate_and_join(self):\n self.assertEqual(\n Author.objects.annotate(c=Count(\"friends__name\")).exclude(friends__name=\"Joe\").count(),\n Author.objects.count()\n )", "metadata": "root.AggregationTests.test_annotate_and_join", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 697 }, { "content": " def test_f_expression_annotation(self):\n # Books with less than 200 pages per author.\n qs = Book.objects.values(\"name\").annotate(\n n_authors=Count(\"authors\")\n ).filter(\n pages__lt=F(\"n_authors\") * 200\n ).values_list(\"pk\")\n self.assertQuerysetEqual(\n Book.objects.filter(pk__in=qs), [\n \"Python Web Development with Django\"\n ],\n attrgetter(\"name\")\n )", "metadata": "root.AggregationTests.test_f_expression_annotation", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 703 }, { "content": " def test_values_annotate_values(self):\n qs = Book.objects.values(\"name\").annotate(\n n_authors=Count(\"authors\")\n ).values_list(\"pk\", flat=True)\n self.assertEqual(list(qs), list(Book.objects.values_list(\"pk\", flat=True)))", "metadata": "root.AggregationTests.test_values_annotate_values", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 717 }, { "content": " def test_having_group_by(self):\n # Test that when a field occurs on the LHS of a HAVING clause that it\n # appears correctly in the GROUP BY clause\n qs = Book.objects.values_list(\"name\").annotate(\n n_authors=Count(\"authors\")\n ).filter(\n pages__gt=F(\"n_authors\")\n ).values_list(\"name\", flat=True)\n # Results should be the same, all Books have more pages than authors\n self.assertEqual(\n list(qs), list(Book.objects.values_list(\"name\", flat=True))\n )", "metadata": "root.AggregationTests.test_having_group_by", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 723 }, { "content": " def test_annotation_disjunction(self):\n qs = Book.objects.annotate(n_authors=Count(\"authors\")).filter(\n Q(n_authors=2) | Q(name=\"Python Web Development with Django\")\n )\n self.assertQuerysetEqual(\n qs, [\n \"Artificial Intelligence: A Modern Approach\",\n \"Python Web Development with Django\",\n \"The Definitive Guide to Django: Web Development Done Right\",\n ],\n attrgetter(\"name\")\n )\n\n qs = Book.objects.annotate(n_authors=Count(\"authors\")).filter(\n Q(name=\"The Definitive Guide to Django: Web Development Done Right\") | (Q(name=\"Artificial Intelligence: A Modern Approach\") & Q(n_authors=3))\n )\n self.assertQuerysetEqual(\n qs, [\n \"The Definitive Guide to Django: Web Development Done Right\",\n ],\n attrgetter(\"name\")\n )\n\n qs = Publisher.objects.annotate(\n rating_sum=Sum(\"book__rating\"),\n book_count=Count(\"book\")\n ).filter(\n Q(rating_sum__gt=5.5) | Q(rating_sum__isnull=True)\n ).order_by('pk')\n self.assertQuerysetEqual(\n qs, [\n \"Apress\",\n \"Prentice Hall\",\n \"Jonno's House of Books\",\n ],\n attrgetter(\"name\")\n )\n\n qs = Publisher.objects.annotate(\n rating_sum=Sum(\"book__rating\"),\n book_count=Count(\"book\")\n ).filter(\n Q(pk__lt=F(\"book_count\")) | Q(rating_sum=None)\n ).order_by(\"pk\")\n self.assertQuerysetEqual(\n qs, [\n \"Apress\",\n \"Jonno's House of Books\",\n ],\n attrgetter(\"name\")\n )", "metadata": "root.AggregationTests.test_annotation_disjunction", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 736 }, { "content": " def test_quoting_aggregate_order_by(self):\n qs = Book.objects.filter(\n name=\"Python Web Development with Django\"\n ).annotate(\n authorCount=Count(\"authors\")\n ).order_by(\"authorCount\")\n self.assertQuerysetEqual(\n qs, [\n (\"Python Web Development with Django\", 3),\n ],\n lambda b: (b.name, b.authorCount)\n )", "metadata": "root.AggregationTests.test_quoting_aggregate_order_by", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 788 }, { "content": " @skipUnlessDBFeature('supports_stddev')\n def test_stddev(self):\n self.assertEqual(\n Book.objects.aggregate(StdDev('pages')),\n {'pages__stddev': Approximate(311.46, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(StdDev('rating')),\n {'rating__stddev': Approximate(0.60, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(StdDev('price')),\n {'price__stddev': Approximate(24.16, 2)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(StdDev('pages', sample=True)),\n {'pages__stddev': Approximate(341.19, 2)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(StdDev('rating', sample=True)),\n {'rating__stddev': Approximate(0.66, 2)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(StdDev('price', sample=True)),\n {'price__stddev': Approximate(26.46, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(Variance('pages')),\n {'pages__variance': Approximate(97010.80, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(Variance('rating')),\n {'rating__variance': Approximate(0.36, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(Variance('price')),\n {'price__variance': Approximate(583.77, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(Variance('pages', sample=True)),\n {'pages__variance': Approximate(116412.96, 1)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(Variance('rating', sample=True)),\n {'rating__variance': Approximate(0.44, 2)}\n )\n\n self.assertEqual(\n Book.objects.aggregate(Variance('price', sample=True)),\n {'price__variance': Approximate(700.53, 2)}\n )", "metadata": "root.AggregationTests.test_stddev", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 801 }, { "content": " def test_filtering_by_annotation_name(self):\n # Regression test for #14476\n\n # The name of the explicitly provided annotation name in this case\n # poses no problem\n qs = Author.objects.annotate(book_cnt=Count('book')).filter(book_cnt=2).order_by('name')\n self.assertQuerysetEqual(\n qs,\n ['Peter Norvig'],\n lambda b: b.name\n )\n # Neither in this case\n qs = Author.objects.annotate(book_count=Count('book')).filter(book_count=2).order_by('name')\n self.assertQuerysetEqual(\n qs,\n ['Peter Norvig'],\n lambda b: b.name\n )\n # This case used to fail because the ORM couldn't resolve the\n # automatically generated annotation name `book__count`\n qs = Author.objects.annotate(Count('book')).filter(book__count=2).order_by('name')\n self.assertQuerysetEqual(\n qs,\n ['Peter Norvig'],\n lambda b: b.name\n )", "metadata": "root.AggregationTests.test_filtering_by_annotation_name", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 863 }, { "content": " def test_type_conversion(self):\n # The database backend convert_values function should not try to covert\n # CharFields to float. Refs #13844.\n from django.db.models import CharField\n from django.db import connection\n testData = 'not_a_float_value'\n testField = CharField()\n self.assertEqual(\n connection.ops.convert_values(testData, testField),\n testData\n )", "metadata": "root.AggregationTests.test_type_conversion", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 890 }, { "content": " def test_annotate_joins(self):\n \"\"\"\n Test that the base table's join isn't promoted to LOUTER. This could\n cause the query generation to fail if there is an exclude() for fk-field\n in the query, too. Refs #19087.\n \"\"\"\n qs = Book.objects.annotate(n=Count('pk'))\n self.assertIs(qs.query.alias_map['aggregation_regress_book'].join_type, None)\n # Check that the query executes without problems.\n self.assertEqual(len(qs.exclude(publisher=-1)), 6)", "metadata": "root.AggregationTests.test_annotate_joins", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 902 }, { "content": " @skipUnlessDBFeature(\"allows_group_by_pk\")\n def test_aggregate_duplicate_columns(self):\n # Regression test for #17144\n\n results = Author.objects.annotate(num_contacts=Count('book_contact_set'))\n\n # There should only be one GROUP BY clause, for the `id` column.\n # `name` and `age` should not be grouped on.\n grouping, gb_params = results.query.get_compiler(using='default').get_grouping([], [])\n self.assertEqual(len(grouping), 1)\n assert 'id' in grouping[0]\n assert 'name' not in grouping[0]\n assert 'age' not in grouping[0]\n\n # The query group_by property should also only show the `id`.\n self.assertEqual(results.query.group_by, [('aggregation_regress_author', 'id')])\n\n # Ensure that we get correct results.\n self.assertEqual(\n [(a.name, a.num_contacts) for a in results.order_by('name')],\n [\n ('Adrian Holovaty', 1),\n ('Brad Dayley', 1),\n ('Jacob Kaplan-Moss', 0),\n ('James Bennett', 1),\n ('Jeffrey Forcier', 1),\n ('Paul Bissex', 0),\n ('Peter Norvig', 2),\n ('Stuart Russell', 0),\n ('Wesley J. Chun', 0),\n ]\n )", "metadata": "root.AggregationTests.test_aggregate_duplicate_columns", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 913 }, { "content": " @skipUnlessDBFeature(\"allows_group_by_pk\")\n def test_aggregate_duplicate_columns_only(self):\n # Works with only() too.\n results = Author.objects.only('id', 'name').annotate(num_contacts=Count('book_contact_set'))\n grouping, gb_params = results.query.get_compiler(using='default').get_grouping([], [])\n self.assertEqual(len(grouping), 1)\n assert 'id' in grouping[0]\n assert 'name' not in grouping[0]\n assert 'age' not in grouping[0]\n\n # The query group_by property should also only show the `id`.\n self.assertEqual(results.query.group_by, [('aggregation_regress_author', 'id')])\n\n # Ensure that we get correct results.\n self.assertEqual(\n [(a.name, a.num_contacts) for a in results.order_by('name')],\n [\n ('Adrian Holovaty', 1),\n ('Brad Dayley', 1),\n ('Jacob Kaplan-Moss', 0),\n ('James Bennett', 1),\n ('Jeffrey Forcier', 1),\n ('Paul Bissex', 0),\n ('Peter Norvig', 2),\n ('Stuart Russell', 0),\n ('Wesley J. Chun', 0),\n ]\n )", "metadata": "root.AggregationTests.test_aggregate_duplicate_columns_only", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 946 }, { "content": " @skipUnlessDBFeature(\"allows_group_by_pk\")\n def test_aggregate_duplicate_columns_select_related(self):\n # And select_related()\n results = Book.objects.select_related('contact').annotate(\n num_authors=Count('authors'))\n grouping, gb_params = results.query.get_compiler(using='default').get_grouping([], [])\n self.assertEqual(len(grouping), 1)\n assert 'id' in grouping[0]\n assert 'name' not in grouping[0]\n assert 'contact' not in grouping[0]\n\n # The query group_by property should also only show the `id`.\n self.assertEqual(results.query.group_by, [('aggregation_regress_book', 'id')])\n\n # Ensure that we get correct results.\n self.assertEqual(\n [(b.name, b.num_authors) for b in results.order_by('name')],\n [\n ('Artificial Intelligence: A Modern Approach', 2),\n ('Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp', 1),\n ('Practical Django Projects', 1),\n ('Python Web Development with Django', 3),\n ('Sams Teach Yourself Django in 24 Hours', 1),\n ('The Definitive Guide to Django: Web Development Done Right', 2)\n ]\n )", "metadata": "root.AggregationTests.test_aggregate_duplicate_columns_select_related", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 975 }, { "content": " def test_reverse_join_trimming(self):\n qs = Author.objects.annotate(Count('book_contact_set__contact'))\n self.assertIn(' JOIN ', str(qs.query))", "metadata": "root.AggregationTests.test_reverse_join_trimming", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1002 }, { "content": " def test_aggregation_with_generic_reverse_relation(self):\n \"\"\"\n Regression test for #10870: Aggregates with joins ignore extra\n filters provided by setup_joins\n\n tests aggregations with generic reverse relations\n \"\"\"\n b = Book.objects.get(name='Practical Django Projects')\n ItemTag.objects.create(object_id=b.id, tag='intermediate',\n content_type=ContentType.objects.get_for_model(b))\n ItemTag.objects.create(object_id=b.id, tag='django',\n content_type=ContentType.objects.get_for_model(b))\n # Assign a tag to model with same PK as the book above. If the JOIN\n # used in aggregation doesn't have content type as part of the\n # condition the annotation will also count the 'hi mom' tag for b.\n wmpk = WithManualPK.objects.create(id=b.pk)\n ItemTag.objects.create(object_id=wmpk.id, tag='hi mom',\n content_type=ContentType.objects.get_for_model(wmpk))\n b = Book.objects.get(name__startswith='Paradigms of Artificial Intelligence')\n ItemTag.objects.create(object_id=b.id, tag='intermediate',\n content_type=ContentType.objects.get_for_model(b))\n\n self.assertEqual(Book.objects.aggregate(Count('tags')), {'tags__count': 3})\n results = Book.objects.annotate(Count('tags')).order_by('-tags__count', 'name')\n self.assertEqual(\n [(b.name, b.tags__count) for b in results],\n [\n ('Practical Django Projects', 2),\n ('Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp', 1),\n ('Artificial Intelligence: A Modern Approach', 0),\n ('Python Web Development with Django', 0),\n ('Sams Teach Yourself Django in 24 Hours', 0),\n ('The Definitive Guide to Django: Web Development Done Right', 0)\n ]\n )", "metadata": "root.AggregationTests.test_aggregation_with_generic_reverse_relation", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1006 }, { "content": " def test_negated_aggregation(self):\n expected_results = Author.objects.exclude(\n pk__in=Author.objects.annotate(book_cnt=Count('book')).filter(book_cnt=2)\n ).order_by('name')\n expected_results = [a.name for a in expected_results]\n qs = Author.objects.annotate(book_cnt=Count('book')).exclude(\n Q(book_cnt=2), Q(book_cnt=2)).order_by('name')\n self.assertQuerysetEqual(\n qs,\n expected_results,\n lambda b: b.name\n )\n expected_results = Author.objects.exclude(\n pk__in=Author.objects.annotate(book_cnt=Count('book')).filter(book_cnt=2)\n ).order_by('name')\n expected_results = [a.name for a in expected_results]\n qs = Author.objects.annotate(book_cnt=Count('book')).exclude(Q(book_cnt=2)|Q(book_cnt=2)).order_by('name')\n self.assertQuerysetEqual(\n qs,\n expected_results,\n lambda b: b.name\n )", "metadata": "root.AggregationTests.test_negated_aggregation", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1042 }, { "content": " def test_name_filters(self):\n qs = Author.objects.annotate(Count('book')).filter(\n Q(book__count__exact=2)|Q(name='Adrian Holovaty')\n ).order_by('name')\n self.assertQuerysetEqual(\n qs,\n ['Adrian Holovaty', 'Peter Norvig'],\n lambda b: b.name\n )", "metadata": "root.AggregationTests.test_name_filters", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1065 }, { "content": " def test_name_expressions(self):\n # Test that aggregates are spotted corretly from F objects.\n # Note that Adrian's age is 34 in the fixtures, and he has one book\n # so both conditions match one author.\n qs = Author.objects.annotate(Count('book')).filter(\n Q(name='Peter Norvig')|Q(age=F('book__count') + 33)\n ).order_by('name')\n self.assertQuerysetEqual(\n qs,\n ['Adrian Holovaty', 'Peter Norvig'],\n lambda b: b.name\n )", "metadata": "root.AggregationTests.test_name_expressions", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1075 }, { "content": " def test_ticket_11293(self):\n q1 = Q(price__gt=50)\n q2 = Q(authors__count__gt=1)\n query = Book.objects.annotate(Count('authors')).filter(\n q1 | q2).order_by('pk')\n self.assertQuerysetEqual(\n query, [1, 4, 5, 6],\n lambda b: b.pk)", "metadata": "root.AggregationTests.test_ticket_11293", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1088 }, { "content": " def test_ticket_11293_q_immutable(self):\n \"\"\"\n Check that splitting a q object to parts for where/having doesn't alter\n the original q-object.\n \"\"\"\n q1 = Q(isbn='')\n q2 = Q(authors__count__gt=1)\n query = Book.objects.annotate(Count('authors'))\n query.filter(q1 | q2)\n self.assertEqual(len(q2.children), 1)", "metadata": "root.AggregationTests.test_ticket_11293_q_immutable", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1097 }, { "content": " def test_fobj_group_by(self):\n \"\"\"\n Check that an F() object referring to related column works correctly\n in group by.\n \"\"\"\n qs = Book.objects.annotate(\n acount=Count('authors')\n ).filter(\n acount=F('publisher__num_awards')\n )\n self.assertQuerysetEqual(\n qs, ['Sams Teach Yourself Django in 24 Hours'],\n lambda b: b.name)", "metadata": "root.AggregationTests.test_fobj_group_by", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1108 }, { "content": " def test_ticket_21150(self):\n b = Bravo.objects.create()\n c = Charlie.objects.create(bravo=b)\n qs = Charlie.objects.select_related('alfa').annotate(Count('bravo__charlie'))\n self.assertQuerysetEqual(\n qs, [c], lambda x: x)\n self.assertIs(qs[0].alfa, None)\n a = Alfa.objects.create()\n c.alfa = a\n c.save()\n # Force re-evaluation\n qs = qs.all()\n self.assertQuerysetEqual(\n qs, [c], lambda x: x)\n self.assertEqual(qs[0].alfa, a)", "metadata": "root.AggregationTests.test_ticket_21150", "header": "['class', 'AggregationTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1122 } ]
[ { "span": "from django.utils.unittest import expectedFailure", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 49 } ]
[]
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_", ",_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "decimal_", "import_", "Decimal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "operator_", "import_", "attrgetter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Field", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "._", "models_", "import_", "Conten", "t", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "Count_", ",_", "Max_", ",_", "Avg_", ",_", "Sum_", ",_", "Std", "Dev_", ",_", "Variance", "_", ",_", "F_", ",_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "test_", "import_", "Test", "Case_", ",_", "Approx", "imat", "e_", ",_", "skip", "Un", "less", "DB", "Feature_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "six_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "unittest_", "import_", "expected", "Failure_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "models_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", ",_", "Book_", ",_", "Publisher_", ",_", "Clu", "es_", ",_", "Entries_", ",_", "Hard", "back", "Book_", ",_", "Item", "Tag_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "With", "Manu", "al", "PK", "_", ",_", "Al", "fa_", ",_", "Bra", "vo_", ",_", "Charl", "ie_", ")_", "\\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_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fixtures_", "=_", "[_", "\"", "aggregation", "\\u", "regress", ".", "json", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "assert", "Object", "Attrs_", "(_", "self_", ",_", "obj_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "attr_", ",_", "value_", "in_", "six_", "._", "iteritems_", "(_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "getattr_", "(_", "obj_", ",_", "attr_", ")_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "aggregates", "\\u", "in", "\\u", "where", "\\u", "clause_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Regr", "ession", " ", "test", " ", "for", " ", "#", "128", "2", "2", ":", " ", "Databa", "se", "Error", ":", " ", "aggregates", " ", "not", " ", "allow", "ed", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "WHE", "RE", " ", "clause", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "the", " ", "subse", "lect", " ", "works", " ", "and", " ", "return", "s", " ", "results", " ", "equivalent", " ", "to", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "query", " ", "with", " ", "the", " ", "ID", "s", " ", "liste", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Be", "fore", " ", "the", " ", "correspond", "ing", " ", "fix", " ", "for", " ", "this", " ", "bug", ",", " ", "this", " ", "test", " ", "pass", "ed", " ", "in", " ", "1.1", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "fail", "ed", " ", "in", " ", "1.2", "-", "beta", " ", "(", "trunk", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "'", "contact", "'_", ")_", "._", "annotate_", "(_", "Max_", "(_", "'", "id", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "qs_", "._", "order", "\\u", "by_", "(_", "'", "contact", "'_", ")_", "._", "values", "\\u", "list_", "(_", "'", "id", "\\u\\u", "max", "'_", ",_", "flat_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "don", "'", "t", " ", "do", " ", "anyt", "hing", " ", "with", " ", "the", " ", "querys", "et", " ", "(", "qs", ")", " ", "bef", "ore", " ", "inclu", "ding", " ", "it", " ", "as", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "subquery", "_", "\\u\\u\\uNL\\u\\u\\u_", "books_", "=_", "Book_", "._", "objects_", "._", "order", "\\u", "by_", "(_", "'", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs", "1_", "=_", "books_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs", "2_", "=_", "books_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "list_", "(_", "qs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "qs", "1_", ")_", ",_", "list_", "(_", "qs", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "aggregates", "\\u", "in", "\\u", "where", "\\u", "clause", "\\u", "pre", "\\u", "eval_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Regr", "ession", " ", "test", " ", "for", " ", "#", "128", "2", "2", ":", " ", "Databa", "se", "Error", ":", " ", "aggregates", " ", "not", " ", "allow", "ed", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "WHE", "RE", " ", "clause", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sam", "e", " ", "as", " ", "the", " ", "above", " ", "test", ",", " ", "but", " ", "evaluate", "s", " ", "the", " ", "querys", "et", " ", "for", " ", "the", " ", "subquery", "\\", "10", ";", " ", " ", " ", " ", "bef", "ore", " ", "it", "'", "s", " ", "used", " ", "as", " ", "a", " ", "subquery", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Be", "fore", " ", "the", " ", "correspond", "ing", " ", "fix", " ", "for", " ", "this", " ", "bug", ",", " ", "this", " ", "test", " ", "fail", "ed", " ", "in", " ", "bot", "h", "\\", "10", ";", " ", " ", " ", " ", "1.1", " ", "and", " ", "1.2", "-", "beta", " ", "(", "trunk", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "'", "contact", "'_", ")_", "._", "annotate_", "(_", "Max_", "(_", "'", "id", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "qs_", "._", "order", "\\u", "by_", "(_", "'", "contact", "'_", ")_", "._", "values", "\\u", "list_", "(_", "'", "id", "\\u\\u", "max", "'_", ",_", "flat_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "force", " ", "the", " ", "querys", "et", " ", "(", "qs", ")", " ", "for", " ", "the", " ", "subquery", " ", "to", " ", "be", " ", "evaluate", "d", " ", "in", " ", "its_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "current", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "list_", "(_", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "books_", "=_", "Book_", "._", "objects_", "._", "order", "\\u", "by_", "(_", "'", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs", "1_", "=_", "books_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs", "2_", "=_", "books_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "list_", "(_", "qs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "qs", "1_", ")_", ",_", "list_", "(_", "qs", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "Un", "less", "DB", "Feature_", "(_", "'", "support", "s", "\\u", "sub", "querie", "s", "\\u", "in", "\\u", "group", "\\u", "by", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "annot", "ate", "\\u", "with", "\\u", "extra_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Regr", "ession", " ", "test", " ", "for", " ", "#", "119", "16", ":", " ", "Extra", " ", "params", " ", "+", " ", "aggregation", " ", "create", "s", "\\", "10", ";", " ", " ", " ", " ", "incorrect", " ", "SQL", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "oracle", " ", "doe", "sn", "'", "t", " ", "support", " ", "sub", "querie", "s", " ", "in", " ", "group", " ", "by", " ", "clause_", "\\u\\u\\uNL\\u\\u\\u_", "short", "est", "\\u", "book", "\\u", "sql_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "SELECT", " ", "name", "\\", "10", ";", " ", " ", " ", " ", "FROM", " ", "aggregation", "\\u", "regress", "\\u", "book", " ", "b", "\\", "10", ";", " ", " ", " ", " ", "WHE", "RE", " ", "b", ".", "publi", "sher", "\\u", "id", " ", "=", " ", "aggregation", "\\u", "regress", "\\u", "publi", "sher", ".", "id", "\\", "10", ";", " ", " ", " ", " ", "ORDE", "R", " ", "BY", " ", "b", ".", "page", "s", "\\", "10", ";", " ", " ", " ", " ", "LIMIT", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "tests", " ", "tha", "t", " ", "this", " ", "query", " ", "doe", "s", " ", "not", " ", "raise", " ", "a", " ", "Databa", "se", "Error", " ", "due", " ", "to", " ", "the", " ", "full_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "subse", "lect", " ", "bei", "ng", " ", "(", "erro", "neous", "ly", ")", " ", "adde", "d", " ", "to", " ", "the", " ", "GROU", "P", " ", "BY", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "extra_", "(_", "select_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "\\u", "of", "\\u", "short", "est", "\\u", "book", "'_", ":_", "short", "est", "\\u", "book", "\\u", "sql_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "._", "annotate_", "(_", "total", "\\u", "books_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "force", " ", "executi", "on", " ", "of", " ", "the", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "list_", "(_", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "aggregate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Order", "ing", " ", "request", "s", " ", "are", " ", "ignored_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", "._", "objects_", "._", "order", "\\u", "by_", "(_", "\"", "name", "\"_", ")_", "._", "aggregate_", "(_", "Avg_", "(_", "\"", "age", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\"", "age", "\\u\\u", "avg", "\"_", ":_", "Approx", "imat", "e_", "(_", "37.", "444_", ",_", "places_", "=_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Implicit", " ", "orderi", "ng", " ", "is", " ", "als", "o", " ", "ignored_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Sum_", "(_", "\"", "page", "s", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\"", "page", "s", "\\u\\u", "sum", "\"_", ":_", "370", "3_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Base", "line", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Sum_", "(_", "'", "page", "s", "'_", ")_", ",_", "Avg_", "(_", "'", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "sum", "'_", ":_", "370", "3_", ",_", "'", "page", "s", "\\u\\u", "avg", "'_", ":_", "Approx", "imat", "e_", "(_", "617", ".1", "66_", ",_", "places_", "=_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Emp", "ty", " ", "values", " ", "query", " ", "doe", "sn", "'", "t", " ", "affect", " ", "grouping", " ", "or", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "values_", "(_", ")_", "._", "aggregate_", "(_", "Sum_", "(_", "'", "page", "s", "'_", ")_", ",_", "Avg_", "(_", "'", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "sum", "'_", ":_", "370", "3_", ",_", "'", "page", "s", "\\u\\u", "avg", "'_", ":_", "Approx", "imat", "e_", "(_", "617", ".1", "66_", ",_", "places_", "=_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Aggregate", " ", "override", "s", " ", "extra", " ", "selecte", "d", " ", "column_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "price", "\\u", "per", "\\u", "page", "'_", ":_", "'", "price", " ", "/", " ", "page", "s", "'_", "}_", ")_", "._", "aggregate_", "(_", "Sum_", "(_", "'", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "sum", "'_", ":_", "370", "3_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "annotation_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Annotations", " ", "get", " ", "combin", "ed", " ", "with", " ", "extra", " ", "select", " ", "clauses_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "\"", "authors\\u", "\\u", "age", "\"_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "\"", "manufactur", "e\\u", "cost", "\"_", ":_", "\"", "price", " ", "*", " ", ".5", "\"_", "}_", ")_", "._", "get_", "(_", "pk_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Object", "Attrs_", "(_", "obj_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "contact", "\\u", "id_", "=_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "isbn", "_", "=_", "'", "067", "232", "959", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mean", "\\u", "auth", "\\u", "age_", "=_", "45.", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pages_", "=_", "528", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "price_", "=_", "Decimal_", "(_", "\"", "23.", "09", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "date_", "=_", "datetime_", "._", "date_", "(_", "2008_", ",_", "3_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "publi", "sher", "\\u", "id_", "=_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "rating_", "=_", "3.0_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Different", " ", "DB", " ", "back", "ends", " ", "return", " ", "different", " ", "types", " ", "for", " ", "the", " ", "extra", " ", "select", " ", "computation", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "obj_", "._", "manufactur", "e\\u", "cost_", "==_", "11.", "545", "_", "or_", "obj_", "._", "manufactur", "e\\u", "cost_", "==_", "Decimal_", "(_", "'", "11.", "545", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Order", " ", "of", " ", "the", " ", "annot", "ate", "/", "extra", " ", "in", " ", "the", " ", "query", " ", "doe", "sn", "'", "t", " ", "matte", "r_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "manufactur", "e\\u", "cost", "'_", ":_", "'", "price", " ", "*", " ", ".5", "'_", "}_", ")_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "get_", "(_", "pk_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Object", "Attrs_", "(_", "obj_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "contact", "\\u", "id_", "=_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "isbn", "_", "=_", "'", "067", "232", "959", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mean", "\\u", "auth", "\\u", "age_", "=_", "45.", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pages_", "=_", "528", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "price_", "=_", "Decimal_", "(_", "\"", "23.", "09", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "date_", "=_", "datetime_", "._", "date_", "(_", "2008_", ",_", "3_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "publi", "sher", "\\u", "id_", "=_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "rating_", "=_", "3.0_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Different", " ", "DB", " ", "back", "ends", " ", "return", " ", "different", " ", "types", " ", "for", " ", "the", " ", "extra", " ", "select", " ", "computation", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "obj_", "._", "manufactur", "e\\u", "cost_", "==_", "11.", "545", "_", "or_", "obj_", "._", "manufactur", "e\\u", "cost_", "==_", "Decimal_", "(_", "'", "11.", "545", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Value", "s", " ", "querie", "s", " ", "can", " ", "be", " ", "combin", "ed", " ", "with", " ", "annot", "ate", " ", "and", " ", "extra_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "manufactur", "e\\u", "cost", "'_", ":_", "'", "price", " ", "*", " ", ".5", "'_", "}_", ")_", "._", "values_", "(_", ")_", "._", "get_", "(_", "pk_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "manufactur", "e\\u", "cost_", "=_", "obj_", "[_", "'", "manufactur", "e\\u", "cost", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "manufactur", "e\\u", "cost_", "==_", "11.", "545", "_", "or_", "manufactur", "e\\u", "cost_", "==_", "Decimal_", "(_", "'", "11.", "545", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "obj_", "[_", "'", "manufactur", "e\\u", "cost", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "obj_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "contact", "\\u", "id", "\"_", ":_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "isbn", "\"_", ":_", "\"", "067", "232", "959", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "mean", "\\u", "auth", "\\u", "age", "\"_", ":_", "45.", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "page", "s", "\"_", ":_", "528", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "price", "\"_", ":_", "Decimal_", "(_", "\"", "23.", "09", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pub", "date", "\"_", ":_", "datetime_", "._", "date_", "(_", "2008_", ",_", "3_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "publi", "sher", "\\u", "id", "\"_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "rati", "ng", "\"_", ":_", "3.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "order", " ", "of", " ", "the", " ", "(", "empty", ")", " ", "values", ",", " ", "annot", "ate", " ", "and", " ", "extra", " ", "clause", "s", " ", "doe", "sn", "'", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "matte", "r_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", ")_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "manufactur", "e\\u", "cost", "'_", ":_", "'", "price", " ", "*", " ", ".5", "'_", "}_", ")_", "._", "get_", "(_", "pk_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "manufactur", "e\\u", "cost_", "=_", "obj_", "[_", "'", "manufactur", "e\\u", "cost", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "manufactur", "e\\u", "cost_", "==_", "11.", "545", "_", "or_", "manufactur", "e\\u", "cost_", "==_", "Decimal_", "(_", "'", "11.", "545", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "obj_", "[_", "'", "manufactur", "e\\u", "cost", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "obj_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contact", "\\u", "id", "'_", ":_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isbn", "'_", ":_", "'", "067", "232", "959", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mean", "\\u", "auth", "\\u", "age", "'_", ":_", "45.", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "page", "s", "'_", ":_", "528", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "23.", "09", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pub", "date", "'_", ":_", "datetime_", "._", "date_", "(_", "2008_", ",_", "3_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "publi", "sher", "\\u", "id", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rati", "ng", "'_", ":_", "3.0_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "annot", "ation", " ", "prece", "des", " ", "the", " ", "values", " ", "clause", ",", " ", "it", " ", "won", "'", "t", " ", "be", " ", "included_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "unl", "ess", " ", "it", " ", "is", " ", "explicit", "ly", " ", "named_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "price", "\\u", "per", "\\u", "page", "'_", ":_", "'", "price", " ", "/", " ", "page", "s", "'_", "}_", ")_", "._", "values_", "(_", "'", "name", "'_", ")_", "._", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "obj_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "'", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "price", "\\u", "per", "\\u", "page", "'_", ":_", "'", "price", " ", "/", " ", "page", "s", "'_", "}_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "mean", "\\u", "auth", "\\u", "age", "'_", ")_", "._", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "obj_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mean", "\\u", "auth", "\\u", "age", "'_", ":_", "34.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "an", " ", "annot", "ation", " ", "isn", "'", "t", " ", "include", "d", " ", "in", " ", "the", " ", "values", ",", " ", "it", " ", "can", " ", "still", " ", "be", " ", "used_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "a", " ", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "n", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "values_", "(_", "'", "name", "'_", ")_", "._", "filter_", "(_", "n", "\\u", "authors\\u", "\\u", "gt_", "=_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\"", "name", "\"_", ":_", "'", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "'_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "annot", "ation", "s", " ", "are", " ", "adde", "d", " ", "to", " ", "values", " ", "output", " ", "if", " ", "values", "()", " ", "prece", "des_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "annot", "ate", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "'", "name", "'_", ")_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "price", "\\u", "per", "\\u", "page", "'_", ":_", "'", "price", " ", "/", " ", "page", "s", "'_", "}_", ")_", "._", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "obj_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mean", "\\u", "auth", "\\u", "age", "'_", ":_", "34.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "all", " ", "of", " ", "the", " ", "object", "s", " ", "are", " ", "getti", "ng", " ", "counted", " ", "(", "allow", "\\u", "null", "s", ")", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "values", " ", "respec", "ts", " ", "the", " ", "amo", "unt", " ", "of", " ", "objects_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "Author_", "._", "objects_", "._", "annotate_", "(_", "Avg_", "(_", "'", "friends", "\\u\\u", "age", "'_", ")_", ")_", "._", "values_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "9_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "consec", "uti", "ve", " ", "calls", " ", "to", " ", "annot", "ate", " ", "accumulate", " ", "in", " ", "the", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "'", "price", "'_", ")_", "._", "annotate_", "(_", "oldest", "_", "=_", "Max_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "oldest", "'_", ",_", "'", "price", "'_", ")_", "._", "annotate_", "(_", "Max_", "(_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "30", "\"_", ")_", ",_", "'", "oldest", "'_", ":_", "35_", ",_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "\\u\\u", "max", "'_", ":_", "3_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "29.", "6", "9", "\"_", ")_", ",_", "'", "oldest", "'_", ":_", "37_", ",_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "\\u\\u", "max", "'_", ":_", "7_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "23.", "09", "\"_", ")_", ",_", "'", "oldest", "'_", ":_", "45_", ",_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "\\u\\u", "max", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "7", "5", "\"_", ")_", ",_", "'", "oldest", "'_", ":_", "57_", ",_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "\\u\\u", "max", "'_", ":_", "9_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "82.", "8", "\"_", ")_", ",_", "'", "oldest", "'_", ":_", "57_", ",_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "\\u\\u", "max", "'_", ":_", "7_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "aggr", "ate", "\\u", "annotation_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Aggregate", "s", " ", "can", " ", "be", " ", "compose", "d", " ", "over", " ", "annot", "ation", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "return", " ", "type", " ", "is", " ", "derive", "d", " ", "from", " ", "the", " ", "compose", "d", " ", "aggregate_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "Book_", "._", "objects_", "._", "all_", "(_", ")_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "authors\\u", "\\u", "id", "'_", ")_", ")_", "._", "aggregate_", "(_", "Max_", "(_", "'", "page", "s", "'_", ")_", ",_", "Max_", "(_", "'", "price", "'_", ")_", ",_", "Sum_", "(_", "'", "num", "\\u", "author", "s", "'_", ")_", ",_", "Avg_", "(_", "'", "num", "\\u", "author", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "vals_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "num", "\\u", "authors\\u", "\\u", "sum", "'_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "num", "\\u", "authors\\u", "\\u", "avg", "'_", ":_", "Approx", "imat", "e_", "(_", "1.6", "66_", ",_", "places_", "=_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "page", "s", "\\u\\u", "max", "'_", ":_", "113", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "price", "\\u\\u", "max", "'_", ":_", "Decimal_", "(_", "\"", "82.", "80", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "field", "\\u", "error_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ba", "d", " ", "field", " ", "request", "s", " ", "in", " ", "aggregates", " ", "are", " ", "cau", "ght", " ", "and", " ", "reporte", "d_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Raises_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Field", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", ":_", "Book_", "._", "objects_", "._", "all_", "(_", ")_", "._", "aggregate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "foo", "'_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Field", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", ":_", "Book_", "._", "objects_", "._", "all_", "(_", ")_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "foo", "'_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Field", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", ":_", "Book_", "._", "objects_", "._", "all_", "(_", ")_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "authors\\u", "\\u", "id", "'_", ")_", ")_", "._", "aggregate_", "(_", "Max_", "(_", "'", "foo", "'_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "more_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Old", "-", "style", " ", "count", " ", "aggregation", "s", " ", "can", " ", "be", " ", "mixed", " ", "with", " ", "new", "-", "style_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "6_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Non", "-", "ordinal", ",", " ", "non", "-", "compute", "d", " ", "Aggregate", "s", " ", "over", " ", "annot", "ation", "s", " ", "correct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "inherit", " ", "the", " ", "annot", "ation", "'", "s", " ", "internal", " ", "type", " ", "if", " ", "the", " ", "annot", "ation", " ", "is", " ", "ordinal_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "compute", "d_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "aggregate_", "(_", "Max_", "(_", "'", "num", "\\u", "author", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "authors\\u", "\\u", "max", "'_", ":_", "3_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "avg", "\\u", "price_", "=_", "Avg_", "(_", "'", "book", "\\u\\u", "price", "'_", ")_", ")_", "._", "aggregate_", "(_", "Max_", "(_", "'", "avg", "\\u", "price", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "avg", "\\u", "price", "\\u\\u", "max", "'_", ":_", "75.", "0_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Aliase", "s", " ", "are", " ", "quoted", " ", "to", " ", "protect", "ed", " ", "alias", "es", " ", "tha", "t", " ", "mig", "ht", " ", "be", " ", "reserve", "d", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", "=_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "number_", "=_", "Max_", "(_", "'", "page", "s", "'_", ")_", ",_", "select_", "=_", "Max_", "(_", "'", "page", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "number", "'_", ":_", "113", "2_", ",_", "'", "select", "'_", ":_", "113", "2_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "1006", "4", ":", " ", "select", "\\u", "relate", "d", "()", " ", "plays", " ", "nice", " ", "with", " ", "aggregates", "_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "Book_", "._", "objects_", "._", "select", "\\u", "related_", "(_", "'", "publi", "sher", "'_", ")_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "values_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "obj_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contact", "\\u", "id", "'_", ":_", "8_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isbn", "'_", ":_", "'", "013", "790", "395", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "num", "\\u", "author", "s", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "page", "s", "'_", ":_", "113", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "price", "'_", ":_", "Decimal_", "(_", "\"", "82.", "8", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pub", "date", "'_", ":_", "datetime_", "._", "date_", "(_", "1995", "_", ",_", "1_", ",_", "15_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "publi", "sher", "\\u", "id", "'_", ":_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rati", "ng", "'_", ":_", "4.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "10010", ":", " ", "exclu", "de", " ", "on", " ", "an", " ", "aggre", "gate", " ", "field", " ", "is", " ", "correct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "negate", "d_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "6_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "filter_", "(_", "num", "\\u", "authors\\u", "\\u", "gt_", "=_", "2_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "exclude_", "(_", "num", "\\u", "authors\\u", "\\u", "gt_", "=_", "2_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "5_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "filter_", "(_", "num", "\\u", "authors\\u", "\\u", "lt_", "=_", "3_", ")_", "._", "exclude_", "(_", "num", "\\u", "authors\\u", "\\u", "lt_", "=_", "2_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "exclude_", "(_", "num", "\\u", "authors\\u", "\\u", "lt_", "=_", "2_", ")_", "._", "filter_", "(_", "num", "\\u", "authors\\u", "\\u", "lt_", "=_", "3_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "aggre", "gate", "\\u", "fe", "xpr", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Aggregate", "s", " ", "can", " ", "be", " ", "used", " ", "with", " ", "F", "()", " ", "expressions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "...", " ", "where", " ", "the", " ", "F", "()", " ", "is", " ", "pushed", " ", "int", "o", " ", "the", " ", "HA", "VING", " ", "clause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "books_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "num", "\\u", "books", "\\u\\u", "lt_", "=_", "F_", "(_", "'", "num", "\\u", "awards", "'_", ")_", "/_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "num", "\\u", "books", "'_", ",_", "'", "num", "\\u", "awards", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "1_", ",_", "'", "name", "'_", ":_", "'", "Mor", "gan", " ", "Ka", "uf", "man", "n", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "9_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "2_", ",_", "'", "name", "'_", ":_", "'", "Pre", "ntic", "e", " ", "Hall", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "7_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "p_", ":_", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "books_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "exclude_", "(_", "num", "\\u", "books", "\\u\\u", "lt_", "=_", "F_", "(_", "'", "num", "\\u", "awards", "'_", ")_", "/_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "num", "\\u", "books", "'_", ",_", "'", "num", "\\u", "awards", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "2_", ",_", "'", "name", "'_", ":_", "'", "Ap", "ress", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "3_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "0_", ",_", "'", "name", "'_", ":_", "\"", "Jon", "no", "'", "s", " ", "House", " ", "of", " ", "Books", "\"_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "0_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "1_", ",_", "'", "name", "'_", ":_", "'", "Sam", "s", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "1_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "p_", ":_", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "...", " ", "and", " ", "where", " ", "the", " ", "F", "()", " ", "reference", "s", " ", "an", " ", "aggregate_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "books_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "num", "\\u", "awards", "\\u\\u", "gt_", "=_", "2_", "*_", "F_", "(_", "'", "num", "\\u", "books", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "num", "\\u", "books", "'_", ",_", "'", "num", "\\u", "awards", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "1_", ",_", "'", "name", "'_", ":_", "'", "Mor", "gan", " ", "Ka", "uf", "man", "n", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "9_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "2_", ",_", "'", "name", "'_", ":_", "'", "Pre", "ntic", "e", " ", "Hall", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "7_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "p_", ":_", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "books_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "exclude_", "(_", "num", "\\u", "books", "\\u\\u", "lt_", "=_", "F_", "(_", "'", "num", "\\u", "awards", "'_", ")_", "/_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "num", "\\u", "books", "'_", ",_", "'", "num", "\\u", "awards", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "2_", ",_", "'", "name", "'_", ":_", "'", "Ap", "ress", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "3_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "0_", ",_", "'", "name", "'_", ":_", "\"", "Jon", "no", "'", "s", " ", "House", " ", "of", " ", "Books", "\"_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "0_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "num", "\\u", "books", "'_", ":_", "1_", ",_", "'", "name", "'_", ":_", "'", "Sam", "s", "'_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "1_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "p_", ":_", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "db", "\\u", "col", "\\u", "table_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", "s", " ", "on", " ", "fields", " ", "with", " ", "non", "-", "default", " ", "table", " ", "and", " ", "column", " ", "names", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Clu", "es_", "._", "objects_", "._", "values_", "(_", "'", "Entr", "y", "ID", "\\u\\u", "Entr", "y", "'_", ")_", "._", "annotate_", "(_", "Appearance", "s_", "=_", "Count_", "(_", "'", "Entr", "y", "ID", "'_", ")_", ",_", "Dist", "inc", "t", "\\u", "Clu", "es_", "=_", "Count_", "(_", "'", "Clu", "e", "'_", ",_", "distinct_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "qs_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Entries_", "._", "objects_", "._", "annotate_", "(_", "clue", "\\u", "count_", "=_", "Count_", "(_", "'", "clue", "s", "\\u\\u", "ID", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "qs_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "boolean", "\\u", "conversion_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Aggregate", "s", " ", "mixed", " ", "up", " ", "orderi", "ng", " ", "of", " ", "column", "s", " ", "for", " ", "back", "end", "'", "s", " ", "convert", "\\u", "values_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "method", ".", " ", "Refs", " ", "#", "211", "26.", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "=_", "Entries_", "._", "objects_", "._", "create_", "(_", "Entry_", "=_", "'", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Clu", "es_", "._", "objects_", "._", "create_", "(_", "Entr", "y", "ID_", "=_", "e_", ",_", "Clu", "e_", "=_", "'", "bar", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Clu", "es_", "._", "objects_", "._", "select", "\\u", "related_", "(_", "'", "Entr", "y", "ID", "'_", ")_", "._", "annotate_", "(_", "Count_", "(_", "'", "ID", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "c_", "]_", ",_", "lambda_", "x_", ":_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "qs_", "[_", "0_", "]_", "._", "Entr", "y", "ID_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is_", "(_", "qs_", "[_", "0_", "]_", "._", "Entr", "y", "ID_", "._", "Exclude", "_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "empty_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "1008", "9", ":", " ", "Check", " ", "handling", " ", "of", " ", "empty", " ", "result", " ", "sets", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "aggregates", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "[_", "]_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", "=_", "Book_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "[_", "]_", ")_", "._", "aggregate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ",_", "avg", "\\u", "authors_", "=_", "Avg_", "(_", "'", "author", "s", "'_", ")_", ",_", "max", "\\u", "authors_", "=_", "Max_", "(_", "'", "author", "s", "'_", ")_", ",_", "max", "\\u", "price_", "=_", "Max_", "(_", "'", "price", "'_", ")_", ",_", "max", "\\u", "rating_", "=_", "Max_", "(_", "'", "rati", "ng", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "vals_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "max", "\\u", "author", "s", "'_", ":_", "None_", ",_", "'", "max", "\\u", "rati", "ng", "'_", ":_", "None_", ",_", "'", "num", "\\u", "author", "s", "'_", ":_", "0_", ",_", "'", "avg", "\\u", "author", "s", "'_", ":_", "None_", ",_", "'", "max", "\\u", "price", "'_", ":_", "None_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "filter_", "(_", "pk_", "=_", "5_", ")_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "book", "\\u\\u", "author", "s", "'_", ")_", ",_", "avg", "\\u", "authors_", "=_", "Avg_", "(_", "'", "book", "\\u\\u", "author", "s", "'_", ")_", ",_", "max", "\\u", "authors_", "=_", "Max_", "(_", "'", "book", "\\u\\u", "author", "s", "'_", ")_", ",_", "max", "\\u", "price_", "=_", "Max_", "(_", "'", "book", "\\u\\u", "price", "'_", ")_", ",_", "max", "\\u", "rating_", "=_", "Max_", "(_", "'", "book", "\\u\\u", "rati", "ng", "'_", ")_", ")_", "._", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "max", "\\u", "author", "s", "'_", ":_", "None_", ",_", "'", "name", "'_", ":_", "\"", "Jon", "no", "'", "s", " ", "House", " ", "of", " ", "Books", "\"_", ",_", "'", "num", "\\u", "awards", "'_", ":_", "0_", ",_", "'", "max", "\\u", "price", "'_", ":_", "None_", ",_", "'", "num", "\\u", "author", "s", "'_", ":_", "0_", ",_", "'", "max", "\\u", "rati", "ng", "'_", ":_", "None_", ",_", "'", "id", "'_", ":_", "5_", ",_", "'", "avg", "\\u", "author", "s", "'_", ":_", "None_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "p_", ":_", "p_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "more", "\\u", "more_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "1011", "3", " ", "-", " ", "Field", "s", " ", "mentioned", " ", "in", " ", "order", "\\u", "by", "()", " ", "must", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "include", "d", " ", "in", " ", "the", " ", "GROU", "P", " ", "BY", ".", " ", "Thi", "s", " ", "only", " ", "bec", "ome", "s", " ", "a", " ", "problem", " ", "whe", "n", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "order", "\\u", "by", " ", "introduce", "s", " ", "a", " ", "new", " ", "join", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "publi", "sher", "\\u\\u", "name", "'_", ",_", "'", "name", "'_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", " ", "Programm", "ing", ":", " ", "Case", " ", "Stud", "ies", " ", "in", " ", "Common", " ", "Lis", "p", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "1012", "7", " ", "-", " ", "Emp", "ty", " ", "select", "\\u", "relate", "d", "()", " ", "works", " ", "with", " ", "annotate_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "filter_", "(_", "rati", "ng", "\\u\\u", "lt_", "=_", "4.5_", ")_", "._", "select", "\\u", "related_", "(_", ")_", "._", "annotate_", "(_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", ",_", "51.", "5_", ",_", "'", "Pre", "ntic", "e", " ", "Hall", "'_", ",_", "'", "Peter", " ", "Nor", "vig", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "'_", ",_", "29.", "0_", ",_", "'", "Ap", "ress", "'_", ",_", "'", "Jam", "es", " ", "Ben", "nett", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "'_", ",_", "Approx", "imat", "e_", "(_", "30.", "333_", ",_", "places_", "=_", "2_", ")_", ",_", "'", "Pre", "ntic", "e", " ", "Hall", "'_", ",_", "'", "Je", "ff", "rey", " ", "For", "cier", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "45.", "0_", ",_", "'", "Sam", "s", "'_", ",_", "'", "Bra", "d", " ", "Day", "ley", "'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "(_", "b_", "._", "name_", ",_", "b_", "._", "authors\\u", "\\u", "age", "\\u\\u", "avg_", ",_", "b_", "._", "publisher_", "._", "name_", ",_", "b_", "._", "contact_", "._", "name_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "1013", "2", " ", "-", " ", "If", " ", "the", " ", "values", "()", " ", "clause", " ", "only", " ", "mentioned", " ", "extra_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "select", "=", ")", " ", "column", "s", ",", " ", "tho", "se", " ", "column", "s", " ", "are", " ", "used", " ", "for", " ", "grouping_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "pub", "'_", ":_", "'", "publi", "sher", "\\u", "id", "'_", "}_", ")_", "._", "values_", "(_", "'", "pub", "'_", ")_", "._", "annotate_", "(_", "Count_", "(_", "'", "id", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "pub", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "1_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "2_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "2_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "3_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "2_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "4_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "1_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "pub", "'_", ":_", "'", "publi", "sher", "\\u", "id", "'_", ",_", "'", "foo", "'_", ":_", "'", "page", "s", "'_", "}_", ")_", "._", "values_", "(_", "'", "pub", "'_", ")_", "._", "annotate_", "(_", "Count_", "(_", "'", "id", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "pub", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "1_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "2_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "2_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "3_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "2_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "pub", "'_", ":_", "4_", ",_", "'", "id", "\\u\\u", "count", "'_", ":_", "1_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "101", "8", "2", " ", "-", " ", "Querie", "s", " ", "with", " ", "aggre", "gate", " ", "calls", " ", "are", " ", "correct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "reali", "ase", "d", " ", "whe", "n", " ", "used", " ", "in", " ", "a", " ", "subquery", "_", "\\u\\u\\uNL\\u\\u\\u_", "ids_", "=_", "Book_", "._", "objects_", "._", "filter_", "(_", "page", "s", "\\u\\u", "gt_", "=_", "100_", ")_", "._", "annotate_", "(_", "n", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "filter_", "(_", "n", "\\u", "authors\\u", "\\u", "gt_", "=_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "n", "\\u", "author", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "ids_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "157", "09", " ", "-", " ", "Ensur", "e", " ", "each", " ", "group", "\\u", "by", " ", "field", " ", "only", " ", "exist", "s", " ", "once_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "per", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "'", "publi", "sher", "'_", ")_", "._", "annotate_", "(_", "max", "\\u", "pages_", "=_", "Max_", "(_", "'", "page", "s", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "grouping_", ",_", "gb", "\\u", "params_", "=_", "qs_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "qs_", "._", "db_", ")_", "._", "get", "\\u", "grouping_", "(_", "[_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "grouping_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "duplicat", "e\\u", "alias_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "112", "56", " ", "-", " ", "duplicat", "ing", " ", "a", " ", "default", " ", "alias", " ", "raise", "s", " ", "Value", "Error", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "Book_", "._", "objects_", "._", "all_", "(_", ")_", "._", "annotate_", ",_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ",_", "authors\\u", "\\u", "age", "\\u\\u", "avg_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "field", "\\u", "name", "\\u", "conflict_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "112", "56", " ", "-", " ", "provi", "ding", " ", "an", " ", "aggre", "gate", " ", "name", " ", "tha", "t", " ", "confl", "icts", " ", "with", " ", "a", " ", "field", " ", "name", " ", "on", " ", "the", " ", "model", " ", "raise", "s", " ", "Value", "Error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "Author_", "._", "objects_", "._", "annotate_", ",_", "age_", "=_", "Avg_", "(_", "'", "friends", "\\u\\u", "age", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "m2", "m", "\\u", "name", "\\u", "conflict_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "112", "56", " ", "-", " ", "provi", "ding", " ", "an", " ", "aggre", "gate", " ", "name", " ", "tha", "t", " ", "confl", "icts", " ", "with", " ", "an", " ", "m2", "m", " ", "name", " ", "on", " ", "the", " ", "model", " ", "raise", "s", " ", "Value", "Error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "Author_", "._", "objects_", "._", "annotate_", ",_", "friends_", "=_", "Count_", "(_", "'", "friends", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "values", "\\u", "querys", "et", "\\u", "non", "\\u", "conflict_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "147", "0", "7", " ", "--", " ", "If", " ", "you", "'", "re", " ", "usi", "ng", " ", "a", " ", "values", " ", "query", " ", "set", ",", " ", "some", " ", "potenti", "al", " ", "confl", "icts", " ", "are", " ", "avoid", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "age", " ", "is", " ", "a", " ", "field", " ", "on", " ", "Author", ",", " ", "so", " ", "it", " ", "shou", "ld", "n", "'", "t", " ", "be", " ", "allow", "ed", " ", "as", " ", "an", " ", "aggre", "gate", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bu", "t", " ", "age", " ", "isn", "'", "t", " ", "include", "d", " ", "in", " ", "the", " ", "Value", "s", "Query", "Set", ",", " ", "so", " ", "it", " ", "is", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "Author_", "._", "objects_", "._", "values_", "(_", "'", "name", "'_", ")_", "._", "annotate_", "(_", "age_", "=_", "Count_", "(_", "'", "book", "\\u", "contact", "\\u", "set", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "results_", ")_", ",_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "0_", "]_", "[_", "'", "name", "'_", "]_", ",_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "0_", "]_", "[_", "'", "age", "'_", "]_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sam", "e", " ", "problem", ",", " ", "but", " ", "aggre", "gati", "ng", " ", "over", " ", "m2", "m", " ", "fields_", "\\u\\u\\uNL\\u\\u\\u_", "results_", "=_", "Author_", "._", "objects_", "._", "values_", "(_", "'", "name", "'_", ")_", "._", "annotate_", "(_", "age_", "=_", "Avg_", "(_", "'", "friends", "\\u\\u", "age", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "results_", ")_", ",_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "0_", "]_", "[_", "'", "name", "'_", "]_", ",_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "0_", "]_", "[_", "'", "age", "'_", "]_", ",_", "32.", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sam", "e", " ", "problem", ",", " ", "but", " ", "colli", "ding", " ", "with", " ", "an", " ", "m2", "m", " ", "field_", "\\u\\u\\uNL\\u\\u\\u_", "results_", "=_", "Author_", "._", "objects_", "._", "values_", "(_", "'", "name", "'_", ")_", "._", "annotate_", "(_", "friends_", "=_", "Count_", "(_", "'", "friends", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "results_", ")_", ",_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "0_", "]_", "[_", "'", "name", "'_", "]_", ",_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "0_", "]_", "[_", "'", "friends", "'_", "]_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "reverse", "\\u", "relation", "\\u", "name", "\\u", "conflict_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "112", "56", " ", "-", " ", "provi", "ding", " ", "an", " ", "aggre", "gate", " ", "name", " ", "tha", "t", " ", "confl", "icts", " ", "with", " ", "a", " ", "reverse", "-", "relate", "d", " ", "name", " ", "on", " ", "the", " ", "model", " ", "raise", "s", " ", "Value", "Error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "Author_", "._", "objects_", "._", "annotate_", ",_", "book", "\\u", "contact", "\\u", "set_", "=_", "Avg_", "(_", "'", "friends", "\\u\\u", "age", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "pickle_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "101", "9", "7", " ", "--", " ", "Querie", "s", " ", "with", " ", "aggregates", " ", "can", " ", "be", " ", "pickled", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "check", " ", "tha", "t", " ", "pick", "ling", " ", "is", " ", "possib", "le", " ", "at", " ", "all", ".", " ", "No", " ", "crash", " ", "=", " ", "success_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pickle_", "._", "dumps_", "(_", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "n", " ", "check", " ", "tha", "t", " ", "the", " ", "round", " ", "trip", " ", "works", "._", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "qs_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "qs_", "._", "db_", ")_", "._", "as", "\\u", "sql_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs", "2_", "=_", "pickle_", "._", "loads_", "(_", "pickle_", "._", "dumps_", "(_", "qs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs", "2_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "qs", "2_", "._", "db_", ")_", "._", "as", "\\u", "sql_", "(_", ")_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "query_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "more", "\\u", "more", "\\u", "more_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "101", "9", "9", " ", "-", " ", "Aggregate", " ", "calls", " ", "clone", " ", "the", " ", "original", " ", "query", " ", "so_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "original", " ", "query", " ", "can", " ", "still", " ", "be", " ", "used_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "books_", "=_", "Book_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "books_", "._", "aggregate_", "(_", "Avg_", "(_", "\"", "authors\\u", "\\u", "age", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "books_", "._", "all_", "(_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", " ", "Programm", "ing", ":", " ", "Case", " ", "Stud", "ies", " ", "in", " ", "Common", " ", "Lis", "p", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "1024", "8", " ", "-", " ", "Annotations", " ", "work", " ", "with", " ", "Date", "Query", "Sets_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "filter_", "(_", "num", "\\u", "authors_", "=_", "2_", ")_", "._", "dates_", "(_", "'", "pub", "date", "'_", ",_", "'", "day", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "date_", "(_", "1995", "_", ",_", "1_", ",_", "15_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "date_", "(_", "2007_", ",_", "12_", ",_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "102", "90", " ", "-", " ", "extra", " ", "select", "s", " ", "with", " ", "parameter", "s", " ", "can", " ", "be", " ", "used", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "grouping", "._", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "mean", "\\u", "auth", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "extra_", "(_", "select_", "=_", "{_", "'", "sheet", "s", "'_", ":_", "'(", "page", "s", " ", "+", " ", "%", "s", ")", " ", "/", " ", "%", "s", "'_", "}_", ",_", "select", "\\u", "params_", "=_", "[_", "1_", ",_", "2_", "]_", ")_", "._", "order", "\\u", "by_", "(_", "'", "sheet", "s", "'_", ")_", "._", "values_", "(_", "'", "sheet", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "150_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "175_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "224_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "264_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "473", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "566", "_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "int_", "(_", "b_", "[_", "\"", "sheet", "s", "\"_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "104", "25", " ", "-", " ", "annot", "ation", "s", " ", "don", "'", "t", " ", "get", " ", "in", " ", "the", " ", "way", " ", "of", " ", "a", " ", "count", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "clause_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "values_", "(_", "'", "publi", "sher", "'_", ")_", "._", "annotate_", "(_", "Count_", "(_", "'", "publi", "sher", "'_", ")_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "4_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "publi", "sher", "'_", ")_", ")_", "._", "values_", "(_", "'", "publi", "sher", "'_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "6_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Not", "e", ":", " ", "intent", "ional", "ly", " ", "no", " ", "order", "\\u", "by", "()", ",", " ", "tha", "t", " ", "case", " ", "need", "s", " ", "tests", ",", " ", "too", "._", "\\u\\u\\uNL\\u\\u\\u_", "publishers", "_", "=_", "Publisher_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "[_", "1_", ",_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "p_", "._", "name_", "for_", "p_", "in_", "publishers", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ap", "ress", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sam", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "publishers", "_", "=_", "publishers", "_", "._", "annotate_", "(_", "n", "\\u", "books_", "=_", "Count_", "(_", "\"", "book", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sorte", "d\\u", "publishers", "_", "=_", "sorted_", "(_", "publishers", "_", ",_", "key_", "=_", "lambda_", "x_", ":_", "x_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorte", "d\\u", "publishers", "_", "[_", "0_", "]_", "._", "n", "\\u", "books_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorte", "d\\u", "publishers", "_", "[_", "1_", "]_", "._", "n", "\\u", "books_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "p_", "._", "name_", "for_", "p_", "in_", "publishers", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ap", "ress", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sam", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "books_", "=_", "Book_", "._", "objects_", "._", "filter_", "(_", "publi", "sher", "\\u\\u", "in_", "=_", "publishers", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "books_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "p_", "._", "name_", "for_", "p_", "in_", "publishers", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ap", "ress", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sam", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "106", "6", "6", " ", "-", " ", "inherited", " ", "fields", " ", "work", " ", "with", " ", "annot", "ation", "s", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "aggregation", "s_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Hard", "back", "Book_", "._", "objects_", "._", "aggregate_", "(_", "n", "\\u", "pages_", "=_", "Sum_", "(_", "'", "book", "\\u", "ptr", "\\u\\u", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "n", "\\u", "page", "s", "'_", ":_", "207", "8_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Hard", "back", "Book_", "._", "objects_", "._", "aggregate_", "(_", "n", "\\u", "pages_", "=_", "Sum_", "(_", "'", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "n", "\\u", "page", "s", "'_", ":_", "207", "8_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Hard", "back", "Book_", "._", "objects_", "._", "annotate_", "(_", "n", "\\u", "authors_", "=_", "Count_", "(_", "'", "book", "\\u", "ptr", "\\u\\u", "author", "s", "'_", ")_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "n", "\\u", "author", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "n", "\\u", "author", "s", "'_", ":_", "2_", ",_", "'", "name", "'_", ":_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "n", "\\u", "author", "s", "'_", ":_", "1_", ",_", "'", "name", "'_", ":_", "'", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", " ", "Programm", "ing", ":", " ", "Case", " ", "Stud", "ies", " ", "in", " ", "Common", " ", "Lis", "p", "'_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "h_", ":_", "h_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Hard", "back", "Book_", "._", "objects_", "._", "annotate_", "(_", "n", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "values_", "(_", "'", "name", "'_", ",_", "'", "n", "\\u", "author", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "n", "\\u", "author", "s", "'_", ":_", "2_", ",_", "'", "name", "'_", ":_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "n", "\\u", "author", "s", "'_", ":_", "1_", ",_", "'", "name", "'_", ":_", "'", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", " ", "Programm", "ing", ":", " ", "Case", " ", "Stud", "ies", " ", "in", " ", "Common", " ", "Lis", "p", "'_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "h_", ":_", "h_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "107", "6", "6", " ", "-", " ", "Sho", "ul", "dn", "'", "t", " ", "be", " ", "able", " ", "to", " ", "reference", " ", "an", " ", "aggregate_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fields", " ", "in", " ", "an", " ", "aggre", "gate", "()", " ", "call", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Field", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", ":_", "Book_", "._", "objects_", "._", "annotate_", "(_", "mean", "\\u", "age_", "=_", "Avg_", "(_", "'", "authors\\u", "\\u", "age", "'_", ")_", ")_", "._", "annotate_", "(_", "Avg_", "(_", "'", "mean", "\\u", "age", "'_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "empty", "\\u", "filter", "\\u", "count_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "[_", "]_", ")_", "._", "annotate_", "(_", "Count_", "(_", "\"", "friends", "\"_", ")_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "empty", "\\u", "filter", "\\u", "aggregate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "[_", "]_", ")_", "._", "annotate_", "(_", "Count_", "(_", "\"", "friends", "\"_", ")_", ")_", "._", "aggregate_", "(_", "Count_", "(_", "\"", "pk", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\"", "pk", "\\u\\u", "count", "\"_", ":_", "None_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "none", "\\u", "call", "\\u", "bef", "ore", "\\u", "aggregate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "for", " ", "#", "117", "89_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", "._", "objects_", "._", "none_", "(_", ")_", "._", "aggregate_", "(_", "Avg_", "(_", "'", "age", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "age", "\\u\\u", "avg", "'_", ":_", "None_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "annot", "ate", "\\u", "and", "\\u", "join_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", "._", "objects_", "._", "annotate_", "(_", "c_", "=_", "Count_", "(_", "\"", "friends", "\\u\\u", "name", "\"_", ")_", ")_", "._", "exclude_", "(_", "friends", "\\u\\u", "name_", "=_", "\"", "Jo", "e", "\"_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Author_", "._", "objects_", "._", "count_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "f", "\\u", "express", "ion", "\\u", "annotation_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Books", " ", "with", " ", "less", " ", "than", " ", "200", " ", "page", "s", " ", "per", " ", "author", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "\"", "name", "\"_", ")_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "authors_", "=_", "Count_", "(_", "\"", "author", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "page", "s", "\\u\\u", "lt_", "=_", "F_", "(_", "\"", "n", "\\u", "author", "s", "\"_", ")_", "*_", "200_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "values", "\\u", "list_", "(_", "\"", "pk", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "filter_", "(_", "pk", "\\u\\u", "in_", "=_", "qs_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attrgetter_", "(_", "\"", "name", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "values", "\\u", "annot", "ate", "\\u", "values_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Book_", "._", "objects_", "._", "values_", "(_", "\"", "name", "\"_", ")_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "authors_", "=_", "Count_", "(_", "\"", "author", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "values", "\\u", "list_", "(_", "\"", "pk", "\"_", ",_", "flat_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "qs_", ")_", ",_", "list_", "(_", "Book_", "._", "objects_", "._", "values", "\\u", "list_", "(_", "\"", "pk", "\"_", ",_", "flat_", "=_", "True_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "hav", "ing", "\\u", "group", "\\u", "by_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "tha", "t", " ", "whe", "n", " ", "a", " ", "field", " ", "occur", "s", " ", "on", " ", "the", " ", "LH", "S", " ", "of", " ", "a", " ", "HA", "VING", " ", "clause", " ", "tha", "t", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "appear", "s", " ", "correct", "ly", " ", "in", " ", "the", " ", "GROU", "P", " ", "BY", " ", "clause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Book_", "._", "objects_", "._", "values", "\\u", "list_", "(_", "\"", "name", "\"_", ")_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "authors_", "=_", "Count_", "(_", "\"", "author", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "page", "s", "\\u\\u", "gt_", "=_", "F_", "(_", "\"", "n", "\\u", "author", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "values", "\\u", "list_", "(_", "\"", "name", "\"_", ",_", "flat_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Result", "s", " ", "shou", "ld", " ", "be", " ", "the", " ", "same", ",", " ", "all", " ", "Books", " ", "have", " ", "more", " ", "page", "s", " ", "than", " ", "authors_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "list_", "(_", "qs_", ")_", ",_", "list_", "(_", "Book_", "._", "objects_", "._", "values", "\\u", "list_", "(_", "\"", "name", "\"_", ",_", "flat_", "=_", "True_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "annot", "ation", "\\u", "disj", "unction_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "n", "\\u", "authors_", "=_", "Count_", "(_", "\"", "author", "s", "\"_", ")_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "n", "\\u", "authors_", "=_", "2_", ")_", "|_", "Q_", "(_", "name_", "=_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attrgetter_", "(_", "\"", "name", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "n", "\\u", "authors_", "=_", "Count_", "(_", "\"", "author", "s", "\"_", ")_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "name_", "=_", "\"", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "\"_", ")_", "|_", "(_", "Q_", "(_", "name_", "=_", "\"", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "\"_", ")_", "&_", "Q_", "(_", "n", "\\u", "authors_", "=_", "3_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attrgetter_", "(_", "\"", "name", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "rati", "ng", "\\u", "sum_", "=_", "Sum_", "(_", "\"", "book", "\\u\\u", "rati", "ng", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "book", "\\u", "count_", "=_", "Count_", "(_", "\"", "book", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "rati", "ng", "\\u", "sum", "\\u\\u", "gt_", "=_", "5.5_", ")_", "|_", "Q_", "(_", "rati", "ng", "\\u", "sum", "\\u\\u", "isnull_", "=_", "True_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'", "pk", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ap", "ress", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pre", "ntic", "e", " ", "Hall", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Jon", "no", "'", "s", " ", "House", " ", "of", " ", "Books", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attrgetter_", "(_", "\"", "name", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Publisher_", "._", "objects_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "rati", "ng", "\\u", "sum_", "=_", "Sum_", "(_", "\"", "book", "\\u\\u", "rati", "ng", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "book", "\\u", "count_", "=_", "Count_", "(_", "\"", "book", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "pk", "\\u\\u", "lt_", "=_", "F_", "(_", "\"", "book", "\\u", "count", "\"_", ")_", ")_", "|_", "Q_", "(_", "rati", "ng", "\\u", "sum_", "=_", "None_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "\"", "pk", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ap", "ress", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Jon", "no", "'", "s", " ", "House", " ", "of", " ", "Books", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attrgetter_", "(_", "\"", "name", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "quoting", "\\u", "aggre", "gate", "\\u", "order", "\\u", "by_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Book_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "author", "Count_", "=_", "Count_", "(_", "\"", "author", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "\"", "author", "Count", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "\"_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "(_", "b_", "._", "name_", ",_", "b_", "._", "author", "Count_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "Un", "less", "DB", "Feature_", "(_", "'", "support", "s", "\\u", "stddev", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "stddev_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Std", "Dev_", "(_", "'", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "stddev", "'_", ":_", "Approx", "imat", "e_", "(_", "311", ".4", "6_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Std", "Dev_", "(_", "'", "rati", "ng", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "rati", "ng", "\\u\\u", "stddev", "'_", ":_", "Approx", "imat", "e_", "(_", "0.60", "_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Std", "Dev_", "(_", "'", "price", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "\\u\\u", "stddev", "'_", ":_", "Approx", "imat", "e_", "(_", "24.", "16_", ",_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Std", "Dev_", "(_", "'", "page", "s", "'_", ",_", "sample_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "stddev", "'_", ":_", "Approx", "imat", "e_", "(_", "341", ".1", "9_", ",_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Std", "Dev_", "(_", "'", "rati", "ng", "'_", ",_", "sample_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "rati", "ng", "\\u\\u", "stddev", "'_", ":_", "Approx", "imat", "e_", "(_", "0.66", "_", ",_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Std", "Dev_", "(_", "'", "price", "'_", ",_", "sample_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "\\u\\u", "stddev", "'_", ":_", "Approx", "imat", "e_", "(_", "26.", "46_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Variance", "_", "(_", "'", "page", "s", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "varian", "ce", "'_", ":_", "Approx", "imat", "e_", "(_", "970", "10.", "80_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Variance", "_", "(_", "'", "rati", "ng", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "rati", "ng", "\\u\\u", "varian", "ce", "'_", ":_", "Approx", "imat", "e_", "(_", "0.36", "_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Variance", "_", "(_", "'", "price", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "\\u\\u", "varian", "ce", "'_", ":_", "Approx", "imat", "e_", "(_", "583", ".7", "7_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Variance", "_", "(_", "'", "page", "s", "'_", ",_", "sample_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "page", "s", "\\u\\u", "varian", "ce", "'_", ":_", "Approx", "imat", "e_", "(_", "116", "412", ".96", "_", ",_", "1_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Variance", "_", "(_", "'", "rati", "ng", "'_", ",_", "sample_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "rati", "ng", "\\u\\u", "varian", "ce", "'_", ":_", "Approx", "imat", "e_", "(_", "0.44", "_", ",_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Variance", "_", "(_", "'", "price", "'_", ",_", "sample_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "price", "\\u\\u", "varian", "ce", "'_", ":_", "Approx", "imat", "e_", "(_", "700", ".5", "3_", ",_", "2_", ")_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "filtering", "\\u", "by", "\\u", "annot", "ation", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "test", " ", "for", " ", "#", "144", "76_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "name", " ", "of", " ", "the", " ", "explicit", "ly", " ", "provided", " ", "annot", "ation", " ", "name", " ", "in", " ", "this", " ", "case_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "poses", " ", "no", " ", "problem_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "book", "\\u", "cnt_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Peter", " ", "Nor", "vig", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Nei", "ther", " ", "in", " ", "this", " ", "case_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "book", "\\u", "count_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "book", "\\u", "count_", "=_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Peter", " ", "Nor", "vig", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "case", " ", "used", " ", "to", " ", "fail", " ", "bec", "aus", "e", " ", "the", " ", "ORM", " ", "coul", "dn", "'", "t", " ", "resolve", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "automati", "call", "y", " ", "generat", "ed", " ", "annot", "ation", " ", "name", " ", "`", "book", "\\u\\u", "count", "`_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "book", "\\u\\u", "count_", "=_", "2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Peter", " ", "Nor", "vig", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "type", "\\u", "conversion_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "databa", "se", " ", "back", "end", " ", "convert", "\\u", "values", " ", "function", " ", "shou", "ld", " ", "not", " ", "try", " ", "to", " ", "cover", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Char", "Field", "s", " ", "to", " ", "float", ".", " ", "Refs", " ", "#", "138", "44.", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "db_", "._", "models_", "import_", "Char", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test", "Data_", "=_", "'", "not", "\\u", "a", "\\u", "float", "\\u", "value", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test", "Field_", "=_", "Char", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "connection_", "._", "ops_", "._", "convert", "\\u", "values_", "(_", "test", "Data_", ",_", "test", "Field_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "test", "Data_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "annot", "ate", "\\u", "joins", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "tha", "t", " ", "the", " ", "base", " ", "table", "'", "s", " ", "join", " ", "isn", "'", "t", " ", "promote", "d", " ", "to", " ", "LO", "UT", "ER", ".", " ", "Thi", "s", " ", "coul", "d", "\\", "10", ";", " ", " ", " ", " ", "caus", "e", " ", "the", " ", "query", " ", "generat", "ion", " ", "to", " ", "fail", " ", "if", " ", "there", " ", "is", " ", "an", " ", "exclu", "de", "()", " ", "for", " ", "fk", "-", "field", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "the", " ", "query", ",", " ", "too", ".", " ", "Refs", " ", "#", "190", "87", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "n_", "=_", "Count_", "(_", "'", "pk", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is_", "(_", "qs_", "._", "query_", "._", "alias", "\\u", "map_", "[_", "'", "aggregation", "\\u", "regress", "\\u", "book", "'_", "]_", "._", "join", "\\u", "type_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "the", " ", "query", " ", "execute", "s", " ", "with", "out", " ", "problem", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "qs_", "._", "exclude_", "(_", "publisher_", "=_", "-_", "1_", ")_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "Un", "less", "DB", "Feature_", "(_", "\"", "allow", "s", "\\u", "group", "\\u", "by", "\\u", "pk", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "aggre", "gate", "\\u", "duplicat", "e\\u", "columns_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "test", " ", "for", " ", "#", "171", "44_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "num", "\\u", "contacts_", "=_", "Count_", "(_", "'", "book", "\\u", "contact", "\\u", "set", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "There", " ", "shou", "ld", " ", "only", " ", "be", " ", "one", " ", "GROU", "P", " ", "BY", " ", "clause", ",", " ", "for", " ", "the", " ", "`", "id", "`", " ", "column", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "`", "name", "`", " ", "and", " ", "`", "age", "`", " ", "shou", "ld", " ", "not", " ", "be", " ", "groupe", "d", " ", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "grouping_", ",_", "gb", "\\u", "params_", "=_", "results_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "using_", "=_", "'", "default", "'_", ")_", "._", "get", "\\u", "grouping_", "(_", "[_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "grouping_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "id", "'_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "name", "'_", "not_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "age", "'_", "not_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "query", " ", "group", "\\u", "by", " ", "property", " ", "shou", "ld", " ", "als", "o", " ", "only", " ", "show", " ", "the", " ", "`", "id", "`.", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "._", "query_", "._", "group", "\\u", "by_", ",_", "[_", "(_", "'", "aggregation", "\\u", "regress", "\\u", "author", "'_", ",_", "'", "id", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "tha", "t", " ", "we", " ", "get", " ", "correct", " ", "results", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "a_", "._", "name_", ",_", "a_", "._", "num", "\\u", "contacts_", ")_", "for_", "a_", "in_", "results_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Bra", "d", " ", "Day", "ley", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Jacob", " ", "Kap", "lan", "-", "Mos", "s", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Jam", "es", " ", "Ben", "nett", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Je", "ff", "rey", " ", "For", "cier", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Paul", " ", "Bis", "sex", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Peter", " ", "Nor", "vig", "'_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Stu", "art", " ", "Rus", "sell", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "We", "sle", "y", " ", "J", ".", " ", "Chu", "n", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "Un", "less", "DB", "Feature_", "(_", "\"", "allow", "s", "\\u", "group", "\\u", "by", "\\u", "pk", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "aggre", "gate", "\\u", "duplicat", "e\\u", "column", "s", "\\u", "only_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Works", " ", "with", " ", "only", "()", " ", "too", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "Author_", "._", "objects_", "._", "only_", "(_", "'", "id", "'_", ",_", "'", "name", "'_", ")_", "._", "annotate_", "(_", "num", "\\u", "contacts_", "=_", "Count_", "(_", "'", "book", "\\u", "contact", "\\u", "set", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "grouping_", ",_", "gb", "\\u", "params_", "=_", "results_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "using_", "=_", "'", "default", "'_", ")_", "._", "get", "\\u", "grouping_", "(_", "[_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "grouping_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "id", "'_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "name", "'_", "not_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "age", "'_", "not_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "query", " ", "group", "\\u", "by", " ", "property", " ", "shou", "ld", " ", "als", "o", " ", "only", " ", "show", " ", "the", " ", "`", "id", "`.", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "._", "query_", "._", "group", "\\u", "by_", ",_", "[_", "(_", "'", "aggregation", "\\u", "regress", "\\u", "author", "'_", ",_", "'", "id", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "tha", "t", " ", "we", " ", "get", " ", "correct", " ", "results", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "a_", "._", "name_", ",_", "a_", "._", "num", "\\u", "contacts_", ")_", "for_", "a_", "in_", "results_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Bra", "d", " ", "Day", "ley", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Jacob", " ", "Kap", "lan", "-", "Mos", "s", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Jam", "es", " ", "Ben", "nett", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Je", "ff", "rey", " ", "For", "cier", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Paul", " ", "Bis", "sex", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Peter", " ", "Nor", "vig", "'_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Stu", "art", " ", "Rus", "sell", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "We", "sle", "y", " ", "J", ".", " ", "Chu", "n", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "Un", "less", "DB", "Feature_", "(_", "\"", "allow", "s", "\\u", "group", "\\u", "by", "\\u", "pk", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "aggre", "gate", "\\u", "duplicat", "e\\u", "column", "s", "\\u", "select", "\\u", "related_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "And", " ", "select", "\\u", "relate", "d", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "Book_", "._", "objects_", "._", "select", "\\u", "related_", "(_", "'", "contact", "'_", ")_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "authors_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "grouping_", ",_", "gb", "\\u", "params_", "=_", "results_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "using_", "=_", "'", "default", "'_", ")_", "._", "get", "\\u", "grouping_", "(_", "[_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "grouping_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "id", "'_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "name", "'_", "not_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "contact", "'_", "not_", "in_", "grouping_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "query", " ", "group", "\\u", "by", " ", "property", " ", "shou", "ld", " ", "als", "o", " ", "only", " ", "show", " ", "the", " ", "`", "id", "`.", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "._", "query_", "._", "group", "\\u", "by_", ",_", "[_", "(_", "'", "aggregation", "\\u", "regress", "\\u", "book", "'_", ",_", "'", "id", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "tha", "t", " ", "we", " ", "get", " ", "correct", " ", "results", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "b_", "._", "name_", ",_", "b_", "._", "num", "\\u", "authors_", ")_", "for_", "b_", "in_", "results_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", " ", "Programm", "ing", ":", " ", "Case", " ", "Stud", "ies", " ", "in", " ", "Common", " ", "Lis", "p", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "'_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "'_", ",_", "2_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "reverse", "\\u", "join", "\\u", "trim", "ming", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "book", "\\u", "contact", "\\u", "set\\u", "\\u", "contact", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "'", " ", "JOIN", " ", "'_", ",_", "str_", "(_", "qs_", "._", "query_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "aggregation", "\\u", "with", "\\u", "gener", "ic", "\\u", "reverse", "\\u", "relation_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Regr", "ession", " ", "test", " ", "for", " ", "#", "1087", "0", ":", " ", " ", "Aggregate", "s", " ", "with", " ", "joins", " ", "ignore", " ", "extra", "\\", "10", ";", " ", " ", " ", " ", "filter", "s", " ", "provided", " ", "by", " ", "setup", "\\u", "joins", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "tests", " ", "aggregation", "s", " ", "with", " ", "gener", "ic", " ", "reverse", " ", "relation", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "Book_", "._", "objects_", "._", "get_", "(_", "name_", "=_", "'", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Item", "Tag_", "._", "objects_", "._", "create_", "(_", "object\\u", "id_", "=_", "b_", "._", "id_", ",_", "tag_", "=_", "'", "intermediate", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "b_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Item", "Tag_", "._", "objects_", "._", "create_", "(_", "object\\u", "id_", "=_", "b_", "._", "id_", ",_", "tag_", "=_", "'", "django", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "b_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Assign", " ", "a", " ", "tag", " ", "to", " ", "model", " ", "with", " ", "same", " ", "PK", " ", "as", " ", "the", " ", "book", " ", "above", ".", " ", "If", " ", "the", " ", "JOIN", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "used", " ", "in", " ", "aggregation", " ", "doe", "sn", "'", "t", " ", "have", " ", "content", " ", "type", " ", "as", " ", "part", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "condition", " ", "the", " ", "annot", "ation", " ", "will", " ", "als", "o", " ", "count", " ", "the", " ", "'", "hi", " ", "mom", "'", " ", "tag", " ", "for", " ", "b", "._", "\\u\\u\\uNL\\u\\u\\u_", "wm", "pk_", "=_", "With", "Manu", "al", "PK", "_", "._", "objects_", "._", "create_", "(_", "id_", "=_", "b_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Item", "Tag_", "._", "objects_", "._", "create_", "(_", "object\\u", "id_", "=_", "wm", "pk_", "._", "id_", ",_", "tag_", "=_", "'", "hi", " ", "mom", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "wm", "pk_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "Book_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "startswith_", "=_", "'", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Item", "Tag_", "._", "objects_", "._", "create_", "(_", "object\\u", "id_", "=_", "b_", "._", "id_", ",_", "tag_", "=_", "'", "intermediate", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "b_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Book_", "._", "objects_", "._", "aggregate_", "(_", "Count_", "(_", "'", "tags", "'_", ")_", ")_", ",_", "{_", "'", "tags", "\\u\\u", "count", "'_", ":_", "3_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "tags", "'_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "tags", "\\u\\u", "count", "'_", ",_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "b_", "._", "name_", ",_", "b_", "._", "tags", "\\u\\u", "count_", ")_", "for_", "b_", "in_", "results_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Pra", "ctic", "al", " ", "Dj", "ang", "o", " ", "Project", "s", "'_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Para", "dig", "ms", " ", "of", " ", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", " ", "Programm", "ing", ":", " ", "Case", " ", "Stud", "ies", " ", "in", " ", "Common", " ", "Lis", "p", "'_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Arti", "ficia", "l", " ", "Intel", "lig", "ence", ":", " ", "A", " ", "Mode", "rn", " ", "Appro", "ach", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Pyth", "on", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "with", " ", "Dj", "ang", "o", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "The", " ", "Definit", "ive", " ", "Guide", " ", "to", " ", "Dj", "ang", "o", ":", " ", "Web", " ", "Dev", "elo", "pme", "nt", " ", "Don", "e", " ", "Rig", "ht", "'_", ",_", "0_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "negate", "d\\u", "aggregation_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expected", "\\u", "results_", "=_", "Author_", "._", "objects_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk", "\\u\\u", "in_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "book", "\\u", "cnt_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "results_", "=_", "[_", "a_", "._", "name_", "for_", "a_", "in_", "expected", "\\u", "results_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "book", "\\u", "cnt_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", ",_", "Q_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "results_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "results_", "=_", "Author_", "._", "objects_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk", "\\u\\u", "in_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "book", "\\u", "cnt_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "results_", "=_", "[_", "a_", "._", "name_", "for_", "a_", "in_", "expected", "\\u", "results_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "book", "\\u", "cnt_", "=_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "exclude_", "(_", "Q_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", "|_", "Q_", "(_", "book", "\\u", "cnt_", "=_", "2_", ")_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "results_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "name", "\\u", "filters_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "book", "\\u\\u", "count", "\\u\\u", "exact_", "=_", "2_", ")_", "|_", "Q_", "(_", "name_", "=_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ",_", "'", "Peter", " ", "Nor", "vig", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "name", "\\u", "expressions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "tha", "t", " ", "aggregates", " ", "are", " ", "spot", "ted", " ", "corre", "tl", "y", " ", "from", " ", "F", " ", "object", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Not", "e", " ", "tha", "t", " ", "Adr", "ian", "'", "s", " ", "age", " ", "is", " ", "3", "4", " ", "in", " ", "the", " ", "fixture", "s", ",", " ", "and", " ", "he", " ", "has", " ", "one", " ", "book_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "so", " ", "bot", "h", " ", "condition", "s", " ", "match", " ", "one", " ", "author", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "Author_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "book", "'_", ")_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Q_", "(_", "name_", "=_", "'", "Peter", " ", "Nor", "vig", "'_", ")_", "|_", "Q_", "(_", "age_", "=_", "F_", "(_", "'", "book", "\\u\\u", "count", "'_", ")_", "+_", "33_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Adr", "ian", " ", "Hol", "ova", "ty", "'_", ",_", "'", "Peter", " ", "Nor", "vig", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "tick", "et", "\\u", "112", "93_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q1_", "=_", "Q_", "(_", "price", "\\u\\u", "gt_", "=_", "50_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q2_", "=_", "Q_", "(_", "authors\\u", "\\u", "count", "\\u\\u", "gt_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "q1_", "|_", "q2_", ")_", "._", "order", "\\u", "by_", "(_", "'", "pk", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "query_", ",_", "[_", "1_", ",_", "4_", ",_", "5_", ",_", "6_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "tick", "et", "\\u", "112", "9", "3", "\\u", "q", "\\u", "immutable", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "tha", "t", " ", "splitting", " ", "a", " ", "q", " ", "object", " ", "to", " ", "part", "s", " ", "for", " ", "where", "/", "hav", "ing", " ", "doe", "sn", "'", "t", " ", "alter", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "original", " ", "q", "-", "object", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q1_", "=_", "Q_", "(_", "isbn", "_", "=_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q2_", "=_", "Q_", "(_", "authors\\u", "\\u", "count", "\\u\\u", "gt_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "Count_", "(_", "'", "author", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "._", "filter_", "(_", "q1_", "|_", "q2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "q2_", "._", "children_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "fo", "bj", "\\u", "group", "\\u", "by_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "tha", "t", " ", "an", " ", "F", "()", " ", "object", " ", "refer", "ring", " ", "to", " ", "relate", "d", " ", "column", " ", "works", " ", "correct", "ly", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "group", " ", "by", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Book_", "._", "objects_", "._", "annotate_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "aco", "unt_", "=_", "Count_", "(_", "'", "author", "s", "'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "aco", "unt_", "=_", "F_", "(_", "'", "publi", "sher", "\\u\\u", "num", "\\u", "awards", "'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "'", "Sam", "s", " ", "Tea", "ch", " ", "You", "rse", "lf", " ", "Dj", "ang", "o", " ", "in", " ", "24", " ", "Hour", "s", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "b_", ":_", "b_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Aggregation", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "tick", "et", "\\u", "211", "50_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "b_", "=_", "Bra", "vo_", "._", "objects_", "._", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Charl", "ie_", "._", "objects_", "._", "create_", "(_", "bra", "vo_", "=_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qs_", "=_", "Charl", "ie_", "._", "objects_", "._", "select", "\\u", "related_", "(_", "'", "alfa", "'_", ")_", "._", "annotate_", "(_", "Count_", "(_", "'", "bra", "vo", "\\u\\u", "charl", "ie", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "c_", "]_", ",_", "lambda_", "x_", ":_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is_", "(_", "qs_", "[_", "0_", "]_", "._", "alfa", "_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "Al", "fa_", "._", "objects_", "._", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "alfa", "_", "=_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Force", " ", "re", "-", "evaluation_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "qs_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", ",_", "[_", "c_", "]_", ",_", "lambda_", "x_", ":_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "qs_", "[_", "0_", "]_", "._", "alfa", "_", ",_", "a_", ")_" ]
[ 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,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Redundant assignment
mrknow/filmkodi/plugin.video.specto/resources/lib/resolvers/divxpress.py
[ { "content": "def resolve(url):\n try:\n url = url.replace('/embed-', '/')\n url = re.compile('//.+?/([\\w]+)').findall(url)[0]\n url = 'http://divxpress.com/embed-%s.html' % url\n\n result = client.request(url, close=False)\n\n post = {}\n f = client.parseDOM(result, 'form', attrs = {'method': 'POST'})[0]\n k = client.parseDOM(f, 'input', ret='name', attrs = {'type': 'hidden'})\n for i in k: post.update({i: client.parseDOM(f, 'input', ret='value', attrs = {'name': i})[0]})\n post = post\n\n result = client.request(url, post=post)\n\n result = re.compile('(eval.*?\\)\\)\\))').findall(result)[-1]\n result = jsunpack.unpack(result)\n\n url = client.parseDOM(result, 'embed', ret='src')\n url += re.compile(\"'file' *, *'(.+?)'\").findall(result)\n url = [i for i in url if not i.endswith('.srt')]\n url = 'http://' + url[0].split('://', 1)[-1]\n\n return url\n except:\n return", "metadata": "root.resolve", "header": "['module', '___EOS___']", "index": 26 } ]
[ { "span": "post = post", "start_line": 38, "start_column": 8, "end_line": 38, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Redu", "ndan", "t_", "assignment_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "resolve_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "url_", "._", "replace_", "(_", "'/", "embed", "-'_", ",_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "re_", "._", "compile_", "(_", "'//", ".+?", "/([", "\\\\", "w", "]+)'_", ")_", "._", "findall_", "(_", "url_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "'", "http", "://", "div", "xpr", "ess", ".", "com", "/", "embed", "-%", "s", ".", "html", "'_", "%_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "request_", "(_", "url_", ",_", "close_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "post_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "client_", "._", "parse", "DOM_", "(_", "result_", ",_", "'", "form", "'_", ",_", "attrs_", "=_", "{_", "'", "method", "'_", ":_", "'", "POST", "'_", "}_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "client_", "._", "parse", "DOM_", "(_", "f_", ",_", "'", "input", "'_", ",_", "ret_", "=_", "'", "name", "'_", ",_", "attrs_", "=_", "{_", "'", "type", "'_", ":_", "'", "hidden", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "k_", ":_", "post_", "._", "update_", "(_", "{_", "i_", ":_", "client_", "._", "parse", "DOM_", "(_", "f_", ",_", "'", "input", "'_", ",_", "ret_", "=_", "'", "value", "'_", ",_", "attrs_", "=_", "{_", "'", "name", "'_", ":_", "i_", "}_", ")_", "[_", "0_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post_", "=_", "post_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "request_", "(_", "url_", ",_", "post_", "=_", "post_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "re_", "._", "compile_", "(_", "'(", "eval", ".*?\\\\", ")\\\\", ")\\\\", "))'_", ")_", "._", "findall_", "(_", "result_", ")_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "js", "unpack_", "._", "unpack_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "client_", "._", "parse", "DOM_", "(_", "result_", ",_", "'", "embed", "'_", ",_", "ret_", "=_", "'", "src", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "+=_", "re_", "._", "compile_", "(_", "\"'", "file", "'", " ", "*", ",", " ", "*'", "(.+?)", "'\"_", ")_", "._", "findall_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "[_", "i_", "for_", "i_", "in_", "url_", "if_", "not_", "i_", "._", "endswith_", "(_", "'.", "srt", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "'", "http", "://'_", "+_", "url_", "[_", "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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
neurodata/ndstore/onetime/asingest.py
[ { "content": "# Copyright 2014 Open Connectome Project (http://openconnecto.me)\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\nimport argparse\nimport sys\nimport os\nimport numpy as np\nimport urllib, urllib2\nimport cStringIO\nfrom PIL import Image\nimport zlib\nimport MySQLdb\nimport aerospike\nimport tempfile\nimport h5py\n\nsys.path += [os.path.abspath('../django')]\nimport OCP.settings\nos.environ['DJANGO_SETTINGS_MODULE'] = 'OCP.settings'\nfrom django.conf import settings\n\nimport ocpcaproj\nimport ocpcadb\nimport zindex\n\n\"\"\"Construct an image hierarchy up from a given resolution\"\"\"\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n main()\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def main():\n\n parser = argparse.ArgumentParser(description='Build an aeropsike DB from mysql data.')\n parser.add_argument('token', action=\"store\", help='Token for the project.')\n parser.add_argument('resolution', action=\"store\", type=int)\n \n result = parser.parse_args()\n\n # as database\n ascfg = { 'hosts': [ ('127.0.0.1', 3000) ] }\n ascli = aerospike.client(ascfg).connect()\n\n # mysql database\n projdb = ocpcaproj.OCPCAProjectsDB()\n proj = projdb.loadProject ( result.token )\n\n # Bind the annotation database\n imgDB = ocpcadb.OCPCADB ( proj )\n\n # Get the source database sizes\n [ximagesz, yimagesz] = proj.datasetcfg.imagesz [ result.resolution ]\n [xcubedim, ycubedim, zcubedim] = cubedim = proj.datasetcfg.cubedim [ result.resolution ]\n\n # Get the slices\n [ startslice, endslice ] = proj.datasetcfg.slicerange\n slices = endslice - startslice + 1\n\n # Set the limits for iteration on the number of cubes in each dimension\n # RBTODO These limits may be wrong for even (see channelingest.py)\n xlimit = ximagesz / xcubedim\n ylimit = yimagesz / ycubedim\n # Round up the zlimit to the next larger\n zlimit = (((slices-1)/zcubedim+1)*zcubedim)/zcubedim \n\n cursor = imgDB.conn.cursor()\n\n for z in range(zlimit):\n for y in range(ylimit):\n for x in range(xlimit):\n\n mysqlcube = imgDB.cutout ( [ x*xcubedim, y*ycubedim, z*zcubedim ], cubedim, result.resolution )\n zidx = zindex.XYZMorton ( [x,y,z] )\n\n tmpfile = tempfile.NamedTemporaryFile ()\n h5tocass = h5py.File ( tmpfile.name ) \n h5tocass.create_dataset ( \"cuboid\", tuple(mysqlcube.data.shape), mysqlcube.data.dtype,\n compression='gzip', data=mysqlcube.data )\n h5tocass.close()\n tmpfile.seek(0)\n\n askey = (\"ocp\",str(result.token)+\":\"+str(result.resolution),str(zidx))\n\n print askey\n ascli.put ( askey, { 'cuboid' : tmpfile.read().encode('hex') } )\n\n try:\n import pdb; pdb.set_trace()\n ascli.get ( askey )\n except:\n print \"Except\"", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 38 } ]
[ { "span": "import numpy as np", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 18 }, { "span": "import urllib, urllib2", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 22 }, { "span": "import cStringIO", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 16 }, { "span": "from PIL import Image", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 21 }, { "span": "import zlib", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 11 }, { "span": "import MySQLdb", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 14 }, { "span": "import OCP.settings", "start_line": 28, "start_column": 0, "end_line": 28, "end_column": 19 }, { "span": "from django.conf import settings", "start_line": 30, "start_column": 0, "end_line": 30, "end_column": 32 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2014", " ", "Open", " ", "Connect", "ome", " ", "Project", " ", "(", "http", "://", "openco", "nnect", "o", ".", "me", ")_", "\\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_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", ",_", "urllib2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "c", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "zlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "My", "SQL", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "aeros", "pike", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "h5py_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "path_", "+=_", "[_", "os_", "._", "path_", "._", "abspath_", "(_", "'../", "django", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "OC", "P_", "._", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "environ_", "[_", "'", "DJANGO", "\\u", "SETTING", "S", "\\u", "MODUL", "E", "'_", "]_", "=_", "'", "OC", "P", ".", "settings", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "oc", "pcap", "roj", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "oc", "pca", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "zin", "dex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Construct", " ", "an", " ", "image", " ", "hier", "arch", "y", " ", "up", " ", "from", " ", "a", " ", "give", "n", " ", "resolu", "tion", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "\\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_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "description_", "=_", "'", "Build", " ", "an", " ", "aero", "psi", "ke", " ", "DB", " ", "from", " ", "mysql", " ", "data", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'", "token", "'_", ",_", "action_", "=_", "\"", "store", "\"_", ",_", "help_", "=_", "'", "Token", " ", "for", " ", "the", " ", "project", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'", "resolu", "tion", "'_", ",_", "action_", "=_", "\"", "store", "\"_", ",_", "type_", "=_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "as", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "asc", "fg_", "=_", "{_", "'", "host", "s", "'_", ":_", "[_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "3000_", ")_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "asc", "li_", "=_", "aeros", "pike", "_", "._", "client_", "(_", "asc", "fg_", ")_", "._", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mysql", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "proj", "db_", "=_", "oc", "pcap", "roj", "_", "._", "OC", "PCA", "Project", "s", "DB_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "proj_", "=_", "proj", "db_", "._", "load", "Project_", "(_", "result_", "._", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bind", " ", "the", " ", "annot", "ation", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "img", "DB_", "=_", "oc", "pca", "db_", "._", "OC", "PCA", "DB_", "(_", "proj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "source", " ", "databa", "se", " ", "sizes_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "xim", "age", "sz_", ",_", "yi", "mage", "sz_", "]_", "=_", "proj_", "._", "dataset", "cfg_", "._", "images", "z_", "[_", "result_", "._", "resolution_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[_", "xc", "ube", "dim_", ",_", "yc", "ube", "dim_", ",_", "zc", "ube", "dim_", "]_", "=_", "cube", "dim_", "=_", "proj_", "._", "dataset", "cfg_", "._", "cube", "dim_", "[_", "result_", "._", "resolution_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "slices_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "starts", "lice", "_", ",_", "ends", "lice", "_", "]_", "=_", "proj_", "._", "dataset", "cfg_", "._", "slicer", "ange_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slices_", "=_", "ends", "lice", "_", "-_", "starts", "lice", "_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "the", " ", "limit", "s", " ", "for", " ", "iterati", "on", " ", "on", " ", "the", " ", "number", " ", "of", " ", "cubes", " ", "in", " ", "each", " ", "dimension_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "RB", "TOD", "O", " ", "The", "se", " ", "limit", "s", " ", "may", " ", "be", " ", "wrong", " ", "for", " ", "even", " ", "(", "see", " ", "channel", "ingest", ".", "py", ")_", "\\u\\u\\uNL\\u\\u\\u_", "xlim", "it_", "=_", "xim", "age", "sz_", "/_", "xc", "ube", "dim_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ylim", "it_", "=_", "yi", "mage", "sz_", "/_", "yc", "ube", "dim_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Round", " ", "up", " ", "the", " ", "zli", "mit", " ", "to", " ", "the", " ", "next", " ", "large", "r_", "\\u\\u\\uNL\\u\\u\\u_", "zli", "mit_", "=_", "(_", "(_", "(_", "slices_", "-_", "1_", ")_", "/_", "zc", "ube", "dim_", "+_", "1_", ")_", "*_", "zc", "ube", "dim_", ")_", "/_", "zc", "ube", "dim_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cursor_", "=_", "img", "DB_", "._", "conn_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "z_", "in_", "range_", "(_", "zli", "mit_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "y_", "in_", "range_", "(_", "ylim", "it_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "x_", "in_", "range_", "(_", "xlim", "it_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mysql", "cube_", "=_", "img", "DB_", "._", "cuto", "ut_", "(_", "[_", "x_", "*_", "xc", "ube", "dim_", ",_", "y_", "*_", "yc", "ube", "dim_", ",_", "z_", "*_", "zc", "ube", "dim_", "]_", ",_", "cube", "dim_", ",_", "result_", "._", "resolution_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zi", "dx_", "=_", "zin", "dex_", "._", "XY", "ZM", "ort", "on_", "(_", "[_", "x_", ",_", "y_", ",_", "z_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tmpfile_", "=_", "tempfile_", "._", "Name", "d", "Tempora", "ry", "File_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h5", "toc", "ass_", "=_", "h5py_", "._", "File_", "(_", "tmpfile_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h5", "toc", "ass_", "._", "create", "\\u", "dataset_", "(_", "\"", "cub", "oid", "\"_", ",_", "tuple_", "(_", "mysql", "cube_", "._", "data_", "._", "shape_", ")_", ",_", "mysql", "cube_", "._", "data_", "._", "dtype_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "compression_", "=_", "'", "gzip", "'_", ",_", "data_", "=_", "mysql", "cube_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h5", "toc", "ass_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmpfile_", "._", "seek_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ask", "ey_", "=_", "(_", "\"", "oc", "p", "\"_", ",_", "str_", "(_", "result_", "._", "token_", ")_", "+_", "\":\"_", "+_", "str_", "(_", "result_", "._", "resolution_", ")_", ",_", "str_", "(_", "zi", "dx_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "ask", "ey_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "asc", "li_", "._", "put_", "(_", "ask", "ey_", ",_", "{_", "'", "cub", "oid", "'_", ":_", "tmpfile_", "._", "read_", "(_", ")_", "._", "encode_", "(_", "'", "hex", "'_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\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, 2 ]
Unused import
celery/kombu/kombu/transport/qpid_patches.py
[ { "content": "# This module applies two patches to qpid.messaging that are required for\n# correct operation. Each patch fixes a bug. See links to the bugs below:\n# https://issues.apache.org/jira/browse/QPID-5637\n# https://issues.apache.org/jira/browse/QPID-5557\n\n# ## Begin Monkey Patch 1 ###\n# https://issues.apache.org/jira/browse/QPID-5637\n\n#############################################################################\n# _ _ ___ _____ _____\n# | \\ | |/ _ \\_ _| ____|\n# | \\| | | | || | | _|\n# | |\\ | |_| || | | |___\n# |_| \\_|\\___/ |_| |_____|\n#\n# If you have code that also uses qpid.messaging and imports kombu,\n# or causes this file to be imported, then you need to make sure that this\n# import occurs first.\n#\n# Failure to do this will cause the following exception:\n# AttributeError: 'Selector' object has no attribute '_current_pid'\n#\n# Fix this by importing this module prior to using qpid.messaging in other\n# code that also uses this module.\n#############################################################################\n\n\n# this import is needed for Python 2.6. Without it, qpid.py will \"mask\" the\n# system's qpid lib\nfrom __future__ import absolute_import, unicode_literals\n\nimport os\n\n\n# Imports for Monkey Patch 1\ntry:\n from qpid.selector import Selector\nexcept ImportError: # pragma: no cover\n Selector = None # noqa\nimport atexit\n\n\n# Prepare for Monkey Patch 1\n\n# Apply Monkey Patch 1\n\ntry:\n import qpid.selector\n qpid.selector.Selector.default = staticmethod(default_monkey)\nexcept ImportError: # pragma: no cover\n pass\n\n# ## End Monkey Patch 1 ###\n\n# ## Begin Monkey Patch 2 ###\n# https://issues.apache.org/jira/browse/QPID-5557\n\n# Imports for Monkey Patch 2\ntry:\n from qpid.ops import ExchangeQuery, QueueQuery\nexcept ImportError: # pragma: no cover\n ExchangeQuery = None\n QueueQuery = None\n\ntry:\n from qpid.messaging.exceptions import (\n NotFound, AssertionFailed, ConnectionError,\n )\nexcept ImportError: # pragma: no cover\n NotFound = None\n AssertionFailed = None\n ConnectionError = None\n\n\n# Prepare for Monkey Patch 2\n\n\n\n\n# Apply monkey patch 2\ntry:\n import qpid.messaging.driver\n qpid.messaging.driver.Engine.resolve_declare = resolve_declare_monkey\n qpid.messaging.driver.Engine.resolve = resolve_monkey\nexcept ImportError: # pragma: no cover\n pass\n# ## End Monkey Patch 2 ###\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def default_monkey(): # pragma: no cover\n Selector.lock.acquire()\n try:\n if Selector.DEFAULT is None:\n sel = Selector()\n atexit.register(sel.stop)\n sel.start()\n Selector.DEFAULT = sel\n Selector._current_pid = os.getpid()\n elif Selector._current_pid != os.getpid():\n sel = Selector()\n atexit.register(sel.stop)\n sel.start()\n Selector.DEFAULT = sel\n Selector._current_pid = os.getpid()\n return Selector.DEFAULT\n finally:\n Selector.lock.release()", "metadata": "root.default_monkey", "header": "['module', '___EOS___']", "index": 43 }, { "content": "def resolve_declare_monkey(self, sst, lnk, dir, action): # pragma: no cover\n declare = lnk.options.get('create') in ('always', dir)\n assrt = lnk.options.get('assert') in ('always', dir)\n requested_type = lnk.options.get('node', {}).get('type')\n\n def do_resolved(type, subtype):\n err = None\n if type is None:\n if declare:\n err = self.declare(sst, lnk, action)\n else:\n err = NotFound(text='no such queue: %s' % lnk.name)\n else:\n if assrt:\n expected = lnk.options.get('node', {}).get('type')\n if expected and type != expected:\n err = AssertionFailed(\n text='expected %s, got %s' % (expected, type))\n if err is None:\n action(type, subtype)\n if err:\n tgt = lnk.target\n tgt.error = err\n del self._attachments[tgt]\n tgt.closed = True\n return\n\n self.resolve(sst, lnk.name, do_resolved, node_type=requested_type,\n force=declare)", "metadata": "root.resolve_declare_monkey", "header": "['module', '___EOS___']", "index": 93 }, { "content": "def resolve_monkey(self, sst, name, action, force=False,\n node_type=None): # pragma: no cover\n if not force and not node_type:\n try:\n type, subtype = self.address_cache[name]\n action(type, subtype)\n return\n except KeyError:\n pass\n args = []\n\n def do_result(r):\n args.append(r)\n\n def do_action(r):\n do_result(r)\n er, qr = args\n if node_type == 'topic' and not er.not_found:\n type, subtype = 'topic', er.type\n elif node_type == 'queue' and qr.queue:\n type, subtype = 'queue', None\n elif er.not_found and not qr.queue:\n type, subtype = None, None\n elif qr.queue:\n type, subtype = 'queue', None\n else:\n type, subtype = 'topic', er.type\n if type is not None:\n self.address_cache[name] = (type, subtype)\n action(type, subtype)\n\n sst.write_query(ExchangeQuery(name), do_result)\n sst.write_query(QueueQuery(name), do_action)", "metadata": "root.resolve_monkey", "header": "['module', '___EOS___']", "index": 124 } ]
[ { "span": "from qpid.messaging.exceptions import (\n NotFound, AssertionFailed, ConnectionError,\n )", "start_line": 83, "start_column": 4, "end_line": 85, "end_column": 5 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Thi", "s", " ", "module", " ", "appli", "es", " ", "two", " ", "patche", "s", " ", "to", " ", "qp", "id", ".", "mess", "agin", "g", " ", "tha", "t", " ", "are", " ", "require", "d", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "correct", " ", "operati", "on", ".", " ", "Ea", "ch", " ", "patch", " ", "fixes", " ", "a", " ", "bug", ".", " ", "See", " ", "link", "s", " ", "to", " ", "the", " ", "bug", "s", " ", "belo", "w", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "issue", "s", ".", "apa", "che", ".", "org", "/", "jira", "/", "browse", "/", "QP", "ID", "-", "563", "7_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "issue", "s", ".", "apa", "che", ".", "org", "/", "jira", "/", "browse", "/", "QP", "ID", "-", "555", "7_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "##", " ", "Begin", " ", "Mon", "key", " ", "Pat", "ch", " ", "1", " ", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "issue", "s", ".", "apa", "che", ".", "org", "/", "jira", "/", "browse", "/", "QP", "ID", "-", "563", "7_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "\\u", " ", " ", " ", "\\u", " ", " ", "\\u\\u\\u", " ", "\\u\\u\\u\\u\\u", " ", "\\u\\u\\u\\u\\u", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", " ", "\\\\", " ", "|", " ", "|/", " ", "\\u", " ", "\\\\\\u", " ", " ", " ", "\\u|", " ", "\\u\\u\\u\\u", "|_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", " ", " ", "\\\\|", " ", "|", " ", "|", " ", "|", " ", "||", " ", "|", " ", "|", " ", " ", "\\u|", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", " ", "|\\\\", " ", " ", "|", " ", "|\\u", "|", " ", "||", " ", "|", " ", "|", " ", "|\\u\\u\\u", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|\\u", "|", " ", "\\\\\\u", "|\\\\", "\\u\\u\\u", "/", " ", "|\\u", "|", " ", "|\\u\\u\\u", "\\u\\u", "|_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "you", " ", "have", " ", "code", " ", "tha", "t", " ", "als", "o", " ", "use", "s", " ", "qp", "id", ".", "mess", "agin", "g", " ", "and", " ", "import", "s", " ", "kom", "bu", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "caus", "es", " ", "this", " ", "file", " ", "to", " ", "be", " ", "import", "ed", ",", " ", "then", " ", "you", " ", "need", " ", "to", " ", "make", " ", "sure", " ", "tha", "t", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "import", " ", "occur", "s", " ", "first", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fail", "ure", " ", "to", " ", "do", " ", "this", " ", "will", " ", "caus", "e", " ", "the", " ", "follow", "ing", " ", "exception", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Attribute", "Error", ":", " ", "'", "Select", "or", "'", " ", "object", " ", "has", " ", "no", " ", "attribute", " ", "'\\u", "current", "\\u", "pid", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fix", " ", "this", " ", "by", " ", "import", "ing", " ", "this", " ", "module", " ", "prior", " ", "to", " ", "usi", "ng", " ", "qp", "id", ".", "mess", "agin", "g", " ", "in", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "code", " ", "tha", "t", " ", "als", "o", " ", "use", "s", " ", "this", " ", "module", "._", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "import", " ", "is", " ", "need", "ed", " ", "for", " ", "Pyth", "on", " ", "2.6", ".", " ", "With", "out", " ", "it", ",", " ", "qp", "id", ".", "py", " ", "will", " ", "\"", "mask", "\"", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "system", "'", "s", " ", "qp", "id", " ", "lib_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\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_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Imports", " ", "for", " ", "Mon", "key", " ", "Pat", "ch", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "qp", "id_", "._", "selector_", "import_", "Selector_", "\\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 ", " _", "Selector_", "=_", "None_", "#", " ", "no", "qa_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "atexit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prepare", " ", "for", " ", "Mon", "key", " ", "Pat", "ch", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Apply", " ", "Mon", "key", " ", "Pat", "ch", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "qp", "id_", "._", "selector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qp", "id_", "._", "selector_", "._", "Selector_", "._", "default_", "=_", "staticmethod_", "(_", "default", "\\u", "monkey_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "##", " ", "End", " ", "Mon", "key", " ", "Pat", "ch", " ", "1", " ", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "##", " ", "Begin", " ", "Mon", "key", " ", "Pat", "ch", " ", "2", " ", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "issue", "s", ".", "apa", "che", ".", "org", "/", "jira", "/", "browse", "/", "QP", "ID", "-", "555", "7_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Imports", " ", "for", " ", "Mon", "key", " ", "Pat", "ch", " ", "2_", "\\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_", "qp", "id_", "._", "ops_", "import_", "Exc", "hange", "Query_", ",_", "Queue", "Query_", "\\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 ", " _", "Exc", "hange", "Query_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Queue", "Query_", "=_", "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 ", " _", "from_", "qp", "id_", "._", "messaging_", "._", "exceptions_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Not", "Found_", ",_", "Assert", "ion", "Failed_", ",_", "Connect", "ion", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\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 ", " _", "Not", "Found_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Assert", "ion", "Failed_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Connect", "ion", "Error_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prepare", " ", "for", " ", "Mon", "key", " ", "Pat", "ch", " ", "2_", "\\u\\u\\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_", "#", " ", "Apply", " ", "monkey", " ", "patch", " ", "2_", "\\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_", "qp", "id_", "._", "messaging_", "._", "driver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qp", "id_", "._", "messaging_", "._", "driver_", "._", "Engine_", "._", "resolve", "\\u", "declare_", "=_", "resolve", "\\u", "declar", "e\\u", "monkey_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qp", "id_", "._", "messaging_", "._", "driver_", "._", "Engine_", "._", "resolve_", "=_", "resolve", "\\u", "monkey_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "##", " ", "End", " ", "Mon", "key", " ", "Pat", "ch", " ", "2", " ", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "default", "\\u", "monkey_", "(_", ")_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Selector_", "._", "lock_", "._", "acquire_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "Selector_", "._", "DEFAULT_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sel_", "=_", "Selector_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "atexit_", "._", "register_", "(_", "sel_", "._", "stop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sel_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Selector_", "._", "DEFAULT_", "=_", "sel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Selector_", "._", "\\u", "current", "\\u", "pid_", "=_", "os_", "._", "getpid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "Selector_", "._", "\\u", "current", "\\u", "pid_", "!=_", "os_", "._", "getpid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sel_", "=_", "Selector_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "atexit_", "._", "register_", "(_", "sel_", "._", "stop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sel_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Selector_", "._", "DEFAULT_", "=_", "sel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Selector_", "._", "\\u", "current", "\\u", "pid_", "=_", "os_", "._", "getpid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Selector_", "._", "DEFAULT_", "\\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 ", " _", "Selector_", "._", "lock_", "._", "release_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resolve", "\\u", "declar", "e\\u", "monkey_", "(_", "self_", ",_", "sst", "_", ",_", "lnk", "_", ",_", "dir_", ",_", "action_", ")_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "declare_", "=_", "lnk", "_", "._", "options_", "._", "get_", "(_", "'", "create", "'_", ")_", "in_", "(_", "'", "alw", "ay", "s", "'_", ",_", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ass", "rt_", "=_", "lnk", "_", "._", "options_", "._", "get_", "(_", "'", "assert", "'_", ")_", "in_", "(_", "'", "alw", "ay", "s", "'_", ",_", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request", "ed", "\\u", "type_", "=_", "lnk", "_", "._", "options_", "._", "get_", "(_", "'", "node", "'_", ",_", "{_", "}_", ")_", "._", "get_", "(_", "'", "type", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "do", "\\u", "resolved_", "(_", "type_", ",_", "subtype_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "declare_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err_", "=_", "self_", "._", "declare_", "(_", "sst", "_", ",_", "lnk", "_", ",_", "action_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err_", "=_", "Not", "Found_", "(_", "text_", "=_", "'", "no", " ", "suc", "h", " ", "queue", ":", " ", "%", "s", "'_", "%_", "lnk", "_", "._", "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 ", " _", "if_", "ass", "rt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expected_", "=_", "lnk", "_", "._", "options_", "._", "get_", "(_", "'", "node", "'_", ",_", "{_", "}_", ")_", "._", "get_", "(_", "'", "type", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "expected_", "and_", "type_", "!=_", "expected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "err_", "=_", "Assert", "ion", "Failed_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "'", "expected", " ", "%", "s", ",", " ", "got", " ", "%", "s", "'_", "%_", "(_", "expected_", ",_", "type_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "err_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "action_", "(_", "type_", ",_", "subtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tgt_", "=_", "lnk", "_", "._", "target_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tgt_", "._", "error_", "=_", "err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "\\u", "attachments_", "[_", "tgt_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tgt_", "._", "closed_", "=_", "True_", "\\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_", "self_", "._", "resolve_", "(_", "sst", "_", ",_", "lnk", "_", "._", "name_", ",_", "do", "\\u", "resolved_", ",_", "node", "\\u", "type_", "=_", "request", "ed", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "force_", "=_", "declare_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resolve", "\\u", "monkey_", "(_", "self_", ",_", "sst", "_", ",_", "name_", ",_", "action_", ",_", "force_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node", "\\u", "type_", "=_", "None_", ")_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "force_", "and_", "not_", "node", "\\u", "type_", ":_", "\\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 ", " _", "type_", ",_", "subtype_", "=_", "self_", "._", "address", "\\u", "cache_", "[_", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "action_", "(_", "type_", ",_", "subtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\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\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "do", "\\u", "result_", "(_", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "._", "append_", "(_", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "action_", "(_", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "do", "\\u", "result_", "(_", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "er_", ",_", "qr_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "node", "\\u", "type_", "==_", "'", "topic", "'_", "and_", "not_", "er_", "._", "not", "\\u", "found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", ",_", "subtype_", "=_", "'", "topic", "'_", ",_", "er_", "._", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "node", "\\u", "type_", "==_", "'", "queue", "'_", "and_", "qr_", "._", "queue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", ",_", "subtype_", "=_", "'", "queue", "'_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "er_", "._", "not", "\\u", "found_", "and_", "not_", "qr_", "._", "queue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", ",_", "subtype_", "=_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "qr_", "._", "queue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", ",_", "subtype_", "=_", "'", "queue", "'_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", ",_", "subtype_", "=_", "'", "topic", "'_", ",_", "er_", "._", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "type_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "address", "\\u", "cache_", "[_", "name_", "]_", "=_", "(_", "type_", ",_", "subtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "action_", "(_", "type_", ",_", "subtype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sst", "_", "._", "write", "\\u", "query_", "(_", "Exc", "hange", "Query_", "(_", "name_", ")_", ",_", "do", "\\u", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sst", "_", "._", "write", "\\u", "query_", "(_", "Queue", "Query_", "(_", "name_", ")_", ",_", "do", "\\u", "action_", ")_", "\\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, 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 ]
Unused import
F-Secure/mittn/mittn/headlessscanner/test_dbtools.py
[ { "content": "import unittest\nimport tempfile\nimport uuid\nimport os\nimport mittn.headlessscanner.dbtools as dbtools\nimport datetime\nimport socket\nimport json\nimport sqlalchemy\nfrom sqlalchemy import create_engine, Table, Column, MetaData, exc, types\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class dbtools_test_case(unittest.TestCase):\n\n\n\n\n\n\n", "metadata": "root.dbtools_test_case", "header": "['module', '___EOS___']", "index": 12 }, { "content": " def setUp(self):\n # Create an empty mock inline \"context\" object\n # See https://docs.python.org/2/library/functions.html#type\n self.context = type('context', (object,), dict())\n\n # Whip up a sqlite database URI for testing\n self.db_file = os.path.join(tempfile.gettempdir(),\n 'mittn_unittest.' + str(uuid.uuid4()))\n self.context.dburl = 'sqlite:///' + self.db_file", "metadata": "root.dbtools_test_case.setUp", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 13 }, { "content": " def test_dburl_not_defined(self):\n # Try to open connection without a defined database URI\n empty_context = type('context', (object,), dict())\n dbconn = dbtools.open_database(empty_context)\n self.assertEqual(dbconn,\n None,\n \"No dburl provided should return None as connection\")", "metadata": "root.dbtools_test_case.test_dburl_not_defined", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 23 }, { "content": " def test_create_db_connection(self):\n # Try whether an actual database connection can be opened\n dbconn = dbtools.open_database(self.context)\n self.assertEqual(type(dbconn),\n sqlalchemy.engine.base.Connection,\n \"An SQLAlchemy connection object was not returned\")", "metadata": "root.dbtools_test_case.test_create_db_connection", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 31 }, { "content": " def test_add_false_positive(self):\n # Add a false positive to database and check that all fields\n # get populated and can be compared back originals\n issue = {'scenario_id': '1',\n 'url': 'testurl',\n 'severity': 'testseverity',\n 'issuetype': 'testissuetype',\n 'issuename': 'testissuename',\n 'issuedetail': 'testissuedetail',\n 'confidence': 'testconfidence',\n 'host': 'testhost',\n 'port': 'testport',\n 'protocol': 'testprotocol',\n 'messages': '{foo=bar}'}\n\n dbtools.add_false_positive(self.context, issue)\n\n # Connect directly to the database and check the data is there\n db_engine = sqlalchemy.create_engine(self.context.dburl)\n dbconn = db_engine.connect()\n db_metadata = sqlalchemy.MetaData()\n headlessscanner_issues = Table('headlessscanner_issues',\n db_metadata,\n Column('new_issue', types.Boolean),\n Column('issue_no', types.Integer, primary_key=True, nullable=False), # Implicit autoincrement\n Column('timestamp', types.DateTime(timezone=True)),\n Column('test_runner_host', types.Text),\n Column('scenario_id', types.Text),\n Column('url', types.Text),\n Column('severity', types.Text),\n Column('issuetype', types.Text),\n Column('issuename', types.Text),\n Column('issuedetail', types.Text),\n Column('confidence', types.Text),\n Column('host', types.Text),\n Column('port', types.Text),\n Column('protocol', types.Text),\n Column('messages', types.LargeBinary))\n db_select = sqlalchemy.sql.select([headlessscanner_issues])\n db_result = dbconn.execute(db_select)\n result = db_result.fetchone()\n for key, value in issue.iteritems():\n if key == 'messages':\n self.assertEqual(result[key], json.dumps(value))\n else:\n self.assertEqual(result[key], value,\n '%s not found in database after add' % key)\n self.assertEqual(result['test_runner_host'], socket.gethostbyname(socket.getfqdn()),\n 'Test runner host name not correct in database')\n self.assertLessEqual(result['timestamp'], datetime.datetime.utcnow(),\n 'Timestamp not correctly stored in database')\n dbconn.close()", "metadata": "root.dbtools_test_case.test_add_false_positive", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 38 }, { "content": " def test_number_of_new_false_positives(self):\n # Add a couple of false positives to database as new issues,\n # and check that the they're counted properly\n issue = {'scenario_id': '1',\n 'timestamp': datetime.datetime.utcnow(),\n 'test_runner_host': 'localhost',\n 'url': 'url',\n 'severity': 'severity',\n 'issuetype': 'issuetype',\n 'issuename': 'issuename',\n 'issuedetail': 'issuedetail',\n 'confidence': 'confidence',\n 'host': 'host',\n 'port': 'port',\n 'protocol': 'protocol',\n 'messages': 'messagejson'}\n\n # Add one, expect count to be 1\n dbtools.add_false_positive(self.context, issue)\n self.assertEqual(dbtools.number_of_new_in_database(self.context),\n 1, \"After adding one, expect one finding in database\")\n\n # Add a second one, expect count to be 2\n dbtools.add_false_positive(self.context, issue)\n self.assertEqual(dbtools.number_of_new_in_database(self.context),\n 2, \"After adding two, expect two findings in db\")", "metadata": "root.dbtools_test_case.test_number_of_new_false_positives", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 91 }, { "content": " def test_false_positive_detection(self):\n # Test whether false positives in database are identified properly\n issue = {'scenario_id': '1',\n 'timestamp': datetime.datetime.utcnow(),\n 'test_runner_host': 'localhost',\n 'url': 'url',\n 'severity': 'severity',\n 'issuetype': 'issuetype',\n 'issuename': 'issuename',\n 'issuedetail': 'issuedetail',\n 'confidence': 'confidence',\n 'host': 'host',\n 'port': 'port',\n 'protocol': 'protocol',\n 'messages': 'messagejson'}\n\n # First add one false positive and try checking against it\n dbtools.add_false_positive(self.context, issue)\n\n self.assertEqual(dbtools.known_false_positive(self.context,\n issue),\n True, \"Duplicate false positive not detected\")\n\n # Change one of the differentiating fields, and test, and\n # add the tested one to the database.\n issue['scenario_id'] = '2' # Non-duplicate\n self.assertEqual(dbtools.known_false_positive(self.context,\n issue),\n False, \"Not a duplicate: scenario_id different\")\n dbtools.add_false_positive(self.context, issue)\n\n # Repeat for all the differentiating fields\n issue['url'] = 'another url'\n self.assertEqual(dbtools.known_false_positive(self.context,\n issue),\n False, \"Not a duplicate: url different\")\n dbtools.add_false_positive(self.context, issue)\n\n issue['issuetype'] = 'foo'\n self.assertEqual(dbtools.known_false_positive(self.context,\n issue),\n False, \"Not a duplicate: issuetype different\")\n dbtools.add_false_positive(self.context, issue)\n\n # Finally, test the last one again twice, now it ought to be\n # reported back as a duplicate\n self.assertEqual(dbtools.known_false_positive(self.context,\n issue),\n True, \"A duplicate case not detected\")", "metadata": "root.dbtools_test_case.test_false_positive_detection", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 118 }, { "content": " def tearDown(self):\n try:\n os.unlink(self.db_file)\n except:\n pass", "metadata": "root.dbtools_test_case.tearDown", "header": "['class', 'dbtools_test_case', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 169 } ]
[ { "span": "from sqlalchemy import create_engine, Table, Column, MetaData, exc, types", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 73 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "mit", "tn_", "._", "headl", "ess", "scanner_", "._", "dbt", "ools_", "as_", "dbt", "ools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sqlalchemy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sqlalchemy_", "import_", "create", "\\u", "engine_", ",_", "Table_", ",_", "Column_", ",_", "Meta", "Data_", ",_", "exc_", ",_", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "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_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "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_", "#", " ", "Creat", "e", " ", "an", " ", "empty", " ", "mock", " ", "inline", " ", "\"", "context", "\"", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "https", "://", "docs", ".", "python", ".", "org", "/", "2", "/", "librar", "y", "/", "function", "s", ".", "html", "#", "type_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "context_", "=_", "type_", "(_", "'", "context", "'_", ",_", "(_", "object_", ",_", ")_", ",_", "dict_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Whi", "p", " ", "up", " ", "a", " ", "sql", "ite", " ", "databa", "se", " ", "URI", " ", "for", " ", "testing_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "db", "\\u", "file_", "=_", "os_", "._", "path_", "._", "join_", "(_", "tempfile_", "._", "gettempdir_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mit", "tn", "\\u", "unittest", ".'_", "+_", "str_", "(_", "uuid_", "._", "uuid4_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "context_", "._", "dbu", "rl_", "=_", "'", "sql", "ite", ":///", "'_", "+_", "self_", "._", "db", "\\u", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "dbu", "rl", "\\u", "not", "\\u", "defined_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "to", " ", "open", " ", "connecti", "on", " ", "with", "out", " ", "a", " ", "defin", "ed", " ", "databa", "se", " ", "URI_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "empty", "\\u", "context_", "=_", "type_", "(_", "'", "context", "'_", ",_", "(_", "object_", ",_", ")_", ",_", "dict_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbconn", "_", "=_", "dbt", "ools_", "._", "open", "\\u", "database_", "(_", "empty", "\\u", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbconn", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "No", " ", "dbu", "rl", " ", "provided", " ", "shou", "ld", " ", "return", " ", "Non", "e", " ", "as", " ", "connecti", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "db", "\\u", "connection_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "whe", "ther", " ", "an", " ", "actual", " ", "databa", "se", " ", "connecti", "on", " ", "can", " ", "be", " ", "opened_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dbconn", "_", "=_", "dbt", "ools_", "._", "open", "\\u", "database_", "(_", "self_", "._", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "type_", "(_", "dbconn", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sqlalchemy_", "._", "engine_", "._", "base_", "._", "Connection_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "An", " ", "SQL", "Al", "chem", "y", " ", "connecti", "on", " ", "object", " ", "was", " ", "not", " ", "return", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "fal", "se", " ", "posit", "ive", " ", "to", " ", "databa", "se", " ", "and", " ", "check", " ", "tha", "t", " ", "all", " ", "fields_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "populate", "d", " ", "and", " ", "can", " ", "be", " ", "compare", "d", " ", "back", " ", "original", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issue_", "=_", "{_", "'", "scen", "ario", "\\u", "id", "'_", ":_", "'", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "testu", "rl", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sever", "it", "y", "'_", ":_", "'", "tests", "ever", "it", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "type", "'_", ":_", "'", "testi", "ssu", "etype", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "name", "'_", ":_", "'", "testi", "ssu", "ena", "me", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "deta", "il", "'_", ":_", "'", "testi", "ssu", "ede", "tail", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "confidence", "'_", ":_", "'", "testco", "nfi", "denc", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "host", "'_", ":_", "'", "testh", "ost", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "port", "'_", ":_", "'", "testp", "ort", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "protoc", "ol", "'_", ":_", "'", "testpro", "toco", "l", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "s", "'_", ":_", "'{", "foo", "=", "bar", "}'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Connect", " ", "direct", "ly", " ", "to", " ", "the", " ", "databa", "se", " ", "and", " ", "check", " ", "the", " ", "data", " ", "is", " ", "there", "_", "\\u\\u\\uNL\\u\\u\\u_", "db", "\\u", "engine_", "=_", "sqlalchemy_", "._", "create", "\\u", "engine_", "(_", "self_", "._", "context_", "._", "dbu", "rl_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbconn", "_", "=_", "db", "\\u", "engine_", "._", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db", "\\u", "metadata_", "=_", "sqlalchemy_", "._", "Meta", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headl", "ess", "scanner", "\\u", "issues_", "=_", "Table_", "(_", "'", "headl", "ess", "scanner", "\\u", "issue", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "db", "\\u", "metadata_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "new", "\\u", "issue", "'_", ",_", "types_", "._", "Boolean_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "issue", "\\u", "no", "'_", ",_", "types_", "._", "Integer_", ",_", "primary", "\\u", "key_", "=_", "True_", ",_", "nullable_", "=_", "False_", ")_", ",_", "#", " ", "Implicit", " ", "autoincrement_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "timestamp", "'_", ",_", "types_", "._", "Date", "Time_", "(_", "timezone_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "test\\u", "runn", "er", "\\u", "host", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "scen", "ario", "\\u", "id", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "url", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "sever", "it", "y", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "issue", "type", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "issue", "name", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "issue", "deta", "il", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "confidence", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "host", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "port", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "protoc", "ol", "'_", ",_", "types_", "._", "Text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Column_", "(_", "'", "message", "s", "'_", ",_", "types_", "._", "Large", "Binary_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db", "\\u", "select_", "=_", "sqlalchemy_", "._", "sql_", "._", "select_", "(_", "[_", "headl", "ess", "scanner", "\\u", "issues_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db", "\\u", "result_", "=_", "dbconn", "_", "._", "execute_", "(_", "db", "\\u", "select_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "db", "\\u", "result_", "._", "fetchone_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "issue_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "==_", "'", "message", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "result_", "[_", "key_", "]_", ",_", "json_", "._", "dumps_", "(_", "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 ", " _", "self_", "._", "assert", "Equal_", "(_", "result_", "[_", "key_", "]_", ",_", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'%", "s", " ", "not", " ", "found", " ", "in", " ", "databa", "se", " ", "after", " ", "add", "'_", "%_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result_", "[_", "'", "test\\u", "runn", "er", "\\u", "host", "'_", "]_", ",_", "socket_", "._", "gethostbyname", "_", "(_", "socket_", "._", "getf", "qd", "n_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Test", " ", "runn", "er", " ", "host", " ", "name", " ", "not", " ", "correct", " ", "in", " ", "databa", "se", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Less", "Equal_", "(_", "result_", "[_", "'", "timestamp", "'_", "]_", ",_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Timest", "amp", " ", "not", " ", "correct", "ly", " ", "store", "d", " ", "in", " ", "databa", "se", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbconn", "_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "number", "\\u", "of", "\\u", "new", "\\u", "fal", "se", "\\u", "positives", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "couple", " ", "of", " ", "fal", "se", " ", "positives", " ", "to", " ", "databa", "se", " ", "as", " ", "new", " ", "issue", "s", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "check", " ", "tha", "t", " ", "the", " ", "the", "y", "'", "re", " ", "counted", " ", "proper", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issue_", "=_", "{_", "'", "scen", "ario", "\\u", "id", "'_", ":_", "'", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test\\u", "runn", "er", "\\u", "host", "'_", ":_", "'", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "url", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sever", "it", "y", "'_", ":_", "'", "sever", "it", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "type", "'_", ":_", "'", "issue", "type", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "name", "'_", ":_", "'", "issue", "name", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "deta", "il", "'_", ":_", "'", "issue", "deta", "il", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "confidence", "'_", ":_", "'", "confidence", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "host", "'_", ":_", "'", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "port", "'_", ":_", "'", "port", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "protoc", "ol", "'_", ":_", "'", "protoc", "ol", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "s", "'_", ":_", "'", "message", "json", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "one", ",", " ", "expect", " ", "count", " ", "to", " ", "be", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "number", "\\u", "of", "\\u", "new", "\\u", "in", "\\u", "database_", "(_", "self_", "._", "context_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1_", ",_", "\"", "Af", "ter", " ", "addin", "g", " ", "one", ",", " ", "expect", " ", "one", " ", "finding", " ", "in", " ", "databa", "se", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "second", " ", "one", ",", " ", "expect", " ", "count", " ", "to", " ", "be", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "number", "\\u", "of", "\\u", "new", "\\u", "in", "\\u", "database_", "(_", "self_", "._", "context_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", ",_", "\"", "Af", "ter", " ", "addin", "g", " ", "two", ",", " ", "expect", " ", "two", " ", "finding", "s", " ", "in", " ", "db", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "fal", "se", "\\u", "posit", "ive", "\\u", "detection_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "whe", "ther", " ", "fal", "se", " ", "positives", " ", "in", " ", "databa", "se", " ", "are", " ", "identifi", "ed", " ", "proper", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issue_", "=_", "{_", "'", "scen", "ario", "\\u", "id", "'_", ":_", "'", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test\\u", "runn", "er", "\\u", "host", "'_", ":_", "'", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "url", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sever", "it", "y", "'_", ":_", "'", "sever", "it", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "type", "'_", ":_", "'", "issue", "type", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "name", "'_", ":_", "'", "issue", "name", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "deta", "il", "'_", ":_", "'", "issue", "deta", "il", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "confidence", "'_", ":_", "'", "confidence", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "host", "'_", ":_", "'", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "port", "'_", ":_", "'", "port", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "protoc", "ol", "'_", ":_", "'", "protoc", "ol", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "s", "'_", ":_", "'", "message", "json", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "add", " ", "one", " ", "fal", "se", " ", "posit", "ive", " ", "and", " ", "try", " ", "checking", " ", "against", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "know", "n", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "True_", ",_", "\"", "Duplicate", " ", "fal", "se", " ", "posit", "ive", " ", "not", " ", "detect", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Change", " ", "one", " ", "of", " ", "the", " ", "different", "iati", "ng", " ", "fields", ",", " ", "and", " ", "test", ",", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "the", " ", "tested", " ", "one", " ", "to", " ", "the", " ", "databa", "se", "._", "\\u\\u\\uNL\\u\\u\\u_", "issue_", "[_", "'", "scen", "ario", "\\u", "id", "'_", "]_", "=_", "'", "2", "'_", "#", " ", "Non", "-", "duplicate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "know", "n", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ",_", "\"", "Not", " ", "a", " ", "duplicat", "e", ":", " ", "scen", "ario", "\\u", "id", " ", "different", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Repeat", " ", "for", " ", "all", " ", "the", " ", "different", "iati", "ng", " ", "fields_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", "[_", "'", "url", "'_", "]_", "=_", "'", "anot", "her", " ", "url", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "know", "n", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ",_", "\"", "Not", " ", "a", " ", "duplicat", "e", ":", " ", "url", " ", "different", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", "[_", "'", "issue", "type", "'_", "]_", "=_", "'", "foo", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "know", "n", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ",_", "\"", "Not", " ", "a", " ", "duplicat", "e", ":", " ", "issue", "type", " ", "different", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dbt", "ools_", "._", "add", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "issue_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Final", "ly", ",", " ", "test", " ", "the", " ", "last", " ", "one", " ", "again", " ", "twi", "ce", ",", " ", "now", " ", "it", " ", "ou", "ght", " ", "to", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "reporte", "d", " ", "back", " ", "as", " ", "a", " ", "duplicate_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "dbt", "ools_", "._", "know", "n", "\\u", "fal", "se", "\\u", "positive_", "(_", "self_", "._", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "issue_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "True_", ",_", "\"", "A", " ", "duplicat", "e", " ", "case", " ", "not", " ", "detect", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "dbt", "ool", "s", "\\u", "test\\u", "case_", "(_", "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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "unlink_", "(_", "self_", "._", "db", "\\u", "file_", ")_", "\\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_" ]
[ 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, 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, 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, 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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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'
Esri/ago-tools/samples/MakeLab_CreateGroupAndUsersFromCsv.py
[ { "content": "# Requires admin role.\nimport csv, time,sys,arcpy\nfrom agoTools.admin import Admin\nadminAccount = arcpy.GetParameterAsText(0)\nadminPassword =arcpy.GetParameterAsText(1)\nclassName = arcpy.GetParameterAsText(2)\nclassSnippet = arcpy.GetParameterAsText(3)\ncsvFile = arcpy.GetParameterAsText(4)\nuserPrefix = arcpy.GetParameterAsText(5)\nuserPassword = arcpy.GetParameterAsText(6)\nuserRole = arcpy.GetParameterAsText(7)\ninstructorAccount = arcpy.GetParameterAsText(8)\nprovider = \"arcgis\"\n\nif not adminAccount:\n adminAccount = \"your ago account\"\nif not adminPassword:\n adminPassword = \"your ago password\"\nif not className:\n className = \"Sample Class\"\nif not classSnippet:\n classSnippet = \"Snippet goes here\"\nif not csvFile:\n csvFile = r\"C:\\students.csv\"\nif not userPrefix:\n userPrefix = \"labUser_\"\nif not userPassword:\n userPassword = \"password1\"\nif not userRole:\n userRole = \"account_user\"\nif not provider:\n provider = \"arcgis\"\n\n##Unicode is not encoding properly so convert all arcpy params\nadminAccount = str(adminAccount)\nadminPassword = str(adminPassword)\nclassName = str(className)\nclassSnippet = str(classSnippet)\nuserPrefix = str(userPrefix)\nuserPassword = str(userPassword)\nuserRole = str(userRole)\nprovider = str(provider)\n\narcpy.AddMessage(\"Logging in...\")\ntry:\n agoAdmin = Admin(adminAccount,password=adminPassword)\nexcept:\n arcpy.AddError(\"Login failed. Please re-enter your admin username and password.\")\n sys.exit()\n\n\n##Get roles from the portal so we can translate the user-entered name to the role id that the api needs.\n##Also confirm that the user-entered role is valid.\nallRoles = agoAdmin.getRoles()\n##getRoles doesn't return predefined system roles, so we'll add those\nroles = {'Administrator':'org_admin', 'Publisher':'org_publisher', 'Author':'org_author', 'User':'org_viewer'}\nfor role in allRoles:\n roles[role[\"name\"]] = role[\"id\"]\nif not userRole in roles.keys():\n arcpy.AddError(userRole + \" is not a valid role.\")\n sys.exit()\n\nroleId =roles[userRole]\n\narcpy.AddMessage(\"Creating Group...\")\nprint \"Creating Group...\"\ngroup = agoAdmin.createGroup(className,classSnippet)\ndescription = \"Lab account for \" + className\n\nif \"group\" in group:\n groupId = group[\"group\"][\"id\"]\n arcpy.AddMessage(\"Creating Users...\")\n print \"Creating Users...\"\n i = 1\n users = []\n sameNameCounter = 1\n\n with open(csvFile,\"rb\") as userFile:\n rows = csv.reader(userFile)\n for row in rows:\n userFirstName = row[0]\n userLastName = row[1]\n userEmail = row[2]\n username = userPrefix + \"_\" + userLastName\n\n if username in users:\n username += \"_\" + str(sameNameCounter)\n sameNameCounter +=1\n arcpy.AddMessage(\"creating \" + username + \"...\")\n print \"creating \" + username + \"...\"\n agoAdmin.createUser(username,userPassword,userFirstName,userLastName,userEmail,description,roleId,provider)\n users.append(username)\n\n arcpy.AddMessage(\"Adding New Users to Group...\")\n print \"Adding Users to Group...\"\n agoAdmin.addUsersToGroups(users,[groupId])\n if instructorAccount:\n arcpy.AddMessage(\"Reassigning group ownership to \" + instructorAccount + \"...\")\n print \"Reassigning group ownership to \" + instructorAccount + \"...\"\n agoAdmin.reassignGroupOwnership(groupId,instructorAccount)\n print \"Done\"\nelse:\n arcpy.AddError(\"Failed to create group\")\n arcpy.AddError(group[\"error\"][\"details\"])\n print \"Failed to create group: \" + group[\"error\"][\"details\"]\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 46, "start_column": 0, "end_line": 46, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Requ", "ires", " ", "admin", " ", "role", "._", "\\u\\u\\uNL\\u\\u\\u_", "import_", "csv_", ",_", "time_", ",_", "sys_", ",_", "arcpy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ago", "Tools_", "._", "admin_", "import_", "Admin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "Account_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "Password_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class", "Name_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class", "Snippet", "_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "csv", "File_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Prefix_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Password_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Role_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instructor", "Account_", "=_", "arcpy_", "._", "Get", "Parameter", "As", "Text_", "(_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "provider_", "=_", "\"", "arc", "gi", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "admin", "Account_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "admin", "Account_", "=_", "\"", "your", " ", "ago", " ", "account", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "admin", "Password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "admin", "Password_", "=_", "\"", "your", " ", "ago", " ", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "class", "Name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class", "Name_", "=_", "\"", "Sampl", "e", " ", "Class", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "class", "Snippet", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class", "Snippet", "_", "=_", "\"", "Snippet", " ", "go", "es", " ", "here", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "csv", "File_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "csv", "File_", "=_", "r", "\"", "C", ":\\\\", "student", "s", ".", "csv", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "user", "Prefix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "Prefix_", "=_", "\"", "lab", "User", "\\u\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "user", "Password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "Password_", "=_", "\"", "password", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "user", "Role_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "Role_", "=_", "\"", "account", "\\u", "user", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "provider_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "provider_", "=_", "\"", "arc", "gi", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "Unic", "ode", " ", "is", " ", "not", " ", "encoding", " ", "proper", "ly", " ", "so", " ", "convert", " ", "all", " ", "arc", "py", " ", "params_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "admin", "Account_", "=_", "str_", "(_", "admin", "Account_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "Password_", "=_", "str_", "(_", "admin", "Password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class", "Name_", "=_", "str_", "(_", "class", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class", "Snippet", "_", "=_", "str_", "(_", "class", "Snippet", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Prefix_", "=_", "str_", "(_", "user", "Prefix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Password_", "=_", "str_", "(_", "user", "Password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Role_", "=_", "str_", "(_", "user", "Role_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "provider_", "=_", "str_", "(_", "provider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "arcpy_", "._", "Add", "Message_", "(_", "\"", "Log", "ging", " ", "in", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ago", "Admin_", "=_", "Admin_", "(_", "admin", "Account_", ",_", "password_", "=_", "admin", "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 ", " _", "arcpy_", "._", "Add", "Error_", "(_", "\"", "Logi", "n", " ", "fail", "ed", ".", " ", "Ple", "ase", " ", "re", "-", "enter", " ", "your", " ", "admin", " ", "user", "name", " ", "and", " ", "password", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "Get", " ", "role", "s", " ", "from", " ", "the", " ", "portal", " ", "so", " ", "we", " ", "can", " ", "translat", "e", " ", "the", " ", "user", "-", "enter", "ed", " ", "name", " ", "to", " ", "the", " ", "role", " ", "id", " ", "tha", "t", " ", "the", " ", "api", " ", "need", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", "Al", "so", " ", "confirm", " ", "tha", "t", " ", "the", " ", "user", "-", "enter", "ed", " ", "role", " ", "is", " ", "valid", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "all", "Roles_", "=_", "ago", "Admin_", "._", "get", "Roles_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "get", "Ro", "les", " ", "doe", "sn", "'", "t", " ", "return", " ", "prede", "fined", " ", "system", " ", "role", "s", ",", " ", "so", " ", "we", "'", "ll", " ", "add", " ", "tho", "se_", "\\u\\u\\uNL\\u\\u\\u_", "roles_", "=_", "{_", "'", "Administra", "tor", "'_", ":_", "'", "org", "\\u", "admin", "'_", ",_", "'", "Publish", "er", "'_", ":_", "'", "org", "\\u", "publi", "sher", "'_", ",_", "'", "Author", "'_", ":_", "'", "org", "\\u", "author", "'_", ",_", "'", "User", "'_", ":_", "'", "org", "\\u", "viewer", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "role_", "in_", "all", "Roles_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "roles_", "[_", "role_", "[_", "\"", "name", "\"_", "]_", "]_", "=_", "role_", "[_", "\"", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "user", "Role_", "in_", "roles_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arcpy_", "._", "Add", "Error_", "(_", "user", "Role_", "+_", "\"", " ", "is", " ", "not", " ", "a", " ", "valid", " ", "role", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "role", "Id_", "=_", "roles_", "[_", "user", "Role_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "arcpy_", "._", "Add", "Message_", "(_", "\"", "Creat", "ing", " ", "Group", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Creat", "ing", " ", "Group", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "group_", "=_", "ago", "Admin_", "._", "create", "Group_", "(_", "class", "Name_", ",_", "class", "Snippet", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "description_", "=_", "\"", "Lab", " ", "account", " ", "for", " ", "\"_", "+_", "class", "Name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\"", "group", "\"_", "in_", "group_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "group", "Id_", "=_", "group_", "[_", "\"", "group", "\"_", "]_", "[_", "\"", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Add", "Message_", "(_", "\"", "Creat", "ing", " ", "User", "s", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Creat", "ing", " ", "User", "s", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "same", "Name", "Counter_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "csv", "File_", ",_", "\"", "rb", "\"_", ")_", "as_", "user", "File_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rows_", "=_", "csv_", "._", "reader_", "(_", "user", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "Fi", "rst", "Name_", "=_", "row_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Las", "t", "Name_", "=_", "row_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Email_", "=_", "row_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "username_", "=_", "user", "Prefix_", "+_", "\"\\u\"_", "+_", "user", "Las", "t", "Name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "username_", "in_", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "username_", "+=_", "\"\\u\"_", "+_", "str_", "(_", "same", "Name", "Counter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "same", "Name", "Counter_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "arcpy_", "._", "Add", "Message_", "(_", "\"", "creati", "ng", " ", "\"_", "+_", "username_", "+_", "\"...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "creati", "ng", " ", "\"_", "+_", "username_", "+_", "\"...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ago", "Admin_", "._", "create", "User_", "(_", "username_", ",_", "user", "Password_", ",_", "user", "Fi", "rst", "Name_", ",_", "user", "Las", "t", "Name_", ",_", "user", "Email_", ",_", "description_", ",_", "role", "Id_", ",_", "provider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users_", "._", "append_", "(_", "username_", ")_", "\\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_", "._", "Add", "Message_", "(_", "\"", "Add", "ing", " ", "New", " ", "User", "s", " ", "to", " ", "Group", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Add", "ing", " ", "User", "s", " ", "to", " ", "Group", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ago", "Admin_", "._", "add", "User", "s", "To", "Groups_", "(_", "users_", ",_", "[_", "group", "Id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "instructor", "Account_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arcpy_", "._", "Add", "Message_", "(_", "\"", "Rea", "ssi", "gni", "ng", " ", "group", " ", "owner", "ship", " ", "to", " ", "\"_", "+_", "instructor", "Account_", "+_", "\"...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Rea", "ssi", "gni", "ng", " ", "group", " ", "owner", "ship", " ", "to", " ", "\"_", "+_", "instructor", "Account_", "+_", "\"...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ago", "Admin_", "._", "reass", "ign", "Group", "Owne", "rshi", "p_", "(_", "group", "Id_", ",_", "instructor", "Account_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\"", "Don", "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 ", " _", "arcpy_", "._", "Add", "Error_", "(_", "\"", "Fail", "ed", " ", "to", " ", "create", " ", "group", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arcpy_", "._", "Add", "Error_", "(_", "group_", "[_", "\"", "error", "\"_", "]_", "[_", "\"", "deta", "il", "s", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Fail", "ed", " ", "to", " ", "create", " ", "group", ":", " ", "\"_", "+_", "group_", "[_", "\"", "error", "\"_", "]_", "[_", "\"", "deta", "il", "s", "\"_", "]_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Module is imported with 'import' and 'import from'
amrdraz/kodr/app/brython/www/src/Lib/test/test_urllib2.py
[ { "content": "import unittest\nfrom test import support\n\nimport os\nimport io\nimport socket\nimport array\nimport sys\n\nimport urllib.request\n# The proxy bypass method imported below has logic specific to the OSX\n# proxy config data structure but is testable on all platforms.\nfrom urllib.request import Request, OpenerDirector, _proxy_bypass_macosx_sysconf\nimport urllib.error\n\n# XXX\n# Request\n# CacheFTPHandler (hard to write)\n# parse_keqv_list, parse_http_list, HTTPDigestAuthHandler\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 test_main(verbose=True)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import urllib.request", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 21 }, { "span": "import urllib.error", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "with_", "'", "import", "'_", "and_", "'", "import", " ", "from", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "test_", "import_", "support_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "io_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "array_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "urllib_", "._", "request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "proxy", " ", "bypass", " ", "method", " ", "import", "ed", " ", "belo", "w", " ", "has", " ", "logic", " ", "specific", " ", "to", " ", "the", " ", "OSX", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "proxy", " ", "config", " ", "data", " ", "structure", " ", "but", " ", "is", " ", "testa", "ble", " ", "on", " ", "all", " ", "platform", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "from_", "urllib_", "._", "request_", "import_", "Request_", ",_", "Open", "er", "Director", "_", ",_", "\\u", "proxy", "\\u", "bypass", "\\u", "macos", "x", "\\u", "sysc", "onf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "._", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "XX", "X_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Request_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Cache", "FTP", "Handle", "r", " ", "(", "hard", " ", "to", " ", "write", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "parse", "\\u", "ke", "qv", "\\u", "list", ",", " ", "parse", "\\u", "http", "\\u", "list", ",", " ", "HTTP", "Dig", "est", "Auth", "Handler_", "\\u\\u\\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_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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 ", " _", "test\\u", "main_", "(_", "verbose_", "=_", "True_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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 ]
Unused import
anandology/pyjamas/pyjs/src/pyjs/lib/pyjspath.py
[ { "content": "\"\"\"Common operations on Posix pathnames.\n\nInstead of importing this module directly, import os and refer to\nthis module as os.path. The \"os.path\" name is an alias for this\nmodule on Posix systems; on other systems (e.g. Mac, Windows),\nos.path provides the same operations in a manner specific to that\nplatform, and is an alias to another module (e.g. macpath, ntpath).\n\nSome of this can actually be useful on non-Posix systems too, e.g.\nfor manipulation of the pathname component of URLs.\n\"\"\"\n\nimport os\nimport sys\nimport stat\nimport genericpath\nimport warnings\nfrom genericpath import *\n\n__all__ = [\"normcase\",\"isabs\",\"join\",\"splitdrive\",\"split\",\"splitext\",\n \"basename\",\"dirname\",\"commonprefix\",\"getsize\",\"getmtime\",\n \"getatime\",\"getctime\",\"islink\",\"exists\",\"lexists\",\"isdir\",\"isfile\",\n \"ismount\",\"walk\",\"expanduser\",\"expandvars\",\"normpath\",\"abspath\",\n \"samefile\",\"sameopenfile\",\"samestat\",\n \"curdir\",\"pardir\",\"sep\",\"pathsep\",\"defpath\",\"altsep\",\"extsep\",\n \"devnull\",\"realpath\",\"supports_unicode_filenames\",\"relpath\"]\n\n# strings representing various path-related bits and pieces\ncurdir = '.'\npardir = '..'\nextsep = '.'\nsep = '/'\npathsep = ':'\ndefpath = ':/bin:/usr/bin'\naltsep = None\ndevnull = '/dev/null'\n\n# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.\n# On MS-DOS this may also turn slashes into backslashes; however, other\n# normalizations (such as optimizing '../' away) are not allowed\n# (another function should be defined to do that).\n\n\n\n# Return whether a path is absolute.\n# Trivial in Posix, harder on the Mac or MS-DOS.\n\n\n\n# Join pathnames.\n# Ignore the previous parts if a part is absolute.\n# Insert a '/' unless the first part is empty or already ends in '/'.\n\n\n\n# Split a path in head (everything up to the last '/') and tail (the\n# rest). If the path ends in '/', tail will be empty. If there is no\n# '/' in the path, head will be empty.\n# Trailing '/'es are stripped from head unless it is the root.\n\n\n\n# Split a path in root and extension.\n# The extension is everything starting at the last dot in the last\n# pathname component; the root is everything before that.\n# It is always true that root + ext == p.\n\nsplitext.__doc__ = genericpath._splitext.__doc__\n\n# Split a pathname into a drive specification and the rest of the\n# path. Useful on DOS/Windows/NT; on Unix, the drive is always empty.\n\n\n\n# Return the tail (basename) part of a path, same as split(path)[1].\n\n\n\n# Return the head (dirname) part of a path, same as split(path)[0].\n\n\n\n\n\n\n#\n# These funcs cannot be implemented in\n# abstract pyjs, should be overloaded for\n# pyv8 and pysm\n#\n\n\n\n\n\n\n\n\n\nsupports_unicode_filenames = (sys.platform == 'darwin')\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def normcase(s):\n \"\"\"Normalize case of pathname. Has no effect under Posix\"\"\"\n return s", "metadata": "root.normcase", "header": "['module', '___EOS___']", "index": 42 }, { "content": "def isabs(s):\n \"\"\"Test whether a path is absolute\"\"\"\n return s.startswith('/')", "metadata": "root.isabs", "header": "['module', '___EOS___']", "index": 50 }, { "content": "def join(a, *p):\n \"\"\"Join two or more pathname components, inserting '/' as needed.\n If any component is an absolute path, all previous path components\n will be discarded.\"\"\"\n path = a\n for b in p:\n if b.startswith('/'):\n path = b\n elif path == '' or path.endswith('/'):\n path += b\n else:\n path += '/' + b\n return path", "metadata": "root.join", "header": "['module', '___EOS___']", "index": 59 }, { "content": "def split(p):\n \"\"\"Split a pathname. Returns tuple \"(head, tail)\" where \"tail\" is\n everything after the final slash. Either part may be empty.\"\"\"\n i = p.rfind('/') + 1\n head, tail = p[:i], p[i:]\n if head and head != '/'*len(head):\n head = head.rstrip('/')\n return head, tail", "metadata": "root.split", "header": "['module', '___EOS___']", "index": 79 }, { "content": "def splitext(p):\n return genericpath._splitext(p, sep, altsep, extsep)", "metadata": "root.splitext", "header": "['module', '___EOS___']", "index": 94 }, { "content": "def splitdrive(p):\n \"\"\"Split a pathname into drive and path. On Posix, drive is always\n empty.\"\"\"\n return '', p", "metadata": "root.splitdrive", "header": "['module', '___EOS___']", "index": 101 }, { "content": "def basename(p):\n \"\"\"Returns the final component of a pathname\"\"\"\n i = p.rfind('/') + 1\n return p[i:]", "metadata": "root.basename", "header": "['module', '___EOS___']", "index": 109 }, { "content": "def dirname(p):\n \"\"\"Returns the directory component of a pathname\"\"\"\n i = p.rfind('/') + 1\n head = p[:i]\n if head and head != '/'*len(head):\n head = head.rstrip('/')\n return head", "metadata": "root.dirname", "header": "['module', '___EOS___']", "index": 117 }, { "content": "def samestat(s1, s2):\n \"\"\"Test whether two stat buffers reference the same file\"\"\"\n return s1.st_ino == s2.st_ino and \\\n s1.st_dev == s2.st_dev", "metadata": "root.samestat", "header": "['module', '___EOS___']", "index": 125 }, { "content": "def normpath(path):\n \"\"\"Normalize path, eliminating double slashes, etc.\"\"\"\n # Preserve unicode (if path is unicode)\n slash, dot = (u'/', u'.') if isinstance(path, unicode) else ('/', '.')\n if path == '':\n return dot\n initial_slashes = path.startswith('/')\n # POSIX allows one or two initial slashes, but treats three or more\n # as single slash.\n if (initial_slashes and\n path.startswith('//') and not path.startswith('///')):\n initial_slashes = 2\n comps = path.split('/')\n new_comps = []\n for comp in comps:\n if comp in ('', '.'):\n continue\n if (comp != '..' or (not initial_slashes and not new_comps) or\n (new_comps and new_comps[-1] == '..')):\n new_comps.append(comp)\n elif new_comps:\n new_comps.pop()\n comps = new_comps\n path = slash.join(comps)\n if initial_slashes:\n path = slash*initial_slashes + path\n return path or dot", "metadata": "root.normpath", "header": "['module', '___EOS___']", "index": 130 }, { "content": "def abspath(path):\n \"\"\"Return an absolute path.\"\"\"\n return normpath(path)", "metadata": "root.abspath", "header": "['module', '___EOS___']", "index": 158 }, { "content": "def realpath(filename):\n return abspath(filename)", "metadata": "root.realpath", "header": "['module', '___EOS___']", "index": 162 }, { "content": "def islink(path):\n raise NotImplemented()", "metadata": "root.islink", "header": "['module', '___EOS___']", "index": 171 }, { "content": "def lexists(path):\n raise NotImplemented()", "metadata": "root.lexists", "header": "['module', '___EOS___']", "index": 174 }, { "content": "def samefile(f1, f2):\n raise NotImplemented()", "metadata": "root.samefile", "header": "['module', '___EOS___']", "index": 177 }, { "content": "def sameopenfile(fp1, fp2):\n raise NotImplemented()", "metadata": "root.sameopenfile", "header": "['module', '___EOS___']", "index": 180 }, { "content": "def ismount(path):\n raise NotImplemented()", "metadata": "root.ismount", "header": "['module', '___EOS___']", "index": 183 }, { "content": "def walk(top, func, arg):\n raise NotImplemented()", "metadata": "root.walk", "header": "['module', '___EOS___']", "index": 186 }, { "content": "def expanduser(path):\n raise NotImplemented()", "metadata": "root.expanduser", "header": "['module', '___EOS___']", "index": 189 }, { "content": "def expandvars(path):\n raise NotImplemented()", "metadata": "root.expandvars", "header": "['module', '___EOS___']", "index": 192 }, { "content": "def relpath(path, start=curdir):\n raise NotImplemented()", "metadata": "root.relpath", "header": "['module', '___EOS___']", "index": 197 } ]
[ { "span": "import os", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 9 }, { "span": "import stat", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 11 }, { "span": "import warnings", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 15 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Common", " ", "operati", "ons", " ", "on", " ", "Posi", "x", " ", "path", "names", ".", "\\", "10", ";", "\\", "10", ";", "Ins", "tea", "d", " ", "of", " ", "import", "ing", " ", "this", " ", "module", " ", "direct", "ly", ",", " ", "import", " ", "os", " ", "and", " ", "refer", " ", "to", "\\", "10", ";", "this", " ", "module", " ", "as", " ", "os", ".", "path", ".", " ", " ", "The", " ", "\"", "os", ".", "path", "\"", " ", "name", " ", "is", " ", "an", " ", "alias", " ", "for", " ", "this", "\\", "10", ";", "module", " ", "on", " ", "Posi", "x", " ", "system", "s", ";", " ", "on", " ", "other", " ", "system", "s", " ", "(", "e", ".", "g", ".", " ", "Mac", ",", " ", "Window", "s", "),", "\\", "10", ";", "os", ".", "path", " ", "provide", "s", " ", "the", " ", "same", " ", "operati", "ons", " ", "in", " ", "a", " ", "manner", " ", "specific", " ", "to", " ", "tha", "t", "\\", "10", ";", "platform", ",", " ", "and", " ", "is", " ", "an", " ", "alias", " ", "to", " ", "anot", "her", " ", "module", " ", "(", "e", ".", "g", ".", " ", "mac", "path", ",", " ", "ntpath", ").", "\\", "10", ";", "\\", "10", ";", "Some", " ", "of", " ", "this", " ", "can", " ", "actual", "ly", " ", "be", " ", "usef", "ul", " ", "on", " ", "non", "-", "Posi", "x", " ", "system", "s", " ", "too", ",", " ", "e", ".", "g", ".", "\\", "10", ";", "for", " ", "manipulati", "on", " ", "of", " ", "the", " ", "path", "name", " ", "component", " ", "of", " ", "URL", "s", ".", "\\", "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_", "stat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gener", "icp", "ath_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gener", "icp", "ath_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "\"", "norm", "case", "\"_", ",_", "\"", "isa", "bs", "\"_", ",_", "\"", "join", "\"_", ",_", "\"", "split", "drive", "\"_", ",_", "\"", "split", "\"_", ",_", "\"", "split", "ext", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "basen", "ame", "\"_", ",_", "\"", "dir", "name", "\"_", ",_", "\"", "common", "prefix", "\"_", ",_", "\"", "gets", "ize", "\"_", ",_", "\"", "getm", "time", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "geta", "time", "\"_", ",_", "\"", "getc", "time", "\"_", ",_", "\"", "isl", "ink", "\"_", ",_", "\"", "exist", "s", "\"_", ",_", "\"", "lexi", "sts", "\"_", ",_", "\"", "isdi", "r", "\"_", ",_", "\"", "isfi", "le", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "ism", "ount", "\"_", ",_", "\"", "walk", "\"_", ",_", "\"", "expand", "user", "\"_", ",_", "\"", "expand", "vars", "\"_", ",_", "\"", "norm", "path", "\"_", ",_", "\"", "abs", "path", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "same", "file", "\"_", ",_", "\"", "same", "openf", "ile", "\"_", ",_", "\"", "same", "stat", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "cur", "dir", "\"_", ",_", "\"", "par", "dir", "\"_", ",_", "\"", "sep", "\"_", ",_", "\"", "path", "sep", "\"_", ",_", "\"", "def", "path", "\"_", ",_", "\"", "alts", "ep", "\"_", ",_", "\"", "ext", "sep", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "devn", "ull", "\"_", ",_", "\"", "real", "path", "\"_", ",_", "\"", "support", "s", "\\u", "unicode", "\\u", "filename", "s", "\"_", ",_", "\"", "rel", "path", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "string", "s", " ", "represent", "ing", " ", "vari", "ous", " ", "path", "-", "relate", "d", " ", "bits", " ", "and", " ", "pieces_", "\\u\\u\\uNL\\u\\u\\u_", "curdir_", "=_", "'.'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pardir_", "=_", "'..'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ext", "sep_", "=_", "'.'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sep_", "=_", "'/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pathsep_", "=_", "':'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def", "path_", "=_", "':/", "bin", ":/", "usr", "/", "bin", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alts", "ep_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "devnull_", "=_", "'/", "dev", "/", "null", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Normalize", " ", "the", " ", "case", " ", "of", " ", "a", " ", "path", "name", ".", " ", " ", "Tri", "via", "l", " ", "in", " ", "Posi", "x", ",", " ", "string", ".", "lower", " ", "on", " ", "Mac", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "On", " ", "MS", "-", "DOS", " ", "this", " ", "may", " ", "als", "o", " ", "turn", " ", "slash", "es", " ", "int", "o", " ", "backslash", "es", ";", " ", "how", "ever", ",", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "normaliza", "tion", "s", " ", "(", "suc", "h", " ", "as", " ", "optim", "izi", "ng", " ", "'../", "'", " ", "awa", "y", ")", " ", "are", " ", "not", " ", "allowed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "anot", "her", " ", "function", " ", "shou", "ld", " ", "be", " ", "defin", "ed", " ", "to", " ", "do", " ", "tha", "t", ").", "_", "\\u\\u\\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_", "#", " ", "Return", " ", "whe", "ther", " ", "a", " ", "path", " ", "is", " ", "abs", "olute", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tri", "via", "l", " ", "in", " ", "Posi", "x", ",", " ", "hard", "er", " ", "on", " ", "the", " ", "Mac", " ", "or", " ", "MS", "-", "DOS", "._", "\\u\\u\\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_", "#", " ", "Join", " ", "path", "names", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ignor", "e", " ", "the", " ", "previ", "ous", " ", "part", "s", " ", "if", " ", "a", " ", "part", " ", "is", " ", "abs", "olute", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Insert", " ", "a", " ", "'/'", " ", "unl", "ess", " ", "the", " ", "first", " ", "part", " ", "is", " ", "empty", " ", "or", " ", "alr", "ead", "y", " ", "ends", " ", "in", " ", "'/'", "._", "\\u\\u\\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_", "#", " ", "Split", " ", "a", " ", "path", " ", "in", " ", "head", " ", "(", "every", "thing", " ", "up", " ", "to", " ", "the", " ", "last", " ", "'/'", ")", " ", "and", " ", "tail", " ", "(", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "rest", ").", " ", " ", "If", " ", "the", " ", "path", " ", "ends", " ", "in", " ", "'/'", ",", " ", "tail", " ", "will", " ", "be", " ", "empty", ".", " ", " ", "If", " ", "there", " ", "is", " ", "no_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'/'", " ", "in", " ", "the", " ", "path", ",", " ", "head", " ", " ", "will", " ", "be", " ", "empty", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Trailing", " ", "'/'", "es", " ", "are", " ", "strip", "ped", " ", "from", " ", "head", " ", "unl", "ess", " ", "it", " ", "is", " ", "the", " ", "root", "._", "\\u\\u\\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_", "#", " ", "Split", " ", "a", " ", "path", " ", "in", " ", "root", " ", "and", " ", "extensi", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "extensi", "on", " ", "is", " ", "every", "thing", " ", "startin", "g", " ", "at", " ", "the", " ", "last", " ", "dot", " ", "in", " ", "the", " ", "last_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "path", "name", " ", "component", ";", " ", "the", " ", "root", " ", "is", " ", "every", "thing", " ", "bef", "ore", " ", "tha", "t", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "It", " ", "is", " ", "alw", "ay", "s", " ", "true", " ", "tha", "t", " ", "root", " ", "+", " ", "ext", " ", "==", " ", "p", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "splitext_", "._", "\\u\\u", "doc\\u\\u_", "=_", "gener", "icp", "ath_", "._", "\\u", "splitext_", "._", "\\u\\u", "doc\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Split", " ", "a", " ", "path", "name", " ", "int", "o", " ", "a", " ", "drive", " ", "specifica", "tion", " ", "and", " ", "the", " ", "rest", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "path", ".", " ", " ", "Us", "efu", "l", " ", "on", " ", "DOS", "/", "Window", "s", "/", "NT", ";", " ", "on", " ", "Uni", "x", ",", " ", "the", " ", "drive", " ", "is", " ", "alw", "ay", "s", " ", "empty", "._", "\\u\\u\\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_", "#", " ", "Return", " ", "the", " ", "tail", " ", "(", "basen", "ame", ")", " ", "part", " ", "of", " ", "a", " ", "path", ",", " ", "same", " ", "as", " ", "split", "(", "path", ")[", "1", "].", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Return", " ", "the", " ", "head", " ", "(", "dir", "name", ")", " ", "part", " ", "of", " ", "a", " ", "path", ",", " ", "same", " ", "as", " ", "split", "(", "path", ")[", "0", "].", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "The", "se", " ", "funcs", " ", "cann", "ot", " ", "be", " ", "implemented", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "abstract", " ", "pyj", "s", ",", " ", "shou", "ld", " ", "be", " ", "overload", "ed", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "pyv", "8", " ", "and", " ", "pys", "m_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "support", "s", "\\u", "unicode", "\\u", "filenames_", "=_", "(_", "sys_", "._", "platform_", "==_", "'", "dar", "win", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "norm", "case_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Normalize", " ", "case", " ", "of", " ", "path", "name", ".", " ", " ", "Has", " ", "no", " ", "effect", " ", "under", " ", "Posi", "x", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "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_", "isabs_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "whe", "ther", " ", "a", " ", "path", " ", "is", " ", "abs", "olute", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "s_", "._", "startswith_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "join_", "(_", "a_", ",_", "*_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Join", " ", "two", " ", "or", " ", "more", " ", "path", "name", " ", "component", "s", ",", " ", "insert", "ing", " ", "'/'", " ", "as", " ", "need", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "any", " ", "component", " ", "is", " ", "an", " ", "abs", "olute", " ", "path", ",", " ", "all", " ", "previ", "ous", " ", "path", " ", "component", "s", "\\", "10", ";", " ", " ", " ", " ", "will", " ", "be", " ", "discard", "ed", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "b_", "in_", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "b_", "._", "startswith_", "(_", "'/'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "==_", "''_", "or_", "path_", "._", "endswith_", "(_", "'/'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "+=_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "+=_", "'/'_", "+_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "split_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Split", " ", "a", " ", "path", "name", ".", " ", " ", "Return", "s", " ", "tuple", " ", "\"(", "head", ",", " ", "tail", ")\"", " ", "where", " ", "\"", "tail", "\"", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "every", "thing", " ", "after", " ", "the", " ", "final", " ", "slash", ".", " ", " ", "Ei", "ther", " ", "part", " ", "may", " ", "be", " ", "empty", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "p_", "._", "rfind_", "(_", "'/'_", ")_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "head_", ",_", "tail_", "=_", "p_", "[_", ":_", "i_", "]_", ",_", "p_", "[_", "i_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "head_", "and_", "head_", "!=_", "'/'_", "*_", "len_", "(_", "head_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "head_", "=_", "head_", "._", "rstrip_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "head_", ",_", "tail_", "\\u\\u\\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_", "splitext_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "gener", "icp", "ath_", "._", "\\u", "splitext_", "(_", "p_", ",_", "sep_", ",_", "alts", "ep_", ",_", "ext", "sep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "split", "drive_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Split", " ", "a", " ", "path", "name", " ", "int", "o", " ", "drive", " ", "and", " ", "path", ".", " ", "On", " ", "Posi", "x", ",", " ", "drive", " ", "is", " ", "alw", "ay", "s", "\\", "10", ";", " ", " ", " ", " ", "empty", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "''_", ",_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "basename_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "final", " ", "component", " ", "of", " ", "a", " ", "path", "name", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "p_", "._", "rfind_", "(_", "'/'_", ")_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "p_", "[_", "i_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dirname_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "director", "y", " ", "component", " ", "of", " ", "a", " ", "path", "name", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "p_", "._", "rfind_", "(_", "'/'_", ")_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "head_", "=_", "p_", "[_", ":_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "head_", "and_", "head_", "!=_", "'/'_", "*_", "len_", "(_", "head_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "head_", "=_", "head_", "._", "rstrip_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "head_", "\\u\\u\\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_", "same", "stat_", "(_", "s1_", ",_", "s2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "whe", "ther", " ", "two", " ", "stat", " ", "buffer", "s", " ", "reference", " ", "the", " ", "same", " ", "file", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "s1_", "._", "st", "\\u", "ino_", "==_", "s2_", "._", "st", "\\u", "ino_", "and_", "s1_", "._", "st", "\\u", "dev_", "==_", "s2_", "._", "st", "\\u", "dev_", "\\u\\u\\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_", "normpath_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Normalize", " ", "path", ",", " ", "eliminat", "ing", " ", "double", " ", "slash", "es", ",", " ", "etc", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pres", "erve", " ", "unicode", " ", "(", "if", " ", "path", " ", "is", " ", "unicode", ")_", "\\u\\u\\uNL\\u\\u\\u_", "slash_", ",_", "dot_", "=_", "(_", "u", "'/'_", ",_", "u", "'.'_", ")_", "if_", "isinstance_", "(_", "path_", ",_", "unicode_", ")_", "else_", "(_", "'/'_", ",_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "path_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "initial", "\\u", "slash", "es_", "=_", "path_", "._", "startswith_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "POSI", "X", " ", "allow", "s", " ", "one", " ", "or", " ", "two", " ", "initial", " ", "slash", "es", ",", " ", "but", " ", "treat", "s", " ", "three", " ", "or", " ", "more_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "as", " ", "single", " ", "slash", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "initial", "\\u", "slash", "es_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "._", "startswith_", "(_", "'//'_", ")_", "and_", "not_", "path_", "._", "startswith_", "(_", "'//", "/'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial", "\\u", "slash", "es_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "comps_", "=_", "path_", "._", "split_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "comps_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "comp_", "in_", "comps_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "comp_", "in_", "(_", "''_", ",_", "'.'_", ")_", ":_", "\\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_", "(_", "comp_", "!=_", "'..'_", "or_", "(_", "not_", "initial", "\\u", "slash", "es_", "and_", "not_", "new", "\\u", "comps_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "new", "\\u", "comps_", "and_", "new", "\\u", "comps_", "[_", "-_", "1_", "]_", "==_", "'..'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "comps_", "._", "append_", "(_", "comp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "new", "\\u", "comps_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "comps_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "comps_", "=_", "new", "\\u", "comps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "slash_", "._", "join_", "(_", "comps_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "initial", "\\u", "slash", "es_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "slash_", "*_", "initial", "\\u", "slash", "es_", "+_", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "path_", "or_", "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_", "abspath_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "an", " ", "abs", "olute", " ", "path", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "normpath_", "(_", "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_", "realpath_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "abspath_", "(_", "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_", "def_", "islink_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "lexi", "sts_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "same", "file_", "(_", "f1_", ",_", "f2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "same", "openfile_", "(_", "fp", "1_", ",_", "fp", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "ism", "ount_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "walk_", "(_", "top_", ",_", "func_", ",_", "arg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "expanduser_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\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_", "expand", "vars_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "relpath_", "(_", "path_", ",_", "start_", "=_", "curdir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Implemented_", "(_", ")_" ]
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, 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, 4, 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, 4, 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 ]
`__eq__` not overridden when adding attributes
AppScale/appscale/AppServer/lib/django-1.5/django/utils/datastructures.py
[ { "content": "class SortedDict(dict):\n \"\"\"\n A dictionary that keeps its keys in the order in which they're inserted.\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n if six.PY3:\n items = _iteritems\n keys = _iterkeys\n values = _itervalues\n else:\n iteritems = _iteritems\n iterkeys = _iterkeys\n itervalues = _itervalues\n\n\n\n\n\n\n\n\n\n", "metadata": "root.SortedDict", "header": "['module', '___EOS___']", "index": 111 }, { "content": " def __new__(cls, *args, **kwargs):\n instance = super(SortedDict, cls).__new__(cls, *args, **kwargs)\n instance.keyOrder = []\n return instance", "metadata": "root.SortedDict.__new__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 115 }, { "content": " def __init__(self, data=None):\n if data is None or isinstance(data, dict):\n data = data or []\n super(SortedDict, self).__init__(data)\n self.keyOrder = list(data) if data else []\n else:\n super(SortedDict, self).__init__()\n super_set = super(SortedDict, self).__setitem__\n for key, value in data:\n # Take the ordering from first key\n if key not in self:\n self.keyOrder.append(key)\n # But override with last value in data (dict() does this)\n super_set(key, value)", "metadata": "root.SortedDict.__init__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 120 }, { "content": " def __deepcopy__(self, memo):\n return self.__class__([(key, copy.deepcopy(value, memo))\n for key, value in self.items()])", "metadata": "root.SortedDict.__deepcopy__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 135 }, { "content": " def __copy__(self):\n # The Python's default copy implementation will alter the state\n # of self. The reason for this seems complex but is likely related to\n # subclassing dict.\n return self.copy()", "metadata": "root.SortedDict.__copy__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 139 }, { "content": " def __setitem__(self, key, value):\n if key not in self:\n self.keyOrder.append(key)\n super(SortedDict, self).__setitem__(key, value)", "metadata": "root.SortedDict.__setitem__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 145 }, { "content": " def __delitem__(self, key):\n super(SortedDict, self).__delitem__(key)\n self.keyOrder.remove(key)", "metadata": "root.SortedDict.__delitem__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 150 }, { "content": " def __iter__(self):\n return iter(self.keyOrder)", "metadata": "root.SortedDict.__iter__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 154 }, { "content": " def __reversed__(self):\n return reversed(self.keyOrder)", "metadata": "root.SortedDict.__reversed__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 157 }, { "content": " def pop(self, k, *args):\n result = super(SortedDict, self).pop(k, *args)\n try:\n self.keyOrder.remove(k)\n except ValueError:\n # Key wasn't in the dictionary in the first place. No problem.\n pass\n return result", "metadata": "root.SortedDict.pop", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 160 }, { "content": " def popitem(self):\n result = super(SortedDict, self).popitem()\n self.keyOrder.remove(result[0])\n return result", "metadata": "root.SortedDict.popitem", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 169 }, { "content": " def _iteritems(self):\n for key in self.keyOrder:\n yield key, self[key]", "metadata": "root.SortedDict._iteritems", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 174 }, { "content": " def _iterkeys(self):\n for key in self.keyOrder:\n yield key", "metadata": "root.SortedDict._iterkeys", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 178 }, { "content": " def _itervalues(self):\n for key in self.keyOrder:\n yield self[key]", "metadata": "root.SortedDict._itervalues", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 182 }, { "content": " def items(self):\n return [(k, self[k]) for k in self.keyOrder]", "metadata": "root.SortedDict.items", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 195 }, { "content": " def keys(self):\n return self.keyOrder[:]", "metadata": "root.SortedDict.keys", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 198 }, { "content": " def values(self):\n return [self[k] for k in self.keyOrder]", "metadata": "root.SortedDict.values", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 201 }, { "content": " def update(self, dict_):\n for k, v in six.iteritems(dict_):\n self[k] = v", "metadata": "root.SortedDict.update", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 204 }, { "content": " def setdefault(self, key, default):\n if key not in self:\n self.keyOrder.append(key)\n return super(SortedDict, self).setdefault(key, default)", "metadata": "root.SortedDict.setdefault", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 208 }, { "content": " def value_for_index(self, index):\n \"\"\"Returns the value of the item at the given zero-based index.\"\"\"\n # This, and insert() are deprecated because they cannot be implemented\n # using collections.OrderedDict (Python 2.7 and up), which we'll\n # eventually switch to\n warnings.warn(\n \"SortedDict.value_for_index is deprecated\", PendingDeprecationWarning,\n stacklevel=2\n )\n return self[self.keyOrder[index]]", "metadata": "root.SortedDict.value_for_index", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 213 }, { "content": " def insert(self, index, key, value):\n \"\"\"Inserts the key, value pair before the item with the given index.\"\"\"\n warnings.warn(\n \"SortedDict.insert is deprecated\", PendingDeprecationWarning,\n stacklevel=2\n )\n if key in self.keyOrder:\n n = self.keyOrder.index(key)\n del self.keyOrder[n]\n if n < index:\n index -= 1\n self.keyOrder.insert(index, key)\n super(SortedDict, self).__setitem__(key, value)", "metadata": "root.SortedDict.insert", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 224 }, { "content": " def copy(self):\n \"\"\"Returns a copy of this object.\"\"\"\n # This way of initializing the copy means it works for subclasses, too.\n return self.__class__(self)", "metadata": "root.SortedDict.copy", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 238 }, { "content": " def __repr__(self):\n \"\"\"\n Replaces the normal dict.__repr__ with a version that returns the keys\n in their sorted order.\n \"\"\"\n return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in six.iteritems(self)])", "metadata": "root.SortedDict.__repr__", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 243 }, { "content": " def clear(self):\n super(SortedDict, self).clear()\n self.keyOrder = []", "metadata": "root.SortedDict.clear", "header": "['class', 'SortedDict', '(', 'dict', ')', ':', '___EOS___']", "index": 250 }, { "content": "class DictWrapper(dict):\n \"\"\"\n Wraps accesses to a dictionary so that certain values (those starting with\n the specified prefix) are passed through a function before being returned.\n The prefix is removed before looking up the real value.\n\n Used by the SQL construction code to ensure that values are correctly\n quoted before being used.\n \"\"\"\n", "metadata": "root.DictWrapper", "header": "['module', '___EOS___']", "index": 489 }, { "content": " def __init__(self, data, func, prefix):\n super(DictWrapper, self).__init__(data)\n self.func = func\n self.prefix = prefix", "metadata": "root.DictWrapper.__init__", "header": "['class', 'DictWrapper', '(', 'dict', ')', ':', '___EOS___']", "index": 498 }, { "content": " def __getitem__(self, key):\n \"\"\"\n Retrieves the real value after stripping the prefix string (if\n present). If the prefix is present, pass the value through self.func\n before returning, otherwise return the raw value.\n \"\"\"\n if key.startswith(self.prefix):\n use_func = True\n key = key[len(self.prefix):]\n else:\n use_func = False\n value = super(DictWrapper, self).__getitem__(key)\n if use_func:\n return self.func(value)\n return value", "metadata": "root.DictWrapper.__getitem__", "header": "['class', 'DictWrapper', '(', 'dict', ')', ':', '___EOS___']", "index": 503 } ]
[ { "span": "class SortedDict(dict):", "start_line": 111, "start_column": 0, "end_line": 111, "end_column": 23 }, { "span": "class DictWrapper(dict):", "start_line": 489, "start_column": 0, "end_line": 489, "end_column": 24 } ]
[ { "span": "self.keyOrder ", "start_line": 124, "start_column": 12, "end_line": 124, "end_column": 25 }, { "span": "self.keyOrder ", "start_line": 252, "start_column": 8, "end_line": 252, "end_column": 21 }, { "span": "self.func ", "start_line": 500, "start_column": 8, "end_line": 500, "end_column": 17 }, { "span": "self.prefix ", "start_line": 501, "start_column": 8, "end_line": 501, "end_column": 19 } ]
1
false
[ "[CLS]_", "`_", "\\u\\u", "eq\\u\\u_", "`_", "not_", "overrid", "den_", "when_", "addin", "g_", "attributes_", "[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_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "dictionar", "y", " ", "tha", "t", " ", "keep", "s", " ", "its", " ", "keys", " ", "in", " ", "the", " ", "order", " ", "in", " ", "whi", "ch", " ", "the", "y", "'", "re", " ", "inserted", ".", "\\", "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_", "\\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_", "six_", "._", "PY", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "items_", "=_", "\\u", "iteritems_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "keys_", "=_", "\\u", "iterkeys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "=_", "\\u", "itervalues_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "iteritems_", "=_", "\\u", "iteritems_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iterkeys_", "=_", "\\u", "iterkeys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "itervalues_", "=_", "\\u", "itervalues_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "=_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "cls_", ")_", "._", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance_", "._", "key", "Order_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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_", ",_", "data_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "data_", "is_", "None_", "or_", "isinstance_", "(_", "data_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "data_", "or_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key", "Order_", "=_", "list_", "(_", "data_", ")_", "if_", "data_", "else_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super", "\\u", "set_", "=_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "\\u\\u", "setitem\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tak", "e", " ", "the", " ", "orderi", "ng", " ", "from", " ", "first", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "not_", "in_", "self_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "key", "Order_", "._", "append_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Bu", "t", " ", "override", " ", "with", " ", "last", " ", "value", " ", "in", " ", "data", " ", "(", "dict", "()", " ", "doe", "s", " ", "this", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super", "\\u", "set_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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\\u", "deepc", "opy", "\\u\\u_", "(_", "self_", ",_", "memo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "[_", "(_", "key_", ",_", "copy_", "._", "deepcopy_", "(_", "value_", ",_", "memo_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "items_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "copy", "\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "Pyth", "on", "'", "s", " ", "default", " ", "copy", " ", "implementation", " ", "will", " ", "alter", " ", "the", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "self", ".", " ", "The", " ", "reason", " ", "for", " ", "this", " ", "see", "ms", " ", "complex", " ", "but", " ", "is", " ", "like", "ly", " ", "relate", "d", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "subclassing", " ", "dict", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "setitem\\u\\u_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "not_", "in_", "self_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "key", "Order_", "._", "append_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "\\u\\u", "setitem\\u\\u_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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 ", " _", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "\\u\\u", "delitem\\u\\u_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key", "Order_", "._", "remove_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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_", "iter_", "(_", "self_", "._", "key", "Order_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "reverse", "d\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reversed_", "(_", "self_", "._", "key", "Order_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "pop_", "(_", "self_", ",_", "k_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "pop_", "(_", "k_", ",_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "key", "Order_", "._", "remove_", "(_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Key", " ", "was", "n", "'", "t", " ", "in", " ", "the", " ", "dictionar", "y", " ", "in", " ", "the", " ", "first", " ", "place", ".", " ", "No", " ", "problem", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "popi", "tem_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "popi", "tem_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key", "Order_", "._", "remove_", "(_", "result_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "iteritems_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", "in_", "self_", "._", "key", "Order_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "key_", ",_", "self_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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", "iterkeys_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", "in_", "self_", "._", "key", "Order_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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", "itervalues_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", "in_", "self_", "._", "key", "Order_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "self_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "items_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "(_", "k_", ",_", "self_", "[_", "k_", "]_", ")_", "for_", "k_", "in_", "self_", "._", "key", "Order_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "keys_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "key", "Order_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "values_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "self_", "[_", "k_", "]_", "for_", "k_", "in_", "self_", "._", "key", "Order_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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_", ",_", "dict\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "k_", ",_", "v_", "in_", "six_", "._", "iteritems_", "(_", "dict\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "[_", "k_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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_", "setdefault_", "(_", "self_", ",_", "key_", ",_", "default_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "not_", "in_", "self_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "key", "Order_", "._", "append_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "setdefault_", "(_", "key_", ",_", "default_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "value", "\\u", "for", "\\u", "index_", "(_", "self_", ",_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "the", " ", "item", " ", "at", " ", "the", " ", "give", "n", " ", "zero", "-", "based", " ", "index", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", ",", " ", "and", " ", "insert", "()", " ", "are", " ", "depre", "cated", " ", "bec", "aus", "e", " ", "the", "y", " ", "cann", "ot", " ", "be", " ", "implemented", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "usi", "ng", " ", "collection", "s", ".", "Order", "ed", "Dict", " ", "(", "Pyth", "on", " ", "2.7", " ", "and", " ", "up", "),", " ", "whi", "ch", " ", "we", "'", "ll_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "eventual", "ly", " ", "switch", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "warnings_", "._", "warn_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sorte", "d", "Dict", ".", "value", "\\u", "for", "\\u", "index", " ", "is", " ", "depre", "cated", "\"_", ",_", "Pend", "ing", "Dep", "reca", "tion", "Warning_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "stacklevel_", "=_", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "[_", "self_", "._", "key", "Order_", "[_", "index_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "insert_", "(_", "self_", ",_", "index_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Insert", "s", " ", "the", " ", "key", ",", " ", "value", " ", "pair", " ", "bef", "ore", " ", "the", " ", "item", " ", "with", " ", "the", " ", "give", "n", " ", "index", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "warnings_", "._", "warn_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sorte", "d", "Dict", ".", "insert", " ", "is", " ", "depre", "cated", "\"_", ",_", "Pend", "ing", "Dep", "reca", "tion", "Warning_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "stacklevel_", "=_", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "key_", "in_", "self_", "._", "key", "Order_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "self_", "._", "key", "Order_", "._", "index_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "key", "Order_", "[_", "n_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "n_", "<_", "index_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "key", "Order_", "._", "insert_", "(_", "index_", ",_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "\\u\\u", "setitem\\u\\u_", "(_", "key_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "copy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "a", " ", "copy", " ", "of", " ", "this", " ", "object", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "way", " ", "of", " ", "initiali", "zin", "g", " ", "the", " ", "copy", " ", "means", " ", "it", " ", "works", " ", "for", " ", "subclasses", ",", " ", "too", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Replace", "s", " ", "the", " ", "normal", " ", "dict", ".\\u", "\\u", "repr", "\\u\\u", " ", "with", " ", "a", " ", "version", " ", "tha", "t", " ", "return", "s", " ", "the", " ", "keys", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "thei", "r", " ", "sorte", "d", " ", "order", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'{", "%", "s", "}'_", "%_", "',", " ", "'_", "._", "join_", "(_", "[_", "'%", "r", ":", " ", "%", "r", "'_", "%_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "six_", "._", "iteritems_", "(_", "self_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sorte", "d", "Dict_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clear_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Sorte", "d", "Dict_", ",_", "self_", ")_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key", "Order_", "=_", "[_", "]_", "\\u\\u\\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_", "Dict", "Wrapper_", "(_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Wra", "ps", " ", "accesse", "s", " ", "to", " ", "a", " ", "dictionar", "y", " ", "so", " ", "tha", "t", " ", "cert", "ain", " ", "values", " ", "(", "tho", "se", " ", "startin", "g", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "specified", " ", "prefix", ")", " ", "are", " ", "pass", "ed", " ", "through", " ", "a", " ", "function", " ", "bef", "ore", " ", "bei", "ng", " ", "return", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "prefix", " ", "is", " ", "remove", "d", " ", "bef", "ore", " ", "look", "ing", " ", "up", " ", "the", " ", "real", " ", "value", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Us", "ed", " ", "by", " ", "the", " ", "SQL", " ", "constructi", "on", " ", "code", " ", "to", " ", "ensure", " ", "tha", "t", " ", "values", " ", "are", " ", "correct", "ly", "\\", "10", ";", " ", " ", " ", " ", "quoted", " ", "bef", "ore", " ", "bei", "ng", " ", "used", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Dict", "Wrapper_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data_", ",_", "func_", ",_", "prefix_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Dict", "Wrapper_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "func_", "=_", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prefix_", "=_", "prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dict", "Wrapper_", "(_", "dict_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Retrieve", "s", " ", "the", " ", "real", " ", "value", " ", "after", " ", "strip", "ping", " ", "the", " ", "prefix", " ", "string", " ", "(", "if", "\\", "10", ";", " ", " ", " ", " ", "presen", "t", ").", " ", "If", " ", "the", " ", "prefix", " ", "is", " ", "presen", "t", ",", " ", "pass", " ", "the", " ", "value", " ", "through", " ", "self", ".", "func", "\\", "10", ";", " ", " ", " ", " ", "bef", "ore", " ", "return", "ing", ",", " ", "other", "wis", "e", " ", "return", " ", "the", " ", "raw", " ", "value", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "key_", "._", "startswith_", "(_", "self_", "._", "prefix_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "use", "\\u", "func_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key_", "=_", "key_", "[_", "len_", "(_", "self_", "._", "prefix_", ")_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "use", "\\u", "func_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "value_", "=_", "super_", "(_", "Dict", "Wrapper_", ",_", "self_", ")_", "._", "\\u\\u", "getitem\\u\\u_", "(_", "key_", ")_", "\\u\\u\\uNEWL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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 3, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
cloudera/hue/desktop/core/ext-py/openpyxl-2.3.0-b2/openpyxl/xml/namespace.py
[ { "content": "from __future__ import absolute_import\n# Copyright (c) 2010-2015 openpyxl\n#\n# register_namespace function under a different licence:\n# The ElementTree toolkit is\n#\n# Copyright (c) 1999-2008 by Fredrik Lundh\n#\n# By obtaining, using, and/or copying this software and/or its\n# associated documentation, you agree that you have read, understood,\n# and will comply with the following terms and conditions:\n#\n# Permission to use, copy, modify, and distribute this software and\n# its associated documentation for any purpose and without fee is\n# hereby granted, provided that the above copyright notice appears in\n# all copies, and that both that copyright notice and this permission\n# notice appear in supporting documentation, and that the name of\n# Secret Labs AB or the author not be used in advertising or publicity\n# pertaining to distribution of the software without specific, written\n# prior permission.\n#\n# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD\n# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-\n# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR\n# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY\n# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\n# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\n# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE\n# OF THIS SOFTWARE.\n# --------------------------------------------------------------------\n# Licensed to PSF under a Contributor Agreement.\n# See http://www.python.org/psf/license for licensing details.\n\nimport re\n\n# Python 2.6 without lxml\n\n\ntry:\n from xml.etree.cElementTree import register_namespace\nexcept ImportError:\n try:\n from xml.etree.ElementTree import register_namespace\n except ImportError:\n pass\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def register_namespace(prefix, uri):\n from xml.etree.ElementTree import _namespace_map\n if re.match(\"ns\\d+$\", prefix):\n raise ValueError(\"Prefix format reserved for internal use\")\n for k, v in _namespace_map.items():\n if k == uri or v == prefix:\n del _namespace_map[k]\n _namespace_map[uri] = prefix", "metadata": "root.register_namespace", "header": "['module', '___EOS___']", "index": 36 } ]
[ { "span": "from xml.etree.cElementTree import register_namespace", "start_line": 47, "start_column": 4, "end_line": 47, "end_column": 57 }, { "span": "from xml.etree.ElementTree import register_namespace", "start_line": 50, "start_column": 8, "end_line": 50, "end_column": 60 } ]
[]
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_", "#", " ", "register", "\\u", "namespace", " ", "function", " ", "under", " ", "a", " ", "different", " ", "licence", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Element", "Tree", " ", "tool", "kit", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "1999", "-", "2008", " ", "by", " ", "Fre", "dri", "k", " ", "Lun", "dh_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "By", " ", "obtain", "ing", ",", " ", "usi", "ng", ",", " ", "and", "/", "or", " ", "copy", "ing", " ", "this", " ", "software", " ", "and", "/", "or", " ", "its_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "associate", "d", " ", "documentation", ",", " ", "you", " ", "agree", " ", "tha", "t", " ", "you", " ", "have", " ", "read", ",", " ", "underst", "oo", "d", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "will", " ", "compl", "y", " ", "with", " ", "the", " ", "follow", "ing", " ", "term", "s", " ", "and", " ", "condition", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Permi", "ssion", " ", "to", " ", "use", ",", " ", "copy", ",", " ", "modif", "y", ",", " ", "and", " ", "distribute", " ", "this", " ", "software", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "its", " ", "associate", "d", " ", "documentation", " ", "for", " ", "any", " ", "purpose", " ", "and", " ", "with", "out", " ", "fe", "e", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "here", "by", " ", "grant", "ed", ",", " ", "provided", " ", "tha", "t", " ", "the", " ", "above", " ", "copyr", "ight", " ", "notice", " ", "appear", "s", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "copie", "s", ",", " ", "and", " ", "tha", "t", " ", "bot", "h", " ", "tha", "t", " ", "copyr", "ight", " ", "notice", " ", "and", " ", "this", " ", "permission_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "notice", " ", "appear", " ", "in", " ", "support", "ing", " ", "documentation", ",", " ", "and", " ", "tha", "t", " ", "the", " ", "name", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sec", "ret", " ", "Lab", "s", " ", "AB", " ", "or", " ", "the", " ", "author", " ", "not", " ", "be", " ", "used", " ", "in", " ", "adver", "tis", "ing", " ", "or", " ", "public", "ity_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pert", "ain", "ing", " ", "to", " ", "distribu", "tion", " ", "of", " ", "the", " ", "software", " ", "with", "out", " ", "specific", ",", " ", "written_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "prior", " ", "permissi", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SEC", "RET", " ", "LAB", "S", " ", "AB", " ", "AND", " ", "THE", " ", "AUTHOR", " ", "DISC", "LAI", "MS", " ", "ALL", " ", "WAR", "RAN", "TIES", " ", "WITH", " ", "REG", "ARD", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TO", " ", "THIS", " ", "SOFT", "WARE", ",", " ", "INC", "LU", "DING", " ", "ALL", " ", "IMPL", "IED", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "T", "-_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ABI", "LIT", "Y", " ", "AND", " ", "FIT", "NESS", ".", " ", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "SEC", "RET", " ", "LAB", "S", " ", "AB", " ", "OR", " ", "THE", " ", "AUTHOR", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "SPECIAL", ",", " ", "INDI", "RECT", " ", "OR", " ", "CONS", "EQU", "ENTI", "AL", " ", "DA", "MAGE", "S", " ", "OR", " ", "ANY_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "DA", "MAGE", "S", " ", "WH", "ATS", "OE", "VER", " ", "RESU", "LT", "ING", " ", "FROM", " ", "LOSS", " ", "OF", " ", "USE", ",", " ", "DATA", " ", "OR", " ", "PROF", "IT", "S", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WHE", "THER", " ", "IN", " ", "AN", " ", "ACTI", "ON", " ", "OF", " ", "CONTR", "ACT", ",", " ", "NEG", "LIG", "ENCE", " ", "OR", " ", "OTHER", " ", "TOR", "TIO", "US_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ACTI", "ON", ",", " ", "ARI", "SIN", "G", " ", "OUT", " ", "OF", " ", "OR", " ", "IN", " ", "CONNECTION", " ", "WITH", " ", "THE", " ", "USE", " ", "OR", " ", "PERF", "ORM", "ANCE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OF", " ", "THIS", " ", "SOFT", "WARE", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "------------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "to", " ", "PSF", " ", "under", " ", "a", " ", "Contributor", " ", "Agreement", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "http", "://", "www", ".", "python", ".", "org", "/", "psf", "/", "license", " ", "for", " ", "lice", "nsi", "ng", " ", "deta", "il", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pyth", "on", " ", "2.6", " ", "with", "out", " ", "lxml_", "\\u\\u\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "xml_", "._", "etree_", "._", "c", "Element", "Tree_", "import_", "register", "\\u", "namespace_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "xml_", "._", "etree_", "._", "Element", "Tree_", "import_", "register", "\\u", "namespace_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\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_", "register", "\\u", "namespace_", "(_", "prefix_", ",_", "uri_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "xml_", "._", "etree_", "._", "Element", "Tree_", "import_", "\\u", "namespace", "\\u", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "re_", "._", "match_", "(_", "\"", "ns", "\\\\", "d", "+$", "\"_", ",_", "prefix_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "Pref", "ix", " ", "format", " ", "reserve", "d", " ", "for", " ", "internal", " ", "use", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "\\u", "namespace", "\\u", "map_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "k_", "==_", "uri_", "or_", "v_", "==_", "prefix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "\\u", "namespace", "\\u", "map_", "[_", "k_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "namespace", "\\u", "map_", "[_", "uri_", "]_", "=_", "prefix_", "\\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, 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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 ]
Imprecise assert
django-oscar/django-oscar/tests/unit/shipping/model_tests.py
[ { "content": " def test_doesnt_allow_negative_upper_limit(self):\n band = models.WeightBand(upper_limit=D('-0.1'))\n with self.assertRaises(ValidationError) as cm:\n band.full_clean()\n self.assertTrue('upper_limit' in cm.exception.message_dict)", "metadata": "root.TestWeightBand.test_doesnt_allow_negative_upper_limit", "header": "['class', 'TestWeightBand', '(', 'TestCase', ')', ':', '___EOS___']", "index": 19 }, { "content": " def test_doesnt_allow_negative_charge(self):\n band = models.WeightBand(charge=D('-0.1'))\n with self.assertRaises(ValidationError) as cm:\n band.full_clean()\n self.assertTrue('charge' in cm.exception.message_dict)", "metadata": "root.TestWeightBand.test_doesnt_allow_negative_charge", "header": "['class', 'TestWeightBand', '(', 'TestCase', ')', ':', '___EOS___']", "index": 25 } ]
[ { "span": "self.assertTrue('upper_limit' in cm.exception.message_dict)", "start_line": 23, "start_column": 8, "end_line": 23, "end_column": 67 }, { "span": "self.assertTrue('charge' in cm.exception.message_dict)", "start_line": 29, "start_column": 8, "end_line": 29, "end_column": 62 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Weig", "ht", "Band_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "doesnt", "\\u", "allow", "\\u", "negati", "ve", "\\u", "upper", "\\u", "limit_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "band_", "=_", "models_", "._", "Weig", "ht", "Band_", "(_", "upper", "\\u", "limit_", "=_", "D_", "(_", "'-", "0.", "1", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Validat", "ion", "Error_", ")_", "as_", "cm_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "band_", "._", "full", "\\u", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "upper", "\\u", "limit", "'_", "in_", "cm_", "._", "exception_", "._", "message", "\\u", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Weig", "ht", "Band_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "doesnt", "\\u", "allow", "\\u", "negati", "ve", "\\u", "charge_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "band_", "=_", "models_", "._", "Weig", "ht", "Band_", "(_", "charge_", "=_", "D_", "(_", "'-", "0.", "1", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Validat", "ion", "Error_", ")_", "as_", "cm_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "band_", "._", "full", "\\u", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "charge", "'_", "in_", "cm_", "._", "exception_", "._", "message", "\\u", "dict_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
Calysto/metakernel/metakernel/magics/tests/test_ls_magic.py
[ { "content": "\nimport os\nfrom metakernel.tests.utils import (get_kernel, get_log_text,\n clear_log_text)\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test_ls_magic():\n kernel = get_kernel()\n kernel.do_execute(\"%ls /tmp\")\n text = get_log_text(kernel)\n assert '/tmp/' in text, text[:100]\n clear_log_text(kernel)\n\n kernel.do_execute(\"%ls /tmp --recursive\")\n text = get_log_text(kernel)\n assert '/tmp' in text, text[:100]\n clear_log_text(kernel)", "metadata": "root.test_ls_magic", "header": "['module', '___EOS___']", "index": 6 } ]
[ { "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_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "meta", "kernel_", "._", "tests_", "._", "utils_", "import_", "(_", "get", "\\u", "kernel_", ",_", "get", "\\u", "log", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "clear", "\\u", "log", "\\u", "text_", ")_", "\\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_", "test\\u", "ls", "\\u", "magic_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kernel_", "=_", "get", "\\u", "kernel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kernel_", "._", "do", "\\u", "execute_", "(_", "\"%", "ls", " ", "/", "tmp", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "get", "\\u", "log", "\\u", "text_", "(_", "kernel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'/", "tmp", "/'_", "in_", "text_", ",_", "text_", "[_", ":_", "100_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clear", "\\u", "log", "\\u", "text_", "(_", "kernel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kernel_", "._", "do", "\\u", "execute_", "(_", "\"%", "ls", " ", "/", "tmp", " ", "--", "recurs", "ive", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "get", "\\u", "log", "\\u", "text_", "(_", "kernel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'/", "tmp", "'_", "in_", "text_", ",_", "text_", "[_", ":_", "100_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clear", "\\u", "log", "\\u", "text_", "(_", "kernel_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
karesansui/karesansui/tools/initialize_database.py
[ { "content": "#!/usr/bin/env python\n\nimport sys, os\nimport socket\nimport re\nimport string\nfrom optparse import OptionParser\nimport traceback\n\ntry:\n from distutils.sysconfig import get_python_lib\n sys.real_prefix = '/usr';\n sys.path.append(get_python_lib(0,0))\nexcept:\n pass\n\ntry:\n import sqlalchemy\n import karesansui\n from karesansui import __version__\n from karesansui.lib.utils import is_uuid, is_int\n from karesansui.lib.utils import generate_phrase, generate_uuid, string_from_uuid\n from karesansui.lib.file.k2v import K2V\n from karesansui.lib.crypt import sha1encrypt\n from karesansui.lib.const import MACHINE_ATTRIBUTE, MACHINE_HYPERVISOR\n from karesansui.db import get_engine, get_metadata, get_session\n from karesansui.db.model.user import User\n from karesansui.db.model.notebook import Notebook\n from karesansui.db.model.tag import Tag\n from karesansui.db.model.machine import Machine\n\nexcept ImportError:\n print >>sys.stderr, \"[Error] karesansui package was not found.\"\n sys.exit(1)\n\nusage = '%prog [options]'\n\n\n\n\nkaresansui.config = K2V(\"/etc/karesansui/application.conf\").read()\n\n(opts, args) = getopts()\n#print opts\nchkopts(opts)\n\nfor k in dir(opts):\n v = getattr(opts,k)\n if type(v) == str and k[0:2] != \"__\":\n exec(\"%s = '%s'\" % (k, v,))\n\n#print opts\n#sys.exit()\n\nengine = get_engine()\nmetadata = get_metadata()\n\ntry:\n metadata.drop_all() \n metadata.tables['machine2jobgroup'].create()\n metadata.create_all() \nexcept Exception, e:\n traceback.format_exc()\n raise Exception('Initializing/Updating a database error - %s' % ''.join(e.args))\n\nsession = get_session()\ntry:\n (password, salt) = sha1encrypt(u\"%s\" % password)\n user = session.query(User).filter(User.email == email).first()\n\n if user is None:\n # User Table set.\n new_user = User(u\"%s\" % email,\n unicode(password),\n unicode(salt),\n u\"Administrator\",\n u\"%s\" % lang,\n )\n\n if string.atof(sqlalchemy.__version__[0:3]) >= 0.6:\n session.add(new_user)\n else:\n session.save(new_user)\n session.commit()\n else:\n user.password = password\n user.salt = salt\n user.languages = lang\n if string.atof(sqlalchemy.__version__[0:3]) >= 0.6:\n session.add(user)\n else:\n session.update(user)\n session.commit()\n\n # Tag Table set.\n tag = Tag(u\"default\")\n if string.atof(sqlalchemy.__version__[0:3]) >= 0.6:\n session.add(tag)\n else:\n session.save(tag)\n session.commit()\n \n # Machine Table set.\n user = session.query(User).filter(User.email == email).first()\n notebook = Notebook(u\"\", u\"\")\n machine = Machine(user,\n user,\n u\"%s\" % uuid,\n u\"%s\" % fqdn,\n MACHINE_ATTRIBUTE['HOST'],\n MACHINE_HYPERVISOR['REAL'],\n notebook,\n [tag],\n u\"%s\" % fqdn,\n u'icon-guest1.png',\n False,\n None,\n )\n\n if string.atof(sqlalchemy.__version__[0:3]) >= 0.6:\n session.add(machine)\n else:\n session.save(machine)\n session.commit()\n\n session.close()\nexcept Exception, e:\n traceback.format_exc()\n raise Exception('Initializing/Updating a database error - %s' % ''.join(e.args))\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def getopts():\n optp = OptionParser(usage=usage, version=__version__)\n # basic\n optp.add_option('-m', '--email', dest='email', help=_(\"E-mail Address\"), default=\"root@localhost\")\n optp.add_option('-p', '--password', dest='password', help=_(\"Password\"), default=\"\")\n optp.add_option('-l', '--lang', dest='lang', help=_(\"Language\"), default=\"\")\n optp.add_option('-f', '--host', dest='fqdn', help=_(\"FQDN\"), default=\"\")\n optp.add_option('-u', '--uuid', dest='uuid', help=_(\"UUID\"), default=\"\")\n\n return optp.parse_args()", "metadata": "root.getopts", "header": "['module', '___EOS___']", "index": 37 }, { "content": "def chkopts(opts):\n from karesansui.lib.utils import generate_phrase, generate_uuid, string_from_uuid, is_uuid\n from karesansui.lib.const import DEFAULT_LANGS\n\n reg_email = re.compile(\"^[a-zA-Z0-9\\./_-]{1,}@[a-zA-Z0-9\\./-]{4,}$\")\n if opts.email:\n if reg_email.search(opts.email) is None:\n raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-m or --email', opts.email))\n else:\n raise Exception('ERROR: %s option is required.' % '-m or --email')\n\n reg_passwd = re.compile(\"^.{5,}\")\n if opts.password:\n if reg_passwd.search(opts.password) is None:\n raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-p or --password', opts.password))\n else:\n pass\n\n if opts.password == \"\":\n opts.password = generate_phrase(8)\n\n if opts.uuid:\n if is_uuid(opts.uuid) is False:\n raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-u or --uuid', opts.uuid))\n else:\n pass\n\n if opts.uuid == \"\":\n opts.uuid = string_from_uuid(generate_uuid())\n\n reg_fqdn = re.compile(\"^[a-z0-9][a-z0-9\\.\\-]{2,}$\")\n if opts.fqdn:\n if reg_fqdn.search(opts.fqdn) is None:\n raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-f or --fqdn', opts.fqdn))\n else:\n pass\n\n if opts.fqdn == \"\":\n opts.fqdn = socket.gethostname() \n\n reg_lang = re.compile(\"^[a-z]{2}_[A-Z]{2}$\")\n if opts.lang:\n if reg_lang.search(opts.lang) is None:\n raise Exception('ERROR: Illigal option value. option=%s value=%s' % ('-l or --lang', opts.lang))\n else:\n pass\n\n if opts.lang == \"\":\n try:\n DEFAULT_LANGS[os.environ[\"LANG\"][0:5]]\n opts.lang = os.environ[\"LANG\"][0:5]\n except:\n opts.lang = \"en_US\"", "metadata": "root.chkopts", "header": "['module', '___EOS___']", "index": 48 } ]
[ { "span": "from karesansui.lib.utils import is_uuid, is_int", "start_line": 20, "start_column": 4, "end_line": 20, "end_column": 52 }, { "span": "from karesansui.lib.utils import generate_phrase, generate_uuid, string_from_uuid", "start_line": 21, "start_column": 4, "end_line": 21, "end_column": 85 } ]
[]
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_", "sys_", ",_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "optparse_", "import_", "Optio", "n", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "distutils_", "._", "sysconfig", "_", "import_", "get", "\\u", "python", "\\u", "lib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "real", "\\u", "prefix_", "=_", "'/", "usr", "'_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "get", "\\u", "python", "\\u", "lib_", "(_", "0_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "sqlalchemy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "kar", "esa", "nsu", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "import_", "\\u\\u", "version\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "utils_", "import_", "is", "\\u", "uuid_", ",_", "is", "\\u", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "utils_", "import_", "generat", "e\\u", "phrase_", ",_", "generat", "e\\u", "uuid_", ",_", "string", "\\u", "from", "\\u", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "file_", "._", "k2", "v_", "import_", "K2", "V_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "crypt_", "import_", "sha1", "encrypt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "const_", "import_", "MACHINE", "\\u", "ATTRIBUTE_", ",_", "MACHINE", "\\u", "HYP", "ERV", "ISO", "R_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "import_", "get", "\\u", "engine_", ",_", "get", "\\u", "metadata_", ",_", "get", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "model_", "._", "user_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "model_", "._", "notebook_", "import_", "Notebook", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "model_", "._", "tag_", "import_", "Tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "model_", "._", "machine_", "import_", "Machine_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\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 ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"[", "Error", "]", " ", "kar", "esa", "nsu", "i", " ", "package", " ", "was", " ", "not", " ", "found", ".\"_", "\\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_", "usage_", "=_", "'%", "prog", " ", "[", "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_", "\\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_", "kar", "esa", "nsu", "i_", "._", "config_", "=_", "K2", "V_", "(_", "\"/", "etc", "/", "kar", "esa", "nsu", "i", "/", "applica", "tion", ".", "conf", "\"_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "opts_", ",_", "args_", ")_", "=_", "getop", "ts_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "opts_", "\\u\\u\\uNL\\u\\u\\u_", "chk", "opts_", "(_", "opts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "k_", "in_", "dir_", "(_", "opts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "getattr_", "(_", "opts_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "v_", ")_", "==_", "str_", "and_", "k_", "[_", "0_", ":_", "2_", "]_", "!=_", "\"\\u\\u", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec_", "(_", "\"%", "s", " ", "=", " ", "'%", "s", "'\"_", "%_", "(_", "k_", ",_", "v_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "opts_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sys", ".", "exit", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "engine_", "=_", "get", "\\u", "engine_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "metadata_", "=_", "get", "\\u", "metadata_", "(_", ")_", "\\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 ", " _", "metadata_", "._", "drop", "\\u", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "metadata_", "._", "tables_", "[_", "'", "machine", "2j", "ob", "group", "'_", "]_", "._", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "metadata_", "._", "create", "\\u", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "'", "Initializ", "ing", "/", "Up", "dati", "ng", " ", "a", " ", "databa", "se", " ", "error", " ", "-", " ", "%", "s", "'_", "%_", "''_", "._", "join_", "(_", "e_", "._", "args_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "=_", "get", "\\u", "session_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "password_", ",_", "salt_", ")_", "=_", "sha1", "encrypt_", "(_", "u", "\"%", "s", "\"_", "%_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "session_", "._", "query_", "(_", "User_", ")_", "._", "filter_", "(_", "User_", "._", "email_", "==_", "email_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "user_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "User", " ", "Table", " ", "set", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "user_", "=_", "User_", "(_", "u", "\"%", "s", "\"_", "%_", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unicode_", "(_", "password_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unicode_", "(_", "salt_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"", "Administra", "tor", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"%", "s", "\"_", "%_", "lang_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "string_", "._", "ato", "f_", "(_", "sqlalchemy_", "._", "\\u\\u", "version\\u\\u_", "[_", "0_", ":_", "3_", "]_", ")_", ">=_", "0.6_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "add_", "(_", "new", "\\u", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "save_", "(_", "new", "\\u", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "._", "password_", "=_", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "._", "salt_", "=_", "salt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "._", "languages_", "=_", "lang_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "string_", "._", "ato", "f_", "(_", "sqlalchemy_", "._", "\\u\\u", "version\\u\\u_", "[_", "0_", ":_", "3_", "]_", ")_", ">=_", "0.6_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "add_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "update_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ta", "g", " ", "Table", " ", "set", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tag_", "=_", "Tag_", "(_", "u", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "string_", "._", "ato", "f_", "(_", "sqlalchemy_", "._", "\\u\\u", "version\\u\\u_", "[_", "0_", ":_", "3_", "]_", ")_", ">=_", "0.6_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "add_", "(_", "tag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "save_", "(_", "tag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Machine", " ", "Table", " ", "set", "._", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "session_", "._", "query_", "(_", "User_", ")_", "._", "filter_", "(_", "User_", "._", "email_", "==_", "email_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "notebook_", "=_", "Notebook", "_", "(_", "u", "\"\"_", ",_", "u", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "machine_", "=_", "Machine_", "(_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"%", "s", "\"_", "%_", "uuid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"%", "s", "\"_", "%_", "fqdn_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "MACHINE", "\\u", "ATTRIBUTE_", "[_", "'", "HOST", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "MACHINE", "\\u", "HYP", "ERV", "ISO", "R_", "[_", "'", "REAL", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "notebook_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "tag_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"%", "s", "\"_", "%_", "fqdn_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "icon", "-", "guest", "1", ".", "png", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "string_", "._", "ato", "f_", "(_", "sqlalchemy_", "._", "\\u\\u", "version\\u\\u_", "[_", "0_", ":_", "3_", "]_", ")_", ">=_", "0.6_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "add_", "(_", "machine_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "save_", "(_", "machine_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "session_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "'", "Initializ", "ing", "/", "Up", "dati", "ng", " ", "a", " ", "databa", "se", " ", "error", " ", "-", " ", "%", "s", "'_", "%_", "''_", "._", "join_", "(_", "e_", "._", "args_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "getop", "ts_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opt", "p_", "=_", "Optio", "n", "Parser_", "(_", "usage_", "=_", "usage_", ",_", "version_", "=_", "\\u\\u", "version\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "basic_", "\\u\\u\\uNL\\u\\u\\u_", "opt", "p_", "._", "add", "\\u", "option_", "(_", "'-", "m", "'_", ",_", "'--", "email", "'_", ",_", "dest_", "=_", "'", "email", "'_", ",_", "help_", "=_", "\\u_", "(_", "\"", "E-", "mail", " ", "Address", "\"_", ")_", ",_", "default_", "=_", "\"", "root", "@", "local", "host", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opt", "p_", "._", "add", "\\u", "option_", "(_", "'-", "p", "'_", ",_", "'--", "password", "'_", ",_", "dest_", "=_", "'", "password", "'_", ",_", "help_", "=_", "\\u_", "(_", "\"", "Passw", "ord", "\"_", ")_", ",_", "default_", "=_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opt", "p_", "._", "add", "\\u", "option_", "(_", "'-", "l", "'_", ",_", "'--", "lang", "'_", ",_", "dest_", "=_", "'", "lang", "'_", ",_", "help_", "=_", "\\u_", "(_", "\"", "Lang", "ua", "ge", "\"_", ")_", ",_", "default_", "=_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opt", "p_", "._", "add", "\\u", "option_", "(_", "'-", "f", "'_", ",_", "'--", "host", "'_", ",_", "dest_", "=_", "'", "fq", "dn", "'_", ",_", "help_", "=_", "\\u_", "(_", "\"", "FQ", "DN", "\"_", ")_", ",_", "default_", "=_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opt", "p_", "._", "add", "\\u", "option_", "(_", "'-", "u", "'_", ",_", "'--", "uuid", "'_", ",_", "dest_", "=_", "'", "uuid", "'_", ",_", "help_", "=_", "\\u_", "(_", "\"", "UU", "ID", "\"_", ")_", ",_", "default_", "=_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "opt", "p_", "._", "parse", "\\u", "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_", "def_", "chk", "opts_", "(_", "opts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "utils_", "import_", "generat", "e\\u", "phrase_", ",_", "generat", "e\\u", "uuid_", ",_", "string", "\\u", "from", "\\u", "uuid_", ",_", "is", "\\u", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "const_", "import_", "DEF", "AUL", "T", "\\u", "LANG", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "reg", "\\u", "email_", "=_", "re_", "._", "compile_", "(_", "\"", "^", "[", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "\\\\.", "/\\u", "-]", "{", "1", ",}", "@[", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "\\\\.", "/-", "]{", "4", ",}", "$\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "opts_", "._", "email_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "reg", "\\u", "email_", "._", "search_", "(_", "opts_", "._", "email_", ")_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "ERROR", ":", " ", "Il", "lig", "al", " ", "option", " ", "value", ".", " ", "option", "=", "%", "s", " ", "value", "=", "%", "s", "'_", "%_", "(_", "'-", "m", " ", "or", " ", "--", "email", "'_", ",_", "opts_", "._", "email_", ")_", ")_", "\\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_", "(_", "'", "ERROR", ":", " ", "%", "s", " ", "option", " ", "is", " ", "require", "d", ".'_", "%_", "'-", "m", " ", "or", " ", "--", "email", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reg", "\\u", "passwd_", "=_", "re_", "._", "compile_", "(_", "\"", "^", ".", "{", "5", ",}", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "opts_", "._", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "reg", "\\u", "passwd_", "._", "search_", "(_", "opts_", "._", "password_", ")_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "ERROR", ":", " ", "Il", "lig", "al", " ", "option", " ", "value", ".", " ", "option", "=", "%", "s", " ", "value", "=", "%", "s", "'_", "%_", "(_", "'-", "p", " ", "or", " ", "--", "password", "'_", ",_", "opts_", "._", "password_", ")_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "password_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opts_", "._", "password_", "=_", "generat", "e\\u", "phrase_", "(_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "uuid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "is", "\\u", "uuid_", "(_", "opts_", "._", "uuid_", ")_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "ERROR", ":", " ", "Il", "lig", "al", " ", "option", " ", "value", ".", " ", "option", "=", "%", "s", " ", "value", "=", "%", "s", "'_", "%_", "(_", "'-", "u", " ", "or", " ", "--", "uuid", "'_", ",_", "opts_", "._", "uuid_", ")_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "uuid_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opts_", "._", "uuid_", "=_", "string", "\\u", "from", "\\u", "uuid_", "(_", "generat", "e\\u", "uuid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reg", "\\u", "fqdn_", "=_", "re_", "._", "compile_", "(_", "\"", "^", "[", "a", "-", "z", "0", "-", "9", "][", "a", "-", "z", "0", "-", "9", "\\\\.\\\\", "-]", "{", "2", ",}", "$\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "opts_", "._", "fqdn_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "reg", "\\u", "fqdn_", "._", "search_", "(_", "opts_", "._", "fqdn_", ")_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "ERROR", ":", " ", "Il", "lig", "al", " ", "option", " ", "value", ".", " ", "option", "=", "%", "s", " ", "value", "=", "%", "s", "'_", "%_", "(_", "'-", "f", " ", "or", " ", "--", "fq", "dn", "'_", ",_", "opts_", "._", "fqdn_", ")_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "fqdn_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opts_", "._", "fqdn_", "=_", "socket_", "._", "gethostname_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reg", "\\u", "lang_", "=_", "re_", "._", "compile_", "(_", "\"", "^", "[", "a", "-", "z", "]{", "2", "}\\u", "[", "A", "-", "Z", "]{", "2", "}$\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "opts_", "._", "lang_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "reg", "\\u", "lang_", "._", "search_", "(_", "opts_", "._", "lang_", ")_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "ERROR", ":", " ", "Il", "lig", "al", " ", "option", " ", "value", ".", " ", "option", "=", "%", "s", " ", "value", "=", "%", "s", "'_", "%_", "(_", "'-", "l", " ", "or", " ", "--", "lang", "'_", ",_", "opts_", "._", "lang_", ")_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "lang_", "==_", "\"\"_", ":_", "\\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 ", " _", "DEF", "AUL", "T", "\\u", "LANG", "S_", "[_", "os_", "._", "environ_", "[_", "\"", "LANG", "\"_", "]_", "[_", "0_", ":_", "5_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opts_", "._", "lang_", "=_", "os_", "._", "environ_", "[_", "\"", "LANG", "\"_", "]_", "[_", "0_", ":_", "5_", "]_", "\\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 ", " _", "opts_", "._", "lang_", "=_", "\"", "en", "\\u", "US", "\"_", "\\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, 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n/steps/sync_port_addresses.py
[ { "content": "import os\nimport requests\nimport socket\nimport sys\nimport base64\nfrom django.db.models import F, Q\nfrom xos.config import Config\nfrom synchronizers.base.syncstep import SyncStep\nfrom core.models import Service, Port, Controller, Tag\nfrom core.models.service import COARSE_KIND\nfrom services.cord.models import VSGTenant\nfrom services.cord.models import Tenant\nfrom xos.logger import Logger, logging\nfrom requests.auth import HTTPBasicAuth\n\n# hpclibrary will be in steps/..\nparentdir = os.path.join(os.path.dirname(__file__),\"..\")\nsys.path.insert(0,parentdir)\n\nlogger = Logger(level=logging.INFO)\n\n# XXX should save and load this\nglo_saved_vtn_maps = []\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class SyncPortAddresses(SyncStep):\n requested_interval = 0 # 3600\n provides=[Port]\n observes=Port\n\n", "metadata": "root.SyncPortAddresses", "header": "['module', '___EOS___']", "index": 24 }, { "content": " def __init__(self, **args):\n SyncStep.__init__(self, **args)", "metadata": "root.SyncPortAddresses.__init__", "header": "['class', 'SyncPortAddresses', '(', 'SyncStep', ')', ':', '___EOS___']", "index": 29 }, { "content": " def call(self, **args):\n global glo_saved_vtn_maps\n\n logger.info(\"sync'ing vsg tenant to port addresses\")\n\n # build up a dictionary of port-->[wan_addrs] mappings\n port_addrs = {}\n for vsg in VSGTenant.get_tenant_objects().all():\n if not vsg.instance:\n logger.info(\"skipping vsg %s because it has no instance\" % vsg)\n\n wan_ip = vsg.wan_container_ip\n if not wan_ip:\n logger.info(\"skipping vsg %s because it has no wan_container_ip\" % vsg)\n\n wan_mac = vsg.wan_container_mac\n if not wan_mac:\n logger.info(\"skipping vsg %s because it has no wan_container_mac\" % vsg)\n\n lan_network = vsg.get_lan_network(vsg.instance)\n if not lan_network:\n logger.info(\"skipping vsg %s because it has no lan_network\" % vsg)\n\n lan_port = Port.objects.filter(instance = vsg.instance, network=lan_network)\n if not lan_port:\n logger.info(\"skipping vsg %s because it has no lan_port\" % vsg)\n lan_port = lan_port[0]\n\n if not lan_port.port_id:\n logger.info(\"skipping vsg %s because its lan_port has no port_id\" % vsg)\n\n if not (lan_port.pk in port_addrs):\n port_addrs[lan_port.pk] = []\n entry = {\"mac_address\": wan_mac, \"ip_address\": wan_ip}\n addr_pairs = port_addrs[lan_port.pk]\n if not entry in addr_pairs:\n addr_pairs.append(entry)\n\n # now do the VM_WAN_IP from the instance\n if vsg.instance:\n wan_vm_ip = vsg.wan_vm_ip\n wan_vm_mac = vsg.wan_vm_mac\n entry = {\"mac_address\": wan_vm_mac, \"ip_address\": wan_vm_ip}\n if not entry in addr_pairs:\n addr_pairs.append(entry)\n\n # Get all ports in all controllers\n ports_by_id = {}\n for controller in Controller.objects.all():\n if not controller.admin_tenant:\n logger.info(\"controller %s has no admin_tenant\" % controller)\n continue\n try:\n driver = self.driver.admin_driver(controller = controller)\n ports = driver.shell.quantum.list_ports()[\"ports\"]\n except:\n logger.log_exc(\"failed to get ports from controller %s\" % controller)\n continue\n\n for port in ports:\n ports_by_id[port[\"id\"]] = port\n\n for port_pk in port_addrs.keys():\n port = Port.objects.get(pk=port_pk)\n addr_pairs = port_addrs[port_pk]\n neutron_port = ports_by_id.get(port.port_id,None)\n if not neutron_port:\n logger.info(\"failed to get neutron port for port %s\" % port)\n continue\n\n ips = [x[\"ip_address\"] for x in addr_pairs]\n\n changed = False\n\n # delete addresses in neutron that don't exist in XOS\n aaps = neutron_port.get(\"allowed_address_pairs\", [])\n for aap in aaps[:]:\n if not aap[\"ip_address\"] in ips:\n logger.info(\"removing address %s from port %s\" % (aap[\"ip_address\"], port))\n aaps.remove(aap)\n changed = True\n\n aaps_ips = [x[\"ip_address\"] for x in aaps]\n\n # add addresses in XOS that don't exist in neutron\n for addr in addr_pairs:\n if not addr[\"ip_address\"] in aaps_ips:\n logger.info(\"adding address %s to port %s\" % (addr, port))\n aaps.append( addr )\n aaps_ips.append(addr[\"ip_address\"])\n changed = True\n\n if changed:\n logger.info(\"updating port %s\" % port)\n driver.shell.quantum.update_port(port.port_id, {\"port\": {\"allowed_address_pairs\": aaps}})", "metadata": "root.SyncPortAddresses.call", "header": "['class', 'SyncPortAddresses', '(', 'SyncStep', ')', ':', '___EOS___']", "index": 32 } ]
[ { "span": "import requests", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "import socket", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 13 }, { "span": "import base64", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 13 }, { "span": "from django.db.models import F, Q", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 33 }, { "span": "from xos.config import Config", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 29 }, { "span": "from core.models import Service, Port, Controller, Tag", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 54 }, { "span": "from core.models.service import COARSE_KIND", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 43 }, { "span": "from services.cord.models import Tenant", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 39 }, { "span": "from requests.auth import HTTPBasicAuth", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 39 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "F_", ",_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "xo", "s_", "._", "config_", "import_", "Config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "synchronize", "rs_", "._", "base_", "._", "sync", "step_", "import_", "Sync", "Step_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core_", "._", "models_", "import_", "Service_", ",_", "Port_", ",_", "Controller_", ",_", "Tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core_", "._", "models_", "._", "service_", "import_", "COA", "RSE", "\\u", "KIND", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "services_", "._", "cord", "_", "._", "models_", "import_", "VS", "GT", "ena", "nt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "services_", "._", "cord", "_", "._", "models_", "import_", "Ten", "ant_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "xo", "s_", "._", "logger_", "import_", "Logger_", ",_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "requests_", "._", "auth_", "import_", "HTTP", "Basic", "Auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hp", "clib", "rar", "y", " ", "will", " ", "be", " ", "in", " ", "step", "s", "/.", "._", "\\u\\u\\uNL\\u\\u\\u_", "parent", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "\"..\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "insert_", "(_", "0_", ",_", "parent", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "=_", "Logger_", "(_", "level_", "=_", "logging_", "._", "INFO_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "XX", "X", " ", "shou", "ld", " ", "save", " ", "and", " ", "load", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "glo", "\\u", "saved", "\\u", "vt", "n", "\\u", "maps_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Sync", "Port", "Address", "es_", "(_", "Sync", "Step_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "ed", "\\u", "interval_", "=_", "0_", "#", " ", "3600_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "provides_", "=_", "[_", "Port_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "observe", "s_", "=_", "Port_", "\\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_", "Sync", "Port", "Address", "es_", "(_", "Sync", "Step_", ")_", ":_", "\\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 ", " _", "Sync", "Step_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "**_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sync", "Port", "Address", "es_", "(_", "Sync", "Step_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "call_", "(_", "self_", ",_", "**_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "glo", "\\u", "saved", "\\u", "vt", "n", "\\u", "maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "sync", "'", "ing", " ", "vs", "g", " ", "tenan", "t", " ", "to", " ", "port", " ", "addresse", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "build", " ", "up", " ", "a", " ", "dictionar", "y", " ", "of", " ", "port", "-->", "[", "wan", "\\u", "addr", "s", "]", " ", "mappings_", "\\u\\u\\uNL\\u\\u\\u_", "port", "\\u", "addrs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "vs", "g_", "in_", "VS", "GT", "ena", "nt_", "._", "get", "\\u", "tenan", "t", "\\u", "objects_", "(_", ")_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "vs", "g_", "._", "instance_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "skip", "ping", " ", "vs", "g", " ", "%", "s", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "no", " ", "instance", "\"_", "%_", "vs", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wan", "\\u", "ip_", "=_", "vs", "g_", "._", "wan", "\\u", "container", "\\u", "ip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "wan", "\\u", "ip_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "skip", "ping", " ", "vs", "g", " ", "%", "s", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "no", " ", "wan", "\\u", "container", "\\u", "ip", "\"_", "%_", "vs", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wan", "\\u", "mac_", "=_", "vs", "g_", "._", "wan", "\\u", "container", "\\u", "mac_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "wan", "\\u", "mac_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "skip", "ping", " ", "vs", "g", " ", "%", "s", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "no", " ", "wan", "\\u", "container", "\\u", "mac", "\"_", "%_", "vs", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lan", "\\u", "network_", "=_", "vs", "g_", "._", "get", "\\u", "lan", "\\u", "network_", "(_", "vs", "g_", "._", "instance_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "lan", "\\u", "network_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "skip", "ping", " ", "vs", "g", " ", "%", "s", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "no", " ", "lan", "\\u", "network", "\"_", "%_", "vs", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lan", "\\u", "port_", "=_", "Port_", "._", "objects_", "._", "filter_", "(_", "instance_", "=_", "vs", "g_", "._", "instance_", ",_", "network_", "=_", "lan", "\\u", "network_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "lan", "\\u", "port_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "skip", "ping", " ", "vs", "g", " ", "%", "s", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "no", " ", "lan", "\\u", "port", "\"_", "%_", "vs", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lan", "\\u", "port_", "=_", "lan", "\\u", "port_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "lan", "\\u", "port_", "._", "port", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "skip", "ping", " ", "vs", "g", " ", "%", "s", " ", "bec", "aus", "e", " ", "its", " ", "lan", "\\u", "port", " ", "has", " ", "no", " ", "port", "\\u", "id", "\"_", "%_", "vs", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "(_", "lan", "\\u", "port_", "._", "pk_", "in_", "port", "\\u", "addrs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "\\u", "addrs_", "[_", "lan", "\\u", "port_", "._", "pk_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "entry_", "=_", "{_", "\"", "mac", "\\u", "address", "\"_", ":_", "wan", "\\u", "mac_", ",_", "\"", "ip", "\\u", "address", "\"_", ":_", "wan", "\\u", "ip_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addr", "\\u", "pairs_", "=_", "port", "\\u", "addrs_", "[_", "lan", "\\u", "port_", "._", "pk_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "entry_", "in_", "addr", "\\u", "pairs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "addr", "\\u", "pairs_", "._", "append_", "(_", "entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "do", " ", "the", " ", "VM", "\\u", "WAN", "\\u", "IP", " ", "from", " ", "the", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "vs", "g_", "._", "instance_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wan", "\\u", "vm", "\\u", "ip_", "=_", "vs", "g_", "._", "wan", "\\u", "vm", "\\u", "ip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wan", "\\u", "vm", "\\u", "mac_", "=_", "vs", "g_", "._", "wan", "\\u", "vm", "\\u", "mac_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entry_", "=_", "{_", "\"", "mac", "\\u", "address", "\"_", ":_", "wan", "\\u", "vm", "\\u", "mac_", ",_", "\"", "ip", "\\u", "address", "\"_", ":_", "wan", "\\u", "vm", "\\u", "ip_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "entry_", "in_", "addr", "\\u", "pairs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "addr", "\\u", "pairs_", "._", "append_", "(_", "entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "all", " ", "port", "s", " ", "in", " ", "all", " ", "controllers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "port", "s", "\\u", "by", "\\u", "id_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "controller_", "in_", "Controller_", "._", "objects_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "controller_", "._", "admin", "\\u", "tenant_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "controlle", "r", " ", "%", "s", " ", "has", " ", "no", " ", "admin", "\\u", "tenan", "t", "\"_", "%_", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "driver_", "=_", "self_", "._", "driver_", "._", "admin", "\\u", "driver_", "(_", "controller_", "=_", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ports_", "=_", "driver_", "._", "shell_", "._", "quantum", "_", "._", "list", "\\u", "ports_", "(_", ")_", "[_", "\"", "port", "s", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "log", "\\u", "exc_", "(_", "\"", "fail", "ed", " ", "to", " ", "get", " ", "port", "s", " ", "from", " ", "controlle", "r", " ", "%", "s", "\"_", "%_", "controller_", ")_", "\\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_", "for_", "port_", "in_", "ports_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "s", "\\u", "by", "\\u", "id_", "[_", "port_", "[_", "\"", "id", "\"_", "]_", "]_", "=_", "port_", "\\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_", "port", "\\u", "pk_", "in_", "port", "\\u", "addrs_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port_", "=_", "Port_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "port", "\\u", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addr", "\\u", "pairs_", "=_", "port", "\\u", "addrs_", "[_", "port", "\\u", "pk_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "neut", "ron", "\\u", "port_", "=_", "port", "s", "\\u", "by", "\\u", "id_", "._", "get_", "(_", "port_", "._", "port", "\\u", "id_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "neut", "ron", "\\u", "port_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "fail", "ed", " ", "to", " ", "get", " ", "neut", "ron", " ", "port", " ", "for", " ", "port", " ", "%", "s", "\"_", "%_", "port_", ")_", "\\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_", "ips_", "=_", "[_", "x_", "[_", "\"", "ip", "\\u", "address", "\"_", "]_", "for_", "x_", "in_", "addr", "\\u", "pairs_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "changed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "delete", " ", "addresse", "s", " ", "in", " ", "neut", "ron", " ", "tha", "t", " ", "don", "'", "t", " ", "exist", " ", "in", " ", "XO", "S_", "\\u\\u\\uNL\\u\\u\\u_", "aa", "ps_", "=_", "neut", "ron", "\\u", "port_", "._", "get_", "(_", "\"", "allow", "ed", "\\u", "address", "\\u", "pair", "s", "\"_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "aa", "p_", "in_", "aa", "ps_", "[_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "aa", "p_", "[_", "\"", "ip", "\\u", "address", "\"_", "]_", "in_", "ips_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logger_", "._", "info_", "(_", "\"", "remo", "ving", " ", "address", " ", "%", "s", " ", "from", " ", "port", " ", "%", "s", "\"_", "%_", "(_", "aa", "p_", "[_", "\"", "ip", "\\u", "address", "\"_", "]_", ",_", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aa", "ps_", "._", "remove_", "(_", "aa", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "changed_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "aa", "ps", "\\u", "ips_", "=_", "[_", "x_", "[_", "\"", "ip", "\\u", "address", "\"_", "]_", "for_", "x_", "in_", "aa", "ps_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "addresse", "s", " ", "in", " ", "XO", "S", " ", "tha", "t", " ", "don", "'", "t", " ", "exist", " ", "in", " ", "neutron_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "addr_", "in_", "addr", "\\u", "pairs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "addr_", "[_", "\"", "ip", "\\u", "address", "\"_", "]_", "in_", "aa", "ps", "\\u", "ips_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logger_", "._", "info_", "(_", "\"", "addin", "g", " ", "address", " ", "%", "s", " ", "to", " ", "port", " ", "%", "s", "\"_", "%_", "(_", "addr_", ",_", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aa", "ps_", "._", "append_", "(_", "addr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aa", "ps", "\\u", "ips_", "._", "append_", "(_", "addr_", "[_", "\"", "ip", "\\u", "address", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "changed_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "changed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "updat", "ing", " ", "port", " ", "%", "s", "\"_", "%_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "driver_", "._", "shell_", "._", "quantum", "_", "._", "update", "\\u", "port_", "(_", "port_", "._", "port", "\\u", "id_", ",_", "{_", "\"", "port", "\"_", ":_", "{_", "\"", "allow", "ed", "\\u", "address", "\\u", "pair", "s", "\"_", ":_", "aa", "ps_", "}_", "}_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 2, 2, 2, 0, 1, 2, 0, 1, 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,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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 ]
Unused import
Miserlou/Zappa/tests/tests.py
[ { "content": "# -*- coding: utf8 -*-\nimport base64\nimport collections\nimport json\nimport mock\nimport os\nimport random\nimport string\nimport unittest\n\nfrom lambda_packages import lambda_packages\n\nfrom .utils import placebo_session\n\nfrom zappa.cli import ZappaCLI\nfrom zappa.handler import LambdaHandler, lambda_handler\nfrom zappa.wsgi import create_wsgi_request, common_log\nfrom zappa.zappa import Zappa, ASSUME_POLICY, ATTACH_POLICY\n\n\n\n\n\nif __name__ == '__main__':\n unittest.main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def random_string(length):\n return ''.join(random.choice(string.printable) for _ in range(length))", "metadata": "root.random_string", "header": "['module', '___EOS___']", "index": 20 }, { "content": "class TestZappa(unittest.TestCase):\n ##\n # Sanity Tests\n ##\n\n ##\n # Basic Tests\n ##\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ##\n # Logging\n ##\n\n\n ##\n # Mapping and pattern tests\n ##\n\n\n\n\n ##\n # WSGI\n ##\n\n\n\n\n\n ##\n # Handler\n ##\n\n\n ##\n # CLI\n ##\n\n\n\n", "metadata": "root.TestZappa", "header": "['module', '___EOS___']", "index": 24 }, { "content": " def test_test(self):\n self.assertTrue(True)", "metadata": "root.TestZappa.test_test", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 29 }, { "content": " def test_zappa(self):\n self.assertTrue(True)\n Zappa()", "metadata": "root.TestZappa.test_zappa", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 35 }, { "content": " def test_create_lambda_package(self):\n # mock the pip.get_installed_distributions() to include a package in lambda_packages so that the code\n # for zipping pre-compiled packages gets called\n mock_named_tuple = collections.namedtuple('mock_named_tuple', ['project_name'])\n mock_return_val = [mock_named_tuple(lambda_packages.keys()[0])] # choose name of 1st package in lambda_packages\n with mock.patch('pip.get_installed_distributions', return_value=mock_return_val):\n z = Zappa()\n path = z.create_lambda_zip(handler_file=os.path.realpath(__file__))\n self.assertTrue(os.path.isfile(path))\n os.remove(path)", "metadata": "root.TestZappa.test_create_lambda_package", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 39 }, { "content": " def test_load_credentials(self):\n z = Zappa()\n z.aws_region = 'us-east-1'\n z.load_credentials()\n self.assertEqual(z.boto_session.region_name, 'us-east-1')\n self.assertEqual(z.aws_region, 'us-east-1')\n\n z.aws_region = 'eu-west-1'\n z.profile_name = 'default'\n z.load_credentials()\n self.assertEqual(z.boto_session.region_name, 'eu-west-1')\n self.assertEqual(z.aws_region, 'eu-west-1')\n\n creds = {\n 'AWS_ACCESS_KEY_ID': 'AK123',\n 'AWS_SECRET_ACCESS_KEY': 'JKL456',\n 'AWS_DEFAULT_REGION': 'us-west-1'\n }\n with mock.patch.dict('os.environ', creds):\n z.aws_region = None\n z.load_credentials()\n loaded_creds = z.boto_session._session.get_credentials()\n\n self.assertEqual(loaded_creds.access_key, 'AK123')\n self.assertEqual(loaded_creds.secret_key, 'JKL456')\n self.assertEqual(z.boto_session.region_name, 'us-west-1')", "metadata": "root.TestZappa.test_load_credentials", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 50 }, { "content": " @placebo_session\n def test_upload_remove_s3(self, session):\n bucket_name = 'test_zappa_upload_s3'\n z = Zappa(session)\n zip_path = z.create_lambda_zip(minify=False)\n res = z.upload_to_s3(zip_path, bucket_name)\n os.remove(zip_path)\n self.assertTrue(res)\n s3 = session.resource('s3')\n\n # will throw ClientError with 404 if bucket doesn't exist\n s3.meta.client.head_bucket(Bucket=bucket_name)\n\n # will throw ClientError with 404 if object doesn't exist\n s3.meta.client.head_object(\n Bucket=bucket_name,\n Key=zip_path,\n )\n res = z.remove_from_s3(zip_path, bucket_name)\n self.assertTrue(res)\n\n fail = z.upload_to_s3('/tmp/this_isnt_real', bucket_name)\n self.assertFalse(fail)", "metadata": "root.TestZappa.test_upload_remove_s3", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 77 }, { "content": " @placebo_session\n def test_create_lambda_function(self, session):\n bucket_name = 'lmbda'\n zip_path = 'Spheres-dev-1454694878.zip'\n\n z = Zappa(session)\n z.aws_region = 'us-east-1'\n z.load_credentials(session)\n z.credentials_arn = 'arn:aws:iam::12345:role/ZappaLambdaExecution'\n\n arn = z.create_lambda_function(\n bucket=bucket_name, \n s3_key=zip_path, \n function_name='test_lmbda_function55', \n handler='runme.lambda_handler'\n )\n\n arn = z.update_lambda_function(\n bucket=bucket_name, \n s3_key=zip_path, \n function_name='test_lmbda_function55', \n )", "metadata": "root.TestZappa.test_create_lambda_function", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 101 }, { "content": " @placebo_session\n def test_rollback_lambda_function_version(self, session):\n z = Zappa(session)\n z.credentials_arn = 'arn:aws:iam::724336686645:role/ZappaLambdaExecution'\n\n function_name = 'django-helloworld-unicode'\n too_many_versions = z.rollback_lambda_function_version(function_name, 99999)\n self.assertFalse(too_many_versions)\n\n function_arn = z.rollback_lambda_function_version(function_name, 1)", "metadata": "root.TestZappa.test_rollback_lambda_function_version", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 124 }, { "content": " @placebo_session\n def test_invoke_lambda_function(self, session):\n z = Zappa(session)\n z.credentials_arn = 'arn:aws:iam::724336686645:role/ZappaLambdaExecution'\n\n function_name = 'django-helloworld-unicode'\n payload = '{\"event\": \"hello\"}'\n response = z.invoke_lambda_function(function_name, payload)", "metadata": "root.TestZappa.test_invoke_lambda_function", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 135 }, { "content": " @placebo_session\n def test_create_iam_roles(self, session):\n z = Zappa(session)\n arn = z.create_iam_roles()\n self.assertEqual(arn, \"arn:aws:iam::123:role/{}\".format(z.role_name))", "metadata": "root.TestZappa.test_create_iam_roles", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 144 }, { "content": " @placebo_session\n def test_create_api_gateway_routes(self, session):\n z = Zappa(session)\n z.parameter_depth = 1\n z.integration_response_codes = [200]\n z.method_response_codes = [200]\n z.http_methods = ['GET']\n z.credentials_arn = 'arn:aws:iam::12345:role/ZappaLambdaExecution'\n lambda_arn = 'arn:aws:lambda:us-east-1:12345:function:helloworld'\n with mock.patch('time.time', return_value=123.456):\n api_id = z.create_api_gateway_routes(lambda_arn)\n self.assertEqual(api_id, 'j27idab94h')", "metadata": "root.TestZappa.test_create_api_gateway_routes", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 150 }, { "content": " @placebo_session\n def test_deploy_api_gateway(self, session):\n z = Zappa(session)\n z.credentials_arn = 'arn:aws:iam::12345:role/ZappaLambdaExecution'\n\n z.parameter_depth = 1\n z.integration_response_codes = [200]\n z.method_response_codes = [200]\n z.http_methods = ['GET']\n\n lambda_arn = 'arn:aws:lambda:us-east-1:12345:function:django-helloworld-unicode'\n api_id = z.create_api_gateway_routes(lambda_arn)\n endpoint_url = z.deploy_api_gateway(api_id, \"test_stage\")", "metadata": "root.TestZappa.test_deploy_api_gateway", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 163 }, { "content": " @placebo_session\n def test_get_api_url(self, session):\n z = Zappa(session)\n z.credentials_arn = 'arn:aws:iam::724336686645:role/ZappaLambdaExecution'\n url = z.get_api_url('Spheres-demonstration')", "metadata": "root.TestZappa.test_get_api_url", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 177 }, { "content": " @placebo_session\n def test_fetch_logs(self, session):\n z = Zappa(session)\n z.credentials_arn = 'arn:aws:iam::12345:role/ZappaLambdaExecution'\n events = z.fetch_logs('Spheres-demonstration')\n self.assertTrue(events != None)", "metadata": "root.TestZappa.test_fetch_logs", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 183 }, { "content": " def test_policy_json(self):\n # ensure the policy docs are valid JSON\n json.loads(ASSUME_POLICY)\n json.loads(ATTACH_POLICY)", "metadata": "root.TestZappa.test_policy_json", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 190 }, { "content": " def test_logging(self):\n \"\"\"\n TODO\n \"\"\"\n Zappa()", "metadata": "root.TestZappa.test_logging", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 199 }, { "content": " def test_redirect_pattern(self):\n test_urls = [\n # a regular endpoint url\n 'https://asdf1234.execute-api.us-east-1.amazonaws.com/env/path/to/thing',\n # an external url (outside AWS)\n 'https://github.com/Miserlou/zappa/issues?q=is%3Aissue+is%3Aclosed',\n # a local url\n '/env/path/to/thing'\n ]\n\n for code in ['301', '302']:\n pattern = Zappa.selection_pattern(code)\n\n for url in test_urls:\n self.assertRegexpMatches(url, pattern)", "metadata": "root.TestZappa.test_redirect_pattern", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 209 }, { "content": " def test_b64_pattern(self):\n head = '<!DOCTYPE html>'\n\n for code in ['400', '401', '402', '403', '404', '500']:\n pattern = Zappa.selection_pattern(code)\n\n document = base64.b64encode(head + code + random_string(50))\n self.assertRegexpMatches(document, pattern)\n\n for bad_code in ['200', '301', '302']:\n document = base64.b64encode(head + bad_code + random_string(50))\n self.assertNotRegexpMatches(document, pattern)", "metadata": "root.TestZappa.test_b64_pattern", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 225 }, { "content": " def test_200_pattern(self):\n pattern = Zappa.selection_pattern('200')\n self.assertEqual(pattern, '')", "metadata": "root.TestZappa.test_200_pattern", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 238 }, { "content": " def test_wsgi_event(self):\n\n event = {\n \"body\": {},\n \"headers\": {\n \"Via\": \"1.1 e604e934e9195aaf3e36195adbcb3e18.cloudfront.net (CloudFront)\",\n \"Accept-Language\": \"en-US,en;q=0.5\",\n \"Accept-Encoding\": \"gzip\",\n \"CloudFront-Is-SmartTV-Viewer\": \"false\",\n \"CloudFront-Forwarded-Proto\": \"https\",\n \"X-Forwarded-For\": \"109.81.209.118, 216.137.58.43\",\n \"CloudFront-Viewer-Country\": \"CZ\",\n \"Accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n \"X-Forwarded-Proto\": \"https\",\n \"X-Amz-Cf-Id\": \"LZeP_TZxBgkDt56slNUr_H9CHu1Us5cqhmRSswOh1_3dEGpks5uW-g==\",\n \"CloudFront-Is-Tablet-Viewer\": \"false\",\n \"X-Forwarded-Port\": \"443\",\n \"CloudFront-Is-Mobile-Viewer\": \"false\",\n \"CloudFront-Is-Desktop-Viewer\": \"true\",\n \"Content-Type\": \"application/json\"\n },\n \"params\": {\n \"parameter_1\": \"asdf1\",\n \"parameter_2\": \"asdf2\",\n },\n \"method\": \"POST\",\n \"query\": {\n \"dead\": \"beef\"\n }\n }\n request = create_wsgi_request(event)", "metadata": "root.TestZappa.test_wsgi_event", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 246 }, { "content": " def test_wsgi_path_info(self):\n # Test no parameters (site.com/)\n event = {\n \"body\": {},\n \"headers\": {},\n \"params\": {},\n \"method\": \"GET\",\n \"query\": {}\n }\n\n request = create_wsgi_request(event, trailing_slash=True)\n self.assertEqual(\"/\", request['PATH_INFO'])\n\n request = create_wsgi_request(event, trailing_slash=False)\n self.assertEqual(\"/\", request['PATH_INFO'])\n\n # Test parameters (site.com/asdf1/asdf2 or site.com/asdf1/asdf2/)\n event = {\n \"body\": {},\n \"headers\": {},\n \"params\": {\n \"parameter_1\": \"asdf1\",\n \"parameter_2\": \"asdf2\",\n },\n \"method\": \"GET\",\n \"query\": {}\n }\n\n request = create_wsgi_request(event, trailing_slash=True)\n self.assertEqual(\"/asdf1/asdf2/\", request['PATH_INFO'])\n\n request = create_wsgi_request(event, trailing_slash=False)\n self.assertEqual(\"/asdf1/asdf2\", request['PATH_INFO'])\n\n request = create_wsgi_request(event, trailing_slash=False, script_name='asdf1')\n self.assertEqual(\"/asdf1/asdf2\", request['PATH_INFO'])", "metadata": "root.TestZappa.test_wsgi_path_info", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 278 }, { "content": " def test_wsgi_logging(self):\n event = {\n \"body\": {},\n \"headers\": {},\n \"params\": {\n \"parameter_1\": \"asdf1\",\n \"parameter_2\": \"asdf2\",\n },\n \"method\": \"GET\",\n \"query\": {}\n }\n environ = create_wsgi_request(event, trailing_slash=False)\n response_tuple = collections.namedtuple('Response', ['status_code', 'content'])\n response = response_tuple(200, 'hello')\n le = common_log(environ, response, response_time=True)\n le = common_log(environ, response, response_time=False)", "metadata": "root.TestZappa.test_wsgi_logging", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 315 }, { "content": " def test_wsgi_multipart(self):\n event = {u'body': u'LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS03Njk1MjI4NDg0Njc4MTc2NTgwNjMwOTYxDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9Im15c3RyaW5nIg0KDQpkZGQNCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNzY5NTIyODQ4NDY3ODE3NjU4MDYzMDk2MS0tDQo=', u'headers': {u'Content-Type': u'multipart/form-data; boundary=---------------------------7695228484678176580630961', u'Via': u'1.1 38205a04d96d60185e88658d3185ccee.cloudfront.net (CloudFront)', u'Accept-Language': u'en-US,en;q=0.5', u'Accept-Encoding': u'gzip, deflate, br', u'CloudFront-Is-SmartTV-Viewer': u'false', u'CloudFront-Forwarded-Proto': u'https', u'X-Forwarded-For': u'71.231.27.57, 104.246.180.51', u'CloudFront-Viewer-Country': u'US', u'Accept': u'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', u'User-Agent': u'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:45.0) Gecko/20100101 Firefox/45.0', u'Host': u'xo2z7zafjh.execute-api.us-east-1.amazonaws.com', u'X-Forwarded-Proto': u'https', u'Cookie': u'zappa=AQ4', u'CloudFront-Is-Tablet-Viewer': u'false', u'X-Forwarded-Port': u'443', u'Referer': u'https://xo8z7zafjh.execute-api.us-east-1.amazonaws.com/former/post', u'CloudFront-Is-Mobile-Viewer': u'false', u'X-Amz-Cf-Id': u'31zxcUcVyUxBOMk320yh5NOhihn5knqrlYQYpGGyOngKKwJb0J0BAQ==', u'CloudFront-Is-Desktop-Viewer': u'true'}, u'params': {u'parameter_1': u'post'}, u'method': u'POST', u'query': {}}\n environ = create_wsgi_request(event, trailing_slash=False)\n response_tuple = collections.namedtuple('Response', ['status_code', 'content'])\n response = response_tuple(200, 'hello')", "metadata": "root.TestZappa.test_wsgi_multipart", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 332 }, { "content": " def test_handler(self):\n lh = LambdaHandler('test_settings')\n event = {\n \"body\": {},\n \"headers\": {},\n \"params\": {\n \"parameter_1\": \"asdf1\",\n \"parameter_2\": \"asdf2\",\n },\n \"method\": \"GET\",\n \"query\": {}\n }\n lh.handler(event, None)", "metadata": "root.TestZappa.test_handler", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 342 }, { "content": " def test_cli_sanity(self):\n zappa_cli = ZappaCLI()\n return", "metadata": "root.TestZappa.test_cli_sanity", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 360 }, { "content": " def test_cli_utility(self):\n zappa_cli = ZappaCLI()\n zappa_cli.api_stage = 'ttt333'\n zappa_cli.load_settings('test_settings.json')\n zappa_cli.create_package()\n zappa_cli.remove_local_zip()\n logs = [\n {\n 'timestamp': '12345',\n 'message': '[START RequestId] test'\n },\n {\n 'timestamp': '12345',\n 'message': '[REPORT RequestId] test'\n },\n {\n 'timestamp': '12345',\n 'message': '[END RequestId] test'\n },\n { \n 'timestamp': '12345',\n 'message': 'test'\n }\n ]\n zappa_cli.print_logs(logs)", "metadata": "root.TestZappa.test_cli_utility", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 364 }, { "content": " def test_cli_args(self):\n zappa_cli = ZappaCLI()\n # Sanity\n argv = '-s test_settings.json derp ttt333'.split()\n zappa_cli.handle(argv)", "metadata": "root.TestZappa.test_cli_args", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 390 }, { "content": " @placebo_session\n def test_cli_aws(self, session):\n zappa_cli = ZappaCLI()\n zappa_cli.api_stage = 'ttt333'\n zappa_cli.load_settings('test_settings.json', session)\n zappa_cli.zappa.credentials_arn = 'arn:aws:iam::724336686645:role/ZappaLambdaExecution'\n zappa_cli.deploy()\n zappa_cli.update()\n zappa_cli.rollback(1)\n zappa_cli.tail(False)", "metadata": "root.TestZappa.test_cli_aws", "header": "['class', 'TestZappa', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '##', '___NL___', '# Sanity Tests', '___NL___', '##', '___NL___', '___EOS___']", "index": 396 } ]
[ { "span": "from zappa.handler import LambdaHandler, lambda_handler", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 55 } ]
[]
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_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "collections_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "lambda", "\\u", "packages_", "import_", "lambda", "\\u", "packages_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "utils_", "import_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "zap", "pa_", "._", "cli_", "import_", "Za", "ppa", "CLI_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zap", "pa_", "._", "handler_", "import_", "Lam", "bda", "Handler_", ",_", "lambda", "\\u", "handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zap", "pa_", "._", "wsgi_", "import_", "create", "\\u", "wsgi", "\\u", "request_", ",_", "common", "\\u", "log_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zap", "pa_", "._", "zap", "pa_", "import_", "Za", "ppa", "_", ",_", "ASS", "UM", "E", "\\u", "POLICY", "_", ",_", "ATTACH", "\\u", "POLICY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unittest_", "._", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "random", "\\u", "string_", "(_", "length_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "''_", "._", "join_", "(_", "random_", "._", "choice_", "(_", "string_", "._", "printable", "_", ")_", "for_", "\\u_", "in_", "range_", "(_", "length_", ")_", ")_", "\\u\\u\\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", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\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_", "#", " ", "Basic", " ", "Tests_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "Logging_", "\\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_", "#", " ", "Map", "ping", " ", "and", " ", "pattern", " ", "tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WS", "GI", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Handler_", "\\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_", "#", " ", "CLI_", "\\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_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\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_", "test\\u", "test_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "zap", "pa_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Za", "ppa", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "lambda", "\\u", "package_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "mock", " ", "the", " ", "pip", ".", "get", "\\u", "install", "ed", "\\u", "distribu", "tion", "s", "()", " ", "to", " ", "include", " ", "a", " ", "package", " ", "in", " ", "lambda", "\\u", "package", "s", " ", "so", " ", "tha", "t", " ", "the", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "zip", "ping", " ", "pre", "-", "compile", "d", " ", "package", "s", " ", "gets", " ", "called_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "named", "\\u", "tuple_", "=_", "collections_", "._", "namedtuple_", "(_", "'", "mock", "\\u", "named", "\\u", "tuple", "'_", ",_", "[_", "'", "project", "\\u", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mock", "\\u", "return", "\\u", "val_", "=_", "[_", "mock", "\\u", "named", "\\u", "tuple_", "(_", "lambda", "\\u", "packages_", "._", "keys_", "(_", ")_", "[_", "0_", "]_", ")_", "]_", "#", " ", "choose", " ", "name", " ", "of", " ", "1s", "t", " ", "package", " ", "in", " ", "lambda", "\\u", "packages_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "mock_", "._", "patch_", "(_", "'", "pip", ".", "get", "\\u", "install", "ed", "\\u", "distribu", "tion", "s", "'_", ",_", "return", "\\u", "value_", "=_", "mock", "\\u", "return", "\\u", "val_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "z_", "._", "create", "\\u", "lambda", "\\u", "zip_", "(_", "handler", "\\u", "file_", "=_", "os_", "._", "path_", "._", "realpath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "os_", "._", "path_", "._", "isfile_", "(_", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "remove_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "load", "\\u", "credentials_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "aws", "\\u", "region_", "=_", "'", "us", "-", "east", "-1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "load", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "z_", "._", "boto", "\\u", "session_", "._", "region", "\\u", "name_", ",_", "'", "us", "-", "east", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "z_", "._", "aws", "\\u", "region_", ",_", "'", "us", "-", "east", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "z_", "._", "aws", "\\u", "region_", "=_", "'", "eu", "-", "west", "-1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "profile", "\\u", "name_", "=_", "'", "default", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "load", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "z_", "._", "boto", "\\u", "session_", "._", "region", "\\u", "name_", ",_", "'", "eu", "-", "west", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "z_", "._", "aws", "\\u", "region_", ",_", "'", "eu", "-", "west", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "creds_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "AW", "S", "\\u", "ACCESS", "\\u", "KEY", "\\u", "ID", "'_", ":_", "'", "AK", "123", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "AW", "S", "\\u", "SEC", "RET", "\\u", "ACCESS", "\\u", "KEY", "'_", ":_", "'", "JK", "L4", "56", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "AW", "S", "\\u", "DEF", "AUL", "T", "\\u", "REGION", "'_", ":_", "'", "us", "-", "west", "-1", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "mock_", "._", "patch_", "._", "dict_", "(_", "'", "os", ".", "environ", "'_", ",_", "creds_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "._", "aws", "\\u", "region_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "load", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "load", "ed", "\\u", "creds_", "=_", "z_", "._", "boto", "\\u", "session_", "._", "\\u", "session_", "._", "get", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "load", "ed", "\\u", "creds_", "._", "access", "\\u", "key_", ",_", "'", "AK", "123", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "load", "ed", "\\u", "creds_", "._", "secret", "\\u", "key_", ",_", "'", "JK", "L4", "56", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "z_", "._", "boto", "\\u", "session_", "._", "region", "\\u", "name_", ",_", "'", "us", "-", "west", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "upload", "\\u", "remove", "\\u", "s3_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bucket", "\\u", "name_", "=_", "'", "test\\u", "zap", "pa", "\\u", "upload", "\\u", "s3", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zip", "\\u", "path_", "=_", "z_", "._", "create", "\\u", "lambda", "\\u", "zip_", "(_", "minif", "y_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "z_", "._", "upload", "\\u", "to", "\\u", "s3_", "(_", "zip", "\\u", "path_", ",_", "bucket", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "remove_", "(_", "zip", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s3_", "=_", "session_", "._", "resource_", "(_", "'", "s3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "will", " ", "throw", " ", "Client", "Error", " ", "with", " ", "404", " ", "if", " ", "bucket", " ", "doe", "sn", "'", "t", " ", "exist_", "\\u\\u\\uNL\\u\\u\\u_", "s3_", "._", "meta_", "._", "client_", "._", "head", "\\u", "bucket_", "(_", "Bucket_", "=_", "bucket", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "will", " ", "throw", " ", "Client", "Error", " ", "with", " ", "404", " ", "if", " ", "object", " ", "doe", "sn", "'", "t", " ", "exist_", "\\u\\u\\uNL\\u\\u\\u_", "s3_", "._", "meta_", "._", "client_", "._", "head", "\\u", "object_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Bucket_", "=_", "bucket", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Key_", "=_", "zip", "\\u", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "z_", "._", "remove", "\\u", "from", "\\u", "s3_", "(_", "zip", "\\u", "path_", ",_", "bucket", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fail_", "=_", "z_", "._", "upload", "\\u", "to", "\\u", "s3_", "(_", "'/", "tmp", "/", "this", "\\u", "isn", "t", "\\u", "real", "'_", ",_", "bucket", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "fail_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "lambda", "\\u", "function_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bucket", "\\u", "name_", "=_", "'", "lmb", "da", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zip", "\\u", "path_", "=_", "'", "Sphere", "s", "-", "dev", "-1", "454", "694", "878", ".", "zip", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "aws", "\\u", "region_", "=_", "'", "us", "-", "east", "-1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "load", "\\u", "credentials_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "12345", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "arn_", "=_", "z_", "._", "create", "\\u", "lambda", "\\u", "function_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "bucket_", "=_", "bucket", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "s3", "\\u", "key_", "=_", "zip", "\\u", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "function", "\\u", "name_", "=_", "'", "test\\u", "lmb", "da", "\\u", "function", "5", "5", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "handler_", "=_", "'", "run", "me", ".", "lambda", "\\u", "handler", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "arn_", "=_", "z_", "._", "update", "\\u", "lambda", "\\u", "function_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "bucket_", "=_", "bucket", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "s3", "\\u", "key_", "=_", "zip", "\\u", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "function", "\\u", "name_", "=_", "'", "test\\u", "lmb", "da", "\\u", "function", "5", "5", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "rollback", "\\u", "lambda", "\\u", "function", "\\u", "version_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "724", "336", "686", "645", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "function", "\\u", "name_", "=_", "'", "django", "-", "hellow", "orl", "d", "-", "unicode", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "too", "\\u", "many", "\\u", "versions_", "=_", "z_", "._", "rollback", "\\u", "lambda", "\\u", "function", "\\u", "version_", "(_", "function", "\\u", "name_", ",_", "99999_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "too", "\\u", "many", "\\u", "versions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "function", "\\u", "arn_", "=_", "z_", "._", "rollback", "\\u", "lambda", "\\u", "function", "\\u", "version_", "(_", "function", "\\u", "name_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "invoke", "\\u", "lambda", "\\u", "function_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "724", "336", "686", "645", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "function", "\\u", "name_", "=_", "'", "django", "-", "hellow", "orl", "d", "-", "unicode", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "=_", "'{", "\"", "event", "\":", " ", "\"", "hell", "o", "\"}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "z_", "._", "invoke", "\\u", "lambda", "\\u", "function_", "(_", "function", "\\u", "name_", ",_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "iam", "\\u", "roles_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arn_", "=_", "z_", "._", "create", "\\u", "iam", "\\u", "roles_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "arn_", ",_", "\"", "arn", ":", "aws", ":", "iam", "::", "123", ":", "role", "/{}\"_", "._", "format_", "(_", "z_", "._", "role", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "api", "\\u", "gateway", "\\u", "routes_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "parameter", "\\u", "depth_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "integrati", "on", "\\u", "response", "\\u", "codes_", "=_", "[_", "200_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "method", "\\u", "response", "\\u", "codes_", "=_", "[_", "200_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "http", "\\u", "methods_", "=_", "[_", "'", "GET", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "12345", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lambda", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "lambda", ":", "us", "-", "east", "-1", ":", "12345", ":", "function", ":", "hellow", "orl", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "mock_", "._", "patch_", "(_", "'", "time", ".", "time", "'_", ",_", "return", "\\u", "value_", "=_", "123.", "456_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "api", "\\u", "id_", "=_", "z_", "._", "create", "\\u", "api", "\\u", "gateway", "\\u", "routes_", "(_", "lambda", "\\u", "arn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "api", "\\u", "id_", ",_", "'", "j", "2", "7", "ida", "b9", "4", "h", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "deploy", "\\u", "api", "\\u", "gateway_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "12345", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "z_", "._", "parameter", "\\u", "depth_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "integrati", "on", "\\u", "response", "\\u", "codes_", "=_", "[_", "200_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "method", "\\u", "response", "\\u", "codes_", "=_", "[_", "200_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "http", "\\u", "methods_", "=_", "[_", "'", "GET", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lambda", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "lambda", ":", "us", "-", "east", "-1", ":", "12345", ":", "function", ":", "django", "-", "hellow", "orl", "d", "-", "unicode", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "api", "\\u", "id_", "=_", "z_", "._", "create", "\\u", "api", "\\u", "gateway", "\\u", "routes_", "(_", "lambda", "\\u", "arn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "endpoint", "\\u", "url_", "=_", "z_", "._", "deploy", "\\u", "api", "\\u", "gateway_", "(_", "api", "\\u", "id_", ",_", "\"", "test\\u", "stage", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "api", "\\u", "url_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "724", "336", "686", "645", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "z_", "._", "get", "\\u", "api", "\\u", "url_", "(_", "'", "Sphere", "s", "-", "demonstrat", "ion", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "fetch", "\\u", "logs_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "Za", "ppa", "_", "(_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "12345", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "=_", "z_", "._", "fetch", "\\u", "logs_", "(_", "'", "Sphere", "s", "-", "demonstrat", "ion", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "events_", "!=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "policy", "\\u", "json_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ensure", " ", "the", " ", "policy", " ", "docs", " ", "are", " ", "valid", " ", "JSON_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "json_", "._", "loads_", "(_", "ASS", "UM", "E", "\\u", "POLICY", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json_", "._", "loads_", "(_", "ATTACH", "\\u", "POLICY", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "logging_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "TOD", "O", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Za", "ppa", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "redirec", "t", "\\u", "pattern_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "urls_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "regular", " ", "endpoint", " ", "url_", "\\u\\u\\uNL\\u\\u\\u_", "'", "https", "://", "asd", "f1", "234", ".", "execute", "-", "api", ".", "us", "-", "east", "-1", ".", "amaz", "ona", "ws", ".", "com", "/", "env", "/", "path", "/", "to", "/", "thing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "an", " ", "external", " ", "url", " ", "(", "outsi", "de", " ", "AW", "S", ")_", "\\u\\u\\uNL\\u\\u\\u_", "'", "https", "://", "git", "hub", ".", "com", "/", "Mis", "erl", "ou", "/", "zap", "pa", "/", "issue", "s", "?", "q", "=", "is", "%", "3", "Ai", "ssu", "e", "+", "is", "%", "3", "Ac", "lose", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "local", " ", "url_", "\\u\\u\\uNL\\u\\u\\u_", "'/", "env", "/", "path", "/", "to", "/", "thing", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "code_", "in_", "[_", "'", "301", "'_", ",_", "'", "302", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pattern_", "=_", "Za", "ppa", "_", "._", "selection", "\\u", "pattern_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "url_", "in_", "test\\u", "urls_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Rege", "xp", "Matches_", "(_", "url_", ",_", "pattern_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "b64", "\\u", "pattern_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "head_", "=_", "'<!", "DOC", "TYPE", " ", "html", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "code_", "in_", "[_", "'", "400", "'_", ",_", "'", "401", "'_", ",_", "'", "402", "'_", ",_", "'", "403", "'_", ",_", "'", "404", "'_", ",_", "'", "500", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pattern_", "=_", "Za", "ppa", "_", "._", "selection", "\\u", "pattern_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "document_", "=_", "base64_", "._", "b64encode_", "(_", "head_", "+_", "code_", "+_", "random", "\\u", "string_", "(_", "50_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rege", "xp", "Matches_", "(_", "document_", ",_", "pattern_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "bad", "\\u", "code_", "in_", "[_", "'", "200", "'_", ",_", "'", "301", "'_", ",_", "'", "302", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "document_", "=_", "base64_", "._", "b64encode_", "(_", "head_", "+_", "bad", "\\u", "code_", "+_", "random", "\\u", "string_", "(_", "50_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Not", "Rege", "xp", "Matches_", "(_", "document_", ",_", "pattern_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "200", "\\u", "pattern_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pattern_", "=_", "Za", "ppa", "_", "._", "selection", "\\u", "pattern_", "(_", "'", "200", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "pattern_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "wsgi", "\\u", "event_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "body", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "header", "s", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Via", "\"_", ":_", "\"", "1.1", " ", "e", "604", "e9", "3", "4e", "919", "5a", "af", "3e", "361", "9", "5a", "dbc", "b3", "e1", "8", ".", "cloudf", "ront", ".", "net", " ", "(", "Cloud", "Front", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Accept", "-", "Lang", "ua", "ge", "\"_", ":_", "\"", "en", "-", "US", ",", "en", ";", "q", "=", "0.", "5", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Accept", "-", "Enco", "ding", "\"_", ":_", "\"", "gzip", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cloud", "Front", "-", "Is", "-", "Sma", "rt", "TV", "-", "View", "er", "\"_", ":_", "\"", "fal", "se", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cloud", "Front", "-", "Forward", "ed", "-", "Proto", "\"_", ":_", "\"", "https", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "X", "-", "Forward", "ed", "-", "For", "\"_", ":_", "\"", "109", ".8", "1.2", "09", ".1", "1", "8", ",", " ", "216", ".1", "37.", "58.", "4", "3", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cloud", "Front", "-", "View", "er", "-", "Count", "ry", "\"_", ":_", "\"", "CZ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Accept", "\"_", ":_", "\"", "text", "/", "html", ",", "applica", "tion", "/", "xh", "tml", "+", "xml", ",", "applica", "tion", "/", "xml", ";", "q", "=", "0.", "9", ",*", "/*", ";", "q", "=", "0.", "8", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "X", "-", "Forward", "ed", "-", "Proto", "\"_", ":_", "\"", "https", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "X", "-", "Am", "z", "-", "Cf", "-", "Id", "\"_", ":_", "\"", "LZ", "e", "P", "\\u", "TZ", "x", "Bg", "k", "Dt", "56", "sl", "NU", "r", "\\u", "H", "9", "CH", "u1", "Us", "5c", "qh", "m", "RS", "sw", "Oh", "1", "\\u", "3d", "EG", "pks", "5", "u", "W", "-", "g", "==\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cloud", "Front", "-", "Is", "-", "Table", "t", "-", "View", "er", "\"_", ":_", "\"", "fal", "se", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "X", "-", "Forward", "ed", "-", "Port", "\"_", ":_", "\"", "443", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cloud", "Front", "-", "Is", "-", "Mob", "ile", "-", "View", "er", "\"_", ":_", "\"", "fal", "se", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cloud", "Front", "-", "Is", "-", "Des", "kto", "p", "-", "View", "er", "\"_", ":_", "\"", "true", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Conten", "t", "-", "Type", "\"_", ":_", "\"", "applica", "tion", "/", "json", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "params", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "1", "\"_", ":_", "\"", "asd", "f1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "2", "\"_", ":_", "\"", "asd", "f2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ":_", "\"", "POST", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "query", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dead", "\"_", ":_", "\"", "beef", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "wsgi", "\\u", "path", "\\u", "info_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "no", " ", "parameter", "s", " ", "(", "site", ".", "com", "/)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "body", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "header", "s", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "params", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ":_", "\"", "GET", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "query", "\"_", ":_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"/\"_", ",_", "request_", "[_", "'", "PATH", "\\u", "INFO", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"/\"_", ",_", "request_", "[_", "'", "PATH", "\\u", "INFO", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "parameter", "s", " ", "(", "site", ".", "com", "/", "asd", "f1", "/", "asd", "f2", " ", "or", " ", "site", ".", "com", "/", "asd", "f1", "/", "asd", "f2", "/)", "_", "\\u\\u\\uNL\\u\\u\\u_", "event_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "body", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "header", "s", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "params", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "1", "\"_", ":_", "\"", "asd", "f1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "2", "\"_", ":_", "\"", "asd", "f2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ":_", "\"", "GET", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "query", "\"_", ":_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"/", "asd", "f1", "/", "asd", "f2", "/\"_", ",_", "request_", "[_", "'", "PATH", "\\u", "INFO", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"/", "asd", "f1", "/", "asd", "f2", "\"_", ",_", "request_", "[_", "'", "PATH", "\\u", "INFO", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "False_", ",_", "script", "\\u", "name_", "=_", "'", "asd", "f1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"/", "asd", "f1", "/", "asd", "f2", "\"_", ",_", "request_", "[_", "'", "PATH", "\\u", "INFO", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "wsgi", "\\u", "logging_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "body", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "header", "s", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "params", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "1", "\"_", ":_", "\"", "asd", "f1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "2", "\"_", ":_", "\"", "asd", "f2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ":_", "\"", "GET", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "query", "\"_", ":_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "environ_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response", "\\u", "tuple_", "=_", "collections_", "._", "namedtuple_", "(_", "'", "Respons", "e", "'_", ",_", "[_", "'", "status", "\\u", "code", "'_", ",_", "'", "content", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "response", "\\u", "tuple_", "(_", "200_", ",_", "'", "hell", "o", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "le_", "=_", "common", "\\u", "log_", "(_", "environ_", ",_", "response_", ",_", "response", "\\u", "time_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "le_", "=_", "common", "\\u", "log_", "(_", "environ_", ",_", "response_", ",_", "response", "\\u", "time_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "wsgi", "\\u", "multipart_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "=_", "{_", "u", "'", "body", "'_", ":_", "u", "'", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "03", "Nj", "k", "1", "Mj", "I", "4", "ND", "g0", "Nj", "c4", "MT", "c2", "NT", "gw", "Nj", "M", "w", "OT", "Y", "x", "DQ", "p", "Db", "250", "ZW", "50", "LU", "Rp", "c3", "Bv", "c2", "l", "0a", "W", "9", "u", "Oi", "Bm", "b3", "J", "t", "LW", "Rh", "d", "GE", "7", "IG", "5", "hb", "WU", "9", "Im", "15", "c3", "Ry", "a", "W", "5", "n", "Ig", "0", "KD", "Qp", "k", "ZG", "QN", "Ci", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "LS", "0", "t", "Nz", "Y", "5", "NTI", "y", "OD", "Q", "4", "ND", "Y", "3", "ODE", "3", "Nj", "U", "4", "MD", "Y", "z", "MD", "k2", "MS", "0", "t", "DQ", "o", "='_", ",_", "u", "'", "header", "s", "'_", ":_", "{_", "u", "'", "Conten", "t", "-", "Type", "'_", ":_", "u", "'", "multip", "art", "/", "form", "-", "data", ";", " ", "bound", "ary", "=-", "--------------", "------------", "769", "522", "848", "467", "817", "658", "063", "096", "1", "'_", ",_", "u", "'", "Via", "'_", ":_", "u", "'", "1.1", " ", "382", "05", "a0", "4d", "96", "d6", "018", "5e", "886", "5", "8d", "318", "5c", "cee", ".", "cloudf", "ront", ".", "net", " ", "(", "Cloud", "Front", ")'_", ",_", "u", "'", "Accept", "-", "Lang", "ua", "ge", "'_", ":_", "u", "'", "en", "-", "US", ",", "en", ";", "q", "=", "0.", "5", "'_", ",_", "u", "'", "Accept", "-", "Enco", "ding", "'_", ":_", "u", "'", "gzip", ",", " ", "deflate", ",", " ", "br", "'_", ",_", "u", "'", "Cloud", "Front", "-", "Is", "-", "Sma", "rt", "TV", "-", "View", "er", "'_", ":_", "u", "'", "fal", "se", "'_", ",_", "u", "'", "Cloud", "Front", "-", "Forward", "ed", "-", "Proto", "'_", ":_", "u", "'", "https", "'_", ",_", "u", "'", "X", "-", "Forward", "ed", "-", "For", "'_", ":_", "u", "'", "71.", "231", ".2", "7.5", "7", ",", " ", "104", ".2", "46.", "180", ".5", "1", "'_", ",_", "u", "'", "Cloud", "Front", "-", "View", "er", "-", "Count", "ry", "'_", ":_", "u", "'", "US", "'_", ",_", "u", "'", "Accept", "'_", ":_", "u", "'", "text", "/", "html", ",", "applica", "tion", "/", "xh", "tml", "+", "xml", ",", "applica", "tion", "/", "xml", ";", "q", "=", "0.", "9", ",*", "/*", ";", "q", "=", "0.", "8", "'_", ",_", "u", "'", "User", "-", "Agent", "'_", ":_", "u", "'", "Mo", "zilla", "/", "5.0", " ", "(", "Mac", "int", "osh", ";", " ", "Intel", " ", "Mac", " ", "OS", " ", "X", " ", "10.1", "0", ";", " ", "rv", ":", "45.", "0", ")", " ", "Ge", "cko", "/", "20100", "101", " ", "Fire", "fox", "/", "45.", "0", "'_", ",_", "u", "'", "Host", "'_", ":_", "u", "'", "xo", "2", "z", "7", "za", "fj", "h", ".", "execute", "-", "api", ".", "us", "-", "east", "-1", ".", "amaz", "ona", "ws", ".", "com", "'_", ",_", "u", "'", "X", "-", "Forward", "ed", "-", "Proto", "'_", ":_", "u", "'", "https", "'_", ",_", "u", "'", "Cooki", "e", "'_", ":_", "u", "'", "zap", "pa", "=", "AQ", "4", "'_", ",_", "u", "'", "Cloud", "Front", "-", "Is", "-", "Table", "t", "-", "View", "er", "'_", ":_", "u", "'", "fal", "se", "'_", ",_", "u", "'", "X", "-", "Forward", "ed", "-", "Port", "'_", ":_", "u", "'", "443", "'_", ",_", "u", "'", "Refer", "er", "'_", ":_", "u", "'", "https", "://", "xo", "8", "z", "7", "za", "fj", "h", ".", "execute", "-", "api", ".", "us", "-", "east", "-1", ".", "amaz", "ona", "ws", ".", "com", "/", "former", "/", "post", "'_", ",_", "u", "'", "Cloud", "Front", "-", "Is", "-", "Mob", "ile", "-", "View", "er", "'_", ":_", "u", "'", "fal", "se", "'_", ",_", "u", "'", "X", "-", "Am", "z", "-", "Cf", "-", "Id", "'_", ":_", "u", "'", "3", "1", "zx", "c", "Uc", "Vy", "U", "x", "BOM", "k3", "20", "yh", "5", "NO", "hi", "hn", "5", "kn", "qr", "l", "YQ", "Yp", "GG", "y", "On", "g", "KK", "w", "J", "b0", "J", "0", "BA", "Q", "=='", "_", ",_", "u", "'", "Cloud", "Front", "-", "Is", "-", "Des", "kto", "p", "-", "View", "er", "'_", ":_", "u", "'", "true", "'_", "}_", ",_", "u", "'", "params", "'_", ":_", "{_", "u", "'", "parameter", "\\u", "1", "'_", ":_", "u", "'", "post", "'_", "}_", ",_", "u", "'", "method", "'_", ":_", "u", "'", "POST", "'_", ",_", "u", "'", "query", "'_", ":_", "{_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "environ_", "=_", "create", "\\u", "wsgi", "\\u", "request_", "(_", "event_", ",_", "trail", "ing", "\\u", "slash_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response", "\\u", "tuple_", "=_", "collections_", "._", "namedtuple_", "(_", "'", "Respons", "e", "'_", ",_", "[_", "'", "status", "\\u", "code", "'_", ",_", "'", "content", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "response", "\\u", "tuple_", "(_", "200_", ",_", "'", "hell", "o", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "handler_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lh", "_", "=_", "Lam", "bda", "Handler_", "(_", "'", "test\\u", "settings", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "event_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "body", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "header", "s", "\"_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "params", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "1", "\"_", ":_", "\"", "asd", "f1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "parameter", "\\u", "2", "\"_", ":_", "\"", "asd", "f2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ":_", "\"", "GET", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "query", "\"_", ":_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lh", "_", "._", "handler_", "(_", "event_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cli", "\\u", "sanity", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zap", "pa", "\\u", "cli_", "=_", "Za", "ppa", "CLI_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cli", "\\u", "utility_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zap", "pa", "\\u", "cli_", "=_", "Za", "ppa", "CLI_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "api", "\\u", "stage_", "=_", "'", "ttt", "333", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "load", "\\u", "settings_", "(_", "'", "test\\u", "settings", ".", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "create", "\\u", "package_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "remove", "\\u", "local", "\\u", "zip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logs_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "'", "12345", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "'[", "START", " ", "Request", "Id", "]", " ", "test", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "'", "12345", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "'[", "REPORT", " ", "Request", "Id", "]", " ", "test", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "'", "12345", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "'[", "END", " ", "Request", "Id", "]", " ", "test", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "timestamp", "'_", ":_", "'", "12345", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "'", "test", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "print", "\\u", "logs_", "(_", "logs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cli", "\\u", "args_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zap", "pa", "\\u", "cli_", "=_", "Za", "ppa", "CLI_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sanit", "y_", "\\u\\u\\uNL\\u\\u\\u_", "argv_", "=_", "'-", "s", " ", "test\\u", "settings", ".", "json", " ", "der", "p", " ", "ttt", "333", "'_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "handle_", "(_", "argv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Za", "ppa", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "Tests_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "place", "bo", "\\u", "session_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "cli", "\\u", "aws_", "(_", "self_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zap", "pa", "\\u", "cli_", "=_", "Za", "ppa", "CLI_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "api", "\\u", "stage_", "=_", "'", "ttt", "333", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "load", "\\u", "settings_", "(_", "'", "test\\u", "settings", ".", "json", "'_", ",_", "session_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "zap", "pa_", "._", "cred", "ential", "s", "\\u", "arn_", "=_", "'", "arn", ":", "aws", ":", "iam", "::", "724", "336", "686", "645", ":", "role", "/", "Za", "ppa", "Lam", "bda", "Execut", "ion", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "deploy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zap", "pa", "\\u", "cli_", "._", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
dimagi/commcare-hq/corehq/form_processor/tests/test_dbcache.py
[ { "content": " def testStripHistory(self):\n case_ids = _make_some_cases(3)\n\n history_cache = self.interface.casedb_cache()\n for i, id in enumerate(case_ids):\n self.assertFalse(history_cache.in_cache(id))\n case = history_cache.get(id)\n self.assertEqual(str(i), case.my_index)\n self.assertTrue(len(case.actions) > 0)\n\n nohistory_cache = self.interface.casedb_cache(strip_history=True)\n for i, id in enumerate(case_ids):\n self.assertFalse(nohistory_cache.in_cache(id))\n case = nohistory_cache.get(id)\n self.assertEqual(str(i), case.my_index)\n self.assertTrue(len(case.actions) == 0)\n\n more_case_ids = _make_some_cases(3)\n history_cache.populate(more_case_ids)\n nohistory_cache.populate(more_case_ids)\n\n for i, id in enumerate(more_case_ids):\n self.assertTrue(history_cache.in_cache(id))\n case = history_cache.get(id)\n self.assertEqual(str(i), case.my_index)\n self.assertTrue(len(case.actions) > 0)\n\n for i, id in enumerate(more_case_ids):\n self.assertTrue(nohistory_cache.in_cache(id))\n case = nohistory_cache.get(id)\n self.assertEqual(str(i), case.my_index)\n self.assertTrue(len(case.actions) == 0)", "metadata": "root.CaseDbCacheTest.testStripHistory", "header": "['class', 'CaseDbCacheTest', '(', 'TestCase', ')', ':', '___EOS___']", "index": 101 } ]
[ { "span": "self.assertTrue(len(case.actions) > 0)", "start_line": 109, "start_column": 12, "end_line": 109, "end_column": 50 }, { "span": "self.assertTrue(len(case.actions) == 0)", "start_line": 116, "start_column": 12, "end_line": 116, "end_column": 51 }, { "span": "self.assertTrue(len(case.actions) > 0)", "start_line": 126, "start_column": 12, "end_line": 126, "end_column": 50 }, { "span": "self.assertTrue(len(case.actions) == 0)", "start_line": 132, "start_column": 12, "end_line": 132, "end_column": 51 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Case", "Db", "Cache", "Test_", "(_", "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", "Strip", "History_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "case", "\\u", "ids_", "=_", "\\u", "make", "\\u", "some", "\\u", "cases_", "(_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "histo", "ry", "\\u", "cache_", "=_", "self_", "._", "interface_", "._", "case", "db", "\\u", "cache_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "id_", "in_", "enumerate_", "(_", "case", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "histo", "ry", "\\u", "cache_", "._", "in", "\\u", "cache_", "(_", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case_", "=_", "histo", "ry", "\\u", "cache_", "._", "get_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "str_", "(_", "i_", ")_", ",_", "case_", "._", "my", "\\u", "index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "case_", "._", "actions_", ")_", ">_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "noh", "isto", "ry", "\\u", "cache_", "=_", "self_", "._", "interface_", "._", "case", "db", "\\u", "cache_", "(_", "strip", "\\u", "history_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "id_", "in_", "enumerate_", "(_", "case", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "noh", "isto", "ry", "\\u", "cache_", "._", "in", "\\u", "cache_", "(_", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case_", "=_", "noh", "isto", "ry", "\\u", "cache_", "._", "get_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "str_", "(_", "i_", ")_", ",_", "case_", "._", "my", "\\u", "index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "case_", "._", "actions_", ")_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "more", "\\u", "case", "\\u", "ids_", "=_", "\\u", "make", "\\u", "some", "\\u", "cases_", "(_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "histo", "ry", "\\u", "cache_", "._", "populate_", "(_", "more", "\\u", "case", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "noh", "isto", "ry", "\\u", "cache_", "._", "populate_", "(_", "more", "\\u", "case", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", ",_", "id_", "in_", "enumerate_", "(_", "more", "\\u", "case", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "histo", "ry", "\\u", "cache_", "._", "in", "\\u", "cache_", "(_", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case_", "=_", "histo", "ry", "\\u", "cache_", "._", "get_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "str_", "(_", "i_", ")_", ",_", "case_", "._", "my", "\\u", "index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "case_", "._", "actions_", ")_", ">_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", ",_", "id_", "in_", "enumerate_", "(_", "more", "\\u", "case", "\\u", "ids_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "noh", "isto", "ry", "\\u", "cache_", "._", "in", "\\u", "cache_", "(_", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "case_", "=_", "noh", "isto", "ry", "\\u", "cache_", "._", "get_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "str_", "(_", "i_", ")_", ",_", "case_", "._", "my", "\\u", "index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "case_", "._", "actions_", ")_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
jumoconnect/openjumo/jumodjango/miner/jobs/fetch_facebook.py
[ { "content": "#!/usr/bin/env python\n\nfrom django.core.management import setup_environ\nimport settings\nsetup_environ(settings)\n\nfrom django.db.models.loading import cache as model_cache\nmodel_cache._populate()\n\nimport facebook\n \nfrom django.db import connection\nfrom django.db.models import Q\n\nimport settings\nimport urllib2\nimport urlparse\n\nfrom fabric.api import local\nfrom org.models import Org\nfrom miner.web.crawler import WebCrawler\nfrom miner.jobs.org_social_media import OrgSocialMediaMapper, reducer\n\n\n\n\nif __name__ == '__main__':\n import dumbo\n dumbo.main(runner, starter)", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class FacebookMapper(OrgSocialMediaMapper):\n last_updated_column = 'facebook_last_fetched'\n \n \n\n \n ", "metadata": "root.FacebookMapper", "header": "['module', '___EOS___']", "index": 23 }, { "content": " def get_api(self):\n self.api = facebook.GraphAPI(settings.FACEBOOK_ACCESS_TOKEN)", "metadata": "root.FacebookMapper.get_api", "header": "['class', 'FacebookMapper', '(', 'OrgSocialMediaMapper', ')', ':', '___EOS___']", "index": 26 }, { "content": " def has_links(self, post):\n return post['type'] == 'link'", "metadata": "root.FacebookMapper.has_links", "header": "['class', 'FacebookMapper', '(', 'OrgSocialMediaMapper', ')', ':', '___EOS___']", "index": 29 }, { "content": " def extract_links(self, post):\n return [post['link'].encode('utf-8')]", "metadata": "root.FacebookMapper.extract_links", "header": "['class', 'FacebookMapper', '(', 'OrgSocialMediaMapper', ')', ':', '___EOS___']", "index": 32 }, { "content": " def default_text(self, post):\n return ' '.join([post.get('name', ''), post.get('message', ''), post.get('description', '')])", "metadata": "root.FacebookMapper.default_text", "header": "['class', 'FacebookMapper', '(', 'OrgSocialMediaMapper', ')', ':', '___EOS___']", "index": 35 }, { "content": " def get_batch(self, org, limit=200, page=1, since=None):\n params = dict(limit=limit, offset=(page-1)*limit )\n \n # This is being urlencoded in python-facebook-sdk\n # so don't include the param if it's None\n if since:\n params['since'] = since\n \n try:\n posts = self.api.get_connections(str(org.facebook_id), 'posts', fields='message,link,name,caption,description,type', **params) \n except Exception:\n return [], None, None\n \n # Can use this but doesn't really account for not fetching data twice\n paging = posts.get('paging', {})\n \n next_page = None\n \n if len(posts.get('data', [])) == limit:\n next_page = page + 1\n \n new_last_fetched_date = None\n \n if page==1:\n parsed_query_string = urlparse.parse_qs(urlparse.urlparse(paging.get('previous', '')).query)\n new_last_fetched_date = parsed_query_string.get('since', [None])[0]\n \n return posts['data'], next_page, new_last_fetched_date", "metadata": "root.FacebookMapper.get_batch", "header": "['class', 'FacebookMapper', '(', 'OrgSocialMediaMapper', ')', ':', '___EOS___']", "index": 38 }, { "content": "def runner(job):\n job.additer(FacebookMapper, reducer)", "metadata": "root.runner", "header": "['module', '___EOS___']", "index": 67 }, { "content": "def starter(program):\n tempfile_path = '/tmp/facebook'\n input_path = '/miner/search/inputs/facebook'\n output_path = '/miner/search/outputs/facebook'\n \n with open(tempfile_path, 'w') as tempfile:\n orgs = Org.objects.filter(is_active=True, facebook_id__isnull=False)[:10]\n for org in orgs:\n tempfile.write('\\t'.join([str(org.id), str(org.facebook_id), str(org.facebook_last_fetched or '')]) +'\\n')\n\n local('if hadoop fs -test -e ' + input_path +' ; then hadoop fs -rm ' + input_path + '; fi')\n local('if hadoop fs -test -e ' + output_path + ' ; then hadoop fs -rmr ' + output_path + '; fi')\n \n local('hadoop fs -copyFromLocal ' + tempfile_path + ' ' + input_path)\n\n program.addopt('input', input_path)\n program.addopt('output', output_path)", "metadata": "root.starter", "header": "['module', '___EOS___']", "index": 70 } ]
[ { "span": "from django.db import connection", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 32 }, { "span": "from django.db.models import Q", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 30 }, { "span": "import urllib2", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 14 }, { "span": "from miner.web.crawler import WebCrawler", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 40 } ]
[]
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_", "from_", "django_", "._", "core_", "._", "management_", "import_", "setup", "\\u", "environ_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "setup", "\\u", "environ_", "(_", "settings_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "loading_", "import_", "cache_", "as_", "model", "\\u", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model", "\\u", "cache_", "._", "\\u", "populate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "facebook", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "fabric_", "._", "api_", "import_", "local_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "org_", "._", "models_", "import_", "Org", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "miner", "_", "._", "web_", "._", "crawler_", "import_", "Web", "Crawler", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "miner", "_", "._", "jobs_", "._", "org", "\\u", "social", "\\u", "media_", "import_", "Org", "Soci", "al", "Media", "Mapper_", ",_", "reducer", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "dumb", "o_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dumb", "o_", "._", "main_", "(_", "runner_", ",_", "starter", "_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Face", "book", "Mapper_", "(_", "Org", "Soci", "al", "Media", "Mapper_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "\\u", "update", "d\\u", "column_", "=_", "'", "facebook", "\\u", "last", "\\u", "fetched", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Face", "book", "Mapper_", "(_", "Org", "Soci", "al", "Media", "Mapper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "api_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "api_", "=_", "facebook", "_", "._", "Graph", "API_", "(_", "settings_", "._", "FACE", "BOOK", "\\u", "ACCESS", "\\u", "TOKEN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Face", "book", "Mapper_", "(_", "Org", "Soci", "al", "Media", "Mapper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "has", "\\u", "links_", "(_", "self_", ",_", "post_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "post_", "[_", "'", "type", "'_", "]_", "==_", "'", "link", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Face", "book", "Mapper_", "(_", "Org", "Soci", "al", "Media", "Mapper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "extract", "\\u", "links_", "(_", "self_", ",_", "post_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "post_", "[_", "'", "link", "'_", "]_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Face", "book", "Mapper_", "(_", "Org", "Soci", "al", "Media", "Mapper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "default", "\\u", "text_", "(_", "self_", ",_", "post_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'", " ", "'_", "._", "join_", "(_", "[_", "post_", "._", "get_", "(_", "'", "name", "'_", ",_", "''_", ")_", ",_", "post_", "._", "get_", "(_", "'", "message", "'_", ",_", "''_", ")_", ",_", "post_", "._", "get_", "(_", "'", "description", "'_", ",_", "''_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Face", "book", "Mapper_", "(_", "Org", "Soci", "al", "Media", "Mapper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "batch_", "(_", "self_", ",_", "org_", ",_", "limit_", "=_", "200_", ",_", "page_", "=_", "1_", ",_", "since_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "dict_", "(_", "limit_", "=_", "limit_", ",_", "offset_", "=_", "(_", "page_", "-_", "1_", ")_", "*_", "limit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "bei", "ng", " ", "url", "encode", "d", " ", "in", " ", "python", "-", "facebook", "-", "sdk_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "so", " ", "don", "'", "t", " ", "include", " ", "the", " ", "param", " ", "if", " ", "it", "'", "s", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "since_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "sinc", "e", "'_", "]_", "=_", "since_", "\\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 ", " _", "posts_", "=_", "self_", "._", "api_", "._", "get", "\\u", "connections_", "(_", "str_", "(_", "org_", "._", "facebook", "\\u", "id_", ")_", ",_", "'", "posts", "'_", ",_", "fields_", "=_", "'", "message", ",", "link", ",", "name", ",", "caption", ",", "description", ",", "type", "'_", ",_", "**_", "params_", ")_", "\\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_", "[_", "]_", ",_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Can", " ", "use", " ", "this", " ", "but", " ", "doe", "sn", "'", "t", " ", "reall", "y", " ", "account", " ", "for", " ", "not", " ", "fetch", "ing", " ", "data", " ", "twi", "ce_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "paging", "_", "=_", "posts_", "._", "get_", "(_", "'", "paging", "'_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "next", "\\u", "page_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "posts_", "._", "get_", "(_", "'", "data", "'_", ",_", "[_", "]_", ")_", ")_", "==_", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "page_", "=_", "page_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "last", "\\u", "fetched", "\\u", "date_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "page_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parsed", "\\u", "query", "\\u", "string_", "=_", "urlparse_", "._", "parse", "\\u", "qs_", "(_", "urlparse_", "._", "urlparse_", "(_", "paging", "_", "._", "get_", "(_", "'", "previ", "ous", "'_", ",_", "''_", ")_", ")_", "._", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "last", "\\u", "fetched", "\\u", "date_", "=_", "parsed", "\\u", "query", "\\u", "string_", "._", "get_", "(_", "'", "sinc", "e", "'_", ",_", "[_", "None_", "]_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "posts_", "[_", "'", "data", "'_", "]_", ",_", "next", "\\u", "page_", ",_", "new", "\\u", "last", "\\u", "fetched", "\\u", "date_", "\\u\\u\\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_", "runner_", "(_", "job_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "add", "iter_", "(_", "Face", "book", "Mapper_", ",_", "reducer", "_", ")_", "\\u\\u\\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_", "starter", "_", "(_", "program_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tempfile", "\\u", "path_", "=_", "'/", "tmp", "/", "facebook", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input", "\\u", "path_", "=_", "'/", "miner", "/", "search", "/", "inputs", "/", "facebook", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output", "\\u", "path_", "=_", "'/", "miner", "/", "search", "/", "output", "s", "/", "facebook", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "tempfile", "\\u", "path_", ",_", "'", "w", "'_", ")_", "as_", "tempfile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "orgs", "_", "=_", "Org", "_", "._", "objects_", "._", "filter_", "(_", "is", "\\u", "active_", "=_", "True_", ",_", "facebook", "\\u", "id", "\\u\\u", "isnull_", "=_", "False_", ")_", "[_", ":_", "10_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "org_", "in_", "orgs", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tempfile_", "._", "write_", "(_", "'\\\\", "t", "'_", "._", "join_", "(_", "[_", "str_", "(_", "org_", "._", "id_", ")_", ",_", "str_", "(_", "org_", "._", "facebook", "\\u", "id_", ")_", ",_", "str_", "(_", "org_", "._", "facebook", "\\u", "last", "\\u", "fetched", "_", "or_", "''_", ")_", "]_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "local_", "(_", "'", "if", " ", "hadoop", " ", "fs", " ", "-", "test", " ", "-", "e", " ", "'_", "+_", "input", "\\u", "path_", "+_", "'", " ", ";", " ", " ", "then", " ", "hadoop", " ", "fs", " ", "-", "rm", " ", "'_", "+_", "input", "\\u", "path_", "+_", "';", " ", "fi", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "local_", "(_", "'", "if", " ", "hadoop", " ", "fs", " ", "-", "test", " ", "-", "e", " ", "'_", "+_", "output", "\\u", "path_", "+_", "'", " ", ";", " ", " ", "then", " ", "hadoop", " ", "fs", " ", "-", "rm", "r", " ", "'_", "+_", "output", "\\u", "path_", "+_", "';", " ", "fi", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "local_", "(_", "'", "hadoop", " ", "fs", " ", "-", "copy", "Fro", "m", "Local", " ", "'_", "+_", "tempfile", "\\u", "path_", "+_", "'", " ", "'_", "+_", "input", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "program_", "._", "addop", "t_", "(_", "'", "input", "'_", ",_", "input", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "program_", "._", "addop", "t_", "(_", "'", "output", "'_", ",_", "output", "\\u", "path_", ")_", "\\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,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