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 | CybOXProject/python-cybox/cybox/test/objects/socket_address_test.py | [
{
"content": "# Copyright (c) 2015, The MITRE Corporation. All rights reserved.\n# See LICENSE.txt for complete terms.\n\nimport unittest\n\nfrom mixbox.vendor.six import u\n\nfrom cybox.objects.address_object import Address\nfrom cybox.objects.socket_address_object import SocketAddress\nimport cybox.test\nfrom cybox.test.objects import ObjectTestCase\n\n\n\n\nif __name__ == \"__main__\":\n unittest.main()\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class TestSocketAddress(ObjectTestCase, unittest.TestCase):\n object_type = \"SocketAddressObjectType\"\n klass = SocketAddress\n\n _full_dict = {\n # Normally only one out of IP_Address and Hostname is allowed,\n # but we don't enforce that, so we can test both here.\n 'ip_address': {\n 'category': Address.CAT_IPV4,\n 'address_value': u(\"192.168.1.1\"),\n 'xsi:type': \"AddressObjectType\"\n },\n 'hostname': {\n 'is_domain_name': True,\n 'hostname_value': u(\"www.example.com\"),\n 'xsi:type': \"HostnameObjectType\"\n },\n 'port': {\n 'port_value': 80,\n 'layer4_protocol': u(\"TCP\"),\n 'xsi:type': \"PortObjectType\"\n },\n 'xsi:type': object_type,\n }",
"metadata": "root.TestSocketAddress",
"header": "['module', '___EOS___']",
"index": 13
}
]
| [
{
"span": "import cybox.test",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 17
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"201",
"5",
",",
" ",
"The",
" ",
"MIT",
"RE",
" ",
"Cor",
"porat",
"ion",
".",
" ",
"All",
" ",
"rights",
" ",
"reserve",
"d",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"See",
" ",
"LICENSE",
".",
"txt",
" ",
"for",
" ",
"complete",
" ",
"term",
"s",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"mix",
"box_",
"._",
"vendor_",
"._",
"six_",
"import_",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"cy",
"box_",
"._",
"objects_",
"._",
"address",
"\\u",
"object_",
"import_",
"Address_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cy",
"box_",
"._",
"objects_",
"._",
"socket",
"\\u",
"address",
"\\u",
"object_",
"import_",
"Sock",
"et",
"Address_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"cy",
"box_",
"._",
"test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cy",
"box_",
"._",
"test_",
"._",
"objects_",
"import_",
"Object",
"Test",
"Case_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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 ",
" _",
"unittest_",
"._",
"main_",
"(_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Test",
"Sock",
"et",
"Address_",
"(_",
"Object",
"Test",
"Case_",
",_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"object\\u",
"type_",
"=_",
"\"",
"Sock",
"et",
"Address",
"Object",
"Type",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"klass_",
"=_",
"Sock",
"et",
"Address_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"full",
"\\u",
"dict_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Normal",
"ly",
" ",
"only",
" ",
"one",
" ",
"out",
" ",
"of",
" ",
"IP",
"\\u",
"Address",
" ",
"and",
" ",
"Host",
"name",
" ",
"is",
" ",
"allow",
"ed",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"but",
" ",
"we",
" ",
"don",
"'",
"t",
" ",
"enforce",
" ",
"tha",
"t",
",",
" ",
"so",
" ",
"we",
" ",
"can",
" ",
"test",
" ",
"bot",
"h",
" ",
"here",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ip",
"\\u",
"address",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"category",
"'_",
":_",
"Address_",
"._",
"CAT",
"\\u",
"IP",
"V4",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"address",
"\\u",
"value",
"'_",
":_",
"u_",
"(_",
"\"",
"192",
".1",
"68.",
"1.1",
"\"_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"xsi",
":",
"type",
"'_",
":_",
"\"",
"Address",
"Object",
"Type",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"host",
"name",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"is",
"\\u",
"domain",
"\\u",
"name",
"'_",
":_",
"True_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"host",
"name",
"\\u",
"value",
"'_",
":_",
"u_",
"(_",
"\"",
"www",
".",
"example",
".",
"com",
"\"_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"xsi",
":",
"type",
"'_",
":_",
"\"",
"Host",
"name",
"Object",
"Type",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"port",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"port",
"\\u",
"value",
"'_",
":_",
"80_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"layer",
"4",
"\\u",
"protoc",
"ol",
"'_",
":_",
"u_",
"(_",
"\"",
"TC",
"P",
"\"_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"xsi",
":",
"type",
"'_",
":_",
"\"",
"Port",
"Object",
"Type",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"xsi",
":",
"type",
"'_",
":_",
"object\\u",
"type_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused import | openelections/openelections-core/openelex/us/ar/datasource.py | [
{
"content": "import os.path\nimport re\nimport urlparse\n\nfrom bs4 import BeautifulSoup\nimport requests\nimport clarify\nimport unicodecsv\n\nfrom openelex.base.datasource import BaseDatasource\nfrom openelex.lib import build_github_url\nfrom openelex.lib.text import ocd_type_id\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class Datasource(BaseDatasource):\n RESULTS_PORTAL_URL = \"http://www.sos.arkansas.gov/electionresults/index.php\"\n CLARITY_PORTAL_URL = \"http://results.enr.clarityelections.com/AR/\"\n\n # There aren't precinct-level results for these, just a CSV file with\n # summary data for the county.\n no_precinct_urls = [\n \"http://results.enr.clarityelections.com/AR/Columbia/42858/111213/en/summary.html\",\n \"http://results.enr.clarityelections.com/AR/Ouachita/42896/112694/en/summary.html\",\n \"http://results.enr.clarityelections.com/AR/Union/42914/112664/en/summary.html\",\n ]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
"metadata": "root.Datasource",
"header": "['module', '___EOS___']",
"index": 14
},
{
"content": " def mappings(self, year=None):\n mappings = []\n for yr, elecs in self.elections(year).items():\n mappings.extend(self._build_metadata(yr, elecs))\n return mappings",
"metadata": "root.Datasource.mappings",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 26
},
{
"content": " def target_urls(self, year=None):\n return [item['raw_url'] for item in self.mappings(year)]",
"metadata": "root.Datasource.target_urls",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 32
},
{
"content": " def filename_url_pairs(self, year=None):\n return [(item['generated_filename'], self._url_for_fetch(item))\n for item in self.mappings(year)]",
"metadata": "root.Datasource.filename_url_pairs",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 35
},
{
"content": " def unprocessed_filename_url_pairs(self, year=None):\n return [(item['generated_filename'].replace(\".csv\", \".pdf\"), item['raw_url'])\n for item in self.mappings(year)\n if 'pre_processed_url' in item]",
"metadata": "root.Datasource.unprocessed_filename_url_pairs",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 39
},
{
"content": " def mappings_for_url(self, url):\n return [mapping for mapping in self.mappings() if mapping['raw_url'] == url]",
"metadata": "root.Datasource.mappings_for_url",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 44
},
{
"content": " def _build_metadata(self, year, elections):\n meta_entries = []\n for election in elections:\n meta_entries.extend(self._build_election_metadata(election))\n return meta_entries",
"metadata": "root.Datasource._build_metadata",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 47
},
{
"content": " def _build_election_metadata(self, election):\n \"\"\"\n Return a list of metadata entries for a single election.\n \"\"\"\n slug = election['slug']\n link = election['direct_links'][0]\n\n if slug == 'ar-2000-11-07-general':\n return self._build_election_metadata_2000_general(election)\n elif slug in ('ar-2000-11-07-special-general',\n 'ar-2001-09-25-special-primary',\n 'ar-2001-10-16-special-primary-runoff',\n 'ar-2001-11-20-special-general'):\n return self._build_election_metadata_zipped_special(election)\n elif link.startswith(self.CLARITY_PORTAL_URL):\n return self._build_election_metadata_clarity(election)\n else:\n return self._build_election_metadata_default(election)",
"metadata": "root.Datasource._build_election_metadata",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 53
},
{
"content": " def _build_election_metadata_default(self, election):\n link = election['direct_links'][0]\n filename_kwargs = {}\n\n if link.startswith(self.RESULTS_PORTAL_URL):\n # Report portal results are precinct-level\n filename_kwargs['reporting_level'] = 'precinct'\n # And the format is tab-delimited text\n filename_kwargs['extension'] = '.tsv'\n\n generated_filename = self._standardized_filename(election, **filename_kwargs)\n mapping = {\n \"generated_filename\": generated_filename,\n \"raw_url\": link,\n \"ocd_id\": 'ocd-division/country:us/state:ar',\n \"name\": 'Arkansas',\n \"election\": election['slug']\n }\n\n if \"2002\" in election['slug']:\n generated_filename = generated_filename.replace('.pdf', '.csv')\n mapping['pre_processed_url'] = build_github_url(self.state,\n generated_filename)\n mapping['generated_filename'] = generated_filename\n\n return [mapping]",
"metadata": "root.Datasource._build_election_metadata_default",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 72
},
{
"content": " def _build_election_metadata_2000_general(self, election):\n meta_entries = []\n for county in self._counties():\n county_name = county['name']\n filename = self._standardized_filename(election,\n jurisdiction=county_name, reporting_level='precinct',\n extension='.txt')\n raw_extracted_filename = self._raw_extracted_filename_2000_general(county_name)\n meta_entries.append({\n 'generated_filename': filename,\n 'raw_url': election['direct_links'][0],\n 'raw_extracted_filename': raw_extracted_filename,\n 'ocd_id': county['ocd_id'],\n 'name': county_name,\n 'election': election['slug'],\n })\n return meta_entries",
"metadata": "root.Datasource._build_election_metadata_2000_general",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 99
},
{
"content": " def _build_election_metadata_zipped_special(self, election):\n meta_entries = []\n url_paths = self._url_paths_for_election(election['slug'])\n for path in url_paths:\n filename_kwargs = {\n 'reporting_level': path['reporting_level'],\n 'extension': '.txt',\n 'office': path['office'],\n 'office_district': path['district'],\n }\n if path['reporting_level'] == 'precinct':\n filename_kwargs['jurisdiction'] = path['jurisdiction']\n jurisdiction = path['jurisdiction']\n ocd_id = 'ocd-division/country:us/state:ar/county:{}'.format(ocd_type_id(jurisdiction))\n else:\n jurisdiction = 'Arkansas'\n ocd_id = 'ocd-division/country:us/state:ar'\n filename = self._standardized_filename(election, **filename_kwargs)\n meta_entries.append({\n 'generated_filename': filename,\n 'raw_url': path['url'],\n 'raw_extracted_filename': path['raw_extracted_filename'],\n 'ocd_id': ocd_id,\n 'name': jurisdiction,\n 'election': election['slug'],\n })\n return meta_entries",
"metadata": "root.Datasource._build_election_metadata_zipped_special",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 117
},
{
"content": " def _raw_extracted_filename_2000_general(self, county_name):\n county_part = county_name + \" County\"\n county_part = county_part.upper().replace(' ', '')\n return \"cty{}.txt\".format(county_part[:7])",
"metadata": "root.Datasource._raw_extracted_filename_2000_general",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 146
},
{
"content": " def _build_election_metadata_clarity(self, election, fmt=\"xml\"):\n \"\"\"\n Return metadata entries for election results provided by the Clarity\n system.\n\n These results seem to be for elections starting in 2012.\n\n Keyword Arguments:\n\n * fmt - Format of results file. Can be \"xls\", \"txt\" or \"xml\".\n Default is \"xml\".\n \"\"\"\n base_url = election['direct_links'][0]\n jurisdiction = clarity.Jurisdiction(url=base_url, level='state')\n return self._build_election_metadata_clarity_county(election, fmt, jurisdiction) +\\\n self._build_election_metadata_clarity_precinct(election, fmt, jurisdiction)",
"metadata": "root.Datasource._build_election_metadata_clarity",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 152
},
{
"content": " def _build_election_metadata_clarity_county(self, election, fmt, jurisdiction):\n\n return [{\n \"generated_filename\": self._standardized_filename(election,\n reporting_level='county', extension='.'+fmt),\n \"raw_extracted_filename\": \"detail.{}\".format(fmt),\n \"raw_url\": jurisdiction.report_url(fmt),\n \"ocd_id\": 'ocd-division/country:us/state:ar',\n \"name\": 'Arkansas',\n \"election\": election['slug']\n }]",
"metadata": "root.Datasource._build_election_metadata_clarity_county",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 169
},
{
"content": " def _build_election_metadata_clarity_precinct(self, election, fmt, jurisdiction):\n meta_entries = []\n for path in self._clarity_precinct_url_paths(election, fmt, jurisdiction):\n jurisdiction_name = path['jurisdiction']\n ocd_id = 'ocd-division/country:us/state:ar/county:{}'.format(ocd_type_id(jurisdiction_name))\n filename = self._standardized_filename(election,\n jurisdiction=jurisdiction_name, reporting_level='precinct',\n extension='.'+fmt)\n meta_entries.append({\n \"generated_filename\": filename,\n \"raw_extracted_filename\": \"detail.{}\".format(fmt),\n \"raw_url\": path['url'],\n \"ocd_id\": ocd_id,\n \"name\": jurisdiction_name,\n \"election\": election['slug'],\n })\n return meta_entries",
"metadata": "root.Datasource._build_election_metadata_clarity_precinct",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 181
},
{
"content": " def _clarity_precinct_url_paths_filename(self, election):\n filename = self._standardized_filename(election, ['url_paths'],\n reporting_level='precinct', extension='.csv')\n return os.path.join(self.mappings_dir, filename)",
"metadata": "root.Datasource._clarity_precinct_url_paths_filename",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 199
},
{
"content": " def _clarity_precinct_url_paths(self, election, fmt, jurisdiction):\n url_paths_filename = self._clarity_precinct_url_paths_filename(election)\n if os.path.exists(url_paths_filename):\n return self._url_paths(url_paths_filename)\n\n url_paths = []\n for subjurisdiction in jurisdiction.get_subjurisdictions():\n if subjurisdiction.url not in self.no_precinct_urls:\n url_paths.append({\n 'date': election['start_date'],\n 'office': '',\n 'race_type': election['race_type'],\n 'party': '',\n 'special': election['special'],\n 'url': subjurisdiction.report_url(fmt),\n 'reporting_level': 'precinct',\n 'jurisdiction': subjurisdiction.name,\n })\n\n with open(url_paths_filename, 'wb') as f:\n fieldnames = ['date', 'office', 'race_type', 'party',\n 'special', 'url', 'reporting_level', 'jurisdiction']\n writer = unicodecsv.DictWriter(f, fieldnames)\n writer.writeheader()\n writer.writerows(url_paths)\n\n return url_paths",
"metadata": "root.Datasource._clarity_precinct_url_paths",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 204
},
{
"content": " def _url_for_fetch(self, mapping):\n if 'pre_processed_url' in mapping:\n return mapping['pre_processed_url']\n else:\n return mapping['raw_url']",
"metadata": "root.Datasource._url_for_fetch",
"header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___EOS___']",
"index": 232
}
]
| [
{
"span": "import re",
"start_line": 1,
"start_column": 0,
"end_line": 1,
"end_column": 9
},
{
"span": "import urlparse",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 15
},
{
"span": "from bs4 import BeautifulSoup",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 29
},
{
"span": "import requests",
"start_line": 5,
"start_column": 0,
"end_line": 5,
"end_column": 15
},
{
"span": "import clarify",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 14
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"os_",
"._",
"path_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"urlparse_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"bs4_",
"import_",
"Bea",
"uti",
"ful",
"Soup_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"requests_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"clari",
"fy_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"unicode",
"csv_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"opene",
"lex_",
"._",
"base_",
"._",
"datasource_",
"import_",
"Base",
"Datas",
"ource_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"opene",
"lex_",
"._",
"lib_",
"import_",
"build",
"\\u",
"git",
"hub",
"\\u",
"url_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"opene",
"lex_",
"._",
"lib_",
"._",
"text_",
"import_",
"oc",
"d\\u",
"type",
"\\u",
"id_",
"\\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_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"RESULTS",
"\\u",
"PORT",
"AL",
"\\u",
"URL_",
"=_",
"\"",
"http",
"://",
"www",
".",
"sos",
".",
"ark",
"ans",
"as",
".",
"gov",
"/",
"election",
"results",
"/",
"index",
".",
"php",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"CLA",
"RIT",
"Y",
"\\u",
"PORT",
"AL",
"\\u",
"URL_",
"=_",
"\"",
"http",
"://",
"results",
".",
"enr",
".",
"clari",
"ty",
"election",
"s",
".",
"com",
"/",
"AR",
"/\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"There",
" ",
"are",
"n",
"'",
"t",
" ",
"preci",
"nct",
"-",
"level",
" ",
"results",
" ",
"for",
" ",
"these",
",",
" ",
"just",
" ",
"a",
" ",
"CSV",
" ",
"file",
" ",
"with_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"summar",
"y",
" ",
"data",
" ",
"for",
" ",
"the",
" ",
"county",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"no",
"\\u",
"preci",
"nct",
"\\u",
"urls_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"http",
"://",
"results",
".",
"enr",
".",
"clari",
"ty",
"election",
"s",
".",
"com",
"/",
"AR",
"/",
"Colum",
"bi",
"a",
"/",
"4285",
"8",
"/",
"1112",
"13",
"/",
"en",
"/",
"summar",
"y",
".",
"html",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"http",
"://",
"results",
".",
"enr",
".",
"clari",
"ty",
"election",
"s",
".",
"com",
"/",
"AR",
"/",
"Ou",
"achi",
"ta",
"/",
"428",
"96",
"/",
"112",
"694",
"/",
"en",
"/",
"summar",
"y",
".",
"html",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"http",
"://",
"results",
".",
"enr",
".",
"clari",
"ty",
"election",
"s",
".",
"com",
"/",
"AR",
"/",
"Uni",
"on",
"/",
"429",
"14",
"/",
"112",
"664",
"/",
"en",
"/",
"summar",
"y",
".",
"html",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"mappings_",
"(_",
"self_",
",_",
"year_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"mappings_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"yr_",
",_",
"elec",
"s_",
"in_",
"self_",
"._",
"election",
"s_",
"(_",
"year_",
")_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"mappings_",
"._",
"extend_",
"(_",
"self_",
"._",
"\\u",
"build",
"\\u",
"metadata_",
"(_",
"yr_",
",_",
"elec",
"s_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"mappings_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"target",
"\\u",
"urls_",
"(_",
"self_",
",_",
"year_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"[_",
"item_",
"[_",
"'",
"raw",
"\\u",
"url",
"'_",
"]_",
"for_",
"item_",
"in_",
"self_",
"._",
"mappings_",
"(_",
"year_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"filename",
"\\u",
"url",
"\\u",
"pairs_",
"(_",
"self_",
",_",
"year_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"[_",
"(_",
"item_",
"[_",
"'",
"generat",
"ed",
"\\u",
"filename",
"'_",
"]_",
",_",
"self_",
"._",
"\\u",
"url",
"\\u",
"for",
"\\u",
"fetch_",
"(_",
"item_",
")_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"item_",
"in_",
"self_",
"._",
"mappings_",
"(_",
"year_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"unprocess",
"ed",
"\\u",
"filename",
"\\u",
"url",
"\\u",
"pairs_",
"(_",
"self_",
",_",
"year_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"[_",
"(_",
"item_",
"[_",
"'",
"generat",
"ed",
"\\u",
"filename",
"'_",
"]_",
"._",
"replace_",
"(_",
"\".",
"csv",
"\"_",
",_",
"\".",
"pdf",
"\"_",
")_",
",_",
"item_",
"[_",
"'",
"raw",
"\\u",
"url",
"'_",
"]_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"item_",
"in_",
"self_",
"._",
"mappings_",
"(_",
"year_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"'",
"pre",
"\\u",
"process",
"ed",
"\\u",
"url",
"'_",
"in_",
"item_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"mapping",
"s",
"\\u",
"for",
"\\u",
"url_",
"(_",
"self_",
",_",
"url_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"[_",
"mapping_",
"for_",
"mapping_",
"in_",
"self_",
"._",
"mappings_",
"(_",
")_",
"if_",
"mapping_",
"[_",
"'",
"raw",
"\\u",
"url",
"'_",
"]_",
"==_",
"url_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"metadata_",
"(_",
"self_",
",_",
"year_",
",_",
"election",
"s_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"meta",
"\\u",
"entries_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"election_",
"in_",
"election",
"s_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"meta",
"\\u",
"entries_",
"._",
"extend_",
"(_",
"self_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata_",
"(_",
"election_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"meta",
"\\u",
"entries_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata_",
"(_",
"self_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"a",
" ",
"list",
" ",
"of",
" ",
"metadata",
" ",
"entri",
"es",
" ",
"for",
" ",
"a",
" ",
"single",
" ",
"election",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"slug_",
"=_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"link_",
"=_",
"election_",
"[_",
"'",
"direct",
"\\u",
"link",
"s",
"'_",
"]_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"slug_",
"==_",
"'",
"ar",
"-",
"2000",
"-1",
"1",
"-0",
"7",
"-",
"genera",
"l",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"2000",
"\\u",
"general_",
"(_",
"election_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"slug_",
"in_",
"(_",
"'",
"ar",
"-",
"2000",
"-1",
"1",
"-0",
"7",
"-",
"special",
"-",
"genera",
"l",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ar",
"-",
"200",
"1",
"-0",
"9",
"-",
"25",
"-",
"special",
"-",
"primary",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ar",
"-",
"200",
"1",
"-1",
"0",
"-1",
"6",
"-",
"special",
"-",
"primary",
"-",
"run",
"off",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ar",
"-",
"200",
"1",
"-1",
"1",
"-",
"20",
"-",
"special",
"-",
"genera",
"l",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"zipped",
"\\u",
"special_",
"(_",
"election_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"link_",
"._",
"startswith_",
"(_",
"self_",
"._",
"CLA",
"RIT",
"Y",
"\\u",
"PORT",
"AL",
"\\u",
"URL_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"clari",
"ty_",
"(_",
"election_",
")_",
"\\u\\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_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"default_",
"(_",
"election_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\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",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"default_",
"(_",
"self_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"link_",
"=_",
"election_",
"[_",
"'",
"direct",
"\\u",
"link",
"s",
"'_",
"]_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"filename",
"\\u",
"kwargs_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"link_",
"._",
"startswith_",
"(_",
"self_",
"._",
"RESULTS",
"\\u",
"PORT",
"AL",
"\\u",
"URL_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Report",
" ",
"portal",
" ",
"results",
" ",
"are",
" ",
"preci",
"nct",
"-",
"level_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"filename",
"\\u",
"kwargs_",
"[_",
"'",
"reporting",
"\\u",
"level",
"'_",
"]_",
"=_",
"'",
"preci",
"nct",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"And",
" ",
"the",
" ",
"format",
" ",
"is",
" ",
"tab",
"-",
"delim",
"ited",
" ",
"text_",
"\\u\\u\\uNL\\u\\u\\u_",
"filename",
"\\u",
"kwargs_",
"[_",
"'",
"extensi",
"on",
"'_",
"]_",
"=_",
"'.",
"tsv",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"generat",
"ed",
"\\u",
"filename_",
"=_",
"self_",
"._",
"\\u",
"standardize",
"d\\u",
"filename_",
"(_",
"election_",
",_",
"**_",
"filename",
"\\u",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"mapping_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"generat",
"ed",
"\\u",
"filename",
"\"_",
":_",
"generat",
"ed",
"\\u",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"raw",
"\\u",
"url",
"\"_",
":_",
"link_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"oc",
"d\\u",
"id",
"\"_",
":_",
"'",
"oc",
"d",
"-",
"divisi",
"on",
"/",
"countr",
"y",
":",
"us",
"/",
"state",
":",
"ar",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"name",
"\"_",
":_",
"'",
"Ar",
"kan",
"sas",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"election",
"\"_",
":_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"\"",
"2002",
"\"_",
"in_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"generat",
"ed",
"\\u",
"filename_",
"=_",
"generat",
"ed",
"\\u",
"filename_",
"._",
"replace_",
"(_",
"'.",
"pdf",
"'_",
",_",
"'.",
"csv",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"mapping_",
"[_",
"'",
"pre",
"\\u",
"process",
"ed",
"\\u",
"url",
"'_",
"]_",
"=_",
"build",
"\\u",
"git",
"hub",
"\\u",
"url_",
"(_",
"self_",
"._",
"state_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"generat",
"ed",
"\\u",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"mapping_",
"[_",
"'",
"generat",
"ed",
"\\u",
"filename",
"'_",
"]_",
"=_",
"generat",
"ed",
"\\u",
"filename_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"[_",
"mapping_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"2000",
"\\u",
"general_",
"(_",
"self_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"meta",
"\\u",
"entries_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"county",
"_",
"in_",
"self_",
"._",
"\\u",
"counti",
"es_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"county",
"\\u",
"name_",
"=_",
"county",
"_",
"[_",
"'",
"name",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"filename_",
"=_",
"self_",
"._",
"\\u",
"standardize",
"d\\u",
"filename_",
"(_",
"election_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"jur",
"isdi",
"ction_",
"=_",
"county",
"\\u",
"name_",
",_",
"reporting",
"\\u",
"level_",
"=_",
"'",
"preci",
"nct",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extension_",
"=_",
"'.",
"txt",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raw",
"\\u",
"extracted",
"\\u",
"filename_",
"=_",
"self_",
"._",
"\\u",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"\\u",
"2000",
"\\u",
"general_",
"(_",
"county",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"meta",
"\\u",
"entries_",
"._",
"append_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"generat",
"ed",
"\\u",
"filename",
"'_",
":_",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"raw",
"\\u",
"url",
"'_",
":_",
"election_",
"[_",
"'",
"direct",
"\\u",
"link",
"s",
"'_",
"]_",
"[_",
"0_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"'_",
":_",
"raw",
"\\u",
"extracted",
"\\u",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"oc",
"d\\u",
"id",
"'_",
":_",
"county",
"_",
"[_",
"'",
"oc",
"d\\u",
"id",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"'_",
":_",
"county",
"\\u",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"meta",
"\\u",
"entries_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"zipped",
"\\u",
"special_",
"(_",
"self_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"meta",
"\\u",
"entries_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"url",
"\\u",
"paths_",
"=_",
"self_",
"._",
"\\u",
"url",
"\\u",
"path",
"s",
"\\u",
"for",
"\\u",
"election_",
"(_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"path_",
"in_",
"url",
"\\u",
"paths_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"filename",
"\\u",
"kwargs_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"reporting",
"\\u",
"level",
"'_",
":_",
"path_",
"[_",
"'",
"reporting",
"\\u",
"level",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"extensi",
"on",
"'_",
":_",
"'.",
"txt",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"office",
"'_",
":_",
"path_",
"[_",
"'",
"office",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"office",
"\\u",
"district",
"'_",
":_",
"path_",
"[_",
"'",
"district",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"path_",
"[_",
"'",
"reporting",
"\\u",
"level",
"'_",
"]_",
"==_",
"'",
"preci",
"nct",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"filename",
"\\u",
"kwargs_",
"[_",
"'",
"jur",
"isdi",
"ction",
"'_",
"]_",
"=_",
"path_",
"[_",
"'",
"jur",
"isdi",
"ction",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"jur",
"isdi",
"ction_",
"=_",
"path_",
"[_",
"'",
"jur",
"isdi",
"ction",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"oc",
"d\\u",
"id_",
"=_",
"'",
"oc",
"d",
"-",
"divisi",
"on",
"/",
"countr",
"y",
":",
"us",
"/",
"state",
":",
"ar",
"/",
"county",
":{}'_",
"._",
"format_",
"(_",
"oc",
"d\\u",
"type",
"\\u",
"id_",
"(_",
"jur",
"isdi",
"ction_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"jur",
"isdi",
"ction_",
"=_",
"'",
"Ar",
"kan",
"sas",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"oc",
"d\\u",
"id_",
"=_",
"'",
"oc",
"d",
"-",
"divisi",
"on",
"/",
"countr",
"y",
":",
"us",
"/",
"state",
":",
"ar",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"filename_",
"=_",
"self_",
"._",
"\\u",
"standardize",
"d\\u",
"filename_",
"(_",
"election_",
",_",
"**_",
"filename",
"\\u",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"meta",
"\\u",
"entries_",
"._",
"append_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"generat",
"ed",
"\\u",
"filename",
"'_",
":_",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"raw",
"\\u",
"url",
"'_",
":_",
"path_",
"[_",
"'",
"url",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"'_",
":_",
"path_",
"[_",
"'",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"oc",
"d\\u",
"id",
"'_",
":_",
"oc",
"d\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"'_",
":_",
"jur",
"isdi",
"ction_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"meta",
"\\u",
"entries_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"\\u",
"2000",
"\\u",
"general_",
"(_",
"self_",
",_",
"county",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"county",
"\\u",
"part_",
"=_",
"county",
"\\u",
"name_",
"+_",
"\"",
" ",
"Count",
"y",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"county",
"\\u",
"part_",
"=_",
"county",
"\\u",
"part_",
"._",
"upper_",
"(_",
")_",
"._",
"replace_",
"(_",
"'",
" ",
"'_",
",_",
"''_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\"",
"ct",
"y",
"{}.",
"txt",
"\"_",
"._",
"format_",
"(_",
"county",
"\\u",
"part_",
"[_",
":_",
"7_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"clari",
"ty_",
"(_",
"self_",
",_",
"election_",
",_",
"fmt_",
"=_",
"\"",
"xml",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"metadata",
" ",
"entri",
"es",
" ",
"for",
" ",
"election",
" ",
"results",
" ",
"provided",
" ",
"by",
" ",
"the",
" ",
"Clar",
"it",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"system",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"The",
"se",
" ",
"results",
" ",
"see",
"m",
" ",
"to",
" ",
"be",
" ",
"for",
" ",
"election",
"s",
" ",
"startin",
"g",
" ",
"in",
" ",
"2012",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Key",
"word",
" ",
"Arg",
"ument",
"s",
":",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"*",
" ",
"fmt",
" ",
"-",
" ",
"Format",
" ",
"of",
" ",
"results",
" ",
"file",
".",
" ",
" ",
"Can",
" ",
"be",
" ",
"\"",
"xls",
"\",",
" ",
"\"",
"txt",
"\"",
" ",
"or",
" ",
"\"",
"xml",
"\".\\",
"10",
";",
" ",
" ",
" ",
" ",
"Default",
" ",
"is",
" ",
"\"",
"xml",
"\".\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"base",
"\\u",
"url_",
"=_",
"election_",
"[_",
"'",
"direct",
"\\u",
"link",
"s",
"'_",
"]_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"jur",
"isdi",
"ction_",
"=_",
"clari",
"ty_",
"._",
"Ju",
"ris",
"diction",
"_",
"(_",
"url_",
"=_",
"base",
"\\u",
"url_",
",_",
"level_",
"=_",
"'",
"state",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"clari",
"ty",
"\\u",
"county",
"_",
"(_",
"election_",
",_",
"fmt_",
",_",
"jur",
"isdi",
"ction_",
")_",
"+_",
"self_",
"._",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"clari",
"ty",
"\\u",
"preci",
"nct",
"_",
"(_",
"election_",
",_",
"fmt_",
",_",
"jur",
"isdi",
"ction_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"clari",
"ty",
"\\u",
"county",
"_",
"(_",
"self_",
",_",
"election_",
",_",
"fmt_",
",_",
"jur",
"isdi",
"ction_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"[_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"generat",
"ed",
"\\u",
"filename",
"\"_",
":_",
"self_",
"._",
"\\u",
"standardize",
"d\\u",
"filename_",
"(_",
"election_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"reporting",
"\\u",
"level_",
"=_",
"'",
"county",
"'_",
",_",
"extension_",
"=_",
"'.'_",
"+_",
"fmt_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"\"_",
":_",
"\"",
"deta",
"il",
".{}",
"\"_",
"._",
"format_",
"(_",
"fmt_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"raw",
"\\u",
"url",
"\"_",
":_",
"jur",
"isdi",
"ction_",
"._",
"report",
"\\u",
"url_",
"(_",
"fmt_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"oc",
"d\\u",
"id",
"\"_",
":_",
"'",
"oc",
"d",
"-",
"divisi",
"on",
"/",
"countr",
"y",
":",
"us",
"/",
"state",
":",
"ar",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"name",
"\"_",
":_",
"'",
"Ar",
"kan",
"sas",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"election",
"\"_",
":_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"build",
"\\u",
"election",
"\\u",
"metadata",
"\\u",
"clari",
"ty",
"\\u",
"preci",
"nct",
"_",
"(_",
"self_",
",_",
"election_",
",_",
"fmt_",
",_",
"jur",
"isdi",
"ction_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"meta",
"\\u",
"entries_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"path_",
"in_",
"self_",
"._",
"\\u",
"clari",
"ty",
"\\u",
"preci",
"nct",
"\\u",
"url",
"\\u",
"paths_",
"(_",
"election_",
",_",
"fmt_",
",_",
"jur",
"isdi",
"ction_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"jur",
"isdi",
"ction",
"\\u",
"name_",
"=_",
"path_",
"[_",
"'",
"jur",
"isdi",
"ction",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"oc",
"d\\u",
"id_",
"=_",
"'",
"oc",
"d",
"-",
"divisi",
"on",
"/",
"countr",
"y",
":",
"us",
"/",
"state",
":",
"ar",
"/",
"county",
":{}'_",
"._",
"format_",
"(_",
"oc",
"d\\u",
"type",
"\\u",
"id_",
"(_",
"jur",
"isdi",
"ction",
"\\u",
"name_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"filename_",
"=_",
"self_",
"._",
"\\u",
"standardize",
"d\\u",
"filename_",
"(_",
"election_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"jur",
"isdi",
"ction_",
"=_",
"jur",
"isdi",
"ction",
"\\u",
"name_",
",_",
"reporting",
"\\u",
"level_",
"=_",
"'",
"preci",
"nct",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extension_",
"=_",
"'.'_",
"+_",
"fmt_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"meta",
"\\u",
"entries_",
"._",
"append_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"generat",
"ed",
"\\u",
"filename",
"\"_",
":_",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"raw",
"\\u",
"extracted",
"\\u",
"filename",
"\"_",
":_",
"\"",
"deta",
"il",
".{}",
"\"_",
"._",
"format_",
"(_",
"fmt_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"raw",
"\\u",
"url",
"\"_",
":_",
"path_",
"[_",
"'",
"url",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"oc",
"d\\u",
"id",
"\"_",
":_",
"oc",
"d\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"name",
"\"_",
":_",
"jur",
"isdi",
"ction",
"\\u",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"election",
"\"_",
":_",
"election_",
"[_",
"'",
"slug",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"meta",
"\\u",
"entries_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"clari",
"ty",
"\\u",
"preci",
"nct",
"\\u",
"url",
"\\u",
"path",
"s",
"\\u",
"filename_",
"(_",
"self_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"filename_",
"=_",
"self_",
"._",
"\\u",
"standardize",
"d\\u",
"filename_",
"(_",
"election_",
",_",
"[_",
"'",
"url",
"\\u",
"path",
"s",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"reporting",
"\\u",
"level_",
"=_",
"'",
"preci",
"nct",
"'_",
",_",
"extension_",
"=_",
"'.",
"csv",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"mapping",
"s",
"\\u",
"dir_",
",_",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"clari",
"ty",
"\\u",
"preci",
"nct",
"\\u",
"url",
"\\u",
"paths_",
"(_",
"self_",
",_",
"election_",
",_",
"fmt_",
",_",
"jur",
"isdi",
"ction_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"url",
"\\u",
"path",
"s",
"\\u",
"filename_",
"=_",
"self_",
"._",
"\\u",
"clari",
"ty",
"\\u",
"preci",
"nct",
"\\u",
"url",
"\\u",
"path",
"s",
"\\u",
"filename_",
"(_",
"election_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"url",
"\\u",
"path",
"s",
"\\u",
"filename_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"url",
"\\u",
"paths_",
"(_",
"url",
"\\u",
"path",
"s",
"\\u",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"url",
"\\u",
"paths_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"subj",
"uris",
"diction",
"_",
"in_",
"jur",
"isdi",
"ction_",
"._",
"get",
"\\u",
"subj",
"uris",
"diction",
"s_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"subj",
"uris",
"diction",
"_",
"._",
"url_",
"not_",
"in_",
"self_",
"._",
"no",
"\\u",
"preci",
"nct",
"\\u",
"urls_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"url",
"\\u",
"paths_",
"._",
"append_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"date",
"'_",
":_",
"election_",
"[_",
"'",
"start",
"\\u",
"date",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"office",
"'_",
":_",
"''_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"race",
"\\u",
"type",
"'_",
":_",
"election_",
"[_",
"'",
"race",
"\\u",
"type",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"part",
"y",
"'_",
":_",
"''_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"special",
"'_",
":_",
"election_",
"[_",
"'",
"special",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"url",
"'_",
":_",
"subj",
"uris",
"diction",
"_",
"._",
"report",
"\\u",
"url_",
"(_",
"fmt_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"reporting",
"\\u",
"level",
"'_",
":_",
"'",
"preci",
"nct",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"jur",
"isdi",
"ction",
"'_",
":_",
"subj",
"uris",
"diction",
"_",
"._",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"url",
"\\u",
"path",
"s",
"\\u",
"filename_",
",_",
"'",
"wb",
"'_",
")_",
"as_",
"f_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fieldnames_",
"=_",
"[_",
"'",
"date",
"'_",
",_",
"'",
"office",
"'_",
",_",
"'",
"race",
"\\u",
"type",
"'_",
",_",
"'",
"part",
"y",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"special",
"'_",
",_",
"'",
"url",
"'_",
",_",
"'",
"reporting",
"\\u",
"level",
"'_",
",_",
"'",
"jur",
"isdi",
"ction",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"writer_",
"=_",
"unicode",
"csv_",
"._",
"Dict",
"Writer_",
"(_",
"f_",
",_",
"fieldnames_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"writer_",
"._",
"write",
"header_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"writer_",
"._",
"writer",
"ows_",
"(_",
"url",
"\\u",
"paths_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"url",
"\\u",
"paths_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Datas",
"ource_",
"(_",
"Base",
"Datas",
"ource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"url",
"\\u",
"for",
"\\u",
"fetch_",
"(_",
"self_",
",_",
"mapping_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"'",
"pre",
"\\u",
"process",
"ed",
"\\u",
"url",
"'_",
"in_",
"mapping_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"mapping_",
"[_",
"'",
"pre",
"\\u",
"process",
"ed",
"\\u",
"url",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":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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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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' | chineking/cola/tests/test_master_worker.py | [
{
"content": " def setUp(self):\n self.working_dir = tempfile.mkdtemp() \n self.job_dir = os.path.join(self.working_dir, 'master', 'jobs')\n self.zip_dir = os.path.join(self.working_dir, 'master', 'zip')\n \n if not os.path.exists(self.zip_dir):\n os.makedirs(self.zip_dir)\n \n wiki_path = os.path.join(\n os.path.dirname(os.path.dirname(os.path.abspath(__file__))), \n 'app', 'wiki')\n try:\n shutil.copytree(wiki_path, os.path.join(self.job_dir, 'wiki'))\n except OSError, e:\n if e.errno == errno.ENOTDIR:\n shutil.copy(wiki_path, os.path.join(self.job_dir, 'wiki'))\n else:\n raise\n \n self.job_name = import_job_desc(wiki_path).uniq_name\n old_wiki_path = os.path.join(self.job_dir, 'wiki')\n new_wiki_path = os.path.join(self.job_dir, self.job_name)\n os.rename(old_wiki_path, new_wiki_path)\n \n ZipHandler.compress(os.path.join(self.zip_dir, self.job_name+'.zip'), \n new_wiki_path)\n \n config_file = os.path.join(new_wiki_path, 'wiki.yaml')\n try:\n os.remove(os.path.join(new_wiki_path, 'test.yaml'))\n except:\n pass\n \n with open(config_file) as f:\n yaml_obj = yaml.load(f)\n yaml_obj['job']['size'] = 5\n yaml_obj['job']['instances'] = 1\n yaml_obj['job']['priorities'] = 1\n with open(config_file, 'w') as f:\n yaml.dump(yaml_obj, f)",
"metadata": "root.Test.setUp",
"header": "['class', 'Test', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 36
},
{
"content": " def tearDown(self):\n try:\n shutil.rmtree(self.working_dir)\n except:\n pass",
"metadata": "root.Test.tearDown",
"header": "['class', 'Test', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 77
}
]
| [
{
"span": "except:",
"start_line": 66,
"start_column": 8,
"end_line": 66,
"end_column": 15
},
{
"span": "except:",
"start_line": 80,
"start_column": 8,
"end_line": 80,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"working",
"\\u",
"dir_",
"=_",
"tempfile_",
"._",
"mkdtemp_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"job",
"\\u",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"working",
"\\u",
"dir_",
",_",
"'",
"master",
"'_",
",_",
"'",
"jobs",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"zip",
"\\u",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"working",
"\\u",
"dir_",
",_",
"'",
"master",
"'_",
",_",
"'",
"zip",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"zip",
"\\u",
"dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"makedirs_",
"(_",
"self_",
"._",
"zip",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"wiki",
"\\u",
"path_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"os_",
"._",
"path_",
"._",
"abspath_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"app",
"'_",
",_",
"'",
"wiki",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"shutil_",
"._",
"copytree_",
"(_",
"wiki",
"\\u",
"path_",
",_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"job",
"\\u",
"dir_",
",_",
"'",
"wiki",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"OSE",
"rror_",
",_",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"e_",
"._",
"errno_",
"==_",
"errno_",
"._",
"ENO",
"TD",
"IR_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"shutil_",
"._",
"copy_",
"(_",
"wiki",
"\\u",
"path_",
",_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"job",
"\\u",
"dir_",
",_",
"'",
"wiki",
"'_",
")_",
")_",
"\\u\\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_",
"\\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_",
"._",
"job",
"\\u",
"name_",
"=_",
"import",
"\\u",
"job",
"\\u",
"desc_",
"(_",
"wiki",
"\\u",
"path_",
")_",
"._",
"uniq",
"\\u",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"old",
"\\u",
"wiki",
"\\u",
"path_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"job",
"\\u",
"dir_",
",_",
"'",
"wiki",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"new",
"\\u",
"wiki",
"\\u",
"path_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"job",
"\\u",
"dir_",
",_",
"self_",
"._",
"job",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"os_",
"._",
"rename_",
"(_",
"old",
"\\u",
"wiki",
"\\u",
"path_",
",_",
"new",
"\\u",
"wiki",
"\\u",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"Zip",
"Handler_",
"._",
"compress_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"zip",
"\\u",
"dir_",
",_",
"self_",
"._",
"job",
"\\u",
"name_",
"+_",
"'.",
"zip",
"'_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"new",
"\\u",
"wiki",
"\\u",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"config",
"\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"new",
"\\u",
"wiki",
"\\u",
"path_",
",_",
"'",
"wiki",
".",
"yaml",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"remove_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"new",
"\\u",
"wiki",
"\\u",
"path_",
",_",
"'",
"test",
".",
"yaml",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"config",
"\\u",
"file_",
")_",
"as_",
"f_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"yaml",
"\\u",
"obj_",
"=_",
"yaml_",
"._",
"load_",
"(_",
"f_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yaml",
"\\u",
"obj_",
"[_",
"'",
"job",
"'_",
"]_",
"[_",
"'",
"size",
"'_",
"]_",
"=_",
"5_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yaml",
"\\u",
"obj_",
"[_",
"'",
"job",
"'_",
"]_",
"[_",
"'",
"instance",
"s",
"'_",
"]_",
"=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yaml",
"\\u",
"obj_",
"[_",
"'",
"job",
"'_",
"]_",
"[_",
"'",
"priorities",
"'_",
"]_",
"=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"config",
"\\u",
"file_",
",_",
"'",
"w",
"'_",
")_",
"as_",
"f_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"yaml_",
"._",
"dump_",
"(_",
"yaml",
"\\u",
"obj_",
",_",
"f_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test_",
"(_",
"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_",
"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 ",
" _",
"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-supertagging/supertagging/markup.py | [
{
"content": "def markup_content(obj, field, markup_template='supertagging/markup.html'):\n \"\"\"\n Takes all the items (SuperTaggedItems), and retrieves all the 'instances' to \n embed the markup_template.\n \"\"\"\n ctype = ContentType.objects.get_for_model(obj)\n items = SuperTaggedItem.objects.filter(\n content_type__pk=ctype.pk, object_id=obj.pk, \n relevance__gte=settings.MIN_RELEVANCE_MARKUP).select_related()\n \n value = getattr(obj, field, '')\n full = []\n for item in items:\n if not item.instances:\n continue\n i = item.instances\n skip = False\n for v in i:\n if isinstance(v, list):\n # TODO: figure out a better way to handle list of dicts\n skip = True\n continue\n if isinstance(v, dict):\n v['supertag'] = item.tag\n \n if not skip:\n full.extend(i)\n\n # Sort the list by the inner dict offset value in reverse\n full.sort(tag_instance_cmp, reverse=True)\n \n for n, i in enumerate(full):\n if 'offset' in i and 'length' in i and 'exact' in i:\n off, le, act_val = i['offset'], i['length'], i['exact']\n if act_val.lower() in settings.MARKUP_EXCLUDES:\n continue\n else:\n continue\n \n # This tests to make sure the next tag does\n # not overlap the current tag\n if n != 0:\n if 'offset' in full[n-1]:\n prev_off = full[n-1]['offset']\n if ((off+1)+le) > prev_off:\n continue\n \n # Validate that the data matches the data returned by calais\n if not value[off:(off+le)] == act_val:\n raise FailedMarkupValidation(\n \"Markup failed validation: Offset: %s: \\\"%s\\\" didn't match \\\"%s\\\"\" % (off, value[off:(off+le)], act_val))\n break\n \n tag = i['supertag']\n val = render_to_string(markup_template, {'tag': tag, 'actual_value': act_val})\n pre, suf, repl = '','',''\n \n pre = value[:off]\n suf = value[(off+le):]\n repl = value[off:(off+le)]\n \n value = pre+val+suf\n \n return value",
"metadata": "root.markup_content",
"header": "['module', '___EOS___']",
"index": 95
}
]
| [
{
"span": "pre,",
"start_line": 150,
"start_column": 8,
"end_line": 150,
"end_column": 11
},
{
"span": "suf,",
"start_line": 150,
"start_column": 13,
"end_line": 150,
"end_column": 16
},
{
"span": "repl ",
"start_line": 150,
"start_column": 18,
"end_line": 150,
"end_column": 22
},
{
"span": "repl ",
"start_line": 154,
"start_column": 8,
"end_line": 154,
"end_column": 12
}
]
| [
{
"span": "pre ",
"start_line": 152,
"start_column": 8,
"end_line": 152,
"end_column": 11
},
{
"span": "suf ",
"start_line": 153,
"start_column": 8,
"end_line": 153,
"end_column": 11
}
]
| 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_",
"markup",
"\\u",
"content_",
"(_",
"obj_",
",_",
"field_",
",_",
"markup",
"\\u",
"template_",
"=_",
"'",
"super",
"tagging",
"/",
"markup",
".",
"html",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Tak",
"es",
" ",
"all",
" ",
"the",
" ",
"items",
" ",
"(",
"Super",
"Tagg",
"ed",
"Item",
"s",
"),",
" ",
"and",
" ",
"retrieve",
"s",
" ",
"all",
" ",
"the",
" ",
"'",
"instance",
"s",
"'",
" ",
"to",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"embed",
" ",
"the",
" ",
"markup",
"\\u",
"template",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ctype_",
"=_",
"Conten",
"t",
"Type_",
"._",
"objects_",
"._",
"get",
"\\u",
"for",
"\\u",
"model_",
"(_",
"obj_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"items_",
"=_",
"Super",
"Tagg",
"ed",
"Item_",
"._",
"objects_",
"._",
"filter_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"content",
"\\u",
"type\\u\\u",
"pk_",
"=_",
"ctype_",
"._",
"pk_",
",_",
"object\\u",
"id_",
"=_",
"obj_",
"._",
"pk_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"relevance",
"\\u\\u",
"gte_",
"=_",
"settings_",
"._",
"MIN",
"\\u",
"REL",
"EV",
"ANCE",
"\\u",
"MARK",
"UP_",
")_",
"._",
"select",
"\\u",
"related_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"value_",
"=_",
"getattr_",
"(_",
"obj_",
",_",
"field_",
",_",
"''_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"full_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"item_",
"in_",
"items_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"item_",
"._",
"instances_",
":_",
"\\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_",
"i_",
"=_",
"item_",
"._",
"instances_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"skip_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"v_",
"in_",
"i_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"isinstance_",
"(_",
"v_",
",_",
"list_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"figure",
" ",
"out",
" ",
"a",
" ",
"bett",
"er",
" ",
"way",
" ",
"to",
" ",
"handle",
" ",
"list",
" ",
"of",
" ",
"dicts_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"skip_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"continue_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"v_",
",_",
"dict_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"v_",
"[_",
"'",
"super",
"tag",
"'_",
"]_",
"=_",
"item_",
"._",
"tag_",
"\\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_",
"skip_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"full_",
"._",
"extend_",
"(_",
"i_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sort",
" ",
"the",
" ",
"list",
" ",
"by",
" ",
"the",
" ",
"inner",
" ",
"dict",
" ",
"offset",
" ",
"value",
" ",
"in",
" ",
"reverse_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"full_",
"._",
"sort_",
"(_",
"tag",
"\\u",
"instance",
"\\u",
"cmp_",
",_",
"reverse_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"n_",
",_",
"i_",
"in_",
"enumerate_",
"(_",
"full_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"'",
"offset",
"'_",
"in_",
"i_",
"and_",
"'",
"length",
"'_",
"in_",
"i_",
"and_",
"'",
"exact",
"'_",
"in_",
"i_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"off_",
",_",
"le_",
",_",
"act",
"\\u",
"val_",
"=_",
"i_",
"[_",
"'",
"offset",
"'_",
"]_",
",_",
"i_",
"[_",
"'",
"length",
"'_",
"]_",
",_",
"i_",
"[_",
"'",
"exact",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"act",
"\\u",
"val_",
"._",
"lower_",
"(_",
")_",
"in_",
"settings_",
"._",
"MARK",
"UP",
"\\u",
"EXCLUDE",
"S_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"continue_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\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_",
"#",
" ",
"Thi",
"s",
" ",
"tests",
" ",
"to",
" ",
"make",
" ",
"sure",
" ",
"the",
" ",
"next",
" ",
"tag",
" ",
"doe",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"not",
" ",
"overl",
"ap",
" ",
"the",
" ",
"current",
" ",
"tag_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"n_",
"!=_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"'",
"offset",
"'_",
"in_",
"full_",
"[_",
"n_",
"-_",
"1_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"prev",
"\\u",
"off_",
"=_",
"full_",
"[_",
"n_",
"-_",
"1_",
"]_",
"[_",
"'",
"offset",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"(_",
"(_",
"off_",
"+_",
"1_",
")_",
"+_",
"le_",
")_",
">_",
"prev",
"\\u",
"off_",
":_",
"\\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_",
"#",
" ",
"Validate",
" ",
"tha",
"t",
" ",
"the",
" ",
"data",
" ",
"matche",
"s",
" ",
"the",
" ",
"data",
" ",
"return",
"ed",
" ",
"by",
" ",
"cala",
"is_",
"\\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_",
"value_",
"[_",
"off_",
":_",
"(_",
"off_",
"+_",
"le_",
")_",
"]_",
"==_",
"act",
"\\u",
"val_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Fail",
"ed",
"Mark",
"up",
"Validation_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"Mark",
"up",
" ",
"fail",
"ed",
" ",
"validation",
":",
" ",
"Off",
"set",
":",
" ",
"%",
"s",
":",
" ",
"\\\\\"",
"%",
"s",
"\\\\\"",
" ",
"did",
"n",
"'",
"t",
" ",
"match",
" ",
"\\\\\"",
"%",
"s",
"\\\\\"\"_",
"%_",
"(_",
"off_",
",_",
"value_",
"[_",
"off_",
":_",
"(_",
"off_",
"+_",
"le_",
")_",
"]_",
",_",
"act",
"\\u",
"val_",
")_",
")_",
"\\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_",
"tag_",
"=_",
"i_",
"[_",
"'",
"super",
"tag",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"val_",
"=_",
"render",
"\\u",
"to",
"\\u",
"string_",
"(_",
"markup",
"\\u",
"template_",
",_",
"{_",
"'",
"tag",
"'_",
":_",
"tag_",
",_",
"'",
"actual",
"\\u",
"value",
"'_",
":_",
"act",
"\\u",
"val_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pre_",
",_",
"suf",
"_",
",_",
"repl_",
"=_",
"''_",
",_",
"''_",
",_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"pre_",
"=_",
"value_",
"[_",
":_",
"off_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"suf",
"_",
"=_",
"value_",
"[_",
"(_",
"off_",
"+_",
"le_",
")_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"repl_",
"=_",
"value_",
"[_",
"off_",
":_",
"(_",
"off_",
"+_",
"le_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"value_",
"=_",
"pre_",
"+_",
"val_",
"+_",
"suf",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"value_"
]
| [
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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!/usr/bin/env python\n# Copyright (c) PLUMgrid, Inc.\n# Licensed under the Apache License, Version 2.0 (the \"License\")\n\nfrom ctypes import c_uint, c_ulong, Structure\nfrom bcc import BPF\nimport os\nfrom time import sleep\nimport sys\nfrom unittest import main, TestCase\n\narg1 = sys.argv.pop(1)\narg2 = \"\"\nif len(sys.argv) > 1:\n arg2 = sys.argv.pop(1)\n\nKey = None\nLeaf = None\nif arg1.endswith(\".b\"):\n\n\nif __name__ == \"__main__\":\n main()\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": " class Key(Structure):\n _fields_ = [(\"fd\", c_ulong)]",
"metadata": "root.Key",
"header": "['module', '___EOS___']",
"index": 19
},
{
"content": " class Leaf(Structure):\n _fields_ = [(\"stat1\", c_ulong),\n (\"stat2\", c_ulong)]",
"metadata": "root.Leaf",
"header": "['module', '___EOS___']",
"index": 21
},
{
"content": "class TestKprobe(TestCase):\n",
"metadata": "root.TestKprobe",
"header": "['module', '___EOS___']",
"index": 25
},
{
"content": " def setUp(self):\n b = BPF(arg1, arg2, debug=0)\n self.stats = b.get_table(\"stats\", Key, Leaf)\n b.attach_kprobe(event=\"sys_write\", fn_name=\"sys_wr\", pid=0, cpu=-1)\n b.attach_kprobe(event=\"sys_read\", fn_name=\"sys_rd\", pid=0, cpu=-1)\n b.attach_kprobe(event=\"htab_map_get_next_key\", fn_name=\"sys_rd\", pid=0, cpu=-1)",
"metadata": "root.TestKprobe.setUp",
"header": "['class', 'TestKprobe', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 26
},
{
"content": " def test_trace1(self):\n with open(\"/dev/null\", \"a\") as f:\n for i in range(0, 100):\n os.write(f.fileno(), b\"\")\n with open(\"/etc/services\", \"r\") as f:\n for i in range(0, 200):\n os.read(f.fileno(), 1)\n for key, leaf in self.stats.items():\n print(\"fd %x:\" % key.fd, \"stat1 %d\" % leaf.stat1, \"stat2 %d\" % leaf.stat2)",
"metadata": "root.TestKprobe.test_trace1",
"header": "['class', 'TestKprobe', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 33
}
]
| [
{
"span": "from ctypes import c_uint, c_ulong, Structure",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 45
},
{
"span": "from time import sleep",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 22
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#!",
"/",
"usr",
"/",
"bin",
"/",
"env",
" ",
"python_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"PLU",
"Mgr",
"id",
",",
" ",
"Inc",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"License",
"d",
" ",
"under",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"License",
",",
" ",
"Version",
" ",
"2.0",
" ",
"(",
"the",
" ",
"\"",
"License",
"\")",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"ctypes_",
"import_",
"c\\u",
"uint_",
",_",
"c\\u",
"ulong_",
",_",
"Structure_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bcc",
"_",
"import_",
"BP",
"F_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"time_",
"import_",
"sleep_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"unittest_",
"import_",
"main_",
",_",
"Test",
"Case_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"arg1_",
"=_",
"sys_",
"._",
"argv_",
"._",
"pop_",
"(_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"arg2_",
"=_",
"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"len_",
"(_",
"sys_",
"._",
"argv_",
")_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"arg2_",
"=_",
"sys_",
"._",
"argv_",
"._",
"pop_",
"(_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"Key_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Leaf_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"arg1_",
"._",
"endswith_",
"(_",
"\".",
"b",
"\"_",
")_",
":_",
"\\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\\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\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"class_",
"Key_",
"(_",
"Structure_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"fields\\u_",
"=_",
"[_",
"(_",
"\"",
"fd",
"\"_",
",_",
"c\\u",
"ulong_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Leaf_",
"(_",
"Structure_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"fields\\u_",
"=_",
"[_",
"(_",
"\"",
"stat",
"1",
"\"_",
",_",
"c\\u",
"ulong_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"stat",
"2",
"\"_",
",_",
"c\\u",
"ulong_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"Kp",
"robe",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Kp",
"robe",
"_",
"(_",
"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 ",
" _",
"b_",
"=_",
"BP",
"F_",
"(_",
"arg1_",
",_",
"arg2_",
",_",
"debug_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"stats_",
"=_",
"b_",
"._",
"get",
"\\u",
"table_",
"(_",
"\"",
"stats",
"\"_",
",_",
"Key_",
",_",
"Leaf_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"b_",
"._",
"attach",
"\\u",
"kp",
"robe",
"_",
"(_",
"event_",
"=_",
"\"",
"sys",
"\\u",
"write",
"\"_",
",_",
"fn",
"\\u",
"name_",
"=_",
"\"",
"sys",
"\\u",
"wr",
"\"_",
",_",
"pid_",
"=_",
"0_",
",_",
"cpu_",
"=_",
"-_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"b_",
"._",
"attach",
"\\u",
"kp",
"robe",
"_",
"(_",
"event_",
"=_",
"\"",
"sys",
"\\u",
"read",
"\"_",
",_",
"fn",
"\\u",
"name_",
"=_",
"\"",
"sys",
"\\u",
"rd",
"\"_",
",_",
"pid_",
"=_",
"0_",
",_",
"cpu_",
"=_",
"-_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"b_",
"._",
"attach",
"\\u",
"kp",
"robe",
"_",
"(_",
"event_",
"=_",
"\"",
"hta",
"b",
"\\u",
"map",
"\\u",
"get",
"\\u",
"next",
"\\u",
"key",
"\"_",
",_",
"fn",
"\\u",
"name_",
"=_",
"\"",
"sys",
"\\u",
"rd",
"\"_",
",_",
"pid_",
"=_",
"0_",
",_",
"cpu_",
"=_",
"-_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Kp",
"robe",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"trace",
"1_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"with_",
"open_",
"(_",
"\"/",
"dev",
"/",
"null",
"\"_",
",_",
"\"",
"a",
"\"_",
")_",
"as_",
"f_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"i_",
"in_",
"range_",
"(_",
"0_",
",_",
"100_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"write_",
"(_",
"f_",
"._",
"fileno_",
"(_",
")_",
",_",
"b",
"\"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"\"/",
"etc",
"/",
"service",
"s",
"\"_",
",_",
"\"",
"r",
"\"_",
")_",
"as_",
"f_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"i_",
"in_",
"range_",
"(_",
"0_",
",_",
"200_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"read_",
"(_",
"f_",
"._",
"fileno_",
"(_",
")_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"key_",
",_",
"leaf_",
"in_",
"self_",
"._",
"stats_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"fd",
" ",
"%",
"x",
":\"_",
"%_",
"key_",
"._",
"fd_",
",_",
"\"",
"stat",
"1",
" ",
"%",
"d",
"\"_",
"%_",
"leaf_",
"._",
"stat",
"1_",
",_",
"\"",
"stat",
"2",
" ",
"%",
"d",
"\"_",
"%_",
"leaf_",
"._",
"stat",
"2_",
")_",
"\\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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused local variable | shish/eve-mlp/eve_mlp/gui/mainframe.py | [
{
"content": " def __menu(self):\n menu_bar = wx.MenuBar()\n\n ################################################################\n menu = wx.Menu()\n m_exit = menu.Append(wx.ID_EXIT, \"E&xit\\tAlt-X\", \"Close window and exit program.\")\n self.Bind(wx.EVT_MENU, self.OnClose, m_exit)\n menu_bar.Append(menu, \"&File\")\n\n ################################################################\n menu = wx.Menu()\n\n m_rempasswd = menu.Append(2020, \"Remember Passwords\", \"\", kind=wx.ITEM_CHECK)\n self.m_rempasswd = m_rempasswd # event handler needs this object, not just ID?\n if self.config.settings[\"remember-passwords\"]:\n m_rempasswd.Check(True)\n self.Bind(wx.EVT_MENU, self.OnToggleRememberPasswords, m_rempasswd)\n\n m_start_tray = menu.Append(2021, \"Start in Systray\", \"\", kind=wx.ITEM_CHECK)\n self.m_start_tray = m_start_tray # event handler needs this object, not just ID?\n if self.config.settings[\"start-tray\"]:\n m_start_tray.Check(True)\n self.Bind(wx.EVT_MENU, self.OnToggleStartTray, m_start_tray)\n\n menu_bar.Append(menu, \"&Options\")\n\n ################################################################\n menu = wx.Menu()\n m_exit = menu.Append(wx.ID_EXIT, \"Launch Patcher\", \"\")\n m_exit = menu.Append(wx.ID_EXIT, \"Launch Repair\", \"\")\n #self.Bind(wx.EVT_MENU, self.OnClose, m_exit)\n #menu_bar.Append(menu, \"&Tools\")\n\n ################################################################\n menu = wx.Menu()\n m_about = menu.Append(wx.ID_ABOUT, \"&About\", \"Information about this program\")\n self.Bind(wx.EVT_MENU, self.OnAbout, m_about)\n menu_bar.Append(menu, \"&Help\")\n\n return menu_bar",
"metadata": "root.MainFrame.__menu",
"header": "['class', 'MainFrame', '(', 'wx', '.', 'Frame', ')', ':', '___EOS___']",
"index": 24
}
]
| [
{
"span": "m_exit ",
"start_line": 53,
"start_column": 8,
"end_line": 53,
"end_column": 14
}
]
| []
| 1 | true | [
"[CLS]_",
"Un",
"used_",
"local_",
"variable_",
"[SEP]_",
"class_",
"Main",
"Frame_",
"(_",
"wx_",
"._",
"Frame_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"\\u\\u",
"menu_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"menu",
"\\u",
"bar_",
"=_",
"wx_",
"._",
"Menu",
"Bar_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"###########",
"###########",
"###########",
"###########",
"###########",
"#########",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"menu_",
"=_",
"wx_",
"._",
"Menu_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"m",
"\\u",
"exit_",
"=_",
"menu_",
"._",
"Append_",
"(_",
"wx_",
"._",
"ID",
"\\u",
"EXIT",
"_",
",_",
"\"",
"E",
"&",
"xit",
"\\\\",
"t",
"Alt",
"-",
"X",
"\"_",
",_",
"\"",
"Clos",
"e",
" ",
"window",
" ",
"and",
" ",
"exit",
" ",
"program",
".\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"Bind_",
"(_",
"wx_",
"._",
"EV",
"T",
"\\u",
"MENU_",
",_",
"self_",
"._",
"On",
"Close_",
",_",
"m",
"\\u",
"exit_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"menu",
"\\u",
"bar_",
"._",
"Append_",
"(_",
"menu_",
",_",
"\"&",
"File",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"###########",
"###########",
"###########",
"###########",
"###########",
"#########",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"menu_",
"=_",
"wx_",
"._",
"Menu_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"m",
"\\u",
"rem",
"passwd_",
"=_",
"menu_",
"._",
"Append_",
"(_",
"2020_",
",_",
"\"",
"Reme",
"mber",
" ",
"Passw",
"ords",
"\"_",
",_",
"\"\"_",
",_",
"kind_",
"=_",
"wx_",
"._",
"ITEM",
"\\u",
"CHECK_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"m",
"\\u",
"rem",
"passwd_",
"=_",
"m",
"\\u",
"rem",
"passwd_",
"#",
" ",
"event",
" ",
"handler",
" ",
"need",
"s",
" ",
"this",
" ",
"object",
",",
" ",
"not",
" ",
"just",
" ",
"ID",
"?",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"config_",
"._",
"settings_",
"[_",
"\"",
"remember",
"-",
"passwords",
"\"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"m",
"\\u",
"rem",
"passwd_",
"._",
"Check_",
"(_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"Bind_",
"(_",
"wx_",
"._",
"EV",
"T",
"\\u",
"MENU_",
",_",
"self_",
"._",
"On",
"Toggle",
"Reme",
"mber",
"Passw",
"ords_",
",_",
"m",
"\\u",
"rem",
"passwd_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"m",
"\\u",
"start",
"\\u",
"tray",
"_",
"=_",
"menu_",
"._",
"Append_",
"(_",
"202",
"1_",
",_",
"\"",
"Start",
" ",
"in",
" ",
"Sys",
"tray",
"\"_",
",_",
"\"\"_",
",_",
"kind_",
"=_",
"wx_",
"._",
"ITEM",
"\\u",
"CHECK_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"m",
"\\u",
"start",
"\\u",
"tray",
"_",
"=_",
"m",
"\\u",
"start",
"\\u",
"tray",
"_",
"#",
" ",
"event",
" ",
"handler",
" ",
"need",
"s",
" ",
"this",
" ",
"object",
",",
" ",
"not",
" ",
"just",
" ",
"ID",
"?",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"config_",
"._",
"settings_",
"[_",
"\"",
"start",
"-",
"tray",
"\"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"m",
"\\u",
"start",
"\\u",
"tray",
"_",
"._",
"Check_",
"(_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"Bind_",
"(_",
"wx_",
"._",
"EV",
"T",
"\\u",
"MENU_",
",_",
"self_",
"._",
"On",
"Toggle",
"Start",
"Tra",
"y_",
",_",
"m",
"\\u",
"start",
"\\u",
"tray",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"menu",
"\\u",
"bar_",
"._",
"Append_",
"(_",
"menu_",
",_",
"\"&",
"Optio",
"ns",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"###########",
"###########",
"###########",
"###########",
"###########",
"#########",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"menu_",
"=_",
"wx_",
"._",
"Menu_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"m",
"\\u",
"exit_",
"=_",
"menu_",
"._",
"Append_",
"(_",
"wx_",
"._",
"ID",
"\\u",
"EXIT",
"_",
",_",
"\"",
"Launch",
" ",
"Patche",
"r",
"\"_",
",_",
"\"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"m",
"\\u",
"exit_",
"=_",
"menu_",
"._",
"Append_",
"(_",
"wx_",
"._",
"ID",
"\\u",
"EXIT",
"_",
",_",
"\"",
"Launch",
" ",
"Repair",
"\"_",
",_",
"\"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"self",
".",
"Bind",
"(",
"wx",
".",
"EV",
"T",
"\\u",
"MENU",
",",
" ",
"self",
".",
"On",
"Clos",
"e",
",",
" ",
"m",
"\\u",
"exit",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"menu",
"\\u",
"bar",
".",
"Append",
"(",
"menu",
",",
" ",
"\"&",
"Tool",
"s",
"\")",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"###########",
"###########",
"###########",
"###########",
"###########",
"#########",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"menu_",
"=_",
"wx_",
"._",
"Menu_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"m",
"\\u",
"about_",
"=_",
"menu_",
"._",
"Append_",
"(_",
"wx_",
"._",
"ID",
"\\u",
"ABO",
"UT_",
",_",
"\"&",
"Abo",
"ut",
"\"_",
",_",
"\"",
"Information",
" ",
"abo",
"ut",
" ",
"this",
" ",
"program",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"Bind_",
"(_",
"wx_",
"._",
"EV",
"T",
"\\u",
"MENU_",
",_",
"self_",
"._",
"On",
"About_",
",_",
"m",
"\\u",
"about_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"menu",
"\\u",
"bar_",
"._",
"Append_",
"(_",
"menu_",
",_",
"\"&",
"Help",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"menu",
"\\u",
"bar_",
"\\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,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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,
0,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused import | lebedov/scikit-cuda/tests/test_fft.py | [
{
"content": "#!/usr/bin/env python\n\n\"\"\"\nUnit tests for scikits.cuda.fft\n\"\"\"\n\nfrom __future__ import division\n\nfrom unittest import main, makeSuite, TestCase, TestSuite\n\nimport pycuda.autoinit\nimport pycuda.driver as drv\nimport pycuda.gpuarray as gpuarray\nimport numpy as np\n\nimport skcuda.fft as fft\nimport skcuda.misc as misc\n\natol_float32 = 1e-6\natol_float64 = 1e-8\n\n\n\nif __name__ == '__main__':\n main(defaultTest = 'suite')\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class test_fft(TestCase):\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
"metadata": "root.test_fft",
"header": "['module', '___EOS___']",
"index": 21
},
{
"content": " def setUp(self):\n np.random.seed(0) # for reproducible tests\n self.N = 8\n self.M = 4\n self.B = 3",
"metadata": "root.test_fft.setUp",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 22
},
{
"content": " def test_fft_float32_to_complex64_1d(self):\n x = np.asarray(np.random.rand(self.N), np.float32)\n xf = np.fft.rfftn(x)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty(self.N//2+1, np.complex64)\n plan = fft.Plan(x.shape, np.float32, np.complex64)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_fft_float32_to_complex64_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 28
},
{
"content": " def test_fft_float32_to_complex64_2d(self):\n x = np.asarray(np.random.rand(self.N, self.M), np.float32)\n xf = np.fft.rfftn(x)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty((self.N, self.M//2+1), np.complex64)\n plan = fft.Plan(x.shape, np.float32, np.complex64)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_fft_float32_to_complex64_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 37
},
{
"content": " def test_batch_fft_float32_to_complex64_1d(self):\n x = np.asarray(np.random.rand(self.B, self.N), np.float32)\n xf = np.fft.rfft(x, axis=1)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty((self.B, self.N//2+1), np.complex64)\n plan = fft.Plan(x.shape[1], np.float32, np.complex64, batch=self.B)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_batch_fft_float32_to_complex64_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 46
},
{
"content": " def test_batch_fft_float32_to_complex64_2d(self):\n x = np.asarray(np.random.rand(self.B, self.N, self.M), np.float32)\n xf = np.fft.rfftn(x, axes=(1,2))\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty((self.B, self.N, self.M//2+1), np.complex64)\n plan = fft.Plan([self.N, self.M], np.float32, np.complex64, batch=self.B)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_batch_fft_float32_to_complex64_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 55
},
{
"content": " def test_fft_float64_to_complex128_1d(self):\n x = np.asarray(np.random.rand(self.N), np.float64)\n xf = np.fft.rfftn(x)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty(self.N//2+1, np.complex128)\n plan = fft.Plan(x.shape, np.float64, np.complex128)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_fft_float64_to_complex128_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 64
},
{
"content": " def test_fft_float64_to_complex128_2d(self):\n x = np.asarray(np.random.rand(self.N, self.M), np.float64)\n xf = np.fft.rfftn(x)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty((self.N, self.M//2+1), np.complex128)\n plan = fft.Plan(x.shape, np.float64, np.complex128)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_fft_float64_to_complex128_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 73
},
{
"content": " def test_batch_fft_float64_to_complex128_1d(self):\n x = np.asarray(np.random.rand(self.B, self.N), np.float64)\n xf = np.fft.rfft(x, axis=1)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty((self.B, self.N//2+1), np.complex128)\n plan = fft.Plan(x.shape[1], np.float64, np.complex128, batch=self.B)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_batch_fft_float64_to_complex128_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 82
},
{
"content": " def test_batch_fft_float64_to_complex128_2d(self):\n x = np.asarray(np.random.rand(self.B, self.N, self.M), np.float64)\n xf = np.fft.rfftn(x, axes=(1,2))\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty((self.B, self.N, self.M//2+1), np.complex128)\n plan = fft.Plan([self.N, self.M], np.float64, np.complex128, batch=self.B)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_batch_fft_float64_to_complex128_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 91
},
{
"content": " def test_ifft_complex64_to_float32_1d(self):\n x = np.asarray(np.random.rand(self.N), np.float32)\n xf = np.asarray(np.fft.rfftn(x), np.complex64)\n xf_gpu = gpuarray.to_gpu(xf)\n x_gpu = gpuarray.empty(self.N, np.float32)\n plan = fft.Plan(x.shape, np.complex64, np.float32)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_ifft_complex64_to_float32_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 100
},
{
"content": " def test_ifft_complex64_to_float32_2d(self):\n\n # Note that since rfftn returns a Fortran-ordered array, it\n # needs to be reformatted as a C-ordered array before being\n # passed to gpuarray.to_gpu:\n x = np.asarray(np.random.rand(self.N, self.M), np.float32)\n xf = np.asarray(np.fft.rfftn(x), np.complex64)\n xf_gpu = gpuarray.to_gpu(np.ascontiguousarray(xf))\n x_gpu = gpuarray.empty((self.N, self.M), np.float32)\n plan = fft.Plan(x.shape, np.complex64, np.float32)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_ifft_complex64_to_float32_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 109
},
{
"content": " def test_batch_ifft_complex64_to_float32_1d(self):\n\n # Note that since rfftn returns a Fortran-ordered array, it\n # needs to be reformatted as a C-ordered array before being\n # passed to gpuarray.to_gpu:\n x = np.asarray(np.random.rand(self.B, self.N), np.float32)\n xf = np.asarray(np.fft.rfft(x, axis=1), np.complex64)\n xf_gpu = gpuarray.to_gpu(np.ascontiguousarray(xf))\n x_gpu = gpuarray.empty((self.B, self.N), np.float32)\n plan = fft.Plan(x.shape[1], np.complex64, np.float32, batch=self.B)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_batch_ifft_complex64_to_float32_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 122
},
{
"content": " def test_batch_ifft_complex64_to_float32_2d(self):\n\n # Note that since rfftn returns a Fortran-ordered array, it\n # needs to be reformatted as a C-ordered array before being\n # passed to gpuarray.to_gpu:\n x = np.asarray(np.random.rand(self.B, self.N, self.M), np.float32)\n xf = np.asarray(np.fft.rfftn(x, axes=(1,2)), np.complex64)\n xf_gpu = gpuarray.to_gpu(np.ascontiguousarray(xf))\n x_gpu = gpuarray.empty((self.B, self.N, self.M), np.float32)\n plan = fft.Plan([self.N, self.M], np.complex64, np.float32, batch=self.B)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_batch_ifft_complex64_to_float32_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 135
},
{
"content": " def test_ifft_complex128_to_float64_1d(self):\n x = np.asarray(np.random.rand(self.N), np.float64)\n xf = np.asarray(np.fft.rfftn(x), np.complex128)\n xf_gpu = gpuarray.to_gpu(xf)\n x_gpu = gpuarray.empty(self.N, np.float64)\n plan = fft.Plan(x.shape, np.complex128, np.float64)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_ifft_complex128_to_float64_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 148
},
{
"content": " def test_ifft_complex128_to_float64_2d(self):\n\n # Note that since rfftn returns a Fortran-ordered array, it\n # needs to be reformatted as a C-ordered array before being\n # passed to gpuarray.to_gpu:\n x = np.asarray(np.random.rand(self.N, self.M), np.float64)\n xf = np.asarray(np.fft.rfftn(x), np.complex128)\n xf_gpu = gpuarray.to_gpu(np.ascontiguousarray(xf))\n x_gpu = gpuarray.empty((self.N, self.M), np.float64)\n plan = fft.Plan(x.shape, np.complex128, np.float64)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_ifft_complex128_to_float64_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 157
},
{
"content": " def test_batch_ifft_complex128_to_float64_1d(self):\n\n # Note that since rfftn returns a Fortran-ordered array, it\n # needs to be reformatted as a C-ordered array before being\n # passed to gpuarray.to_gpu:\n x = np.asarray(np.random.rand(self.B, self.N), np.float64)\n xf = np.asarray(np.fft.rfft(x, axis=1), np.complex128)\n xf_gpu = gpuarray.to_gpu(np.ascontiguousarray(xf))\n x_gpu = gpuarray.empty((self.B, self.N), np.float64)\n plan = fft.Plan(x.shape[1], np.complex128, np.float64, batch=self.B)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_batch_ifft_complex128_to_float64_1d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 170
},
{
"content": " def test_batch_ifft_complex128_to_float64_2d(self):\n\n # Note that since rfftn returns a Fortran-ordered array, it\n # needs to be reformatted as a C-ordered array before being\n # passed to gpuarray.to_gpu:\n x = np.asarray(np.random.rand(self.B, self.N, self.M), np.float64)\n xf = np.asarray(np.fft.rfftn(x, axes=(1,2)), np.complex128)\n xf_gpu = gpuarray.to_gpu(np.ascontiguousarray(xf))\n x_gpu = gpuarray.empty((self.B, self.N, self.M), np.float64)\n plan = fft.Plan([self.N, self.M], np.complex128, np.float64, batch=self.B)\n fft.ifft(xf_gpu, x_gpu, plan, True)\n assert np.allclose(x, x_gpu.get(), atol=atol_float64)",
"metadata": "root.test_fft.test_batch_ifft_complex128_to_float64_2d",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 183
},
{
"content": " def test_multiple_streams(self):\n x = np.asarray(np.random.rand(self.N), np.float32)\n xf = np.fft.rfftn(x)\n y = np.asarray(np.random.rand(self.N), np.float32)\n yf = np.fft.rfftn(y)\n x_gpu = gpuarray.to_gpu(x)\n y_gpu = gpuarray.to_gpu(y)\n xf_gpu = gpuarray.empty(self.N//2+1, np.complex64)\n yf_gpu = gpuarray.empty(self.N//2+1, np.complex64)\n stream0 = drv.Stream()\n stream1 = drv.Stream()\n plan1 = fft.Plan(x.shape, np.float32, np.complex64, stream=stream0)\n plan2 = fft.Plan(y.shape, np.float32, np.complex64, stream=stream1)\n fft.fft(x_gpu, xf_gpu, plan1)\n fft.fft(y_gpu, yf_gpu, plan2)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float32)\n assert np.allclose(yf, yf_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_multiple_streams",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 196
},
{
"content": " def test_work_area(self):\n x = np.asarray(np.random.rand(self.N), np.float32)\n xf = np.fft.rfftn(x)\n x_gpu = gpuarray.to_gpu(x)\n xf_gpu = gpuarray.empty(self.N//2+1, np.complex64)\n plan = fft.Plan(x.shape, np.float32, np.complex64, auto_allocate=False)\n work_area = gpuarray.empty((plan.worksize,), np.uint8)\n plan.set_work_area(work_area)\n fft.fft(x_gpu, xf_gpu, plan)\n assert np.allclose(xf, xf_gpu.get(), atol=atol_float32)",
"metadata": "root.test_fft.test_work_area",
"header": "['class', 'test_fft', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 214
},
{
"content": "def suite():\n s = TestSuite()\n s.addTest(test_fft('test_fft_float32_to_complex64_1d'))\n s.addTest(test_fft('test_fft_float32_to_complex64_2d'))\n s.addTest(test_fft('test_batch_fft_float32_to_complex64_1d'))\n s.addTest(test_fft('test_batch_fft_float32_to_complex64_2d'))\n s.addTest(test_fft('test_ifft_complex64_to_float32_1d'))\n s.addTest(test_fft('test_ifft_complex64_to_float32_2d'))\n s.addTest(test_fft('test_batch_ifft_complex64_to_float32_1d'))\n s.addTest(test_fft('test_batch_ifft_complex64_to_float32_2d'))\n s.addTest(test_fft('test_multiple_streams'))\n s.addTest(test_fft('test_work_area'))\n if misc.get_compute_capability(pycuda.autoinit.device) >= 1.3:\n s.addTest(test_fft('test_fft_float64_to_complex128_1d'))\n s.addTest(test_fft('test_fft_float64_to_complex128_2d'))\n s.addTest(test_fft('test_batch_fft_float64_to_complex128_1d'))\n s.addTest(test_fft('test_batch_fft_float64_to_complex128_2d'))\n s.addTest(test_fft('test_ifft_complex128_to_float64_1d'))\n s.addTest(test_fft('test_ifft_complex128_to_float64_2d'))\n s.addTest(test_fft('test_batch_ifft_complex128_to_float64_1d'))\n s.addTest(test_fft('test_batch_ifft_complex128_to_float64_2d'))\n return s",
"metadata": "root.suite",
"header": "['module', '___EOS___']",
"index": 225
}
]
| [
{
"span": "from unittest import main, makeSuite, TestCase, TestSuite",
"start_line": 8,
"start_column": 0,
"end_line": 8,
"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",
".",
"fft",
"\\",
"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_",
"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",
"_",
"._",
"driver_",
"as_",
"drv_",
"\\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_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"sk",
"cuda_",
"._",
"fft_",
"as_",
"fft_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sk",
"cuda_",
"._",
"misc_",
"as_",
"misc_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"atol",
"\\u",
"float32_",
"=_",
"1e-6_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"atol",
"\\u",
"float64_",
"=_",
"1e-8_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"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_",
")_",
"#",
" ",
"for",
" ",
"repro",
"duci",
"ble",
" ",
"tests_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"N_",
"=_",
"8_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"M_",
"=_",
"4_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"B_",
"=_",
"3_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"//_",
"2_",
"+_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft_",
"(_",
"x_",
",_",
"axis_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
"[_",
"1_",
"]_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
",_",
"axes_",
"=_",
"(_",
"1_",
",_",
"2_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"//_",
"2_",
"+_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"[_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"]_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"float64_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"//_",
"2_",
"+_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"float64_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft_",
"(_",
"x_",
",_",
"axis_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
"[_",
"1_",
"]_",
",_",
"np_",
"._",
"float64_",
",_",
"np_",
"._",
"complex",
"128_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
",_",
"axes_",
"=_",
"(_",
"1_",
",_",
"2_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"//_",
"2_",
"+_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"[_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"]_",
",_",
"np_",
"._",
"float64_",
",_",
"np_",
"._",
"complex",
"128_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"xf_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
" ",
"tha",
"t",
" ",
"sinc",
"e",
" ",
"rf",
"ft",
"n",
" ",
"return",
"s",
" ",
"a",
" ",
"Fort",
"ran",
"-",
"order",
"ed",
" ",
"array",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"reformat",
"ted",
" ",
"as",
" ",
"a",
" ",
"C",
"-",
"order",
"ed",
" ",
"array",
" ",
"bef",
"ore",
" ",
"bei",
"ng_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass",
"ed",
" ",
"to",
" ",
"gpu",
"array",
".",
"to",
"\\u",
"gpu",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"np_",
"._",
"asc",
"onti",
"guous",
"array_",
"(_",
"xf_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
" ",
"tha",
"t",
" ",
"sinc",
"e",
" ",
"rf",
"ft",
"n",
" ",
"return",
"s",
" ",
"a",
" ",
"Fort",
"ran",
"-",
"order",
"ed",
" ",
"array",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"reformat",
"ted",
" ",
"as",
" ",
"a",
" ",
"C",
"-",
"order",
"ed",
" ",
"array",
" ",
"bef",
"ore",
" ",
"bei",
"ng_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass",
"ed",
" ",
"to",
" ",
"gpu",
"array",
".",
"to",
"\\u",
"gpu",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft_",
"(_",
"x_",
",_",
"axis_",
"=_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"np_",
"._",
"asc",
"onti",
"guous",
"array_",
"(_",
"xf_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
"[_",
"1_",
"]_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"np_",
"._",
"float32_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
" ",
"tha",
"t",
" ",
"sinc",
"e",
" ",
"rf",
"ft",
"n",
" ",
"return",
"s",
" ",
"a",
" ",
"Fort",
"ran",
"-",
"order",
"ed",
" ",
"array",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"reformat",
"ted",
" ",
"as",
" ",
"a",
" ",
"C",
"-",
"order",
"ed",
" ",
"array",
" ",
"bef",
"ore",
" ",
"bei",
"ng_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass",
"ed",
" ",
"to",
" ",
"gpu",
"array",
".",
"to",
"\\u",
"gpu",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
",_",
"axes_",
"=_",
"(_",
"1_",
",_",
"2_",
")_",
")_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"np_",
"._",
"asc",
"onti",
"guous",
"array_",
"(_",
"xf_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"[_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"]_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"np_",
"._",
"float32_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"xf_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"complex",
"128_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
" ",
"tha",
"t",
" ",
"sinc",
"e",
" ",
"rf",
"ft",
"n",
" ",
"return",
"s",
" ",
"a",
" ",
"Fort",
"ran",
"-",
"order",
"ed",
" ",
"array",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"reformat",
"ted",
" ",
"as",
" ",
"a",
" ",
"C",
"-",
"order",
"ed",
" ",
"array",
" ",
"bef",
"ore",
" ",
"bei",
"ng_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass",
"ed",
" ",
"to",
" ",
"gpu",
"array",
".",
"to",
"\\u",
"gpu",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"np_",
"._",
"asc",
"onti",
"guous",
"array_",
"(_",
"xf_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"complex",
"128_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"1d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
" ",
"tha",
"t",
" ",
"sinc",
"e",
" ",
"rf",
"ft",
"n",
" ",
"return",
"s",
" ",
"a",
" ",
"Fort",
"ran",
"-",
"order",
"ed",
" ",
"array",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"reformat",
"ted",
" ",
"as",
" ",
"a",
" ",
"C",
"-",
"order",
"ed",
" ",
"array",
" ",
"bef",
"ore",
" ",
"bei",
"ng_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass",
"ed",
" ",
"to",
" ",
"gpu",
"array",
".",
"to",
"\\u",
"gpu",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft_",
"(_",
"x_",
",_",
"axis_",
"=_",
"1_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"np_",
"._",
"asc",
"onti",
"guous",
"array_",
"(_",
"xf_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
"[_",
"1_",
"]_",
",_",
"np_",
"._",
"complex",
"128_",
",_",
"np_",
"._",
"float64_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"2d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
" ",
"tha",
"t",
" ",
"sinc",
"e",
" ",
"rf",
"ft",
"n",
" ",
"return",
"s",
" ",
"a",
" ",
"Fort",
"ran",
"-",
"order",
"ed",
" ",
"array",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"reformat",
"ted",
" ",
"as",
" ",
"a",
" ",
"C",
"-",
"order",
"ed",
" ",
"array",
" ",
"bef",
"ore",
" ",
"bei",
"ng_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass",
"ed",
" ",
"to",
" ",
"gpu",
"array",
".",
"to",
"\\u",
"gpu",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
",_",
"axes_",
"=_",
"(_",
"1_",
",_",
"2_",
")_",
")_",
",_",
"np_",
"._",
"complex",
"128_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"np_",
"._",
"asc",
"onti",
"guous",
"array_",
"(_",
"xf_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"self_",
"._",
"B_",
",_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
")_",
",_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"[_",
"self_",
"._",
"N_",
",_",
"self_",
"._",
"M_",
"]_",
",_",
"np_",
"._",
"complex",
"128_",
",_",
"np_",
"._",
"float64_",
",_",
"batch_",
"=_",
"self_",
"._",
"B_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"ifft",
"_",
"(_",
"xf",
"\\u",
"gpu_",
",_",
"x",
"\\u",
"gpu_",
",_",
"plan_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"x_",
",_",
"x",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"multiple",
"\\u",
"streams_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"y_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yf",
"_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"y_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"y",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"y_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"stream",
"0_",
"=_",
"drv_",
"._",
"Stream_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"stream",
"1_",
"=_",
"drv_",
"._",
"Stream_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan",
"1_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"stream_",
"=_",
"stream",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan",
"2_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"y_",
"._",
"shape_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"stream_",
"=_",
"stream",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"y",
"\\u",
"gpu_",
",_",
"yf",
"\\u",
"gpu_",
",_",
"plan",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"yf",
"_",
",_",
"yf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"test\\u",
"fft_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"work",
"\\u",
"area_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"np_",
"._",
"random_",
"._",
"rand_",
"(_",
"self_",
"._",
"N_",
")_",
",_",
"np_",
"._",
"float32_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf_",
"=_",
"np_",
"._",
"fft_",
"._",
"rf",
"ft",
"n_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"to",
"\\u",
"gpu_",
"(_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"xf",
"\\u",
"gpu_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"self_",
"._",
"N_",
"//_",
"2_",
"+_",
"1_",
",_",
"np_",
"._",
"complex",
"64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"=_",
"fft_",
"._",
"Plan_",
"(_",
"x_",
"._",
"shape_",
",_",
"np_",
"._",
"float32_",
",_",
"np_",
"._",
"complex",
"64_",
",_",
"auto",
"\\u",
"allocate",
"_",
"=_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"work",
"\\u",
"area_",
"=_",
"gpu",
"array_",
"._",
"empty_",
"(_",
"(_",
"plan_",
"._",
"works",
"ize_",
",_",
")_",
",_",
"np_",
"._",
"uint8_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plan_",
"._",
"set\\u",
"work",
"\\u",
"area_",
"(_",
"work",
"\\u",
"area_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fft_",
"._",
"fft_",
"(_",
"x",
"\\u",
"gpu_",
",_",
"xf",
"\\u",
"gpu_",
",_",
"plan_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"np_",
"._",
"allclose_",
"(_",
"xf_",
",_",
"xf",
"\\u",
"gpu_",
"._",
"get_",
"(_",
")_",
",_",
"atol_",
"=_",
"atol",
"\\u",
"float32_",
")_",
"\\u\\u\\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",
"fft_",
"(_",
"'",
"test\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"32",
"\\u",
"to",
"\\u",
"complex",
"64",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"64",
"\\u",
"to",
"\\u",
"float",
"32",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"multiple",
"\\u",
"stream",
"s",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"work",
"\\u",
"area",
"'_",
")_",
")_",
"\\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",
"fft_",
"(_",
"'",
"test\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"fft",
"\\u",
"float",
"64",
"\\u",
"to",
"\\u",
"complex",
"128",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"2d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"1d",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s_",
"._",
"add",
"Test_",
"(_",
"test\\u",
"fft_",
"(_",
"'",
"test\\u",
"batch",
"\\u",
"ifft",
"\\u",
"complex",
"128",
"\\u",
"to",
"\\u",
"float",
"64",
"\\u",
"2d",
"'_",
")_",
")_",
"\\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,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2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
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unreachable code | azoft-dev-team/imagrium/env/Lib/xml/sax/__init__.py | [
{
"content": "\"\"\"Simple API for XML (SAX) implementation for Python.\n\nThis module provides an implementation of the SAX 2 interface;\ninformation about the Java version of the interface can be found at\nhttp://www.megginson.com/SAX/. The Python version of the interface is\ndocumented at <...>.\n\nThis package contains the following modules:\n\nhandler -- Base classes and constants which define the SAX 2 API for\n the 'client-side' of SAX for Python.\n\nsaxutils -- Implementation of the convenience classes commonly used to\n work with SAX.\n\nxmlreader -- Base classes and constants which define the SAX 2 API for\n the parsers used with SAX for Python.\n\ndrivers2 -- Contains the driver for that wraps a Java sax implementation in python\n objects.\n\"\"\"\n\nfrom xmlreader import InputSource\nfrom handler import ContentHandler, ErrorHandler\nfrom _exceptions import SAXException, SAXNotRecognizedException, \\\n SAXParseException, SAXNotSupportedException, \\\n SAXReaderNotAvailable\n\n\n\n\n# this is the parser list used by the make_parser function if no\n# alternatives are given as parameters to the function\n\ndefault_parser_list = [\"xml.sax.drivers2.drv_javasax\"]\n\n# tell modulefinder that importing sax potentially imports expatreader\n_false = 0\nif _false:\n import xml.sax.drivers2.drv_javasax\n\nimport os, sys\nif os.environ.has_key(\"PY_SAX_PARSER\"):\n default_parser_list = os.environ[\"PY_SAX_PARSER\"].split(\",\")\ndel os\n\n_key = \"python.xml.sax.parser\"\nif sys.platform[:4] == \"java\" and sys.registry.containsKey(_key):\n default_parser_list = sys.registry.getProperty(_key).split(\",\")\n\n\n\n# --- Internal utility methods used by make_parser\n\n\ndel sys\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "import xml.sax.drivers2.drv_javasax",
"start_line": 59,
"start_column": 4,
"end_line": 59,
"end_column": 39
}
]
| []
| 1 | true | [
"[CLS]_",
"Unrea",
"chab",
"le_",
"code_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\"\"\"",
"Simple",
" ",
"API",
" ",
"for",
" ",
"XML",
" ",
"(",
"SA",
"X",
")",
" ",
"implementation",
" ",
"for",
" ",
"Pyth",
"on",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"Thi",
"s",
" ",
"module",
" ",
"provide",
"s",
" ",
"an",
" ",
"implementation",
" ",
"of",
" ",
"the",
" ",
"SA",
"X",
" ",
"2",
" ",
"interface",
";",
"\\",
"10",
";",
"informati",
"on",
" ",
"abo",
"ut",
" ",
"the",
" ",
"Ja",
"va",
" ",
"version",
" ",
"of",
" ",
"the",
" ",
"interface",
" ",
"can",
" ",
"be",
" ",
"found",
" ",
"at",
"\\",
"10",
";",
"http",
"://",
"www",
".",
"me",
"ggi",
"nso",
"n",
".",
"com",
"/",
"SA",
"X",
"/.",
" ",
" ",
"The",
" ",
"Pyth",
"on",
" ",
"version",
" ",
"of",
" ",
"the",
" ",
"interface",
" ",
"is",
"\\",
"10",
";",
"documente",
"d",
" ",
"at",
" ",
"<",
"...",
">.",
"\\",
"10",
";",
"\\",
"10",
";",
"Thi",
"s",
" ",
"package",
" ",
"contain",
"s",
" ",
"the",
" ",
"follow",
"ing",
" ",
"module",
"s",
":",
"\\",
"10",
";",
"\\",
"10",
";",
"handler",
" ",
"--",
" ",
"Base",
" ",
"classe",
"s",
" ",
"and",
" ",
"constant",
"s",
" ",
"whi",
"ch",
" ",
"defin",
"e",
" ",
"the",
" ",
"SA",
"X",
" ",
"2",
" ",
"API",
" ",
"for",
"\\",
"10",
";",
" ",
" ",
" ",
"the",
" ",
"'",
"client",
"-",
"side",
"'",
" ",
"of",
" ",
"SA",
"X",
" ",
"for",
" ",
"Pyth",
"on",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"sax",
"util",
"s",
" ",
"--",
" ",
"Implementation",
" ",
"of",
" ",
"the",
" ",
"convenien",
"ce",
" ",
"classe",
"s",
" ",
"common",
"ly",
" ",
"used",
" ",
"to",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"work",
" ",
"with",
" ",
"SA",
"X",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"xml",
"reader",
" ",
"--",
" ",
"Base",
" ",
"classe",
"s",
" ",
"and",
" ",
"constant",
"s",
" ",
"whi",
"ch",
" ",
"defin",
"e",
" ",
"the",
" ",
"SA",
"X",
" ",
"2",
" ",
"API",
" ",
"for",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
" ",
"the",
" ",
"parser",
"s",
" ",
"used",
" ",
"with",
" ",
"SA",
"X",
" ",
"for",
" ",
"Pyth",
"on",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"driver",
"s2",
" ",
"--",
" ",
"Contain",
"s",
" ",
"the",
" ",
"driver",
" ",
"for",
" ",
"tha",
"t",
" ",
"wrap",
"s",
" ",
"a",
" ",
"Ja",
"va",
" ",
"sax",
" ",
"implementation",
" ",
"in",
" ",
"python",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"object",
"s",
".",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"xml",
"reader_",
"import_",
"Inp",
"ut",
"Source_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"handler_",
"import_",
"Conten",
"t",
"Handler_",
",_",
"Error",
"Handler_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"\\u",
"exceptions_",
"import_",
"SA",
"XE",
"xcept",
"ion_",
",_",
"SA",
"XN",
"ot",
"Recognize",
"d",
"Exception_",
",_",
"SA",
"XP",
"arse",
"Exception_",
",_",
"SA",
"XN",
"ot",
"Supp",
"orte",
"d",
"Exception_",
",_",
"SA",
"XR",
"eader",
"Not",
"Available_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"#",
" ",
"this",
" ",
"is",
" ",
"the",
" ",
"parser",
" ",
"list",
" ",
"used",
" ",
"by",
" ",
"the",
" ",
"make",
"\\u",
"parser",
" ",
"function",
" ",
"if",
" ",
"no_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"alternatives",
" ",
"are",
" ",
"give",
"n",
" ",
"as",
" ",
"parameter",
"s",
" ",
"to",
" ",
"the",
" ",
"function_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"default",
"\\u",
"parser",
"\\u",
"list_",
"=_",
"[_",
"\"",
"xml",
".",
"sax",
".",
"driver",
"s2",
".",
"drv",
"\\u",
"java",
"sax",
"\"_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"tell",
" ",
"module",
"finde",
"r",
" ",
"tha",
"t",
" ",
"import",
"ing",
" ",
"sax",
" ",
"potenti",
"ally",
" ",
"import",
"s",
" ",
"expa",
"trea",
"der_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"false_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"\\u",
"false_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"import_",
"xml_",
"._",
"sax_",
"._",
"driver",
"s2_",
"._",
"drv",
"\\u",
"java",
"sax_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"import_",
"os_",
",_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"environ_",
"._",
"has",
"\\u",
"key_",
"(_",
"\"",
"PY",
"\\u",
"SA",
"X",
"\\u",
"PARSE",
"R",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"default",
"\\u",
"parser",
"\\u",
"list_",
"=_",
"os_",
"._",
"environ_",
"[_",
"\"",
"PY",
"\\u",
"SA",
"X",
"\\u",
"PARSE",
"R",
"\"_",
"]_",
"._",
"split_",
"(_",
"\",\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"del_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"key_",
"=_",
"\"",
"python",
".",
"xml",
".",
"sax",
".",
"parser",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"sys_",
"._",
"platform_",
"[_",
":_",
"4_",
"]_",
"==_",
"\"",
"java",
"\"_",
"and_",
"sys_",
"._",
"registry_",
"._",
"contain",
"s",
"Key_",
"(_",
"\\u",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"default",
"\\u",
"parser",
"\\u",
"list_",
"=_",
"sys_",
"._",
"registry_",
"._",
"get",
"Property_",
"(_",
"\\u",
"key_",
")_",
"._",
"split_",
"(_",
"\",\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"---",
" ",
"Intern",
"al",
" ",
"utility",
" ",
"method",
"s",
" ",
"used",
" ",
"by",
" ",
"make",
"\\u",
"parser_",
"\\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
]
|
Except block handles 'BaseException' | ufora/ufora/ufora/test/MultiMachineTestRunner.py | [
{
"content": "def extractErrorMessagesFromLogfile(logfile, targetDir):\n try:\n lineNumber = 0\n\n curBlock = []\n output = []\n\n def contains(msg):\n return \" ERROR \" in msg or \" CRITICAL \" in msg\n\n for line in open(logfile, \"r\"):\n lineNumber += 1\n\n if line[0] in (' ', '\\t') or not curBlock:\n curBlock.append(line.rstrip())\n else:\n #found one - dump it\n if contains(\"\\n\".join(curBlock)):\n output.append(\"\\n\".join(curBlock))\n\n curBlock = []\n\n curBlock.append(line.rstrip())\n\n\n if contains(\"\\n\".join(curBlock)):\n output.append(\"\\n\".join(curBlock))\n\n if output:\n fname = os.path.split(logfile)[1]\n finalFname = os.path.join(targetDir, fname + \"_errors.txt\")\n\n with open(finalFname, \"w\") as resultFile:\n for o in output:\n print >> resultFile, o\n logging.info(\n \"Checked %s lines of %s to produce %s lines of error messages in %s\",\n lineNumber,\n logfile,\n len(output),\n finalFname\n )\n else:\n logging.info(\"Checked %s lines of %s, but found no error messages\", lineNumber, logfile)\n except:\n logging.error(\"Failed to extract error messages from %s:\\n%s\",\n logfile,\n traceback.format_exc())",
"metadata": "root.extractErrorMessagesFromLogfile",
"header": "['module', '___EOS___']",
"index": 47
},
{
"content": " def postExecutionCleanup(self, outputDir):\n self.removePath(os.path.join(outputDir, \"cumulus_disk_storage\"))\n\n logDir = os.path.join(outputDir, \"logs\")\n logging.info(\"searching for logs in %s\", logDir)\n\n if not os.path.exists(logDir):\n logging.info(\"Log directory %s does not exist\")\n return\n\n for logfile in os.listdir(logDir):\n fullPath = os.path.join(logDir, logfile)\n if os.path.isfile(fullPath):\n extractErrorMessagesFromLogfile(fullPath, outputDir)\n\n try:\n targetLogPath = os.path.join(outputDir, \"cumulus_logs.tar.gz\")\n\n subprocess.call(['tar czf %s %s' % (targetLogPath, logDir)], shell=True)\n except:\n logging.error(\"Tried to copy %s to %s but failed: %s\",\n logDir,\n targetLogPath,\n traceback.format_exc())",
"metadata": "root.MultiMachineTestRunner.postExecutionCleanup",
"header": "['class', 'MultiMachineTestRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 147
},
{
"content": " @staticmethod\n def removePath(path):\n if not os.path.exists(path):\n return\n\n for tries in range(3):\n try:\n shutil.rmtree(path)\n return True\n except:\n if tries == 2:\n logging.warn(\"Failed to remove the path %s three times because:\\n%s\",\n path,\n traceback.format_exc())\n return False",
"metadata": "root.MultiMachineTestRunner.removePath",
"header": "['class', 'MultiMachineTestRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 172
}
]
| [
{
"span": "except:",
"start_line": 91,
"start_column": 4,
"end_line": 91,
"end_column": 11
},
{
"span": "except:",
"start_line": 166,
"start_column": 8,
"end_line": 166,
"end_column": 15
},
{
"span": "except:",
"start_line": 181,
"start_column": 12,
"end_line": 181,
"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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"extract",
"Error",
"Messag",
"es",
"Fro",
"m",
"Log",
"file_",
"(_",
"logfile_",
",_",
"target",
"Dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"line",
"Number_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"cur",
"Block_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"output_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"contains_",
"(_",
"msg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\"",
" ",
"ERROR",
" ",
"\"_",
"in_",
"msg_",
"or_",
"\"",
" ",
"CRIT",
"ICAL",
" ",
"\"_",
"in_",
"msg_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"line_",
"in_",
"open_",
"(_",
"logfile_",
",_",
"\"",
"r",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"line",
"Number_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"line_",
"[_",
"0_",
"]_",
"in_",
"(_",
"'",
" ",
"'_",
",_",
"'\\\\",
"t",
"'_",
")_",
"or_",
"not_",
"cur",
"Block_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cur",
"Block_",
"._",
"append_",
"(_",
"line_",
"._",
"rstrip_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"found",
" ",
"one",
" ",
"-",
" ",
"dump",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"contains_",
"(_",
"\"\\\\",
"n",
"\"_",
"._",
"join_",
"(_",
"cur",
"Block_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"output_",
"._",
"append_",
"(_",
"\"\\\\",
"n",
"\"_",
"._",
"join_",
"(_",
"cur",
"Block_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"cur",
"Block_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"cur",
"Block_",
"._",
"append_",
"(_",
"line_",
"._",
"rstrip_",
"(_",
")_",
")_",
"\\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_",
"contains_",
"(_",
"\"\\\\",
"n",
"\"_",
"._",
"join_",
"(_",
"cur",
"Block_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"output_",
"._",
"append_",
"(_",
"\"\\\\",
"n",
"\"_",
"._",
"join_",
"(_",
"cur",
"Block_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"output_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fname_",
"=_",
"os_",
"._",
"path_",
"._",
"split_",
"(_",
"logfile_",
")_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"Fn",
"ame_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"target",
"Dir_",
",_",
"fname_",
"+_",
"\"\\u",
"error",
"s",
".",
"txt",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"with_",
"open_",
"(_",
"final",
"Fn",
"ame_",
",_",
"\"",
"w",
"\"_",
")_",
"as_",
"result",
"File_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"o_",
"in_",
"output_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"print_",
">>_",
"result",
"File_",
",_",
"o_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"logging_",
"._",
"info_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"Check",
"ed",
" ",
"%",
"s",
" ",
"lines",
" ",
"of",
" ",
"%",
"s",
" ",
"to",
" ",
"produce",
" ",
"%",
"s",
" ",
"lines",
" ",
"of",
" ",
"error",
" ",
"message",
"s",
" ",
"in",
" ",
"%",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"line",
"Number_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"logfile_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"len_",
"(_",
"output_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"final",
"Fn",
"ame_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logging_",
"._",
"info_",
"(_",
"\"",
"Check",
"ed",
" ",
"%",
"s",
" ",
"lines",
" ",
"of",
" ",
"%",
"s",
",",
" ",
"but",
" ",
"found",
" ",
"no",
" ",
"error",
" ",
"message",
"s",
"\"_",
",_",
"line",
"Number_",
",_",
"logfile_",
")_",
"\\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_",
"(_",
"\"",
"Fail",
"ed",
" ",
"to",
" ",
"extract",
" ",
"error",
" ",
"message",
"s",
" ",
"from",
" ",
"%",
"s",
":\\\\",
"n",
"%",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"logfile_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"traceback_",
"._",
"format\\u",
"exc_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Multi",
"Machine",
"Test",
"Runner_",
"(_",
"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_",
"post",
"Execut",
"ion",
"Cleanup_",
"(_",
"self_",
",_",
"output",
"Dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"remove",
"Path_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"output",
"Dir_",
",_",
"\"",
"cumul",
"us",
"\\u",
"disk",
"\\u",
"storage",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"log",
"Dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"output",
"Dir_",
",_",
"\"",
"logs",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"logging_",
"._",
"info_",
"(_",
"\"",
"search",
"ing",
" ",
"for",
" ",
"logs",
" ",
"in",
" ",
"%",
"s",
"\"_",
",_",
"log",
"Dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"log",
"Dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logging_",
"._",
"info_",
"(_",
"\"",
"Log",
" ",
"director",
"y",
" ",
"%",
"s",
" ",
"doe",
"s",
" ",
"not",
" ",
"exist",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"logfile_",
"in_",
"os_",
"._",
"listdir_",
"(_",
"log",
"Dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"full",
"Path_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"log",
"Dir_",
",_",
"logfile_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"path_",
"._",
"isfile_",
"(_",
"full",
"Path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"extract",
"Error",
"Messag",
"es",
"Fro",
"m",
"Log",
"file_",
"(_",
"full",
"Path_",
",_",
"output",
"Dir_",
")_",
"\\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 ",
" _",
"target",
"Log",
"Path_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"output",
"Dir_",
",_",
"\"",
"cumul",
"us",
"\\u",
"logs",
".",
"tar",
".",
"gz",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"subprocess_",
"._",
"call_",
"(_",
"[_",
"'",
"tar",
" ",
"cz",
"f",
" ",
"%",
"s",
" ",
"%",
"s",
"'_",
"%_",
"(_",
"target",
"Log",
"Path_",
",_",
"log",
"Dir_",
")_",
"]_",
",_",
"shell_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logging_",
"._",
"error_",
"(_",
"\"",
"Trie",
"d",
" ",
"to",
" ",
"copy",
" ",
"%",
"s",
" ",
"to",
" ",
"%",
"s",
" ",
"but",
" ",
"fail",
"ed",
":",
" ",
"%",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"log",
"Dir_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"target",
"Log",
"Path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"traceback_",
"._",
"format\\u",
"exc_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Multi",
"Machine",
"Test",
"Runner_",
"(_",
"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_",
"@_",
"staticmethod_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"remove",
"Path_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"tries_",
"in_",
"range_",
"(_",
"3_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"shutil_",
"._",
"rmtree_",
"(_",
"path_",
")_",
"\\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 ",
" _",
"if_",
"tries_",
"==_",
"2_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"logging_",
"._",
"warn_",
"(_",
"\"",
"Fail",
"ed",
" ",
"to",
" ",
"remove",
" ",
"the",
" ",
"path",
" ",
"%",
"s",
" ",
"three",
" ",
"times",
" ",
"bec",
"aus",
"e",
":\\\\",
"n",
"%",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"traceback_",
"._",
"format\\u",
"exc_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | karlnapf/kameleon-mcmc/kameleon_mcmc/gp/scripts/circle_rect_hybrid_gaussian_ard.py | [
{
"content": "\"\"\"\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3 of the License, or\n(at your option) any later version.\n\nWritten (W) 2013 Heiko Strathmann\n\"\"\"\nfrom kameleon_mcmc.distribution.Gaussian import Gaussian\nfrom kameleon_mcmc.experiments.SingleChainExperiment import SingleChainExperiment\nfrom kameleon_mcmc.gp.GPData import GPData\nfrom kameleon_mcmc.gp.mcmc.PseudoMarginalHyperparameterDistribution import \\\n PseudoMarginalHyperparameterDistribution\nfrom kameleon_mcmc.kernel.GaussianKernel import GaussianKernel\nfrom kameleon_mcmc.mcmc.MCMCChain import MCMCChain\nfrom kameleon_mcmc.mcmc.MCMCParams import MCMCParams\nfrom kameleon_mcmc.mcmc.output.PlottingOutput import PlottingOutput\nfrom kameleon_mcmc.mcmc.output.StatisticsOutput import StatisticsOutput\nfrom kameleon_mcmc.mcmc.samplers.AdaptiveMetropolisLearnScale import \\\n AdaptiveMetropolisLearnScale\nfrom kameleon_mcmc.mcmc.samplers.KameleonWindowLearnScale import KameleonWindowLearnScale\nfrom kameleon_mcmc.mcmc.samplers.StandardMetropolis import StandardMetropolis\nfrom matplotlib.pyplot import plot\nfrom numpy.lib.twodim_base import eye\nfrom numpy.ma.core import mean, std, ones, shape\nfrom numpy.ma.extras import vstack, hstack\nimport os\nimport sys\n \nif __name__ == '__main__':\n # sample data\n data_circle, labels_circle=GPData.sample_circle_data(n=40, seed_init=1)\n data_rect, labels_rect=GPData.sample_rectangle_data(n=60, seed_init=1)\n \n # combine\n data=vstack((data_circle, data_rect))\n labels=hstack((labels_circle, labels_rect))\n dim=shape(data)[1]\n \n # normalise data\n data-=mean(data, 0)\n data/=std(data,0)\n\n # plot\n idx_a=labels>0\n idx_b=labels<0\n plot(data[idx_a,0], data[idx_a,1],\"ro\")\n plot(data[idx_b,0], data[idx_b,1],\"bo\")\n \n # prior on theta and posterior target estimate\n theta_prior=Gaussian(mu=0*ones(dim), Sigma=eye(dim)*5)\n target=PseudoMarginalHyperparameterDistribution(data, labels, \\\n n_importance=100, prior=theta_prior, \\\n ridge=1e-3)\n \n # create sampler\n burnin=10000\n num_iterations=burnin+300000\n kernel = GaussianKernel(sigma=35.0)\n sampler=KameleonWindowLearnScale(target, kernel, stop_adapt=burnin)\n# sampler=AdaptiveMetropolisLearnScale(target)\n# sampler=StandardMetropolis(target)\n \n start=0.0*ones(target.dimension)\n params = MCMCParams(start=start, num_iterations=num_iterations, burnin=burnin)\n \n # create MCMC chain\n chain=MCMCChain(sampler, params)\n chain.append_mcmc_output(StatisticsOutput(print_from=0, lag=100))\n# chain.append_mcmc_output(PlottingOutput(plot_from=0, lag=500))\n \n # create experiment instance to store results\n experiment_dir = str(os.path.abspath(sys.argv[0])).split(os.sep)[-1].split(\".\")[0] + os.sep\n experiment = SingleChainExperiment(chain, experiment_dir)\n \n experiment.run()\n \n sigma=GaussianKernel.get_sigma_median_heuristic(experiment.mcmc_chain.samples.T)\n print \"median kernel width\", sigma",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "from kameleon_mcmc.mcmc.output.PlottingOutput import PlottingOutput",
"start_line": 16,
"start_column": 0,
"end_line": 16,
"end_column": 67
},
{
"span": "from kameleon_mcmc.mcmc.samplers.AdaptiveMetropolisLearnScale import \\\n AdaptiveMetropolisLearnScale",
"start_line": 18,
"start_column": 0,
"end_line": 19,
"end_column": 32
},
{
"span": "from kameleon_mcmc.mcmc.samplers.StandardMetropolis import StandardMetropolis",
"start_line": 21,
"start_column": 0,
"end_line": 21,
"end_column": 77
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
"Thi",
"s",
" ",
"program",
" ",
"is",
" ",
"free",
" ",
"software",
";",
" ",
"you",
" ",
"can",
" ",
"redis",
"tribut",
"e",
" ",
"it",
" ",
"and",
"/",
"or",
" ",
"modif",
"y",
"\\",
"10",
";",
"it",
" ",
"under",
" ",
"the",
" ",
"term",
"s",
" ",
"of",
" ",
"the",
" ",
"GN",
"U",
" ",
"General",
" ",
"Public",
" ",
"License",
" ",
"as",
" ",
"publi",
"shed",
" ",
"by",
"\\",
"10",
";",
"the",
" ",
"Free",
" ",
"Sof",
"twa",
"re",
" ",
"Foun",
"dati",
"on",
";",
" ",
"eit",
"her",
" ",
"version",
" ",
"3",
" ",
"of",
" ",
"the",
" ",
"License",
",",
" ",
"or",
"\\",
"10",
";",
"(",
"at",
" ",
"your",
" ",
"option",
")",
" ",
"any",
" ",
"late",
"r",
" ",
"version",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"Writ",
"ten",
" ",
"(",
"W",
")",
" ",
"2013",
" ",
"Hei",
"ko",
" ",
"Strat",
"hma",
"nn",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"distribution_",
"._",
"Gaussian",
"_",
"import_",
"Gaussian",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"experiments_",
"._",
"Sing",
"le",
"Chain",
"Experiment_",
"import_",
"Sing",
"le",
"Chain",
"Experiment_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"gp_",
"._",
"GP",
"Data_",
"import_",
"GP",
"Data_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"gp_",
"._",
"mcmc",
"_",
"._",
"Pse",
"udo",
"Marg",
"inal",
"Hyper",
"parameter",
"Distribution_",
"import_",
"Pse",
"udo",
"Marg",
"inal",
"Hyper",
"parameter",
"Distribution_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"kernel_",
"._",
"Gaussian",
"Kernel_",
"import_",
"Gaussian",
"Kernel_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"MCM",
"CC",
"hain",
"_",
"import_",
"MCM",
"CC",
"hain",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"MCM",
"CP",
"arams_",
"import_",
"MCM",
"CP",
"arams_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"output_",
"._",
"Plott",
"ing",
"Output_",
"import_",
"Plott",
"ing",
"Output_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"output_",
"._",
"Statistic",
"s",
"Output_",
"import_",
"Statistic",
"s",
"Output_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"sampler",
"s_",
"._",
"Adapti",
"ve",
"Metro",
"polis",
"Learn",
"Scale_",
"import_",
"Adapti",
"ve",
"Metro",
"polis",
"Learn",
"Scale_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"sampler",
"s_",
"._",
"Kam",
"ele",
"on",
"Window",
"Learn",
"Scale_",
"import_",
"Kam",
"ele",
"on",
"Window",
"Learn",
"Scale_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kam",
"ele",
"on",
"\\u",
"mcmc",
"_",
"._",
"mcmc",
"_",
"._",
"sampler",
"s_",
"._",
"Standard",
"Metro",
"polis",
"_",
"import_",
"Standard",
"Metro",
"polis",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"matplotlib_",
"._",
"pyplot_",
"import_",
"plot_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"numpy_",
"._",
"lib_",
"._",
"two",
"dim",
"\\u",
"base_",
"import_",
"eye_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"numpy_",
"._",
"ma_",
"._",
"core_",
"import_",
"mean_",
",_",
"std_",
",_",
"ones_",
",_",
"shape_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"numpy_",
"._",
"ma_",
"._",
"extras_",
"import_",
"vstack_",
",_",
"hstack_",
"\\u\\u\\uNEWLINE\\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_",
"if_",
"\\u\\u",
"name\\u\\u_",
"==_",
"'\\u",
"\\u",
"main",
"\\u\\u'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"sample",
" ",
"data_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data\\u",
"circle_",
",_",
"labels",
"\\u",
"circle_",
"=_",
"GP",
"Data_",
"._",
"sample",
"\\u",
"circle",
"\\u",
"data_",
"(_",
"n_",
"=_",
"40_",
",_",
"seed",
"\\u",
"init_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data\\u",
"rect_",
",_",
"labels",
"\\u",
"rect_",
"=_",
"GP",
"Data_",
"._",
"sample",
"\\u",
"rectangle",
"\\u",
"data_",
"(_",
"n_",
"=_",
"60_",
",_",
"seed",
"\\u",
"init_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"combine_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"=_",
"vstack_",
"(_",
"(_",
"data\\u",
"circle_",
",_",
"data\\u",
"rect_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"labels_",
"=_",
"hstack_",
"(_",
"(_",
"labels",
"\\u",
"circle_",
",_",
"labels",
"\\u",
"rect_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"dim_",
"=_",
"shape_",
"(_",
"data_",
")_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"normalise",
" ",
"data_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"-=_",
"mean_",
"(_",
"data_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"/=_",
"std_",
"(_",
"data_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"plot_",
"\\u\\u\\uNL\\u\\u\\u_",
"idx",
"\\u",
"a_",
"=_",
"labels_",
">_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"idx",
"\\u",
"b_",
"=_",
"labels_",
"<_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plot_",
"(_",
"data_",
"[_",
"idx",
"\\u",
"a_",
",_",
"0_",
"]_",
",_",
"data_",
"[_",
"idx",
"\\u",
"a_",
",_",
"1_",
"]_",
",_",
"\"",
"ro",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plot_",
"(_",
"data_",
"[_",
"idx",
"\\u",
"b_",
",_",
"0_",
"]_",
",_",
"data_",
"[_",
"idx",
"\\u",
"b_",
",_",
"1_",
"]_",
",_",
"\"",
"bo",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"prior",
" ",
"on",
" ",
"theta",
" ",
"and",
" ",
"posterior",
" ",
"target",
" ",
"estimate_",
"\\u\\u\\uNL\\u\\u\\u_",
"theta",
"\\u",
"prior_",
"=_",
"Gaussian",
"_",
"(_",
"mu_",
"=_",
"0_",
"*_",
"ones_",
"(_",
"dim_",
")_",
",_",
"Sigma_",
"=_",
"eye_",
"(_",
"dim_",
")_",
"*_",
"5_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"target_",
"=_",
"Pse",
"udo",
"Marg",
"inal",
"Hyper",
"parameter",
"Distribution_",
"(_",
"data_",
",_",
"labels_",
",_",
"n",
"\\u",
"importance",
"_",
"=_",
"100_",
",_",
"prior_",
"=_",
"theta",
"\\u",
"prior_",
",_",
"ridge",
"_",
"=_",
"1e-3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"create",
" ",
"sampler_",
"\\u\\u\\uNL\\u\\u\\u_",
"burn",
"in_",
"=_",
"10000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"num",
"\\u",
"iterations_",
"=_",
"burn",
"in_",
"+_",
"300000",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kernel_",
"=_",
"Gaussian",
"Kernel_",
"(_",
"sigma_",
"=_",
"35.",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"sampler_",
"=_",
"Kam",
"ele",
"on",
"Window",
"Learn",
"Scale_",
"(_",
"target_",
",_",
"kernel_",
",_",
"stop",
"\\u",
"adapt",
"_",
"=_",
"burn",
"in_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"sampler",
"=",
"Adapti",
"ve",
"Metro",
"polis",
"Learn",
"Scale",
"(",
"target",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"sampler",
"=",
"Standard",
"Metro",
"polis",
"(",
"target",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"start_",
"=_",
"0.0_",
"*_",
"ones_",
"(_",
"target_",
"._",
"dimension_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"params_",
"=_",
"MCM",
"CP",
"arams_",
"(_",
"start_",
"=_",
"start_",
",_",
"num",
"\\u",
"iterations_",
"=_",
"num",
"\\u",
"iterations_",
",_",
"burn",
"in_",
"=_",
"burn",
"in_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"create",
" ",
"MCM",
"C",
" ",
"chain_",
"\\u\\u\\uNL\\u\\u\\u_",
"chain_",
"=_",
"MCM",
"CC",
"hain",
"_",
"(_",
"sampler_",
",_",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"chain_",
"._",
"append",
"\\u",
"mcmc",
"\\u",
"output_",
"(_",
"Statistic",
"s",
"Output_",
"(_",
"print",
"\\u",
"from_",
"=_",
"0_",
",_",
"lag_",
"=_",
"100_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"chain",
".",
"append",
"\\u",
"mcmc",
"\\u",
"output",
"(",
"Plott",
"ing",
"Output",
"(",
"plot",
"\\u",
"from",
"=",
"0",
",",
" ",
"lag",
"=",
"500",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"create",
" ",
"experiment",
" ",
"instance",
" ",
"to",
" ",
"store",
" ",
"results_",
"\\u\\u\\uNL\\u\\u\\u_",
"experiment",
"\\u",
"dir_",
"=_",
"str_",
"(_",
"os_",
"._",
"path_",
"._",
"abspath_",
"(_",
"sys_",
"._",
"argv_",
"[_",
"0_",
"]_",
")_",
")_",
"._",
"split_",
"(_",
"os_",
"._",
"sep_",
")_",
"[_",
"-_",
"1_",
"]_",
"._",
"split_",
"(_",
"\".\"_",
")_",
"[_",
"0_",
"]_",
"+_",
"os_",
"._",
"sep_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"experiment_",
"=_",
"Sing",
"le",
"Chain",
"Experiment_",
"(_",
"chain_",
",_",
"experiment",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"experiment_",
"._",
"run_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"sigma_",
"=_",
"Gaussian",
"Kernel_",
"._",
"get",
"\\u",
"sigma",
"\\u",
"median",
"\\u",
"heuristic",
"_",
"(_",
"experiment_",
"._",
"mcmc",
"\\u",
"chain_",
"._",
"samples_",
"._",
"T_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"median",
" ",
"kernel",
" ",
"widt",
"h",
"\"_",
",_",
"sigma_"
]
| [
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,
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
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Except block handles 'BaseException' | soimort/you-get/src/you_get/util/git.py | [
{
"content": "def get_head(repo_path):\n \"\"\"Get (branch, commit) from HEAD of a git repo.\"\"\"\n try:\n ref = open(os.path.join(repo_path, '.git', 'HEAD'), 'r').read().strip()[5:].split('/')\n branch = ref[-1]\n commit = open(os.path.join(repo_path, '.git', *ref), 'r').read().strip()[:7]\n return branch, commit\n except:\n return None",
"metadata": "root.get_head",
"header": "['module', '___EOS___']",
"index": 6
},
{
"content": "def get_version(repo_path):\n try:\n version = __version__.split('.')\n major, minor, cn = [int(i) for i in version]\n p = subprocess.Popen(['git',\n '--git-dir', os.path.join(repo_path, '.git'),\n '--work-tree', repo_path,\n 'rev-list', 'HEAD', '--count'],\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n raw, err = p.communicate()\n c_head = int(raw.decode('ascii'))\n q = subprocess.Popen(['git',\n '--git-dir', os.path.join(repo_path, '.git'),\n '--work-tree', repo_path,\n 'rev-list', 'master', '--count'],\n stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n raw, err = q.communicate()\n c_master = int(raw.decode('ascii'))\n cc = c_head - c_master\n assert cc\n return '%s.%s.%s' % (major, minor, cn + cc)\n except:\n return __version__",
"metadata": "root.get_version",
"header": "['module', '___EOS___']",
"index": 16
}
]
| [
{
"span": "except:",
"start_line": 13,
"start_column": 4,
"end_line": 13,
"end_column": 11
},
{
"span": "except:",
"start_line": 37,
"start_column": 4,
"end_line": 37,
"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_",
"def_",
"get",
"\\u",
"head_",
"(_",
"repo",
"\\u",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Get",
" ",
"(",
"branch",
",",
" ",
"commit",
")",
" ",
"from",
" ",
"HEAD",
" ",
"of",
" ",
"a",
" ",
"git",
" ",
"repo",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ref_",
"=_",
"open_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"repo",
"\\u",
"path_",
",_",
"'.",
"git",
"'_",
",_",
"'",
"HEAD",
"'_",
")_",
",_",
"'",
"r",
"'_",
")_",
"._",
"read_",
"(_",
")_",
"._",
"strip_",
"(_",
")_",
"[_",
"5_",
":_",
"]_",
"._",
"split_",
"(_",
"'/'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"branch_",
"=_",
"ref_",
"[_",
"-_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"commit_",
"=_",
"open_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"repo",
"\\u",
"path_",
",_",
"'.",
"git",
"'_",
",_",
"*_",
"ref_",
")_",
",_",
"'",
"r",
"'_",
")_",
"._",
"read_",
"(_",
")_",
"._",
"strip_",
"(_",
")_",
"[_",
":_",
"7_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"branch_",
",_",
"commit_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"version_",
"(_",
"repo",
"\\u",
"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 ",
" _",
"version_",
"=_",
"\\u\\u",
"version\\u\\u_",
"._",
"split_",
"(_",
"'.'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"major_",
",_",
"minor_",
",_",
"cn_",
"=_",
"[_",
"int_",
"(_",
"i_",
")_",
"for_",
"i_",
"in_",
"version_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p_",
"=_",
"subprocess_",
"._",
"Popen_",
"(_",
"[_",
"'",
"git",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'--",
"git",
"-",
"dir",
"'_",
",_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"repo",
"\\u",
"path_",
",_",
"'.",
"git",
"'_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'--",
"work",
"-",
"tree",
"'_",
",_",
"repo",
"\\u",
"path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"rev",
"-",
"list",
"'_",
",_",
"'",
"HEAD",
"'_",
",_",
"'--",
"count",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"stdout_",
"=_",
"subprocess_",
"._",
"PIPE_",
",_",
"stderr_",
"=_",
"subprocess_",
"._",
"PIPE_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raw_",
",_",
"err_",
"=_",
"p_",
"._",
"communicate_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"c\\u",
"head_",
"=_",
"int_",
"(_",
"raw_",
"._",
"decode_",
"(_",
"'",
"ascii",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"q_",
"=_",
"subprocess_",
"._",
"Popen_",
"(_",
"[_",
"'",
"git",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'--",
"git",
"-",
"dir",
"'_",
",_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"repo",
"\\u",
"path_",
",_",
"'.",
"git",
"'_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'--",
"work",
"-",
"tree",
"'_",
",_",
"repo",
"\\u",
"path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"rev",
"-",
"list",
"'_",
",_",
"'",
"master",
"'_",
",_",
"'--",
"count",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"stdout_",
"=_",
"subprocess_",
"._",
"PIPE_",
",_",
"stderr_",
"=_",
"subprocess_",
"._",
"PIPE_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raw_",
",_",
"err_",
"=_",
"q_",
"._",
"communicate_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"c\\u",
"master_",
"=_",
"int_",
"(_",
"raw_",
"._",
"decode_",
"(_",
"'",
"ascii",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
2,
2,
2,
2,
2,
2
]
|
Imprecise assert | kivy/kivy/kivy/tests/test_utils.py | [
{
"content": " def test_Platform_android(self):\n with patch.dict('os.environ', {'ANDROID_ARGUMENT': ''}):\n pf = Platform()\n self.assertTrue(pf == 'android')\n self.assertNotIn('ANDROID_ARGUMENT', os.environ)",
"metadata": "root.UtilsTest.test_Platform_android",
"header": "['class', 'UtilsTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 199
},
{
"content": " def _test_platforms(self, input, testval):\n utils._sys_platform = input\n pf = Platform()\n self.assertTrue(pf == testval)\n #with patch('kivy.utils._sys_platform') as m:\n # m.__str__.return_value = input\n # m.__eq__ = lambda x, y: str(x) == y\n # pf = Platform()\n # self.assertTrue(str(pf) == testval)",
"metadata": "root.UtilsTest._test_platforms",
"header": "['class', 'UtilsTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 229
}
]
| [
{
"span": "self.assertTrue(pf == 'android')",
"start_line": 202,
"start_column": 12,
"end_line": 202,
"end_column": 44
},
{
"span": "self.assertTrue(pf == testval)",
"start_line": 232,
"start_column": 8,
"end_line": 232,
"end_column": 38
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Ut",
"il",
"s",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"Plat",
"form",
"\\u",
"android",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"with_",
"patch_",
"._",
"dict_",
"(_",
"'",
"os",
".",
"environ",
"'_",
",_",
"{_",
"'",
"ANDROID",
"\\u",
"ARGUMENT",
"'_",
":_",
"''_",
"}_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pf_",
"=_",
"Platform_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"pf_",
"==_",
"'",
"android",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"'",
"ANDROID",
"\\u",
"ARGUMENT",
"'_",
",_",
"os_",
"._",
"environ_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Ut",
"il",
"s",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"test\\u",
"platforms_",
"(_",
"self_",
",_",
"input_",
",_",
"testv",
"al_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"utils_",
"._",
"\\u",
"sys",
"\\u",
"platform_",
"=_",
"input_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pf_",
"=_",
"Platform_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"pf_",
"==_",
"testv",
"al_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"with",
" ",
"patch",
"('",
"ki",
"vy",
".",
"util",
"s",
".\\u",
"sys",
"\\u",
"platform",
"')",
" ",
"as",
" ",
"m",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"m",
".\\u",
"\\u",
"str",
"\\u\\u",
".",
"return",
"\\u",
"value",
" ",
"=",
" ",
"input_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"m",
".\\u",
"\\u",
"eq",
"\\u\\u",
" ",
"=",
" ",
"lambda",
" ",
"x",
",",
" ",
"y",
":",
" ",
"str",
"(",
"x",
")",
" ",
"==",
" ",
"y_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"pf",
" ",
"=",
" ",
"Plat",
"form",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"self",
".",
"assert",
"Tru",
"e",
"(",
"str",
"(",
"pf",
")",
" ",
"==",
" ",
"testv",
"al",
")_",
"\\u\\u\\uNL\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
2,
2,
2,
2,
2,
2
]
|
Unused import | EricssonResearch/calvin-base/calvin/runtime/south/plugins/storage/twistedimpl/securedht/tests/test_dht_server_nice4.py | [
{
"content": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2015 Ericsson AB\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 pytest\nimport sys\nimport os\nimport traceback\nimport hashlib\nimport twisted\nimport shutil\nimport json\n\nfrom calvin.utilities.calvin_callback import CalvinCB\nfrom calvin.utilities import calvinlogger\nfrom calvin.utilities.utils import get_home\nfrom calvin.runtime.south.plugins.storage.twistedimpl.securedht.append_server import *\nfrom calvin.runtime.south.plugins.storage.twistedimpl.securedht.dht_server import *\nfrom calvin.runtime.south.plugins.storage.twistedimpl.securedht.service_discovery_ssdp import *\nfrom calvin.runtime.south.plugins.storage.twistedimpl.securedht.dht_server_commons import drawNetworkState\nfrom kademlia.node import Node\nfrom kademlia.utils import deferredDict, digest\n\nfrom calvin.runtime.south.plugins.async import threads\nfrom calvin.utilities import calvinconfig\n\n_conf = calvinconfig.get()\n_conf.add_section(\"security\")\n_conf_file = os.path.join(get_home(), \".calvin/security/test/openssl.conf\")\n_conf.set(\"security\", \"certificate_conf\", _conf_file)\n_conf.set(\"security\", \"certificate_domain\", \"test\")\n_cert_conf = None\n\n_log = calvinlogger.get_logger(__name__)\nname = \"node4:\"\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "@pytest.fixture(scope=\"session\", autouse=True)\n\n\ndef cleanup(request):\n def fin():\n reactor.callFromThread(reactor.stop)\n request.addfinalizer(fin)",
"metadata": "root.cleanup",
"header": "['module', '___EOS___']",
"index": 48
},
{
"content": "@pytest.mark.interactive\[email protected]\nclass TestDHT(object):\n test_nodes = 2\n _sucess_start = (True,)\n\n",
"metadata": "root.TestDHT",
"header": "['module', '___EOS___']",
"index": 56
},
{
"content": " @pytest.fixture(autouse=True, scope=\"class\")\n def setup(self, request):\n global _cert_conf\n _cert_conf = certificate.Config(_conf_file, \"test\").configuration",
"metadata": "root.TestDHT.setup",
"header": "['class', 'TestDHT', '(', 'object', ')', ':', '___EOS___']",
"index": 62
},
{
"content": " @pytest.inlineCallbacks\n def test_dht_multi(self, monkeypatch):\n iface = \"0.0.0.0\"\n a = None\n b = None\n q = Queue.Queue()\n\n\n def server_started(aa, *args):\n for b in args:\n if isinstance(b, twisted.python.failure.Failure):\n b.printTraceback()\n else:\n _log.debug(\"** %s\" % b)\n q.put([aa,args])\n\n try:\n amount_of_servers = 5\n # Twisted is using 20 threads so having > 20 server\n # causes threadlocks really easily.\n\n servers = []\n callbacks = []\n for servno in range(0, amount_of_servers):\n a = AutoDHTServer()\n servers.append(a)\n callback = CalvinCB(server_started, str(servno))\n servers[servno].start(iface, network=\"Niklas\", cb=callback, name=name + \"{}\".format(servno))\n callbacks.append(callback)\n \n # Wait for start\n started = []\n while len(started) < amount_of_servers:\n try:\n server = yield threads.defer_to_thread(q.get)\n except Queue.Empty:\n _log.debug(\"Queue empty!\")\n #raise \n if server not in started:\n started.append(server)\n #print(\"DHT Servers added: {}\".format(started))\n callbacks[int(server[0][0])].func = lambda *args, **kvargs:None\n else:\n print(\"Server: {} already started.\" \\\n \" {} out of {}\".format(started,\n len(started),\n amount_of_servers))\n\n print(\"All {} out of {} started\".format(started,\n len(started),\n amount_of_servers))\n for servno in range(0, amount_of_servers):\n assert [str(servno), self._sucess_start] in started\n \n yield threads.defer_to_thread(q.queue.clear)\n yield threads.defer_to_thread(time.sleep, 8)\n\n key = \"HARE\"\n value = json.dumps([\"morot\"])\n set_def = servers[0].append(key=key, value=value)\n set_value = yield threads.defer_to_thread(set_def.wait, 10)\n assert set_value\n print(\"Node with port {} posted append key={}, value={}\".format(servers[0].dht_server.port.getHost().port, key, value))\n value = json.dumps([\"selleri\"])\n set_def = servers[0].append(key=key, value=value)\n set_value = yield threads.defer_to_thread(set_def.wait, 10)\n assert set_value\n print(\"Node with port {} posted append key={}, value={}\".format(servers[0].dht_server.port.getHost().port, key, value))\n get_def = servers[0].get_concat(key=key)\n get_value = yield threads.defer_to_thread(get_def.wait, 10)\n assert set(json.loads(get_value)) == set([\"morot\", \"selleri\"])\n print(\"Node with port {} confirmed key={}, value={} was reachable\".format(servers[0].dht_server.port.getHost().port, key, get_value))\n\n drawNetworkState(\"1nice_graph.png\", servers, amount_of_servers)\n yield threads.defer_to_thread(time.sleep, 7)\n drawNetworkState(\"1middle_graph.png\", servers, amount_of_servers)\n yield threads.defer_to_thread(time.sleep, 7)\n drawNetworkState(\"1end_graph.png\", servers, amount_of_servers)\n\n get_def = servers[0].get_concat(key=key)\n get_value = yield threads.defer_to_thread(get_def.wait, 10)\n assert set(json.loads(get_value)) == set([\"morot\", \"selleri\"])\n print(\"Node with port {} got right value: {}\".format(servers[0].dht_server.port.getHost().port, get_value))\n value = json.dumps([\"morot\"])\n set_def = servers[0].remove(key=key, value=value)\n set_value = yield threads.defer_to_thread(set_def.wait, 10)\n assert set_value\n print(\"Node with port {} posted remove key={}, value={}\".format(servers[0].dht_server.port.getHost().port, key, value))\n get_def = servers[1].get_concat(key=key)\n get_value = yield threads.defer_to_thread(get_def.wait, 10)\n assert set(json.loads(get_value)) == set([\"selleri\"])\n print(\"Node with port {} got right value: {}\".format(servers[0].dht_server.port.getHost().port, get_value))\n for i in range(0, amount_of_servers):\n name_dir = os.path.join(_cert_conf[\"CA_default\"][\"runtimes_dir\"], \"{}{}\".format(name, i))\n filenames = os.listdir(os.path.join(name_dir, \"others\"))\n print(\"Node with port {} has {} certificates in store\".format(servers[i].dht_server.port.getHost().port, len(filenames)))\n\n except AssertionError as e:\n print(\"Node with port {} got wrong value: {}, should have been {}\".format(servers[0].dht_server.port.getHost().port, get_value, value))\n pytest.fail(traceback.format_exc())\n except Exception as e:\n traceback.print_exc()\n pytest.fail(traceback.format_exc())\n finally:\n yield threads.defer_to_thread(time.sleep, 10)\n i = 0\n for server in servers:\n name_dir = os.path.join(_cert_conf[\"CA_default\"][\"runtimes_dir\"], name + \"{}\".format(i))\n shutil.rmtree(os.path.join(name_dir, \"others\"), ignore_errors=True)\n os.mkdir(os.path.join(name_dir, \"others\"))\n i += 1\n server.stop()",
"metadata": "root.TestDHT.test_dht_multi",
"header": "['class', 'TestDHT', '(', 'object', ')', ':', '___EOS___']",
"index": 67
}
]
| [
{
"span": "import sys",
"start_line": 17,
"start_column": 0,
"end_line": 17,
"end_column": 10
},
{
"span": "import hashlib",
"start_line": 20,
"start_column": 0,
"end_line": 20,
"end_column": 14
},
{
"span": "from kademlia.node import Node",
"start_line": 32,
"start_column": 0,
"end_line": 32,
"end_column": 30
},
{
"span": "from kademlia.utils import deferredDict, digest",
"start_line": 33,
"start_column": 0,
"end_line": 33,
"end_column": 47
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"201",
"5",
" ",
"Eri",
"css",
"on",
" ",
"AB_",
"\\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_",
"pytest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"traceback_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"hashlib_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"twisted_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"shutil_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"json_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"utilities_",
"._",
"cal",
"vin",
"\\u",
"callback_",
"import_",
"Cal",
"vin",
"CB_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"utilities_",
"import_",
"cal",
"vin",
"logger_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"utilities_",
"._",
"utils_",
"import_",
"get",
"\\u",
"home_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"runtime_",
"._",
"south_",
"._",
"plugins_",
"._",
"storage_",
"._",
"twist",
"edi",
"mpl_",
"._",
"secure",
"dht",
"_",
"._",
"append",
"\\u",
"server_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"runtime_",
"._",
"south_",
"._",
"plugins_",
"._",
"storage_",
"._",
"twist",
"edi",
"mpl_",
"._",
"secure",
"dht",
"_",
"._",
"dht",
"\\u",
"server_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"runtime_",
"._",
"south_",
"._",
"plugins_",
"._",
"storage_",
"._",
"twist",
"edi",
"mpl_",
"._",
"secure",
"dht",
"_",
"._",
"service",
"\\u",
"discove",
"ry",
"\\u",
"ssd",
"p_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"runtime_",
"._",
"south_",
"._",
"plugins_",
"._",
"storage_",
"._",
"twist",
"edi",
"mpl_",
"._",
"secure",
"dht",
"_",
"._",
"dht",
"\\u",
"server",
"\\u",
"commons_",
"import_",
"draw",
"Network",
"State_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kad",
"em",
"lia",
"_",
"._",
"node_",
"import_",
"Node_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"kad",
"em",
"lia",
"_",
"._",
"utils_",
"import_",
"defer",
"red",
"Dict_",
",_",
"digest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"runtime_",
"._",
"south_",
"._",
"plugins_",
"._",
"async_",
"import_",
"threads_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"utilities_",
"import_",
"cal",
"vin",
"config_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"conf_",
"=_",
"cal",
"vin",
"config_",
"._",
"get_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"conf_",
"._",
"add",
"\\u",
"section_",
"(_",
"\"",
"security",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"conf",
"\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"get",
"\\u",
"home_",
"(_",
")_",
",_",
"\".",
"cal",
"vin",
"/",
"security",
"/",
"test",
"/",
"openss",
"l",
".",
"conf",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"conf_",
"._",
"set_",
"(_",
"\"",
"security",
"\"_",
",_",
"\"",
"certifica",
"te",
"\\u",
"conf",
"\"_",
",_",
"\\u",
"conf",
"\\u",
"file_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"conf_",
"._",
"set_",
"(_",
"\"",
"security",
"\"_",
",_",
"\"",
"certifica",
"te",
"\\u",
"domain",
"\"_",
",_",
"\"",
"test",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"cert",
"\\u",
"conf_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"log_",
"=_",
"cal",
"vin",
"logger_",
"._",
"get",
"\\u",
"logger_",
"(_",
"\\u\\u",
"name\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\"",
"node",
"4",
":\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"pytest_",
"._",
"fixture_",
"(_",
"scope_",
"=_",
"\"",
"session",
"\"_",
",_",
"autou",
"se_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"cleanup_",
"(_",
"request_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"fin_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"reactor_",
"._",
"call",
"Fro",
"m",
"Thread_",
"(_",
"reactor_",
"._",
"stop_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"request_",
"._",
"addfi",
"nali",
"zer_",
"(_",
"fin_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"pytest_",
"._",
"mark_",
"._",
"interactive_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"@_",
"pytest_",
"._",
"mark_",
"._",
"slow_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"class_",
"Test",
"DH",
"T_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"test\\u",
"nodes_",
"=_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"suce",
"ss",
"\\u",
"start_",
"=_",
"(_",
"True_",
",_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"DH",
"T_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"pytest_",
"._",
"fixture_",
"(_",
"autou",
"se_",
"=_",
"True_",
",_",
"scope_",
"=_",
"\"",
"class",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"setup_",
"(_",
"self_",
",_",
"request_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"global_",
"\\u",
"cert",
"\\u",
"conf_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"cert",
"\\u",
"conf_",
"=_",
"certificate_",
"._",
"Config_",
"(_",
"\\u",
"conf",
"\\u",
"file_",
",_",
"\"",
"test",
"\"_",
")_",
"._",
"configuration_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"DH",
"T_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"pytest_",
"._",
"inline",
"Callbacks_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"dht",
"\\u",
"multi_",
"(_",
"self_",
",_",
"monkeypatch_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"iface_",
"=_",
"\"",
"0.",
"0.",
"0.",
"0",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"a_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"b_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"q_",
"=_",
"Queue_",
"._",
"Queue_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"server",
"\\u",
"started_",
"(_",
"aa_",
",_",
"*_",
"args_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"b_",
"in_",
"args_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"isinstance_",
"(_",
"b_",
",_",
"twisted_",
"._",
"python_",
"._",
"failure_",
"._",
"Failure_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"b_",
"._",
"print",
"Trace",
"back_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"\\u",
"log_",
"._",
"debug_",
"(_",
"\"**",
" ",
"%",
"s",
"\"_",
"%_",
"b_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"q_",
"._",
"put_",
"(_",
"[_",
"aa_",
",_",
"args_",
"]_",
")_",
"\\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 ",
" _",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
"=_",
"5_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Twi",
"sted",
" ",
"is",
" ",
"usi",
"ng",
" ",
"20",
" ",
"thread",
"s",
" ",
"so",
" ",
"hav",
"ing",
" ",
">",
" ",
"20",
" ",
"server_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"caus",
"es",
" ",
"thread",
"lock",
"s",
" ",
"reall",
"y",
" ",
"easi",
"ly",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"servers_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"callbacks_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"serv",
"no_",
"in_",
"range_",
"(_",
"0_",
",_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"a_",
"=_",
"Auto",
"DH",
"TS",
"erver_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"servers_",
"._",
"append_",
"(_",
"a_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"callback_",
"=_",
"Cal",
"vin",
"CB_",
"(_",
"server",
"\\u",
"started_",
",_",
"str_",
"(_",
"serv",
"no_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"servers_",
"[_",
"serv",
"no_",
"]_",
"._",
"start_",
"(_",
"iface_",
",_",
"network_",
"=_",
"\"",
"Ni",
"kla",
"s",
"\"_",
",_",
"cb_",
"=_",
"callback_",
",_",
"name_",
"=_",
"name_",
"+_",
"\"{}\"_",
"._",
"format_",
"(_",
"serv",
"no_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"callbacks_",
"._",
"append_",
"(_",
"callback_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Wait",
" ",
"for",
" ",
"start_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"started_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"len_",
"(_",
"started_",
")_",
"<_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
":_",
"\\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 ",
" ",
"_",
"server_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"q_",
"._",
"get_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Queue_",
"._",
"Empty_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"\\u",
"log_",
"._",
"debug_",
"(_",
"\"",
"Queue",
" ",
"empty",
"!\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"raise",
" _",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"server_",
"not_",
"in_",
"started_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"started_",
"._",
"append_",
"(_",
"server_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"print",
"(\"",
"DH",
"T",
" ",
"Server",
"s",
" ",
"adde",
"d",
":",
" ",
"{}",
"\".",
"format",
"(",
"start",
"ed",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"callbacks_",
"[_",
"int_",
"(_",
"server_",
"[_",
"0_",
"]_",
"[_",
"0_",
"]_",
")_",
"]_",
"._",
"func_",
"=_",
"lambda_",
"*_",
"args_",
",_",
"**_",
"kv",
"args_",
":_",
"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 ",
" ",
"_",
"print_",
"(_",
"\"",
"Server",
":",
" ",
"{}",
" ",
"alr",
"ead",
"y",
" ",
"start",
"ed",
".\"_",
"\"",
" ",
"{}",
" ",
"out",
" ",
"of",
" ",
"{}\"_",
"._",
"format_",
"(_",
"started_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"len_",
"(_",
"started_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"(_",
"\"",
"All",
" ",
"{}",
" ",
"out",
" ",
"of",
" ",
"{}",
" ",
"start",
"ed",
"\"_",
"._",
"format_",
"(_",
"started_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"len_",
"(_",
"started_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"serv",
"no_",
"in_",
"range_",
"(_",
"0_",
",_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"assert_",
"[_",
"str_",
"(_",
"serv",
"no_",
")_",
",_",
"self_",
"._",
"\\u",
"suce",
"ss",
"\\u",
"start_",
"]_",
"in_",
"started_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"q_",
"._",
"queue_",
"._",
"clear_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"time_",
"._",
"sleep_",
",_",
"8_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"key_",
"=_",
"\"",
"HAR",
"E",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"value_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"[_",
"\"",
"mor",
"ot",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"def_",
"=_",
"servers_",
"[_",
"0_",
"]_",
"._",
"append_",
"(_",
"key_",
"=_",
"key_",
",_",
"value_",
"=_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"value_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"set\\u",
"def_",
"._",
"wait_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"set\\u",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"poste",
"d",
" ",
"append",
" ",
"key",
"={}",
",",
" ",
"value",
"={}\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"key_",
",_",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"value_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"[_",
"\"",
"seller",
"i",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"def_",
"=_",
"servers_",
"[_",
"0_",
"]_",
"._",
"append_",
"(_",
"key_",
"=_",
"key_",
",_",
"value_",
"=_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"value_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"set\\u",
"def_",
"._",
"wait_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"set\\u",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"poste",
"d",
" ",
"append",
" ",
"key",
"={}",
",",
" ",
"value",
"={}\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"key_",
",_",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"get",
"\\u",
"def_",
"=_",
"servers_",
"[_",
"0_",
"]_",
"._",
"get",
"\\u",
"concat_",
"(_",
"key_",
"=_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"get",
"\\u",
"value_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"get",
"\\u",
"def_",
"._",
"wait_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"set_",
"(_",
"json_",
"._",
"loads_",
"(_",
"get",
"\\u",
"value_",
")_",
")_",
"==_",
"set_",
"(_",
"[_",
"\"",
"mor",
"ot",
"\"_",
",_",
"\"",
"seller",
"i",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"confirm",
"ed",
" ",
"key",
"={}",
",",
" ",
"value",
"={}",
" ",
"was",
" ",
"reachable",
"\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"key_",
",_",
"get",
"\\u",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"draw",
"Network",
"State_",
"(_",
"\"",
"1",
"nice\\u",
"graph",
".",
"png",
"\"_",
",_",
"servers_",
",_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"time_",
"._",
"sleep_",
",_",
"7_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"draw",
"Network",
"State_",
"(_",
"\"",
"1",
"middle",
"\\u",
"graph",
".",
"png",
"\"_",
",_",
"servers_",
",_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"time_",
"._",
"sleep_",
",_",
"7_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"draw",
"Network",
"State_",
"(_",
"\"",
"1e",
"nd",
"\\u",
"graph",
".",
"png",
"\"_",
",_",
"servers_",
",_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"get",
"\\u",
"def_",
"=_",
"servers_",
"[_",
"0_",
"]_",
"._",
"get",
"\\u",
"concat_",
"(_",
"key_",
"=_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"get",
"\\u",
"value_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"get",
"\\u",
"def_",
"._",
"wait_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"set_",
"(_",
"json_",
"._",
"loads_",
"(_",
"get",
"\\u",
"value_",
")_",
")_",
"==_",
"set_",
"(_",
"[_",
"\"",
"mor",
"ot",
"\"_",
",_",
"\"",
"seller",
"i",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"got",
" ",
"right",
" ",
"value",
":",
" ",
"{}\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"get",
"\\u",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"value_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"[_",
"\"",
"mor",
"ot",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"def_",
"=_",
"servers_",
"[_",
"0_",
"]_",
"._",
"remove_",
"(_",
"key_",
"=_",
"key_",
",_",
"value_",
"=_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"value_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"set\\u",
"def_",
"._",
"wait_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"set\\u",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"poste",
"d",
" ",
"remove",
" ",
"key",
"={}",
",",
" ",
"value",
"={}\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"key_",
",_",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"get",
"\\u",
"def_",
"=_",
"servers_",
"[_",
"1_",
"]_",
"._",
"get",
"\\u",
"concat_",
"(_",
"key_",
"=_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"get",
"\\u",
"value_",
"=_",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"get",
"\\u",
"def_",
"._",
"wait_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"set_",
"(_",
"json_",
"._",
"loads_",
"(_",
"get",
"\\u",
"value_",
")_",
")_",
"==_",
"set_",
"(_",
"[_",
"\"",
"seller",
"i",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"got",
" ",
"right",
" ",
"value",
":",
" ",
"{}\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"get",
"\\u",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"0_",
",_",
"amo",
"unt",
"\\u",
"of",
"\\u",
"servers_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name",
"\\u",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"\\u",
"cert",
"\\u",
"conf_",
"[_",
"\"",
"CA",
"\\u",
"default",
"\"_",
"]_",
"[_",
"\"",
"runt",
"imes",
"\\u",
"dir",
"\"_",
"]_",
",_",
"\"{}",
"{}\"_",
"._",
"format_",
"(_",
"name_",
",_",
"i_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"filenames_",
"=_",
"os_",
"._",
"listdir_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"name",
"\\u",
"dir_",
",_",
"\"",
"other",
"s",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"has",
" ",
"{}",
" ",
"certificates",
" ",
"in",
" ",
"store",
"\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"i_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"len_",
"(_",
"filenames_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Assert",
"ion",
"Error_",
"as_",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"Node",
" ",
"with",
" ",
"port",
" ",
"{}",
" ",
"got",
" ",
"wrong",
" ",
"value",
":",
" ",
"{}",
",",
" ",
"shou",
"ld",
" ",
"have",
" ",
"bee",
"n",
" ",
"{}\"_",
"._",
"format_",
"(_",
"servers_",
"[_",
"0_",
"]_",
"._",
"dht",
"\\u",
"server_",
"._",
"port_",
"._",
"get",
"Host_",
"(_",
")_",
"._",
"port_",
",_",
"get",
"\\u",
"value_",
",_",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pytest_",
"._",
"fail_",
"(_",
"traceback_",
"._",
"format\\u",
"exc_",
"(_",
")_",
")_",
"\\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 ",
" _",
"traceback_",
"._",
"print",
"\\u",
"exc_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pytest_",
"._",
"fail_",
"(_",
"traceback_",
"._",
"format\\u",
"exc_",
"(_",
")_",
")_",
"\\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 ",
" _",
"yield_",
"threads_",
"._",
"defer",
"\\u",
"to",
"\\u",
"thread_",
"(_",
"time_",
"._",
"sleep_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"i_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"server_",
"in_",
"servers_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name",
"\\u",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"\\u",
"cert",
"\\u",
"conf_",
"[_",
"\"",
"CA",
"\\u",
"default",
"\"_",
"]_",
"[_",
"\"",
"runt",
"imes",
"\\u",
"dir",
"\"_",
"]_",
",_",
"name_",
"+_",
"\"{}\"_",
"._",
"format_",
"(_",
"i_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"shutil_",
"._",
"rmtree_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"name",
"\\u",
"dir_",
",_",
"\"",
"other",
"s",
"\"_",
")_",
",_",
"ignore",
"\\u",
"errors_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"os_",
"._",
"mkdir_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"name",
"\\u",
"dir_",
",_",
"\"",
"other",
"s",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"i_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"server_",
"._",
"stop_",
"(_",
")_"
]
| [
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,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2,
2,
2,
2,
2,
2
]
|
`__eq__` not overridden when adding attributes | GoogleCloudPlatform/gsutil/gslib/storage_url.py | [
{
"content": "class StorageUrl(object):\n \"\"\"Abstract base class for file and Cloud Storage URLs.\"\"\"\n\n\n\n\n\n\n\n\n",
"metadata": "root.StorageUrl",
"header": "['module', '___EOS___']",
"index": 44
},
{
"content": " def Clone(self):\n raise NotImplementedError('Clone not overridden')",
"metadata": "root.StorageUrl.Clone",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 47
},
{
"content": " def IsFileUrl(self):\n raise NotImplementedError('IsFileUrl not overridden')",
"metadata": "root.StorageUrl.IsFileUrl",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 50
},
{
"content": " def IsCloudUrl(self):\n raise NotImplementedError('IsCloudUrl not overridden')",
"metadata": "root.StorageUrl.IsCloudUrl",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 53
},
{
"content": " def IsStream(self):\n raise NotImplementedError('IsStream not overridden')",
"metadata": "root.StorageUrl.IsStream",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 56
},
{
"content": " def CreatePrefixUrl(self, wildcard_suffix=None):\n \"\"\"Returns a prefix of this URL that can be used for iterating.\n\n Args:\n wildcard_suffix: If supplied, this wildcard suffix will be appended to the\n prefix with a trailing slash before being returned.\n\n Returns:\n A prefix of this URL that can be used for iterating.\n\n If this URL contains a trailing slash, it will be stripped to create the\n prefix. This helps avoid infinite looping when prefixes are iterated, but\n preserves other slashes so that objects with '/' in the name are handled\n properly.\n\n For example, when recursively listing a bucket with the following contents:\n gs://bucket// <-- object named slash\n gs://bucket//one-dir-deep\n a top-level expansion with '/' as a delimiter will result in the following\n URL strings:\n 'gs://bucket//' : OBJECT\n 'gs://bucket//' : PREFIX\n If we right-strip all slashes from the prefix entry and add a wildcard\n suffix, we will get 'gs://bucket/*' which will produce identical results\n (and infinitely recurse).\n\n Example return values:\n ('gs://bucket/subdir/', '*') becomes 'gs://bucket/subdir/*'\n ('gs://bucket/', '*') becomes 'gs://bucket/*'\n ('gs://bucket/', None) becomes 'gs://bucket'\n ('gs://bucket/subdir//', '*') becomes 'gs://bucket/subdir//*'\n ('gs://bucket/subdir///', '**') becomes 'gs://bucket/subdir///**'\n ('gs://bucket/subdir/', '*') where 'subdir/' is an object becomes\n 'gs://bucket/subdir/*', but iterating on this will return 'subdir/'\n as a BucketListingObject, so we will not recurse on it as a subdir\n during listing.\n \"\"\"\n raise NotImplementedError('CreatePrefixUrl not overridden')",
"metadata": "root.StorageUrl.CreatePrefixUrl",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 59
},
{
"content": " @property\n def url_string(self):\n raise NotImplementedError('url_string not overridden')",
"metadata": "root.StorageUrl.url_string",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 98
},
{
"content": " @property\n def versionless_url_string(self):\n raise NotImplementedError('versionless_url_string not overridden')",
"metadata": "root.StorageUrl.versionless_url_string",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 102
},
{
"content": " def __eq__(self, other):\n return isinstance(other, StorageUrl) and self.url_string == other.url_string",
"metadata": "root.StorageUrl.__eq__",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 106
},
{
"content": " def __hash__(self):\n return hash(self.url_string)",
"metadata": "root.StorageUrl.__hash__",
"header": "['class', 'StorageUrl', '(', 'object', ')', ':', '___EOS___']",
"index": 109
},
{
"content": "class _FileUrl(StorageUrl):\n \"\"\"File URL class providing parsing and convenience methods.\n\n This class assists with usage and manipulation of an\n (optionally wildcarded) file URL string. Depending on the string\n contents, this class represents one or more directories or files.\n\n For File URLs, scheme is always file, bucket_name is always blank,\n and object_name contains the file/directory path.\n \"\"\"\n\n\n\n\n\n\n\n\n\n",
"metadata": "root._FileUrl",
"header": "['module', '___EOS___']",
"index": 113
},
{
"content": " def __init__(self, url_string, is_stream=False):\n self.scheme = 'file'\n self.bucket_name = ''\n match = FILE_OBJECT_REGEX.match(url_string)\n if match and match.lastindex == 2:\n self.object_name = match.group(2)\n else:\n self.object_name = url_string\n self.generation = None\n self.is_stream = is_stream\n self.delim = os.sep",
"metadata": "root._FileUrl.__init__",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 124
},
{
"content": " def Clone(self):\n return _FileUrl(self.url_string)",
"metadata": "root._FileUrl.Clone",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 136
},
{
"content": " def IsFileUrl(self):\n return True",
"metadata": "root._FileUrl.IsFileUrl",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 139
},
{
"content": " def IsCloudUrl(self):\n return False",
"metadata": "root._FileUrl.IsCloudUrl",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 142
},
{
"content": " def IsStream(self):\n return self.is_stream",
"metadata": "root._FileUrl.IsStream",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 145
},
{
"content": " def IsDirectory(self):\n return not self.IsStream() and os.path.isdir(self.object_name)",
"metadata": "root._FileUrl.IsDirectory",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 148
},
{
"content": " def CreatePrefixUrl(self, wildcard_suffix=None):\n return self.url_string",
"metadata": "root._FileUrl.CreatePrefixUrl",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 151
},
{
"content": " @property\n def url_string(self):\n return '%s://%s' % (self.scheme, self.object_name)",
"metadata": "root._FileUrl.url_string",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 154
},
{
"content": " @property\n def versionless_url_string(self):\n return self.url_string",
"metadata": "root._FileUrl.versionless_url_string",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 158
},
{
"content": " def __str__(self):\n return self.url_string",
"metadata": "root._FileUrl.__str__",
"header": "['class', '_FileUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 162
},
{
"content": "class _CloudUrl(StorageUrl):\n \"\"\"Cloud URL class providing parsing and convenience methods.\n\n This class assists with usage and manipulation of an\n (optionally wildcarded) cloud URL string. Depending on the string\n contents, this class represents a provider, bucket(s), or object(s).\n\n This class operates only on strings. No cloud storage API calls are\n made from this class.\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
"metadata": "root._CloudUrl",
"header": "['module', '___EOS___']",
"index": 166
},
{
"content": " def __init__(self, url_string):\n self.scheme = None\n self.bucket_name = None\n self.object_name = None\n self.generation = None\n self.delim = '/'\n provider_match = PROVIDER_REGEX.match(url_string)\n bucket_match = BUCKET_REGEX.match(url_string)\n if provider_match:\n self.scheme = provider_match.group('provider')\n elif bucket_match:\n self.scheme = bucket_match.group('provider')\n self.bucket_name = bucket_match.group('bucket')\n if (not ContainsWildcard(self.bucket_name) and\n (not BUCKET_NAME_RE.match(self.bucket_name) or\n TOO_LONG_DNS_NAME_COMP.search(self.bucket_name))):\n raise InvalidUrlError('Invalid bucket name in URL \"%s\"' % url_string)\n else:\n object_match = OBJECT_REGEX.match(url_string)\n if object_match:\n self.scheme = object_match.group('provider')\n self.bucket_name = object_match.group('bucket')\n self.object_name = object_match.group('object')\n if self.scheme == 'gs':\n generation_match = GS_GENERATION_REGEX.match(self.object_name)\n if generation_match:\n self.object_name = generation_match.group('object')\n self.generation = generation_match.group('generation')\n elif self.scheme == 's3':\n version_match = S3_VERSION_REGEX.match(self.object_name)\n if version_match:\n self.object_name = version_match.group('object')\n self.generation = version_match.group('version_id')\n else:\n raise InvalidUrlError(\n 'CloudUrl: URL string %s did not match URL regex' % url_string)",
"metadata": "root._CloudUrl.__init__",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 177
},
{
"content": " def Clone(self):\n return _CloudUrl(self.url_string)",
"metadata": "root._CloudUrl.Clone",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 214
},
{
"content": " def IsFileUrl(self):\n return False",
"metadata": "root._CloudUrl.IsFileUrl",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 217
},
{
"content": " def IsCloudUrl(self):\n return True",
"metadata": "root._CloudUrl.IsCloudUrl",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 220
},
{
"content": " def IsStream(self):\n raise NotImplementedError('IsStream not supported on CloudUrl')",
"metadata": "root._CloudUrl.IsStream",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 223
},
{
"content": " def IsBucket(self):\n return bool(self.bucket_name and not self.object_name)",
"metadata": "root._CloudUrl.IsBucket",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 226
},
{
"content": " def IsObject(self):\n return bool(self.bucket_name and self.object_name)",
"metadata": "root._CloudUrl.IsObject",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 229
},
{
"content": " def HasGeneration(self):\n return bool(self.generation)",
"metadata": "root._CloudUrl.HasGeneration",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 232
},
{
"content": " def IsProvider(self):\n return bool(self.scheme and not self.bucket_name)",
"metadata": "root._CloudUrl.IsProvider",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 235
},
{
"content": " def CreatePrefixUrl(self, wildcard_suffix=None):\n prefix = StripOneSlash(self.versionless_url_string)\n if wildcard_suffix:\n prefix = '%s/%s' % (prefix, wildcard_suffix)\n return prefix",
"metadata": "root._CloudUrl.CreatePrefixUrl",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 238
},
{
"content": " @property\n def bucket_url_string(self):\n return '%s://%s/' % (self.scheme, self.bucket_name)",
"metadata": "root._CloudUrl.bucket_url_string",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 244
},
{
"content": " @property\n def url_string(self):\n url_str = self.versionless_url_string\n if self.HasGeneration():\n url_str += '#%s' % self.generation\n return url_str",
"metadata": "root._CloudUrl.url_string",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 248
},
{
"content": " @property\n def versionless_url_string(self):\n if self.IsProvider():\n return '%s://' % self.scheme\n elif self.IsBucket():\n return self.bucket_url_string\n return '%s://%s/%s' % (self.scheme, self.bucket_name, self.object_name)",
"metadata": "root._CloudUrl.versionless_url_string",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 255
},
{
"content": " def __str__(self):\n return self.url_string",
"metadata": "root._CloudUrl.__str__",
"header": "['class', '_CloudUrl', '(', 'StorageUrl', ')', ':', '___EOS___']",
"index": 263
}
]
| [
{
"span": "class _FileUrl(StorageUrl):",
"start_line": 113,
"start_column": 0,
"end_line": 113,
"end_column": 27
},
{
"span": "class _CloudUrl(StorageUrl):",
"start_line": 166,
"start_column": 0,
"end_line": 166,
"end_column": 28
}
]
| [
{
"span": "def __eq__(self, other):",
"start_line": 106,
"start_column": 2,
"end_line": 106,
"end_column": 26
},
{
"span": "self.scheme ",
"start_line": 125,
"start_column": 4,
"end_line": 125,
"end_column": 15
},
{
"span": "self.bucket_name ",
"start_line": 126,
"start_column": 4,
"end_line": 126,
"end_column": 20
},
{
"span": "self.object_name ",
"start_line": 129,
"start_column": 6,
"end_line": 129,
"end_column": 22
},
{
"span": "self.object_name ",
"start_line": 131,
"start_column": 6,
"end_line": 131,
"end_column": 22
},
{
"span": "self.generation ",
"start_line": 132,
"start_column": 4,
"end_line": 132,
"end_column": 19
},
{
"span": "self.is_stream ",
"start_line": 133,
"start_column": 4,
"end_line": 133,
"end_column": 18
},
{
"span": "self.delim ",
"start_line": 134,
"start_column": 4,
"end_line": 134,
"end_column": 14
},
{
"span": "self.scheme ",
"start_line": 178,
"start_column": 4,
"end_line": 178,
"end_column": 15
},
{
"span": "self.bucket_name ",
"start_line": 179,
"start_column": 4,
"end_line": 179,
"end_column": 20
},
{
"span": "self.object_name ",
"start_line": 180,
"start_column": 4,
"end_line": 180,
"end_column": 20
},
{
"span": "self.generation ",
"start_line": 181,
"start_column": 4,
"end_line": 181,
"end_column": 19
},
{
"span": "self.delim ",
"start_line": 182,
"start_column": 4,
"end_line": 182,
"end_column": 14
},
{
"span": "self.scheme ",
"start_line": 186,
"start_column": 6,
"end_line": 186,
"end_column": 17
},
{
"span": "self.scheme ",
"start_line": 188,
"start_column": 6,
"end_line": 188,
"end_column": 17
},
{
"span": "self.bucket_name ",
"start_line": 189,
"start_column": 6,
"end_line": 189,
"end_column": 22
},
{
"span": "self.scheme ",
"start_line": 197,
"start_column": 8,
"end_line": 197,
"end_column": 19
},
{
"span": "self.bucket_name ",
"start_line": 198,
"start_column": 8,
"end_line": 198,
"end_column": 24
},
{
"span": "self.object_name ",
"start_line": 199,
"start_column": 8,
"end_line": 199,
"end_column": 24
},
{
"span": "self.object_name ",
"start_line": 203,
"start_column": 12,
"end_line": 203,
"end_column": 28
},
{
"span": "self.generation ",
"start_line": 204,
"start_column": 12,
"end_line": 204,
"end_column": 27
},
{
"span": "self.object_name ",
"start_line": 208,
"start_column": 12,
"end_line": 208,
"end_column": 28
},
{
"span": "self.generation ",
"start_line": 209,
"start_column": 12,
"end_line": 209,
"end_column": 27
}
]
| 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_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Abstract",
" ",
"base",
" ",
"class",
" ",
"for",
" ",
"file",
" ",
"and",
" ",
"Cloud",
" ",
"Stor",
"age",
" ",
"URL",
"s",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\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_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"Clone",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"Clone",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"File",
"Url_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"Is",
"File",
"Ur",
"l",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Cloud",
"Url_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"Is",
"Cloud",
"Ur",
"l",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Stream_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"Is",
"Stream",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Creat",
"e",
"Pref",
"ix",
"Url_",
"(_",
"self_",
",_",
"wild",
"card",
"\\u",
"suffix_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Return",
"s",
" ",
"a",
" ",
"prefix",
" ",
"of",
" ",
"this",
" ",
"URL",
" ",
"tha",
"t",
" ",
"can",
" ",
"be",
" ",
"used",
" ",
"for",
" ",
"iterati",
"ng",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Arg",
"s",
":",
"\\",
"10",
";",
" ",
" ",
"wild",
"card",
"\\u",
"suff",
"ix",
":",
" ",
"If",
" ",
"supplie",
"d",
",",
" ",
"this",
" ",
"wild",
"card",
" ",
"suff",
"ix",
" ",
"will",
" ",
"be",
" ",
"append",
"ed",
" ",
"to",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
" ",
"prefix",
" ",
"with",
" ",
"a",
" ",
"trail",
"ing",
" ",
"slash",
" ",
"bef",
"ore",
" ",
"bei",
"ng",
" ",
"return",
"ed",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
":",
"\\",
"10",
";",
" ",
" ",
"A",
" ",
"prefix",
" ",
"of",
" ",
"this",
" ",
"URL",
" ",
"tha",
"t",
" ",
"can",
" ",
"be",
" ",
"used",
" ",
"for",
" ",
"iterati",
"ng",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"If",
" ",
"this",
" ",
"URL",
" ",
"contain",
"s",
" ",
"a",
" ",
"trail",
"ing",
" ",
"slash",
",",
" ",
"it",
" ",
"will",
" ",
"be",
" ",
"strip",
"ped",
" ",
"to",
" ",
"create",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"prefix",
".",
" ",
"Thi",
"s",
" ",
"helps",
" ",
"avoid",
" ",
"infini",
"te",
" ",
"looping",
" ",
"whe",
"n",
" ",
"prefix",
"es",
" ",
"are",
" ",
"iterate",
"d",
",",
" ",
"but",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"preserve",
"s",
" ",
"other",
" ",
"slash",
"es",
" ",
"so",
" ",
"tha",
"t",
" ",
"object",
"s",
" ",
"with",
" ",
"'/'",
" ",
"in",
" ",
"the",
" ",
"name",
" ",
"are",
" ",
"handle",
"d",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"proper",
"ly",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"For",
" ",
"example",
",",
" ",
"whe",
"n",
" ",
"recurs",
"ively",
" ",
"listi",
"ng",
" ",
"a",
" ",
"bucket",
" ",
"with",
" ",
"the",
" ",
"follow",
"ing",
" ",
"content",
"s",
":",
"\\",
"10",
";",
" ",
" ",
"gs",
"://",
"bucket",
"//",
" ",
"<-",
"-",
" ",
"object",
" ",
"named",
" ",
"slash",
"\\",
"10",
";",
" ",
" ",
"gs",
"://",
"bucket",
"//",
"one",
"-",
"dir",
"-",
"deep",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"a",
" ",
"top",
"-",
"level",
" ",
"expansion",
" ",
"with",
" ",
"'/'",
" ",
"as",
" ",
"a",
" ",
"delimiter",
" ",
"will",
" ",
"result",
" ",
"in",
" ",
"the",
" ",
"follow",
"ing",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"URL",
" ",
"string",
"s",
":",
"\\",
"10",
";",
" ",
" ",
"'",
"gs",
"://",
"bucket",
"//",
"'",
" ",
":",
" ",
"OBJ",
"ECT",
"\\",
"10",
";",
" ",
" ",
"'",
"gs",
"://",
"bucket",
"//",
"'",
" ",
":",
" ",
"PREF",
"IX",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"If",
" ",
"we",
" ",
"right",
"-",
"strip",
" ",
"all",
" ",
"slash",
"es",
" ",
"from",
" ",
"the",
" ",
"prefix",
" ",
"entry",
" ",
"and",
" ",
"add",
" ",
"a",
" ",
"wild",
"card",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"suff",
"ix",
",",
" ",
"we",
" ",
"will",
" ",
"get",
" ",
"'",
"gs",
"://",
"bucket",
"/*",
"'",
" ",
"whi",
"ch",
" ",
"will",
" ",
"produce",
" ",
"identi",
"cal",
" ",
"results",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"(",
"and",
" ",
"infini",
"tel",
"y",
" ",
"recurse",
").",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Exam",
"ple",
" ",
"return",
" ",
"values",
":",
"\\",
"10",
";",
" ",
" ",
"('",
"gs",
"://",
"bucket",
"/",
"subdir",
"/'",
",",
" ",
"'*",
"')",
" ",
"bec",
"ome",
"s",
" ",
"'",
"gs",
"://",
"bucket",
"/",
"subdir",
"/*",
"'",
"\\",
"10",
";",
" ",
" ",
"('",
"gs",
"://",
"bucket",
"/'",
",",
" ",
"'*",
"')",
" ",
"bec",
"ome",
"s",
" ",
"'",
"gs",
"://",
"bucket",
"/*",
"'",
"\\",
"10",
";",
" ",
" ",
"('",
"gs",
"://",
"bucket",
"/'",
",",
" ",
"Non",
"e",
")",
" ",
"bec",
"ome",
"s",
" ",
"'",
"gs",
"://",
"bucket",
"'",
"\\",
"10",
";",
" ",
" ",
"('",
"gs",
"://",
"bucket",
"/",
"subdir",
"//",
"',",
" ",
"'*",
"')",
" ",
"bec",
"ome",
"s",
" ",
"'",
"gs",
"://",
"bucket",
"/",
"subdir",
"//",
"*'",
"\\",
"10",
";",
" ",
" ",
"('",
"gs",
"://",
"bucket",
"/",
"subdir",
"//",
"/'",
",",
" ",
"'**",
"')",
" ",
"bec",
"ome",
"s",
" ",
"'",
"gs",
"://",
"bucket",
"/",
"subdir",
"//",
"/**",
"'",
"\\",
"10",
";",
" ",
" ",
"('",
"gs",
"://",
"bucket",
"/",
"subdir",
"/'",
",",
" ",
"'*",
"')",
" ",
"where",
" ",
"'",
"subdir",
"/'",
" ",
"is",
" ",
"an",
" ",
"object",
" ",
"bec",
"ome",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
"'",
"gs",
"://",
"bucket",
"/",
"subdir",
"/*",
"',",
" ",
"but",
" ",
"iterati",
"ng",
" ",
"on",
" ",
"this",
" ",
"will",
" ",
"return",
" ",
"'",
"subdir",
"/'",
"\\",
"10",
";",
" ",
" ",
" ",
"as",
" ",
"a",
" ",
"Buck",
"et",
"Listi",
"ng",
"Object",
",",
" ",
"so",
" ",
"we",
" ",
"will",
" ",
"not",
" ",
"recurse",
" ",
"on",
" ",
"it",
" ",
"as",
" ",
"a",
" ",
"subdir",
"\\",
"10",
";",
" ",
" ",
" ",
"dur",
"ing",
" ",
"listi",
"ng",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"Creat",
"e",
"Pref",
"ix",
"Ur",
"l",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"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_",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"url",
"\\u",
"string",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"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_",
"version",
"less",
"\\u",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"version",
"less",
"\\u",
"url",
"\\u",
"string",
" ",
"not",
" ",
"overrid",
"den",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"eq\\u\\u_",
"(_",
"self_",
",_",
"other_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"isinstance_",
"(_",
"other_",
",_",
"Stor",
"age",
"Url_",
")_",
"and_",
"self_",
"._",
"url",
"\\u",
"string_",
"==_",
"other_",
"._",
"url",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Stor",
"age",
"Url_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"hash\\u\\u_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"hash_",
"(_",
"self_",
"._",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\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_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"File",
" ",
"URL",
" ",
"class",
" ",
"provi",
"ding",
" ",
"pars",
"ing",
" ",
"and",
" ",
"convenien",
"ce",
" ",
"method",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"class",
" ",
"assist",
"s",
" ",
"with",
" ",
"usage",
" ",
"and",
" ",
"manipulati",
"on",
" ",
"of",
" ",
"an",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"(",
"option",
"ally",
" ",
"wild",
"card",
"ed",
")",
" ",
"file",
" ",
"URL",
" ",
"string",
".",
" ",
" ",
"Depend",
"ing",
" ",
"on",
" ",
"the",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"content",
"s",
",",
" ",
"this",
" ",
"class",
" ",
"represent",
"s",
" ",
"one",
" ",
"or",
" ",
"more",
" ",
"director",
"ies",
" ",
"or",
" ",
"files",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"For",
" ",
"File",
" ",
"URL",
"s",
",",
" ",
"sche",
"me",
" ",
"is",
" ",
"alw",
"ay",
"s",
" ",
"file",
",",
" ",
"bucket",
"\\u",
"name",
" ",
"is",
" ",
"alw",
"ay",
"s",
" ",
"blank",
",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"and",
" ",
"object\\u",
"name",
" ",
"contain",
"s",
" ",
"the",
" ",
"file",
"/",
"director",
"y",
" ",
"path",
".",
"\\",
"10",
";",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"url",
"\\u",
"string_",
",_",
"is",
"\\u",
"stream_",
"=_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"scheme_",
"=_",
"'",
"file",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"bucket",
"\\u",
"name_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"match_",
"=_",
"FILE",
"\\u",
"OBJ",
"ECT",
"\\u",
"REGEX_",
"._",
"match_",
"(_",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"match_",
"and_",
"match_",
"._",
"lasti",
"ndex_",
"==_",
"2_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"object\\u",
"name_",
"=_",
"match_",
"._",
"group_",
"(_",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"object\\u",
"name_",
"=_",
"url",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"generation_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"is",
"\\u",
"stream_",
"=_",
"is",
"\\u",
"stream_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"delim_",
"=_",
"os_",
"._",
"sep_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Clone",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u",
"File",
"Url_",
"(_",
"self_",
"._",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"File",
"Url_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Cloud",
"Url_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Stream_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"is",
"\\u",
"stream_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Directory_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"not_",
"self_",
"._",
"Is",
"Stream_",
"(_",
")_",
"and_",
"os_",
"._",
"path_",
"._",
"isdir_",
"(_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Creat",
"e",
"Pref",
"ix",
"Url_",
"(_",
"self_",
",_",
"wild",
"card",
"\\u",
"suffix_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"url",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"property_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'%",
"s",
"://",
"%",
"s",
"'_",
"%_",
"(_",
"self_",
"._",
"scheme_",
",_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\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_",
"version",
"less",
"\\u",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"url",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"File",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\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_",
"self_",
"._",
"url",
"\\u",
"string_",
"\\u\\u\\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_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Cloud",
" ",
"URL",
" ",
"class",
" ",
"provi",
"ding",
" ",
"pars",
"ing",
" ",
"and",
" ",
"convenien",
"ce",
" ",
"method",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"class",
" ",
"assist",
"s",
" ",
"with",
" ",
"usage",
" ",
"and",
" ",
"manipulati",
"on",
" ",
"of",
" ",
"an",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"(",
"option",
"ally",
" ",
"wild",
"card",
"ed",
")",
" ",
"cloud",
" ",
"URL",
" ",
"string",
".",
" ",
" ",
"Depend",
"ing",
" ",
"on",
" ",
"the",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"content",
"s",
",",
" ",
"this",
" ",
"class",
" ",
"represent",
"s",
" ",
"a",
" ",
"provide",
"r",
",",
" ",
"bucket",
"(",
"s",
"),",
" ",
"or",
" ",
"object",
"(",
"s",
").",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"class",
" ",
"operate",
"s",
" ",
"only",
" ",
"on",
" ",
"string",
"s",
".",
" ",
" ",
"No",
" ",
"cloud",
" ",
"storage",
" ",
"API",
" ",
"calls",
" ",
"are",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"made",
" ",
"from",
" ",
"this",
" ",
"class",
".",
"\\",
"10",
";",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"url",
"\\u",
"string_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"scheme_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"bucket",
"\\u",
"name_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"object\\u",
"name_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"generation_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"delim_",
"=_",
"'/'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"provide",
"r",
"\\u",
"match_",
"=_",
"PROVIDER",
"\\u",
"REGEX_",
"._",
"match_",
"(_",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"bucket",
"\\u",
"match_",
"=_",
"BUCKET",
"\\u",
"REGEX_",
"._",
"match_",
"(_",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"provide",
"r",
"\\u",
"match_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"scheme_",
"=_",
"provide",
"r",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"provide",
"r",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"bucket",
"\\u",
"match_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"scheme_",
"=_",
"bucket",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"provide",
"r",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"bucket",
"\\u",
"name_",
"=_",
"bucket",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"bucket",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"(_",
"not_",
"Contain",
"s",
"Wildcard",
"_",
"(_",
"self_",
"._",
"bucket",
"\\u",
"name_",
")_",
"and_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"not_",
"BUCKET",
"\\u",
"NAME",
"\\u",
"RE_",
"._",
"match_",
"(_",
"self_",
"._",
"bucket",
"\\u",
"name_",
")_",
"or_",
"\\u\\u\\uNL\\u\\u\\u_",
"TOO",
"\\u",
"LONG",
"\\u",
"DNS",
"\\u",
"NAME",
"\\u",
"COMP",
"_",
"._",
"search_",
"(_",
"self_",
"._",
"bucket",
"\\u",
"name_",
")_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Inva",
"lid",
"Ur",
"l",
"Error_",
"(_",
"'",
"Inva",
"lid",
" ",
"bucket",
" ",
"name",
" ",
"in",
" ",
"URL",
" ",
"\"%",
"s",
"\"'_",
"%_",
"url",
"\\u",
"string_",
")_",
"\\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 ",
" _",
"object\\u",
"match_",
"=_",
"OBJ",
"ECT",
"\\u",
"REGEX_",
"._",
"match_",
"(_",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"object\\u",
"match_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"scheme_",
"=_",
"object\\u",
"match_",
"._",
"group_",
"(_",
"'",
"provide",
"r",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"bucket",
"\\u",
"name_",
"=_",
"object\\u",
"match_",
"._",
"group_",
"(_",
"'",
"bucket",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"object\\u",
"name_",
"=_",
"object\\u",
"match_",
"._",
"group_",
"(_",
"'",
"object",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"scheme_",
"==_",
"'",
"gs",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"generat",
"ion",
"\\u",
"match_",
"=_",
"GS",
"\\u",
"GENERAT",
"ION",
"\\u",
"REGEX_",
"._",
"match_",
"(_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"generat",
"ion",
"\\u",
"match_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"object\\u",
"name_",
"=_",
"generat",
"ion",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"object",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"generation_",
"=_",
"generat",
"ion",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"generat",
"ion",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"self_",
"._",
"scheme_",
"==_",
"'",
"s3",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"version",
"\\u",
"match_",
"=_",
"S",
"3",
"\\u",
"VERSI",
"ON",
"\\u",
"REGEX_",
"._",
"match_",
"(_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"version",
"\\u",
"match_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"object\\u",
"name_",
"=_",
"version",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"object",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"generation_",
"=_",
"version",
"\\u",
"match_",
"._",
"group_",
"(_",
"'",
"version",
"\\u",
"id",
"'_",
")_",
"\\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 ",
" _",
"raise_",
"Inva",
"lid",
"Ur",
"l",
"Error_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Cloud",
"Ur",
"l",
":",
" ",
"URL",
" ",
"string",
" ",
"%",
"s",
" ",
"did",
" ",
"not",
" ",
"match",
" ",
"URL",
" ",
"regex",
"'_",
"%_",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\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_",
"Clone",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u",
"Cloud",
"Url_",
"(_",
"self_",
"._",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"File",
"Url_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Cloud",
"Url_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Stream_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"Impl",
"ement",
"ed",
"Error_",
"(_",
"'",
"Is",
"Stream",
" ",
"not",
" ",
"support",
"ed",
" ",
"on",
" ",
"Cloud",
"Ur",
"l",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Bucket_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"bool_",
"(_",
"self_",
"._",
"bucket",
"\\u",
"name_",
"and_",
"not_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Object_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"bool_",
"(_",
"self_",
"._",
"bucket",
"\\u",
"name_",
"and_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Has",
"Generat",
"ion_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"bool_",
"(_",
"self_",
"._",
"generation_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Is",
"Provider_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"bool_",
"(_",
"self_",
"._",
"scheme_",
"and_",
"not_",
"self_",
"._",
"bucket",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Creat",
"e",
"Pref",
"ix",
"Url_",
"(_",
"self_",
",_",
"wild",
"card",
"\\u",
"suffix_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"prefix_",
"=_",
"Strip",
"One",
"Sla",
"sh_",
"(_",
"self_",
"._",
"version",
"less",
"\\u",
"url",
"\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"wild",
"card",
"\\u",
"suffix_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"prefix_",
"=_",
"'%",
"s",
"/",
"%",
"s",
"'_",
"%_",
"(_",
"prefix_",
",_",
"wild",
"card",
"\\u",
"suffix_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"prefix_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\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_",
"bucket",
"\\u",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'%",
"s",
"://",
"%",
"s",
"/'_",
"%_",
"(_",
"self_",
"._",
"scheme_",
",_",
"self_",
"._",
"bucket",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"property_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"url",
"\\u",
"str_",
"=_",
"self_",
"._",
"version",
"less",
"\\u",
"url",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"Has",
"Generat",
"ion_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"url",
"\\u",
"str_",
"+=_",
"'#",
"%",
"s",
"'_",
"%_",
"self_",
"._",
"generation_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"url",
"\\u",
"str_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\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_",
"version",
"less",
"\\u",
"url",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"self_",
"._",
"Is",
"Provider_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'%",
"s",
"://'_",
"%_",
"self_",
"._",
"scheme_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"self_",
"._",
"Is",
"Bucket_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"bucket",
"\\u",
"url",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"'%",
"s",
"://",
"%",
"s",
"/",
"%",
"s",
"'_",
"%_",
"(_",
"self_",
"._",
"scheme_",
",_",
"self_",
"._",
"bucket",
"\\u",
"name_",
",_",
"self_",
"._",
"object\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"\\u",
"Cloud",
"Url_",
"(_",
"Stor",
"age",
"Url_",
")_",
":_",
"\\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_",
"self_",
"._",
"url",
"\\u",
"string_",
"\\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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
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' | kuri65536/python-for-android/python-modules/twisted/twisted/mail/mail.py | [
{
"content": " def monitorFile(self, name, callback, interval=10):\n try:\n mtime = os.path.getmtime(name)\n except:\n mtime = 0\n self.files.append([interval, name, callback, mtime])\n self.intervals.addInterval(interval)",
"metadata": "root.FileMonitoringService.monitorFile",
"header": "['class', 'FileMonitoringService', '(', 'internet', '.', 'TimerService', ')', ':', '___EOS___']",
"index": 305
},
{
"content": " def _monitor(self):\n self._call = None\n if self.index is not None:\n name, callback, mtime = self.files[self.index][1:]\n try:\n now = os.path.getmtime(name)\n except:\n now = 0\n if now > mtime:\n log.msg(\"%s changed, notifying listener\" % (name,))\n self.files[self.index][3] = now\n callback(name)\n self._setupMonitor()",
"metadata": "root.FileMonitoringService._monitor",
"header": "['class', 'FileMonitoringService', '(', 'internet', '.', 'TimerService', ')', ':', '___EOS___']",
"index": 320
}
]
| [
{
"span": "except:",
"start_line": 308,
"start_column": 8,
"end_line": 308,
"end_column": 15
},
{
"span": "except:",
"start_line": 326,
"start_column": 12,
"end_line": 326,
"end_column": 19
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"File",
"Monitor",
"ing",
"Service_",
"(_",
"internet_",
"._",
"Time",
"r",
"Service_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"monit",
"or",
"File_",
"(_",
"self_",
",_",
"name_",
",_",
"callback_",
",_",
"interval_",
"=_",
"10_",
")_",
":_",
"\\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 ",
" _",
"mtime_",
"=_",
"os_",
"._",
"path_",
"._",
"getmtime_",
"(_",
"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 ",
" _",
"mtime_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"files_",
"._",
"append_",
"(_",
"[_",
"interval_",
",_",
"name_",
",_",
"callback_",
",_",
"mtime_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"intervals_",
"._",
"add",
"Interval_",
"(_",
"interval_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"File",
"Monitor",
"ing",
"Service_",
"(_",
"internet_",
"._",
"Time",
"r",
"Service_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"monitor_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"\\u",
"call_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"index_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
",_",
"callback_",
",_",
"mtime_",
"=_",
"self_",
"._",
"files_",
"[_",
"self_",
"._",
"index_",
"]_",
"[_",
"1_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"now_",
"=_",
"os_",
"._",
"path_",
"._",
"getmtime_",
"(_",
"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 ",
" _",
"now_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"now_",
">_",
"mtime_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"log_",
"._",
"msg_",
"(_",
"\"%",
"s",
" ",
"change",
"d",
",",
" ",
"notif",
"ying",
" ",
"listen",
"er",
"\"_",
"%_",
"(_",
"name_",
",_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"files_",
"[_",
"self_",
"._",
"index_",
"]_",
"[_",
"3_",
"]_",
"=_",
"now_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"callback_",
"(_",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"\\u",
"setup",
"Monitor_",
"(_",
")_"
]
| [
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,
0,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused local variable | godaddy/Thespian/thespian/system/multiprocCommon.py | [
{
"content": "def startChild(childClass, endpoint, transportClass,\n sourceHash, sourceToLoad,\n parentAddr, adminAddr, notifyAddr, loggerAddr,\n childRequirements, currentSystemCapabilities,\n fileNumsToClose):\n\n closeFileNums(fileNumsToClose)\n\n # Dirty trick here to workaround multiprocessing trying to impose\n # an unnecessary restriction. A process should be set daemonic\n # before start() if the parent shouldn't track it (an specifically\n # automatically join() the subprocess on exit). For Actors, the\n # parent exists independently of the child and the ActorSystem\n # manages them, so daemonic processes are desired. However,\n # multiprocessing imposes a restriction that daemonic processes\n # cannot create more processes. The following reaches deep into\n # the implementation of the multiprocessing module to override\n # that restriction. This process was already started as daemonic,\n # and it's detached from its parent. The following simply clears\n # that flag locally so that other processes can be created from\n # this one.\n multiprocessing.process._current_process._daemonic = False\n\n transport = transportClass(endpoint)\n #closeUnusedFiles(transport)\n\n # Dirty trick here to completely re-initialize logging in this\n # process... something the standard Python logging interface does\n # not allow via the API. We also do not want to run\n # logging.shutdown() because (a) that does not do enough to reset,\n # and (b) it shuts down handlers, but we want to leave the parent's\n # handlers alone.\n logging.root = ThespianLogForwarder(loggerAddr, transport)\n logging.Logger.root = logging.root\n logging.Logger.manager = logging.Manager(logging.Logger.root)\n\n logger = logging.getLogger('Thespian.ActorManager')\n\n am = MultiProcManager(childClass, transport,\n sourceHash, sourceToLoad,\n parentAddr, adminAddr,\n childRequirements, currentSystemCapabilities)\n am.asLogger = loggerAddr\n am.transport.scheduleTransmit(None,\n TransmitIntent(notifyAddr,\n EndpointConnected(endpoint.addrInst)))\n setProcName(getattr(childClass, '__name__', str(childClass)), am.transport.myAddress)\n\n sighandler = signal_detector(getattr(childClass, '__name__', str(childClass)),\n am.transport.myAddress)\n sigexithandler = shutdown_signal_detector(getattr(childClass, '__name__', str(childClass)),\n am.transport.myAddress,\n am)\n\n for each in range(1, signal.NSIG):\n # n.b. normally Python intercepts SIGINT to turn it into a\n # KeyboardInterrupt exception. However, these Actors should\n # be detached from the keyboard, so revert to normal SIGINT\n # behavior.\n if each not in uncatchable_signals:\n if each in child_exit_signals:\n signal.signal(each, am.childDied)\n continue\n try:\n signal.signal(each,\n sigexithandler if each in exit_signals else sighandler)\n except (RuntimeError,ValueError,EnvironmentError) as ex:\n # OK, this signal can't be caught for this\n # environment. We did our best.\n pass\n\n am.run()",
"metadata": "root.startChild",
"header": "['module', '___EOS___']",
"index": 381
}
]
| [
{
"span": "logger ",
"start_line": 417,
"start_column": 4,
"end_line": 417,
"end_column": 10
}
]
| []
| 1 | true | [
"[CLS]_",
"Un",
"used_",
"local_",
"variable_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"start",
"Child_",
"(_",
"child",
"Class_",
",_",
"endpoint_",
",_",
"transport",
"Class_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"source",
"Hash_",
",_",
"source",
"To",
"Load_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"parent",
"Addr_",
",_",
"admin",
"Addr_",
",_",
"notif",
"y",
"Addr_",
",_",
"logg",
"er",
"Addr_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"child",
"Requirements",
"_",
",_",
"current",
"System",
"Capabilities",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"file",
"Num",
"s",
"To",
"Close_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"close",
"File",
"Num",
"s_",
"(_",
"file",
"Num",
"s",
"To",
"Close_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Dirty",
" ",
"trick",
" ",
"here",
" ",
"to",
" ",
"workar",
"ound",
" ",
"multipro",
"cess",
"ing",
" ",
"try",
"ing",
" ",
"to",
" ",
"impos",
"e_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"an",
" ",
"unne",
"cess",
"ary",
" ",
"restriction",
".",
" ",
" ",
"A",
" ",
"process",
" ",
"shou",
"ld",
" ",
"be",
" ",
"set",
" ",
"daemon",
"ic_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"bef",
"ore",
" ",
"start",
"()",
" ",
"if",
" ",
"the",
" ",
"parent",
" ",
"shou",
"ld",
"n",
"'",
"t",
" ",
"track",
" ",
"it",
" ",
"(",
"an",
" ",
"specifica",
"ll",
"y_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"automati",
"call",
"y",
" ",
"join",
"()",
" ",
"the",
" ",
"subproc",
"ess",
" ",
"on",
" ",
"exit",
").",
" ",
" ",
"For",
" ",
"Act",
"ors",
",",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"parent",
" ",
"exist",
"s",
" ",
"independent",
"ly",
" ",
"of",
" ",
"the",
" ",
"child",
" ",
"and",
" ",
"the",
" ",
"Act",
"or",
"System_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"manage",
"s",
" ",
"them",
",",
" ",
"so",
" ",
"daemon",
"ic",
" ",
"process",
"es",
" ",
"are",
" ",
"desi",
"red",
".",
" ",
" ",
"Ho",
"we",
"ver",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"multipro",
"cess",
"ing",
" ",
"impos",
"es",
" ",
"a",
" ",
"restriction",
" ",
"tha",
"t",
" ",
"daemon",
"ic",
" ",
"processes_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"cann",
"ot",
" ",
"create",
" ",
"more",
" ",
"process",
"es",
".",
" ",
" ",
"The",
" ",
"follow",
"ing",
" ",
"reache",
"s",
" ",
"deep",
" ",
"into_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"implementation",
" ",
"of",
" ",
"the",
" ",
"multipro",
"cess",
"ing",
" ",
"module",
" ",
"to",
" ",
"override_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"tha",
"t",
" ",
"restriction",
".",
" ",
" ",
"Thi",
"s",
" ",
"process",
" ",
"was",
" ",
"alr",
"ead",
"y",
" ",
"start",
"ed",
" ",
"as",
" ",
"daemon",
"ic",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"and",
" ",
"it",
"'",
"s",
" ",
"detached",
" ",
"from",
" ",
"its",
" ",
"parent",
".",
" ",
" ",
"The",
" ",
"follow",
"ing",
" ",
"simp",
"ly",
" ",
"clear",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"tha",
"t",
" ",
"flag",
" ",
"local",
"ly",
" ",
"so",
" ",
"tha",
"t",
" ",
"other",
" ",
"process",
"es",
" ",
"can",
" ",
"be",
" ",
"created",
" ",
"from_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"this",
" ",
"one",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"multiprocessing_",
"._",
"process_",
"._",
"\\u",
"current",
"\\u",
"process_",
"._",
"\\u",
"daemon",
"ic_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"transport_",
"=_",
"transport",
"Class_",
"(_",
"endpoint_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"close",
"Un",
"used",
"Files",
"(",
"transport",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Dirty",
" ",
"trick",
" ",
"here",
" ",
"to",
" ",
"complete",
"ly",
" ",
"re",
"-",
"initialize",
" ",
"logg",
"ing",
" ",
"in",
" ",
"this_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"process",
"...",
" ",
"somet",
"hing",
" ",
"the",
" ",
"standard",
" ",
"Pyth",
"on",
" ",
"logg",
"ing",
" ",
"interface",
" ",
"doe",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"not",
" ",
"allow",
" ",
"via",
" ",
"the",
" ",
"API",
".",
" ",
" ",
"We",
" ",
"als",
"o",
" ",
"do",
" ",
"not",
" ",
"want",
" ",
"to",
" ",
"run_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"logg",
"ing",
".",
"shut",
"down",
"()",
" ",
"bec",
"aus",
"e",
" ",
"(",
"a",
")",
" ",
"tha",
"t",
" ",
"doe",
"s",
" ",
"not",
" ",
"do",
" ",
"eno",
"ugh",
" ",
"to",
" ",
"reset",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"and",
" ",
"(",
"b",
")",
" ",
"it",
" ",
"shut",
"s",
" ",
"down",
" ",
"handler",
"s",
",",
" ",
"but",
" ",
"we",
" ",
"want",
" ",
"to",
" ",
"lea",
"ve",
" ",
"the",
" ",
"parent",
"'",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"handler",
"s",
" ",
"alo",
"ne",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"logging_",
"._",
"root_",
"=_",
"The",
"spi",
"an",
"Log",
"Forward",
"er_",
"(_",
"logg",
"er",
"Addr_",
",_",
"transport_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"logging_",
"._",
"Logger_",
"._",
"root_",
"=_",
"logging_",
"._",
"root_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"logging_",
"._",
"Logger_",
"._",
"manager_",
"=_",
"logging_",
"._",
"Manager_",
"(_",
"logging_",
"._",
"Logger_",
"._",
"root_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"logger_",
"=_",
"logging_",
"._",
"get",
"Logger_",
"(_",
"'",
"The",
"spi",
"an",
".",
"Act",
"or",
"Manager",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"am_",
"=_",
"Multi",
"Proc",
"Manager_",
"(_",
"child",
"Class_",
",_",
"transport_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"source",
"Hash_",
",_",
"source",
"To",
"Load_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"parent",
"Addr_",
",_",
"admin",
"Addr_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"child",
"Requirements",
"_",
",_",
"current",
"System",
"Capabilities",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"am_",
"._",
"as",
"Logger_",
"=_",
"logg",
"er",
"Addr_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"am_",
"._",
"transport_",
"._",
"schedule",
"Transmit",
"_",
"(_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Transmit",
"Inten",
"t_",
"(_",
"notif",
"y",
"Addr_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"End",
"point",
"Connected_",
"(_",
"endpoint_",
"._",
"addr",
"Inst_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set",
"Proc",
"Name_",
"(_",
"getattr_",
"(_",
"child",
"Class_",
",_",
"'\\u",
"\\u",
"name",
"\\u\\u'_",
",_",
"str_",
"(_",
"child",
"Class_",
")_",
")_",
",_",
"am_",
"._",
"transport_",
"._",
"my",
"Address_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"sig",
"handler_",
"=_",
"signal",
"\\u",
"detector_",
"(_",
"getattr_",
"(_",
"child",
"Class_",
",_",
"'\\u",
"\\u",
"name",
"\\u\\u'_",
",_",
"str_",
"(_",
"child",
"Class_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"am_",
"._",
"transport_",
"._",
"my",
"Address_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"sig",
"exit",
"handler_",
"=_",
"shut",
"down",
"\\u",
"signal",
"\\u",
"detector_",
"(_",
"getattr_",
"(_",
"child",
"Class_",
",_",
"'\\u",
"\\u",
"name",
"\\u\\u'_",
",_",
"str_",
"(_",
"child",
"Class_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"am_",
"._",
"transport_",
"._",
"my",
"Address_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"am_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"each_",
"in_",
"range_",
"(_",
"1_",
",_",
"signal_",
"._",
"NS",
"IG",
"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"n",
".",
"b",
".",
" ",
"normal",
"ly",
" ",
"Pyth",
"on",
" ",
"intercept",
"s",
" ",
"SIG",
"INT",
" ",
"to",
" ",
"turn",
" ",
"it",
" ",
"int",
"o",
" ",
"a_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Key",
"board",
"Interr",
"upt",
" ",
"exception",
".",
" ",
" ",
"Ho",
"we",
"ver",
",",
" ",
"these",
" ",
"Act",
"ors",
" ",
"should_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"be",
" ",
"detached",
" ",
"from",
" ",
"the",
" ",
"keyb",
"oard",
",",
" ",
"so",
" ",
"revert",
" ",
"to",
" ",
"normal",
" ",
"SIGINT_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"behavior",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"each_",
"not_",
"in_",
"unca",
"tcha",
"ble",
"\\u",
"signals_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"each_",
"in_",
"child",
"\\u",
"exit",
"\\u",
"signals_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"signal_",
"._",
"signal_",
"(_",
"each_",
",_",
"am_",
"._",
"child",
"Die",
"d_",
")_",
"\\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 ",
" _",
"signal_",
"._",
"signal_",
"(_",
"each_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sig",
"exit",
"handler_",
"if_",
"each_",
"in_",
"exit",
"\\u",
"signals_",
"else_",
"sig",
"handler_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"(_",
"Run",
"time",
"Error_",
",_",
"Value",
"Error_",
",_",
"Environ",
"ment",
"Error_",
")_",
"as_",
"ex_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"OK",
",",
" ",
"this",
" ",
"signal",
" ",
"can",
"'",
"t",
" ",
"be",
" ",
"cau",
"ght",
" ",
"for",
" ",
"this_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"environ",
"ment",
".",
" ",
" ",
"We",
" ",
"did",
" ",
"our",
" ",
"best",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"am_",
"._",
"run_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
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
]
|
Unused import | ros/catkin/test/local_tests/test_with_mock_workspace.py | [
{
"content": "#!/usr/bin/env python\n\nimport os\nimport shutil\nimport sys\n\nsys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))\n\nfrom test.utils import AbstractCatkinWorkspaceTest, MOCK_DIR, \\\n MAKE_CMD, succeed, assert_exists, fail\n\n\nimport em\nimport sys\nimport stat\nimport unittest\nimport tempfile\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class MockTest(AbstractCatkinWorkspaceTest):\n \"\"\"\n This test case uses workspaces with catkin projects from the\n test/mock_resources folder.\n \"\"\"\n\n # uncomment to keep temporary files in /tmp\n # def tearDown(self):\n # pass\n\n\n\n\n # Test was not finished apparently\n # def test_help_bad_changelog(self):\n # self.cmake(CATKIN_ENABLE_DEBBUILDING='TRUE',\n # CMAKE_PREFIX_PATH=diskprefix,\n # srcdir=os.path.join(MOCK_DIR,\n # 'src-fail', 'badly_specified_changelog'),\n # CATKIN='YES')\n # succeed(MAKE_CMD + ['help'], cwd=self.builddir)\n",
"metadata": "root.MockTest",
"header": "['module', '___EOS___']",
"index": 21
},
{
"content": " def test_catkin_only(self):\n self.cmake()\n succeed(MAKE_CMD, cwd=self.builddir)\n succeed(MAKE_CMD + [\"install\"], cwd=self.builddir)\n\n assert_exists(self.installdir,\n \"env.sh\",\n \"setup.sh\",\n \"setup.zsh\")",
"metadata": "root.MockTest.test_catkin_only",
"header": "['class', 'MockTest', '(', 'AbstractCatkinWorkspaceTest', ')', ':', '___EOS___']",
"index": 31
},
{
"content": " def test_nolang(self):\n dstdir = os.path.join(self.workspacedir, 'nolangs')\n shutil.copytree(os.path.join(MOCK_DIR, 'src', 'nolangs'), dstdir)\n\n out = self.cmake(CATKIN_WHITELIST_PACKAGES='nolangs',\n CATKIN_DPKG_BUILDPACKAGE_FLAGS='-d;-S;-us;-uc')\n self.assertTrue(os.path.exists(self.builddir + \"/nolangs\"))\n self.assertFalse(os.path.exists(self.builddir + \"/std_msgs\"))\n self.assertFalse(os.path.exists(self.builddir + \"/genmsg\"))\n out = succeed(MAKE_CMD, cwd=self.builddir)\n self.assertTrue(os.path.exists(self.builddir +\n \"/nolangs/bin/nolangs_exec\"))\n out = succeed(MAKE_CMD + [\"install\"], cwd=self.builddir)\n\n assert_exists(self.installdir,\n \"bin/nolangs_exec\",\n \"share/nolangs/cmake/nolangsConfig.cmake\")\n\n # also test make help\n succeed(MAKE_CMD + [\"help\"], cwd=self.builddir)",
"metadata": "root.MockTest.test_nolang",
"header": "['class', 'MockTest', '(', 'AbstractCatkinWorkspaceTest', ')', ':', '___EOS___']",
"index": 41
},
{
"content": " def test_noproject(self):\n # create workspace with just catkin and 'noproject' project\n dstdir = os.path.join(self.workspacedir, 'noproject')\n shutil.copytree(os.path.join(MOCK_DIR, 'src-fail', 'noproject'), dstdir)\n # test with whitelist\n out = self.cmake(CATKIN_WHITELIST_PACKAGES='catkin')\n out = succeed(MAKE_CMD + [\"install\"], cwd=self.builddir)\n\n shutil.rmtree(self.builddir)\n # fail if we try to build noproject stack\n os.makedirs(self.builddir)\n\n out = self.cmake(CMAKE_PREFIX_PATH=self.installdir,\n expect=fail)\n print(\"failed as expected, out=\", out)\n\n self.assertTrue(b\"catkin_package() PROJECT_NAME is set to 'Project'\" in out, out)\n # assert 'You must call project() with the same name before.' in out",
"metadata": "root.MockTest.test_noproject",
"header": "['class', 'MockTest', '(', 'AbstractCatkinWorkspaceTest', ')', ':', '___EOS___']",
"index": 62
},
{
"content": " def test_env_cached_static(self):\n # hack to fix empy nosetests clash\n sys.stdout = em.ProxyFile(sys.stdout)\n dstdir = os.path.join(self.workspacedir, 'catkin_test')\n shutil.copytree(os.path.join(MOCK_DIR, 'src', 'catkin_test'), dstdir)\n template_file = os.path.join(os.path.dirname(__file__), '..', '..', 'cmake', 'em', 'order_packages.cmake.em')\n with open (template_file, 'r') as fhand:\n template = fhand.read()\n gdict = {'CATKIN_DEVEL_PREFIX': '/foo',\n 'CMAKE_PREFIX_PATH': ['/bar'],\n 'CATKIN_GLOBAL_LIB_DESTINATION': '/glob-dest/lib',\n 'CATKIN_GLOBAL_BIN_DESTINATION': '/glob-dest/bin',\n 'PYTHON_INSTALL_DIR': '/foo/dist-packages'}\n result = em.expand(template, gdict,\n source_root_dir=self.workspacedir,\n whitelisted_packages=None,\n blacklisted_packages=None,\n underlay_workspaces=None)\n self.assertTrue('set(CATKIN_ORDERED_PACKAGES \"\")' in result, result)\n self.assertTrue('set(CATKIN_ORDERED_PACKAGE_PATHS \"\")' in result, result)\n self.assertTrue('set(CATKIN_ORDERED_PACKAGES_IS_META \"\")' in result, result)\n self.assertTrue('set(CATKIN_MESSAGE_GENERATORS' in result, result)\n\n self.assertTrue(\"\"\"\\\nlist(APPEND CATKIN_ORDERED_PACKAGES \"catkin_test\")\nlist(APPEND CATKIN_ORDERED_PACKAGE_PATHS \"catkin_test/catkin_test\")\nlist(APPEND CATKIN_ORDERED_PACKAGES_IS_META \"True\")\nlist(APPEND CATKIN_ORDERED_PACKAGES_BUILD_TYPE \"catkin\")\"\"\" in result, result)\n self.assertTrue(\"\"\"\\\nlist(APPEND CATKIN_ORDERED_PACKAGES \"a\")\nlist(APPEND CATKIN_ORDERED_PACKAGE_PATHS \"catkin_test/a\")\nlist(APPEND CATKIN_ORDERED_PACKAGES_IS_META \"False\")\nlist(APPEND CATKIN_ORDERED_PACKAGES_BUILD_TYPE \"catkin\")\"\"\" in result, result)\n # catkin itself filtered out\n self.assertFalse('list(APPEND CATKIN_ORDERED_PACKAGES \"catkin\"' in result, result)\n self.assertEqual(38, len(result.splitlines()))",
"metadata": "root.MockTest.test_env_cached_static",
"header": "['class', 'MockTest', '(', 'AbstractCatkinWorkspaceTest', ')', ':', '___EOS___']",
"index": 90
}
]
| [
{
"span": "import stat",
"start_line": 14,
"start_column": 0,
"end_line": 14,
"end_column": 11
},
{
"span": "import unittest",
"start_line": 15,
"start_column": 0,
"end_line": 15,
"end_column": 15
},
{
"span": "import tempfile",
"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_",
"#!",
"/",
"usr",
"/",
"bin",
"/",
"env",
" ",
"python_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"shutil_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"sys_",
"._",
"path_",
"._",
"insert_",
"(_",
"0_",
",_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
",_",
"'..'_",
",_",
"'..'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"test_",
"._",
"utils_",
"import_",
"Abstract",
"Cat",
"kin",
"Works",
"pace",
"Test_",
",_",
"MOC",
"K",
"\\u",
"DIR_",
",_",
"MAKE",
"\\u",
"CMD_",
",_",
"succeed_",
",_",
"assert",
"\\u",
"exists_",
",_",
"fail_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"em_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"stat_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"tempfile_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Moc",
"k",
"Test_",
"(_",
"Abstract",
"Cat",
"kin",
"Works",
"pace",
"Test_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"test",
" ",
"case",
" ",
"use",
"s",
" ",
"workspaces",
" ",
"with",
" ",
"cat",
"kin",
" ",
"project",
"s",
" ",
"from",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"test",
"/",
"mock",
"\\u",
"resource",
"s",
" ",
"folder",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"uncomm",
"ent",
" ",
"to",
" ",
"keep",
" ",
"temporar",
"y",
" ",
"files",
" ",
"in",
" ",
"/",
"tmp_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"def",
" ",
"tear",
"Down",
"(",
"self",
"):",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"pass_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Test",
" ",
"was",
" ",
"not",
" ",
"finish",
"ed",
" ",
"appare",
"ntl",
"y_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"def",
" ",
"test\\u",
"help",
"\\u",
"bad",
"\\u",
"change",
"log",
"(",
"self",
"):",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"self",
".",
"cma",
"ke",
"(",
"CAT",
"KI",
"N",
"\\u",
"ENABLE",
"\\u",
"DEB",
"BUILD",
"ING",
"='",
"TRU",
"E",
"',",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"CMA",
"KE",
"\\u",
"PREF",
"IX",
"\\u",
"PATH",
"=",
"disk",
"prefix",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"src",
"dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"MOC",
"K",
"\\u",
"DIR",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
" ",
"'",
"src",
"-",
"fail",
"',",
" ",
"'",
"bad",
"ly",
"\\u",
"specified",
"\\u",
"change",
"log",
"')",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"CAT",
"KI",
"N",
"='",
"YE",
"S",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"succe",
"ed",
"(",
"MAKE",
"\\u",
"CMD",
" ",
"+",
" ",
"['",
"help",
"']",
",",
" ",
"cw",
"d",
"=",
"self",
".",
"build",
"dir",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Moc",
"k",
"Test_",
"(_",
"Abstract",
"Cat",
"kin",
"Works",
"pace",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"cat",
"kin",
"\\u",
"only_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cma",
"ke_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"succeed_",
"(_",
"MAKE",
"\\u",
"CMD_",
",_",
"cwd_",
"=_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"succeed_",
"(_",
"MAKE",
"\\u",
"CMD_",
"+_",
"[_",
"\"",
"install",
"\"_",
"]_",
",_",
"cwd_",
"=_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"assert",
"\\u",
"exists_",
"(_",
"self_",
"._",
"installd",
"ir_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"env",
".",
"sh",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"setup",
".",
"sh",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"setup",
".",
"zs",
"h",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Moc",
"k",
"Test_",
"(_",
"Abstract",
"Cat",
"kin",
"Works",
"pace",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"nol",
"ang_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dst",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"works",
"pace",
"dir_",
",_",
"'",
"nol",
"angs",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"shutil_",
"._",
"copytree_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"MOC",
"K",
"\\u",
"DIR_",
",_",
"'",
"src",
"'_",
",_",
"'",
"nol",
"angs",
"'_",
")_",
",_",
"dst",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"out_",
"=_",
"self_",
"._",
"cma",
"ke_",
"(_",
"CAT",
"KI",
"N",
"\\u",
"WHITE",
"LIST",
"\\u",
"PACKAGES",
"_",
"=_",
"'",
"nol",
"angs",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"CAT",
"KI",
"N",
"\\u",
"DP",
"KG",
"\\u",
"BUILD",
"PACKAG",
"E",
"\\u",
"FLAGS_",
"=_",
"'-",
"d",
";",
"-",
"S",
";",
"-",
"us",
";",
"-",
"uc",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"builddir_",
"+_",
"\"/",
"nol",
"angs",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"builddir_",
"+_",
"\"/",
"std",
"\\u",
"msgs",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"builddir_",
"+_",
"\"/",
"gen",
"msg",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"out_",
"=_",
"succeed_",
"(_",
"MAKE",
"\\u",
"CMD_",
",_",
"cwd_",
"=_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"builddir_",
"+_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"/",
"nol",
"angs",
"/",
"bin",
"/",
"nol",
"angs",
"\\u",
"exec",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"out_",
"=_",
"succeed_",
"(_",
"MAKE",
"\\u",
"CMD_",
"+_",
"[_",
"\"",
"install",
"\"_",
"]_",
",_",
"cwd_",
"=_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"assert",
"\\u",
"exists_",
"(_",
"self_",
"._",
"installd",
"ir_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"bin",
"/",
"nol",
"angs",
"\\u",
"exec",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"share",
"/",
"nol",
"angs",
"/",
"cma",
"ke",
"/",
"nol",
"angs",
"Config",
".",
"cma",
"ke",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"als",
"o",
" ",
"test",
" ",
"make",
" ",
"help_",
"\\u\\u\\uNL\\u\\u\\u_",
"succeed_",
"(_",
"MAKE",
"\\u",
"CMD_",
"+_",
"[_",
"\"",
"help",
"\"_",
"]_",
",_",
"cwd_",
"=_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Moc",
"k",
"Test_",
"(_",
"Abstract",
"Cat",
"kin",
"Works",
"pace",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"nop",
"roj",
"ect_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"create",
" ",
"works",
"pace",
" ",
"with",
" ",
"just",
" ",
"cat",
"kin",
" ",
"and",
" ",
"'",
"nop",
"roj",
"ect",
"'",
" ",
"project_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dst",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"works",
"pace",
"dir_",
",_",
"'",
"nop",
"roj",
"ect",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"shutil_",
"._",
"copytree_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"MOC",
"K",
"\\u",
"DIR_",
",_",
"'",
"src",
"-",
"fail",
"'_",
",_",
"'",
"nop",
"roj",
"ect",
"'_",
")_",
",_",
"dst",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"test",
" ",
"with",
" ",
"whitelist_",
"\\u\\u\\uNL\\u\\u\\u_",
"out_",
"=_",
"self_",
"._",
"cma",
"ke_",
"(_",
"CAT",
"KI",
"N",
"\\u",
"WHITE",
"LIST",
"\\u",
"PACKAGES",
"_",
"=_",
"'",
"cat",
"kin",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"out_",
"=_",
"succeed_",
"(_",
"MAKE",
"\\u",
"CMD_",
"+_",
"[_",
"\"",
"install",
"\"_",
"]_",
",_",
"cwd_",
"=_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"shutil_",
"._",
"rmtree_",
"(_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"fail",
" ",
"if",
" ",
"we",
" ",
"try",
" ",
"to",
" ",
"build",
" ",
"nop",
"roj",
"ect",
" ",
"stack_",
"\\u\\u\\uNL\\u\\u\\u_",
"os_",
"._",
"makedirs_",
"(_",
"self_",
"._",
"builddir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"out_",
"=_",
"self_",
"._",
"cma",
"ke_",
"(_",
"CMA",
"KE",
"\\u",
"PREF",
"IX",
"\\u",
"PATH_",
"=_",
"self_",
"._",
"installd",
"ir_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"expect_",
"=_",
"fail_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"fail",
"ed",
" ",
"as",
" ",
"expected",
",",
" ",
"out",
"=\"_",
",_",
"out_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"b",
"\"",
"cat",
"kin",
"\\u",
"package",
"()",
" ",
"PROJECT",
"\\u",
"NAME",
" ",
"is",
" ",
"set",
" ",
"to",
" ",
"'",
"Project",
"'\"_",
"in_",
"out_",
",_",
"out_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"assert",
" ",
"'",
"You",
" ",
"must",
" ",
"call",
" ",
"project",
"()",
" ",
"with",
" ",
"the",
" ",
"same",
" ",
"name",
" ",
"bef",
"ore",
".'",
" ",
"in",
" ",
"out_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Moc",
"k",
"Test_",
"(_",
"Abstract",
"Cat",
"kin",
"Works",
"pace",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"env",
"\\u",
"cache",
"d\\u",
"static_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"hack",
" ",
"to",
" ",
"fix",
" ",
"emp",
"y",
" ",
"nose",
"tests",
" ",
"clas",
"h_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"sys_",
"._",
"stdout_",
"=_",
"em_",
"._",
"Pro",
"xy",
"File_",
"(_",
"sys_",
"._",
"stdout_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"dst",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"works",
"pace",
"dir_",
",_",
"'",
"cat",
"kin",
"\\u",
"test",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"shutil_",
"._",
"copytree_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"MOC",
"K",
"\\u",
"DIR_",
",_",
"'",
"src",
"'_",
",_",
"'",
"cat",
"kin",
"\\u",
"test",
"'_",
")_",
",_",
"dst",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"template",
"\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
",_",
"'..'_",
",_",
"'..'_",
",_",
"'",
"cma",
"ke",
"'_",
",_",
"'",
"em",
"'_",
",_",
"'",
"order",
"\\u",
"package",
"s",
".",
"cma",
"ke",
".",
"em",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"with_",
"open_",
"(_",
"template",
"\\u",
"file_",
",_",
"'",
"r",
"'_",
")_",
"as_",
"fhand",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"template_",
"=_",
"fhand",
"_",
"._",
"read_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"gdi",
"ct_",
"=_",
"{_",
"'",
"CAT",
"KI",
"N",
"\\u",
"DEV",
"EL",
"\\u",
"PREF",
"IX",
"'_",
":_",
"'/",
"foo",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"CMA",
"KE",
"\\u",
"PREF",
"IX",
"\\u",
"PATH",
"'_",
":_",
"[_",
"'/",
"bar",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"CAT",
"KI",
"N",
"\\u",
"GLOB",
"AL",
"\\u",
"LIB",
"\\u",
"DEST",
"INATION",
"'_",
":_",
"'/",
"glob",
"-",
"dest",
"/",
"lib",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"CAT",
"KI",
"N",
"\\u",
"GLOB",
"AL",
"\\u",
"BIN",
"\\u",
"DEST",
"INATION",
"'_",
":_",
"'/",
"glob",
"-",
"dest",
"/",
"bin",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"PYTHON",
"\\u",
"INSTA",
"LL",
"\\u",
"DIR",
"'_",
":_",
"'/",
"foo",
"/",
"dist",
"-",
"package",
"s",
"'_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"result_",
"=_",
"em_",
"._",
"expand_",
"(_",
"template_",
",_",
"gdi",
"ct_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"source",
"\\u",
"root",
"\\u",
"dir_",
"=_",
"self_",
"._",
"works",
"pace",
"dir_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"whitelist",
"ed",
"\\u",
"packages_",
"=_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"blacklisted",
"\\u",
"packages_",
"=_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"underl",
"ay",
"\\u",
"workspaces",
"_",
"=_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"set",
"(",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
" ",
"\"\"",
")'_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"set",
"(",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAG",
"E",
"\\u",
"PATH",
"S",
" ",
"\"\"",
")'_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"set",
"(",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
"\\u",
"IS",
"\\u",
"MET",
"A",
" ",
"\"\"",
")'_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"set",
"(",
"CAT",
"KI",
"N",
"\\u",
"MESSAGE",
"\\u",
"GENERAT",
"ORS",
"'_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"\"\"\"",
"\\\\",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
" ",
"\"",
"cat",
"kin",
"\\u",
"test",
"\")",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAG",
"E",
"\\u",
"PATH",
"S",
" ",
"\"",
"cat",
"kin",
"\\u",
"test",
"/",
"cat",
"kin",
"\\u",
"test",
"\")",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
"\\u",
"IS",
"\\u",
"MET",
"A",
" ",
"\"",
"Tru",
"e",
"\")",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
"\\u",
"BUILD",
"\\u",
"TYPE",
" ",
"\"",
"cat",
"kin",
"\")",
"\"\"\"_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"\"\"\"",
"\\\\",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
" ",
"\"",
"a",
"\")",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAG",
"E",
"\\u",
"PATH",
"S",
" ",
"\"",
"cat",
"kin",
"\\u",
"test",
"/",
"a",
"\")",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
"\\u",
"IS",
"\\u",
"MET",
"A",
" ",
"\"",
"Fal",
"se",
"\")",
"\\",
"10",
";",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
"\\u",
"BUILD",
"\\u",
"TYPE",
" ",
"\"",
"cat",
"kin",
"\")",
"\"\"\"_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"cat",
"kin",
" ",
"its",
"elf",
" ",
"filter",
"ed",
" ",
"out_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"'",
"list",
"(",
"APPEN",
"D",
" ",
"CAT",
"KI",
"N",
"\\u",
"ORDE",
"RED",
"\\u",
"PACKAGES",
" ",
"\"",
"cat",
"kin",
"\"'_",
"in_",
"result_",
",_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"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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
]
|
Except block handles 'BaseException' | AppScale/appscale/AppServer/lib/django-1.4/django/utils/encoding.py | [
{
"content": "import types\nimport urllib\nimport locale\nimport datetime\nimport codecs\nfrom decimal import Decimal\n\nfrom django.utils.functional import Promise\n\n\n\n\n\n\n\n\n\n# The encoding of the default system locale but falls back to the\n# given fallback encoding if the encoding is unsupported by python or could\n# not be determined. See tickets #10335 and #5846\ntry:\n DEFAULT_LOCALE_ENCODING = locale.getdefaultlocale()[1] or 'ascii'\n codecs.lookup(DEFAULT_LOCALE_ENCODING)\nexcept:\n DEFAULT_LOCALE_ENCODING = 'ascii'\n\n# Forwards compatibility with Django 1.5\n\n\nsmart_text = smart_unicode\nforce_text = force_unicode\nsmart_bytes = smart_str\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "except:",
"start_line": 183,
"start_column": 0,
"end_line": 183,
"end_column": 7
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"types_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"urllib_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"locale_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"codecs_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"decimal_",
"import_",
"Decimal_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"django_",
"._",
"utils_",
"._",
"functional_",
"import_",
"Promi",
"se_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"The",
" ",
"encoding",
" ",
"of",
" ",
"the",
" ",
"default",
" ",
"system",
" ",
"locale",
" ",
"but",
" ",
"fall",
"s",
" ",
"back",
" ",
"to",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"give",
"n",
" ",
"fall",
"back",
" ",
"encoding",
" ",
"if",
" ",
"the",
" ",
"encoding",
" ",
"is",
" ",
"unsup",
"porte",
"d",
" ",
"by",
" ",
"python",
" ",
"or",
" ",
"coul",
"d_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"not",
" ",
"be",
" ",
"dete",
"rmin",
"ed",
".",
" ",
" ",
"See",
" ",
"tick",
"ets",
" ",
"#",
"103",
"3",
"5",
" ",
"and",
" ",
"#",
"584",
"6_",
"\\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 ",
" _",
"DEF",
"AUL",
"T",
"\\u",
"LOCALE",
"\\u",
"ENCODING_",
"=_",
"locale_",
"._",
"getde",
"fault",
"locale_",
"(_",
")_",
"[_",
"1_",
"]_",
"or_",
"'",
"ascii",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"codecs_",
"._",
"lookup_",
"(_",
"DEF",
"AUL",
"T",
"\\u",
"LOCALE",
"\\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 ",
" _",
"DEF",
"AUL",
"T",
"\\u",
"LOCALE",
"\\u",
"ENCODING_",
"=_",
"'",
"ascii",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Forward",
"s",
" ",
"compatibility",
" ",
"with",
" ",
"Dj",
"ang",
"o",
" ",
"1.5_",
"\\u\\u\\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_",
"smart",
"\\u",
"text_",
"=_",
"smart",
"\\u",
"unicode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"force",
"\\u",
"text_",
"=_",
"force",
"\\u",
"unicode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"smart",
"\\u",
"bytes_",
"=_",
"smart",
"\\u",
"str_"
]
| [
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,
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
]
|
Unused import | brownhead/superzippy/superzippy/tests/acceptance/samples/passthrough-options/passthrough/main.py | [
{
"content": "#!/usr/env/bin python\n\nfrom yaml import load, dump\ntry:\n # We want this to error because a Super Zip can't have shared libs in it.\n from yaml import CLoader as Loader, CDumper as Dumper\n assert False, \"Should not be able to access shared libraries.\"\nexcept ImportError:\n from yaml import Loader, Dumper\n\ntry:\n unicode\nexcept NameError:\n unicode = str\n\nimport sys\n\n\n\nif __name__ == \"__main__\":\n if sys.argv[2] == \"list\":\n parse_list()\n else:\n parse_dict()\n sys.exit(1)\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def parse_list():\n data = load(sys.argv[1])\n for i in data:\n sys.stdout.write(str(i) + \"\\n\")",
"metadata": "root.parse_list",
"header": "['module', '___EOS___']",
"index": 17
},
{
"content": "def parse_tuple_list():\n data = load(sys.argv[1])\n for k, v in data:\n sys.stdout.write(str(k) + \" \" + str(v) + \"\\n\")",
"metadata": "root.parse_tuple_list",
"header": "['module', '___EOS___']",
"index": 22
}
]
| [
{
"span": "from yaml import load, dump",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 27
},
{
"span": "from yaml import CLoader as Loader, CDumper as Dumper",
"start_line": 5,
"start_column": 4,
"end_line": 5,
"end_column": 57
},
{
"span": "from yaml import Loader, Dumper",
"start_line": 8,
"start_column": 4,
"end_line": 8,
"end_column": 35
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#!",
"/",
"usr",
"/",
"env",
"/",
"bin",
" ",
"python_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"yaml_",
"import_",
"load_",
",_",
"dump_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"We",
" ",
"want",
" ",
"this",
" ",
"to",
" ",
"error",
" ",
"bec",
"aus",
"e",
" ",
"a",
" ",
"Super",
" ",
"Zip",
" ",
"can",
"'",
"t",
" ",
"have",
" ",
"shared",
" ",
"libs",
" ",
"in",
" ",
"it",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"yaml_",
"import_",
"CL",
"oad",
"er_",
"as_",
"Loader_",
",_",
"CD",
"ump",
"er_",
"as_",
"Dumper",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"False_",
",_",
"\"",
"Sho",
"ul",
"d",
" ",
"not",
" ",
"be",
" ",
"able",
" ",
"to",
" ",
"access",
" ",
"shared",
" ",
"librar",
"ies",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Import",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"yaml_",
"import_",
"Loader_",
",_",
"Dumper",
"_",
"\\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 ",
" _",
"unicode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Name",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"unicode_",
"=_",
"str_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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 ",
" _",
"if_",
"sys_",
"._",
"argv_",
"[_",
"2_",
"]_",
"==_",
"\"",
"list",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"parse",
"\\u",
"list_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"parse",
"\\u",
"dict_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"sys_",
"._",
"exit_",
"(_",
"1_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"parse",
"\\u",
"list_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load_",
"(_",
"sys_",
"._",
"argv_",
"[_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"sys_",
"._",
"stdout_",
"._",
"write_",
"(_",
"str_",
"(_",
"i_",
")_",
"+_",
"\"\\\\",
"n",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"parse",
"\\u",
"tuple",
"\\u",
"list_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load_",
"(_",
"sys_",
"._",
"argv_",
"[_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
",_",
"v_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"sys_",
"._",
"stdout_",
"._",
"write_",
"(_",
"str_",
"(_",
"k_",
")_",
"+_",
"\"",
" ",
"\"_",
"+_",
"str_",
"(_",
"v_",
")_",
"+_",
"\"\\\\",
"n",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | cournape/Bento/bento/compat/_tempfile.py | [
{
"content": " def __init__(self, file, name, delete=True):\n self.file = file\n self.name = name\n self.close_called = False\n self.delete = delete",
"metadata": "root._TemporaryFileWrapper.__init__",
"header": "['class', '_TemporaryFileWrapper', ':', '___EOS___']",
"index": 24
},
{
"content": "def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix=\"\",\n prefix=template, dir=None, delete=True):\n \"\"\"Create and return a temporary file.\n Arguments:\n 'prefix', 'suffix', 'dir' -- as for mkstemp.\n 'mode' -- the mode argument to os.fdopen (default \"w+b\").\n 'bufsize' -- the buffer size argument to os.fdopen (default -1).\n 'delete' -- whether the file is deleted on close (default True).\n The file is created as mkstemp() would do it.\n\n Returns an object with a file-like interface; the name of the file\n is accessible as file.name. The file will be automatically deleted\n when it is closed unless the 'delete' argument is set to False.\n \"\"\"\n\n if dir is None:\n dir = gettempdir()\n\n if 'b' in mode:\n flags = _bin_openflags\n else:\n flags = _text_openflags\n\n # Setting O_TEMPORARY in the flags causes the OS to delete\n # the file when it is closed. This is only supported by Windows.\n if _os.name == 'nt' and delete:\n flags |= _os.O_TEMPORARY\n\n (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)\n file = _os.fdopen(fd, mode, bufsize)\n return _TemporaryFileWrapper(file, name, delete)",
"metadata": "root.NamedTemporaryFile",
"header": "['module', '___EOS___']",
"index": 75
}
]
| [
{
"span": "_mkstemp_inner(dir, prefix, suffix, flags)",
"start_line": 103,
"start_column": 17,
"end_line": 103,
"end_column": 59
}
]
| []
| 1 | false | [
"[CLS]_",
"Wro",
"ng_",
"number_",
"of_",
"arguments_",
"in_",
"a_",
"call_",
"[SEP]_",
"class_",
"\\u",
"Tempora",
"ry",
"File",
"Wrapper_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"file_",
",_",
"name_",
",_",
"delete_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"file_",
"=_",
"file_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"name_",
"=_",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"close",
"\\u",
"called_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"delete_",
"=_",
"delete_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Name",
"d",
"Tempora",
"ry",
"File_",
"(_",
"mode_",
"=_",
"'",
"w",
"+",
"b",
"'_",
",_",
"bufsize_",
"=_",
"-_",
"1_",
",_",
"suffix_",
"=_",
"\"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"prefix_",
"=_",
"template_",
",_",
"dir_",
"=_",
"None_",
",_",
"delete_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Creat",
"e",
" ",
"and",
" ",
"return",
" ",
"a",
" ",
"temporar",
"y",
" ",
"file",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Arg",
"ument",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'",
"prefix",
"',",
" ",
"'",
"suff",
"ix",
"',",
" ",
"'",
"dir",
"'",
" ",
"--",
" ",
"as",
" ",
"for",
" ",
"mks",
"temp",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'",
"mode",
"'",
" ",
"--",
" ",
"the",
" ",
"mode",
" ",
"argu",
"ment",
" ",
"to",
" ",
"os",
".",
"fdo",
"pen",
" ",
"(",
"default",
" ",
"\"",
"w",
"+",
"b",
"\")",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'",
"buf",
"size",
"'",
" ",
"--",
" ",
"the",
" ",
"buffer",
" ",
"size",
" ",
"argu",
"ment",
" ",
"to",
" ",
"os",
".",
"fdo",
"pen",
" ",
"(",
"default",
" ",
"-1",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'",
"delete",
"'",
" ",
"--",
" ",
"whe",
"ther",
" ",
"the",
" ",
"file",
" ",
"is",
" ",
"delete",
"d",
" ",
"on",
" ",
"close",
" ",
"(",
"default",
" ",
"Tru",
"e",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"The",
" ",
"file",
" ",
"is",
" ",
"created",
" ",
"as",
" ",
"mks",
"temp",
"()",
" ",
"wou",
"ld",
" ",
"do",
" ",
"it",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
" ",
"an",
" ",
"object",
" ",
"with",
" ",
"a",
" ",
"file",
"-",
"like",
" ",
"interface",
";",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"the",
" ",
"file",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"is",
" ",
"accessible",
" ",
"as",
" ",
"file",
".",
"name",
".",
" ",
" ",
"The",
" ",
"file",
" ",
"will",
" ",
"be",
" ",
"automati",
"call",
"y",
" ",
"delete",
"d",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"whe",
"n",
" ",
"it",
" ",
"is",
" ",
"close",
"d",
" ",
"unl",
"ess",
" ",
"the",
" ",
"'",
"delete",
"'",
" ",
"argu",
"ment",
" ",
"is",
" ",
"set",
" ",
"to",
" ",
"Fal",
"se",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"dir_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dir_",
"=_",
"gettempdir_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"'",
"b",
"'_",
"in_",
"mode_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"flags_",
"=_",
"\\u",
"bin",
"\\u",
"openf",
"lags_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"flags_",
"=_",
"\\u",
"text",
"\\u",
"openf",
"lags_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sett",
"ing",
" ",
"O",
"\\u",
"TEMP",
"ORA",
"RY",
" ",
"in",
" ",
"the",
" ",
"flags",
" ",
"caus",
"es",
" ",
"the",
" ",
"OS",
" ",
"to",
" ",
"delete_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"file",
" ",
"whe",
"n",
" ",
"it",
" ",
"is",
" ",
"close",
"d",
".",
" ",
" ",
"Thi",
"s",
" ",
"is",
" ",
"only",
" ",
"support",
"ed",
" ",
"by",
" ",
"Window",
"s",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\\u",
"os_",
"._",
"name_",
"==_",
"'",
"nt",
"'_",
"and_",
"delete_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"flags_",
"|=_",
"\\u",
"os_",
"._",
"O",
"\\u",
"TEMP",
"ORA",
"RY_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"(_",
"fd_",
",_",
"name_",
")_",
"=_",
"\\u",
"mks",
"temp",
"\\u",
"inner_",
"(_",
"dir_",
",_",
"prefix_",
",_",
"suffix_",
",_",
"flags_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"file_",
"=_",
"\\u",
"os_",
"._",
"fdo",
"pen_",
"(_",
"fd_",
",_",
"mode_",
",_",
"bufsize_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u",
"Tempora",
"ry",
"File",
"Wrapper_",
"(_",
"file_",
",_",
"name_",
",_",
"delete_",
")_"
]
| [
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,
4,
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,
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
]
|
Unused import | googlefonts/fontbakery/bakery_lint/fonttests/test_metadata.py | [
{
"content": "\"\"\" Contains TestCases for METADATA.pb \"\"\"\n# coding: utf-8\n# Copyright 2013 The Font Bakery Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n# See AUTHORS.txt for the list of Authors and LICENSE.txt for the License.\n\nimport magic\nimport os\nimport os.path as op\nimport re\nimport requests\nfrom google.protobuf import text_format\nfrom bakery_cli.fonts_public_pb2 import FontProto, FamilyProto\nfrom bakery_cli.ttfont import Font\nfrom bakery_lint.base import BakeryTestCase as TestCase, tags, autofix\nfrom bakery_lint.base import TestCaseOperator\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\nweights = {\n 'Thin': 100,\n 'ThinItalic': 100,\n 'ExtraLight': 200,\n 'ExtraLightItalic': 200,\n 'Light': 300,\n 'LightItalic': 300,\n 'Regular': 400,\n 'Italic': 400,\n 'Medium': 500,\n 'MediumItalic': 500,\n 'SemiBold': 600,\n 'SemiBoldItalic': 600,\n 'Bold': 700,\n 'BoldItalic': 700,\n 'ExtraBold': 800,\n 'ExtraBoldItalic': 800,\n 'Black': 900,\n 'BlackItalic': 900,\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def get_test_subset_function(path):\n def function(self):\n\n if not op.exists(path):\n self.fail('%s subset does not exist' % op.basename(path))\n\n if magic.from_file(path) != 'TrueType font data':\n _ = '%s does not seem to be truetype font'\n self.fail(_ % op.basename(path))\n function.tags = ['required']\n return function",
"metadata": "root.get_test_subset_function",
"header": "['module', '___EOS___']",
"index": 30
},
{
"content": "def get_FamilyProto_Message(path):\n metadata = FamilyProto()\n text_data = open(path, \"rb\").read()\n text_format.Merge(text_data, metadata)\n return metadata",
"metadata": "root.get_FamilyProto_Message",
"header": "['module', '___EOS___']",
"index": 42
},
{
"content": "class MetadataSubsetsListTest(TestCase):\n\n targets = ['metadata']\n tool = 'METADATA.pb'\n name = __name__\n",
"metadata": "root.MetadataSubsetsListTest",
"header": "['module', '___EOS___']",
"index": 48
},
{
"content": " @classmethod\n def __generateTests__(cls):\n try:\n metadata = get_FamilyProto_Message(cls.operator.path)\n except:\n return\n for font in metadata.fonts:\n# for subset in metadata.subsets.extend(['menu']):\n for subset in metadata.subsets:\n path = op.join(op.dirname(cls.operator.path),\n font.filename[:-3] + subset)\n\n subsetid = re.sub(r'\\W', '_', subset)\n\n # cls.operator.debug('cls.test_charset_{0} = get_test_subset_function(\"{1}\")'.format(subsetid, path))\n # cls.operator.debug('cls.test_charset_{0}.__func__.__doc__ = \"{1} is real TrueType file\"'.format(subsetid, font.get('filename')[:-3] + subset))\n\n exec 'cls.test_charset_{0} = get_test_subset_function(\"{1}\")'.format(subsetid, path)\n exec 'cls.test_charset_{0}.__func__.__doc__ = \"{1} is real TrueType file\"'.format(subsetid, font.filename[:-3] + subset)",
"metadata": "root.MetadataSubsetsListTest.__generateTests__",
"header": "['class', 'MetadataSubsetsListTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 54
},
{
"content": "class TestFontOnDiskFamilyEqualToMetadataProtoBuf(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n",
"metadata": "root.TestFontOnDiskFamilyEqualToMetadataProtoBuf",
"header": "['module', '___EOS___']",
"index": 75
},
{
"content": " @tags('required',)\n def test_font_on_disk_family_equal_in_metadata_protobuf(self):\n \"\"\" Font on disk and in METADATA.pb have the same family name ? \"\"\"\n metadata = get_FamilyProto_Message(self.operator.path)\n\n unmatched_fonts = []\n for font_metadata in metadata.fonts:\n try:\n font = Font.get_ttfont_from_metadata(self.operator.path,\n font_metadata)\n except IOError:\n continue\n if font.familyname != font_metadata.name:\n unmatched_fonts.append(font_metadata.filename)\n\n if unmatched_fonts:\n msg = 'Unmatched family name are in fonts: {}'\n self.fail(msg.format(', '.join(unmatched_fonts)))",
"metadata": "root.TestFontOnDiskFamilyEqualToMetadataProtoBuf.test_font_on_disk_family_equal_in_metadata_protobuf",
"header": "['class', 'TestFontOnDiskFamilyEqualToMetadataProtoBuf', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 81
},
{
"content": "class TestPostScriptNameInMetadataEqualFontOnDisk(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n",
"metadata": "root.TestPostScriptNameInMetadataEqualFontOnDisk",
"header": "['module', '___EOS___']",
"index": 101
},
{
"content": " @tags('required')\n def test_postscriptname_in_metadata_equal_to_font_on_disk(self):\n \"\"\" Checks METADATA.pb 'postScriptName' matches TTF 'postScriptName' \"\"\"\n metadata = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in metadata.fonts:\n try:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n except IOError:\n continue\n if font.post_script_name != font_metadata.post_script_name:\n\n msg = 'In METADATA postScriptName=\"{0}\", but in TTF \"{1}\"'\n self.fail(msg.format(font.post_script_name,\n font_metadata.post_script_name))",
"metadata": "root.TestPostScriptNameInMetadataEqualFontOnDisk.test_postscriptname_in_metadata_equal_to_font_on_disk",
"header": "['class', 'TestPostScriptNameInMetadataEqualFontOnDisk', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 107
},
{
"content": "class CheckMetadataAgreements(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n\n\n\n\n\n\n\n\n\n",
"metadata": "root.CheckMetadataAgreements",
"header": "['module', '___EOS___']",
"index": 124
},
{
"content": " def setUp(self):\n self.metadata = get_FamilyProto_Message(self.operator.path)",
"metadata": "root.CheckMetadataAgreements.setUp",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 130
},
{
"content": " def test_metadata_family_values_are_all_the_same(self):\n \"\"\" Check that METADATA family values are all the same \"\"\"\n name = ''\n for font_metadata in self.metadata.fonts:\n if name and font_metadata.name != name:\n self.fail('Family name in metadata fonts items not the same')\n name = font_metadata.name",
"metadata": "root.CheckMetadataAgreements.test_metadata_family_values_are_all_the_same",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 133
},
{
"content": " def test_metadata_font_have_regular(self):\n \"\"\" According GWF standarts font should have Regular style. \"\"\"\n # this tests will appear in each font\n have = False\n for i in self.metadata.fonts:\n if i.weight == 400 and i.style == 'normal':\n have = True\n\n self.assertTrue(have)",
"metadata": "root.CheckMetadataAgreements.test_metadata_font_have_regular",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 141
},
{
"content": " @tags('required')\n def test_metadata_regular_is_400(self):\n \"\"\" Regular should be 400 \"\"\"\n have = False\n for i in self.metadata.fonts:\n if i.filename.endswith('Regular.ttf') and i.weight == 400:\n have = True\n if not have:\n self.fail(('METADATA.pb does not contain Regular font. At least'\n ' one font must be Regular and its weight must be 400'))",
"metadata": "root.CheckMetadataAgreements.test_metadata_regular_is_400",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 151
},
{
"content": " def test_metadata_regular_is_normal(self):\n \"\"\" Usually Regular should be normal style \"\"\"\n have = False\n for x in self.metadata.fonts:\n if x.full_name.endswith('Regular') and x.style == 'normal':\n have = True\n self.assertTrue(have)",
"metadata": "root.CheckMetadataAgreements.test_metadata_regular_is_normal",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 162
},
{
"content": " @tags('required')\n def test_metadata_filename_matches_postscriptname(self):\n \"\"\" METADATA.pb `filename` matches `postScriptName` ? \"\"\"\n import re\n regex = re.compile(r'\\W')\n\n fonts = [font for font in self.metadata.fonts\n if not font.post_script_name.endswith('-Regular')]\n\n for x in fonts:\n post_script_name = regex.sub('', x.post_script_name)\n filename = regex.sub('', os.path.splitext(x.filename)[0])\n if filename != post_script_name:\n msg = '\"{0}\" does not match \"{1}\"'\n self.fail(msg.format(x.filename, x.post_script_name))",
"metadata": "root.CheckMetadataAgreements.test_metadata_filename_matches_postscriptname",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 170
},
{
"content": " @tags('required')\n def test_metadata_fullname_matches_postScriptName(self):\n \"\"\" METADATA.pb `fullName` matches `postScriptName` ? \"\"\"\n import re\n regex = re.compile(r'\\W')\n\n for x in self.metadata.fonts:\n post_script_name = regex.sub('', x.post_script_name)\n fullname = regex.sub('', x.full_name)\n if fullname != post_script_name:\n msg = '\"{0}\" does not match \"{1}\"'\n self.fail(msg.format(x.full_name, x.post_script_name))",
"metadata": "root.CheckMetadataAgreements.test_metadata_fullname_matches_postScriptName",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 186
},
{
"content": " def test_metadata_fullname_is_equal_to_internal_font_fullname(self):\n \"\"\" METADATA.pb 'fullname' value matches internal 'fullname' ? \"\"\"\n for font_metadata in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n self.assertEqual(font.fullname, font_metadata.full_name)",
"metadata": "root.CheckMetadataAgreements.test_metadata_fullname_is_equal_to_internal_font_fullname",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 199
},
{
"content": " def test_font_name_matches_family(self):\n \"\"\" METADATA.pb fonts 'name' property should be same as font familyname \"\"\"\n\n for font_metadata in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if font_metadata.name != font.familyname:\n msg = '\"fonts.name\" property is not the same as TTF familyname'\n self.fail(msg)",
"metadata": "root.CheckMetadataAgreements.test_font_name_matches_family",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 205
},
{
"content": " def test_metadata_fonts_fields_have_fontname(self):\n \"\"\" METADATA.pb font item fields \"name\", \"postScriptName\", \"fullName\", \"filename\" contains font name right format ? \"\"\"\n for x in self.metadata.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, x)\n\n self.assertIn(font.familyname, x.name)\n self.assertIn(font.familyname, x.full_name)\n self.assertIn(\"\".join(str(font.familyname).split()),\n x.filename)\n self.assertIn(\"\".join(str(font.familyname).split()),\n x.post_script_name)",
"metadata": "root.CheckMetadataAgreements.test_metadata_fonts_fields_have_fontname",
"header": "['class', 'CheckMetadataAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 214
},
{
"content": "class CheckMetadataContainsReservedFontName(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n\n\n\n",
"metadata": "root.CheckMetadataContainsReservedFontName",
"header": "['module', '___EOS___']",
"index": 227
},
{
"content": " @tags('info')\n def test_copyright_contains_correct_rfn(self):\n \"\"\" Copyright notice does not contain Reserved Font Name \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n if 'Reserved Font Name' in font_metadata.copyright:\n msg = '\"%s\" contains \"Reserved Font Name\"'\n self.fail(msg % font_metadata.copyright)",
"metadata": "root.CheckMetadataContainsReservedFontName.test_copyright_contains_correct_rfn",
"header": "['class', 'CheckMetadataContainsReservedFontName', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 233
},
{
"content": " @tags('info')\n def test_copyright_matches_pattern(self):\n \"\"\" Copyright notice matches canonical pattern? \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n almost_matches = re.search(r'(Copyright\\s+\\(c\\)\\s+20\\d{2}.*)', font_metadata.copyright)\n does_match = re.search(r'(Copyright\\s+\\(c\\)\\s+20\\d{2}.*\\(.*@.*.*\\))', font_metadata.copyright)\n\n if (does_match == None):\n if (almost_matches):\n self.fail(\"Copyright notice is okay, but it lacks an email address. Expected pattern is: 'Copyright 2016 Author Name ([email protected])'\")\n else:\n self.fail(\"Copyright notices should match the folowing pattern: 'Copyright 2016 Author Name ([email protected])'\")",
"metadata": "root.CheckMetadataContainsReservedFontName.test_copyright_matches_pattern",
"header": "['class', 'CheckMetadataContainsReservedFontName', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 243
},
{
"content": " @tags('info')\n def test_copyright_is_consistent_across_family(self):\n \"\"\" Copyright notice is the same in all fonts ? \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n copyright = ''\n for font_metadata in fm.fonts:\n if copyright and font_metadata.copyright != copyright:\n self.fail('Copyright is inconsistent across family')\n copyright = font_metadata.copyright",
"metadata": "root.CheckMetadataContainsReservedFontName.test_copyright_is_consistent_across_family",
"header": "['class', 'CheckMetadataContainsReservedFontName', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 258
},
{
"content": " @tags('info')\n def test_metadata_copyright_size(self):\n \"\"\" Copyright notice should be less than 500 chars \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n self.assertLessEqual(len(font_metadata.copyright), 500)",
"metadata": "root.CheckMetadataContainsReservedFontName.test_metadata_copyright_size",
"header": "['class', 'CheckMetadataContainsReservedFontName', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 269
},
{
"content": "class File(object):\n\n\n\n",
"metadata": "root.File",
"header": "['module', '___EOS___']",
"index": 278
},
{
"content": " def __init__(self, rootdir):\n self.rootdir = rootdir",
"metadata": "root.File.__init__",
"header": "['class', 'File', '(', 'object', ')', ':', '___EOS___']",
"index": 280
},
{
"content": " def exists(self, filename):\n return op.exists(op.join(self.rootdir, filename))",
"metadata": "root.File.exists",
"header": "['class', 'File', '(', 'object', ')', ':', '___EOS___']",
"index": 283
},
{
"content": " def size(self, filename):\n return op.getsize(op.join(self.rootdir, filename))",
"metadata": "root.File.size",
"header": "['class', 'File', '(', 'object', ')', ':', '___EOS___']",
"index": 286
},
{
"content": " def mime(self, filename):\n return magic.from_file(op.join(self.rootdir, filename), mime=True)",
"metadata": "root.File.mime",
"header": "['class', 'File', '(', 'object', ')', ':', '___EOS___']",
"index": 289
},
{
"content": "class CheckMonospaceAgreement(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n",
"metadata": "root.CheckMonospaceAgreement",
"header": "['module', '___EOS___']",
"index": 293
},
{
"content": " def test_check_monospace_agreement(self):\n \"\"\" Monospace font has hhea.advanceWidthMax equal to each glyph's advanceWidth ? \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n if fm.category != 'Monospace':\n return\n for font_metadata in fm.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path,\n font_metadata.filename)\n prev = 0\n for g in font.glyphs():\n if prev and font.advance_width(g) != prev:\n self.fail(('Glyph advanceWidth must be same'\n ' across all glyphs %s' % prev))\n prev = font.advance_width(g)\n\n if prev != font.advance_width():\n msg = ('\"hhea\" table advanceWidthMax property differs'\n ' to glyphs advanceWidth [%s, %s]')\n self.fail(msg % (prev, font.advance_width()))",
"metadata": "root.CheckMonospaceAgreement.test_check_monospace_agreement",
"header": "['class', 'CheckMonospaceAgreement', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 299
},
{
"content": "class CheckItalicStyleMatchesMacStyle(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n",
"metadata": "root.CheckItalicStyleMatchesMacStyle",
"header": "['module', '___EOS___']",
"index": 321
},
{
"content": " def test_check_italic_style_matches_names(self):\n \"\"\" METADATA.pb font.style `italic` matches font internals? \"\"\"\n family = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in family.fonts:\n if font_metadata.style != 'italic':\n continue\n\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n\n if not bool(font.macStyle & 0b10):\n self.fail(('Metadata style has been set to italic'\n ' but font second bit in macStyle has'\n ' not been set'))\n\n style = font.familyname.split('-')[-1]\n if not style.endswith('Italic'):\n self.fail(('macStyle second bit is set but postScriptName \"%s\"'\n ' is not ended with \"Italic\"') % font.familyname)\n\n style = font.fullname.split('-')[-1]\n if not style.endswith('Italic'):\n self.fail(('macStyle second bit is set but fullName \"%s\"'\n ' is not ended with \"Italic\"') % font.fullname)",
"metadata": "root.CheckItalicStyleMatchesMacStyle.test_check_italic_style_matches_names",
"header": "['class', 'CheckItalicStyleMatchesMacStyle', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 327
},
{
"content": "class CheckNormalStyleMatchesMacStyle(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n",
"metadata": "root.CheckNormalStyleMatchesMacStyle",
"header": "['module', '___EOS___']",
"index": 353
},
{
"content": " def test_check_normal_style_matches_names(self):\n \"\"\" Check METADATA.pb font.style `italic` matches font internal \"\"\"\n family = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in family.fonts:\n if font_metadata.style != 'normal':\n continue\n\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n\n if bool(font.macStyle & 0b10):\n self.fail(('Metadata style has been set to normal'\n ' but font second bit (italic) in macStyle has'\n ' been set'))\n\n style = font.familyname.split('-')[-1]\n if style.endswith('Italic'):\n self.fail(('macStyle second bit is not set but postScriptName \"%s\"'\n ' is ended with \"Italic\"') % font.familyname)\n\n style = font.fullname.split('-')[-1]\n if style.endswith('Italic'):\n self.fail(('macStyle second bit is not set but fullName \"%s\"'\n ' is ended with \"Italic\"') % font.fullname)",
"metadata": "root.CheckNormalStyleMatchesMacStyle.test_check_normal_style_matches_names",
"header": "['class', 'CheckNormalStyleMatchesMacStyle', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 359
},
{
"content": "class CheckMetadataMatchesNameTable(TestCase):\n\n targets = ['metadata']\n tool = 'lint'\n name = __name__\n",
"metadata": "root.CheckMetadataMatchesNameTable",
"header": "['module', '___EOS___']",
"index": 385
},
{
"content": " def test_check_metadata_matches_nametable(self):\n \"\"\" Metadata key-value match to table name fields \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n\n report = '%s: Family name was supposed to be \"%s\" but is \"%s\"'\n report = report % (font_metadata.name, fm.name,\n ttfont.familyname)\n self.assertEqual(ttfont.familyname, fm.name, report)\n self.assertEqual(ttfont.fullname, font_metadata.full_name)",
"metadata": "root.CheckMetadataMatchesNameTable.test_check_metadata_matches_nametable",
"header": "['class', 'CheckMetadataMatchesNameTable', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 391
},
{
"content": "class CheckMenuSubsetContainsProperGlyphs(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n\n",
"metadata": "root.CheckMenuSubsetContainsProperGlyphs",
"header": "['module', '___EOS___']",
"index": 405
},
{
"content": " def test_check_menu_contains_proper_glyphs(self):\n \"\"\" Check menu file contains proper glyphs \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n tf = Font.get_ttfont_from_metadata(self.operator.path, font_metadata, is_menu=True)\n self.check_retrieve_glyphs(tf, font_metadata)",
"metadata": "root.CheckMenuSubsetContainsProperGlyphs.test_check_menu_contains_proper_glyphs",
"header": "['class', 'CheckMenuSubsetContainsProperGlyphs', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 411
},
{
"content": " def check_retrieve_glyphs(self, ttfont, font_metadata):\n cmap = ttfont.retrieve_cmap_format_4()\n\n glyphs = cmap.cmap\n\n missing_glyphs = set()\n if ord(' ') not in glyphs:\n missing_glyphs.add(' ')\n\n for g in font_metadata.name:\n if ord(g) not in glyphs:\n missing_glyphs.add(g)\n\n if missing_glyphs:\n _ = '%s: Menu is missing glyphs: \"%s\"'\n report = _ % (font_metadata.filename, ''.join(missing_glyphs))\n self.fail(report)",
"metadata": "root.CheckMenuSubsetContainsProperGlyphs.check_retrieve_glyphs",
"header": "['class', 'CheckMenuSubsetContainsProperGlyphs', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 419
},
{
"content": "class CheckGlyphConsistencyInFamily(TestCase):\n\n targets = ['metadata']\n tool = 'lint'\n name = __name__\n\n\n\n",
"metadata": "root.CheckGlyphConsistencyInFamily",
"header": "['module', '___EOS___']",
"index": 438
},
{
"content": " def setUp(self):\n self.familymetadata = get_FamilyProto_Message(self.operator.path)",
"metadata": "root.CheckGlyphConsistencyInFamily.setUp",
"header": "['class', 'CheckGlyphConsistencyInFamily', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 444
},
{
"content": " def test_the_same_number_of_glyphs_across_family(self):\n \"\"\" The same number of glyphs across family? \"\"\"\n glyphs_count = 0\n for font_metadata in self.familymetadata.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if not glyphs_count:\n glyphs_count = len(ttfont.glyphs)\n\n if glyphs_count != len(ttfont.glyphs):\n self.fail('Family has a different glyphs\\'s count in fonts')",
"metadata": "root.CheckGlyphConsistencyInFamily.test_the_same_number_of_glyphs_across_family",
"header": "['class', 'CheckGlyphConsistencyInFamily', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 447
},
{
"content": " def test_the_same_names_of_glyphs_across_family(self):\n \"\"\" The same names of glyphs across family? \"\"\"\n glyphs = None\n for font_metadata in self.familymetadata.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if not glyphs:\n glyphs = len(ttfont.glyphs)\n\n if glyphs != len(ttfont.glyphs):\n self.fail('Family has a different glyphs\\'s names in fonts')",
"metadata": "root.CheckGlyphConsistencyInFamily.test_the_same_names_of_glyphs_across_family",
"header": "['class', 'CheckGlyphConsistencyInFamily', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 458
},
{
"content": " def test_the_same_encodings_of_glyphs_across_family(self):\n \"\"\" The same unicode encodings of glyphs across family? \"\"\"\n encoding = None\n for font_metadata in self.familymetadata.fonts:\n ttfont = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n cmap = ttfont.retrieve_cmap_format_4()\n\n if not encoding:\n encoding = cmap.platEncID\n\n if encoding != cmap.platEncID:\n self.fail('Family has different encoding across fonts')",
"metadata": "root.CheckGlyphConsistencyInFamily.test_the_same_encodings_of_glyphs_across_family",
"header": "['class', 'CheckGlyphConsistencyInFamily', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 469
},
{
"content": "class CheckFontNameNotInCamelCase(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n",
"metadata": "root.CheckFontNameNotInCamelCase",
"header": "['module', '___EOS___']",
"index": 483
},
{
"content": " def test_fontname_not_in_camel_case(self):\n \"\"\" Check if fontname is not camel cased \"\"\"\n familymetadata = get_FamilyProto_Message(self.operator.path)\n\n camelcased_fontnames = []\n for font_metadata in familymetadata.fonts:\n if bool(re.match(r'([A-Z][a-z]+){2,}', font_metadata.name)):\n camelcased_fontnames.append(font_metadata.name)\n\n if camelcased_fontnames:\n self.fail(('%s are camel cased names. To solve this check just '\n 'use spaces in names.'))",
"metadata": "root.CheckFontNameNotInCamelCase.test_fontname_not_in_camel_case",
"header": "['class', 'CheckFontNameNotInCamelCase', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 489
},
{
"content": "class CheckFontsMenuAgreements(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n\n",
"metadata": "root.CheckFontsMenuAgreements",
"header": "['module', '___EOS___']",
"index": 503
},
{
"content": " def menufile(self, font_metadata):\n return '%s.menu' % font_metadata.filename[:-4]",
"metadata": "root.CheckFontsMenuAgreements.menufile",
"header": "['class', 'CheckFontsMenuAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 509
},
{
"content": " @tags('required')\n def test_menu_file_agreement(self):\n \"\"\" Check fonts have corresponding menu files \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n menufile = self.menufile(font_metadata)\n path = op.join(op.dirname(self.operator.path), menufile)\n\n if not op.exists(path):\n self.fail('%s does not exist' % menufile)\n\n if magic.from_file(path) != 'TrueType font data':\n self.fail('%s is not actual TTF file' % menufile)",
"metadata": "root.CheckFontsMenuAgreements.test_menu_file_agreement",
"header": "['class', 'CheckFontsMenuAgreements', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 512
},
{
"content": "class CheckFamilyNameMatchesFontNames(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n",
"metadata": "root.CheckFamilyNameMatchesFontNames",
"header": "['module', '___EOS___']",
"index": 528
},
{
"content": " def test_check_familyname_matches_fontnames(self):\n \"\"\" Check font name is the same as family name \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n _ = '%s: Family name \"%s\" does not match font name: \"%s\"'\n _ = _ % (font_metadata.filename, fm.name, font_metadata.name)\n self.assertEqual(font_metadata.name, fm.name, _)",
"metadata": "root.CheckFamilyNameMatchesFontNames.test_check_familyname_matches_fontnames",
"header": "['class', 'CheckFamilyNameMatchesFontNames', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 534
},
{
"content": "class CheckCanonicalWeights(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n",
"metadata": "root.CheckCanonicalWeights",
"header": "['module', '___EOS___']",
"index": 566
},
{
"content": " def test_check_canonical_weights(self):\n \"\"\" Weights have canonical value? \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n weight = font_metadata.weight\n first_digit = weight / 100\n is_invalid = (weight % 100) != 0 or (first_digit < 1\n or first_digit > 9)\n _ = (\"%s: The weight is %d which is not a \"\n \"multiple of 100 between 1 and 9\")\n\n self.assertFalse(is_invalid, _ % (op.basename(self.operator.path),\n font_metadata.weight))\n\n tf = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n _ = (\"%s: METADATA.pb overwrites the weight. \"\n \" The METADATA.pb weight is %d and the font\"\n \" file %s weight is %d\")\n _ = _ % (font_metadata.filename, font_metadata.weight,\n font_metadata.filename, tf.OS2_usWeightClass)\n\n self.assertEqual(tf.OS2_usWeightClass, font_metadata.weight)",
"metadata": "root.CheckCanonicalWeights.test_check_canonical_weights",
"header": "['class', 'CheckCanonicalWeights', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 572
},
{
"content": "class CheckPostScriptNameMatchesWeight(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n",
"metadata": "root.CheckPostScriptNameMatchesWeight",
"header": "['module', '___EOS___']",
"index": 597
},
{
"content": " def test_postscriptname_contains_correct_weight(self):\n \"\"\" Metadata weight matches postScriptName \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n pair = []\n for k, weight in weights.items():\n if weight == font_metadata.weight:\n pair.append((k, weight))\n\n if not pair:\n self.fail('Font weight does not match for \"postScriptName\"')\n\n if not (font_metadata.post_script_name.endswith('-%s' % pair[0][0])\n or font_metadata.post_script_name.endswith('-%s' % pair[1][0])):\n\n _ = ('postScriptName with weight %s must be '\n 'ended with \"%s\" or \"%s\"')\n self.fail(_ % (pair[0][1], pair[0][0], pair[1][0]))",
"metadata": "root.CheckPostScriptNameMatchesWeight.test_postscriptname_contains_correct_weight",
"header": "['class', 'CheckPostScriptNameMatchesWeight', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 603
},
{
"content": "class CheckFontWeightSameAsInMetadata(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n",
"metadata": "root.CheckFontWeightSameAsInMetadata",
"header": "['module', '___EOS___']",
"index": 624
},
{
"content": " def test_font_weight_same_as_in_metadata(self):\n \"\"\" Font weight matches metadata.pb value of key \"weight\" \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n if font.OS2_usWeightClass != font_metadata.weight:\n msg = 'METADATA.pb has weight %s but in TTF it is %s'\n self.fail(msg % (font_metadata.weight, font.OS2_usWeightClass))",
"metadata": "root.CheckFontWeightSameAsInMetadata.test_font_weight_same_as_in_metadata",
"header": "['class', 'CheckFontWeightSameAsInMetadata', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 630
},
{
"content": "class CheckFullNameEqualCanonicalName(TestCase):\n\n targets = ['metadata']\n name = __name__\n tool = 'lint'\n",
"metadata": "root.CheckFullNameEqualCanonicalName",
"header": "['module', '___EOS___']",
"index": 642
},
{
"content": " def test_metadata_contains_current_font(self):\n \"\"\" METADATA.pb lists fonts named canonicaly? \"\"\"\n\n fm = get_FamilyProto_Message(self.operator.path)\n\n is_canonical = False\n for font_metadata in fm.fonts:\n font = Font.get_ttfont_from_metadata(self.operator.path, font_metadata)\n\n _weights = []\n for value, intvalue in weights.items():\n if intvalue == font.OS2_usWeightClass:\n _weights.append(value)\n\n for w in _weights:\n current_font = \"%s %s\" % (font.familyname, w)\n if font_metadata.full_name != current_font:\n is_canonical = True\n\n if not is_canonical:\n v = map(lambda x: font.familyname + ' ' + x, _weights)\n msg = 'Canonical name in font expected: [%s] but %s'\n self.fail(msg % (v, font_metadata.full_name))",
"metadata": "root.CheckFullNameEqualCanonicalName.test_metadata_contains_current_font",
"header": "['class', 'CheckFullNameEqualCanonicalName', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 648
},
{
"content": "class CheckCanonicalStyles(TestCase):\n\n name = __name__\n targets = ['metadata']\n tool = 'lint'\n\n CANONICAL_STYLE_VALUES = ['italic', 'normal']\n ITALIC_MASK = 0b10\n\n\n",
"metadata": "root.CheckCanonicalStyles",
"header": "['module', '___EOS___']",
"index": 673
},
{
"content": " def test_check_canonical_styles(self):\n \"\"\" Font styles are named canonically? \"\"\"\n fm = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in fm.fonts:\n self.assertIn(font_metadata.style, self.CANONICAL_STYLE_VALUES)\n if self.is_italic(font_metadata):\n if font_metadata.style != 'italic':\n _ = \"%s: The font style is %s but it should be italic\"\n self.fail(_ % (font_metadata.filename, font_metadata.style))\n else:\n if font_metadata.style != 'normal':\n _ = \"%s: The font style is %s but it should be normal\"\n self.fail(_ % (font_metadata.filename, font_metadata.style))",
"metadata": "root.CheckCanonicalStyles.test_check_canonical_styles",
"header": "['class', 'CheckCanonicalStyles', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 682
},
{
"content": " def is_italic(self, font_metadata):\n ttfont = Font.get_ttfont_from_metadata(self.operator.path,\n font_metadata)\n return (ttfont.macStyle & self.ITALIC_MASK\n or ttfont.italicAngle\n or self.find_italic_in_name_table(ttfont))",
"metadata": "root.CheckCanonicalStyles.is_italic",
"header": "['class', 'CheckCanonicalStyles', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 697
},
{
"content": " def find_italic_in_name_table(self, ttfont):\n for entry in ttfont.names:\n if 'italic' in Font.bin2unistring(entry).lower():\n return True",
"metadata": "root.CheckCanonicalStyles.find_italic_in_name_table",
"header": "['class', 'CheckCanonicalStyles', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 704
},
{
"content": "class CheckCanonicalFilenames(TestCase):\n weights = {\n 100: 'Thin',\n 200: 'ExtraLight',\n 300: 'Light',\n 400: '',\n 500: 'Medium',\n 600: 'SemiBold',\n 700: 'Bold',\n 800: 'ExtraBold',\n 900: 'Black'\n }\n\n style_names = {\n 'normal': '',\n 'italic': 'Italic'\n }\n\n name = __name__\n tool = 'lint'\n targets = ['metadata']\n\n",
"metadata": "root.CheckCanonicalFilenames",
"header": "['module', '___EOS___']",
"index": 710
},
{
"content": " @tags('required')\n def test_check_canonical_filenames(self):\n \"\"\" Filename is set canonically? \"\"\"\n family_metadata = get_FamilyProto_Message(self.operator.path)\n\n for font_metadata in family_metadata.fonts:\n canonical_filename = self.create_canonical_filename(font_metadata)\n if canonical_filename != font_metadata.filename:\n self.fail('{} != {}'.format(canonical_filename,\n font_metadata.filename))",
"metadata": "root.CheckCanonicalFilenames.test_check_canonical_filenames",
"header": "['class', 'CheckCanonicalFilenames', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 732
},
{
"content": " def create_canonical_filename(self, font_metadata):\n familyname = font_metadata.name.replace(' ', '')\n style_weight = '%s%s' % (self.weights.get(font_metadata.weight),\n self.style_names.get(font_metadata.style))\n if not style_weight:\n style_weight = 'Regular'\n return '%s-%s.ttf' % (familyname, style_weight)",
"metadata": "root.CheckCanonicalFilenames.create_canonical_filename",
"header": "['class', 'CheckCanonicalFilenames', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 743
},
{
"content": "def get_suite(path, apply_autofix=False):\n import unittest\n suite = unittest.TestSuite()\n\n testcases = [\n MetadataSubsetsListTest,\n MetadataTest,\n TestFontOnDiskFamilyEqualToMetadataProtoBuf,\n TestPostScriptNameInMetadataEqualFontOnDisk,\n CheckMetadataAgreements,\n CheckMetadataContainsReservedFontName,\n CheckMonospaceAgreement,\n CheckItalicStyleMatchesMacStyle,\n CheckNormalStyleMatchesMacStyle,\n CheckMetadataMatchesNameTable,\n CheckMenuSubsetContainsProperGlyphs,\n CheckGlyphConsistencyInFamily,\n CheckFontNameNotInCamelCase,\n CheckFontsMenuAgreements,\n CheckFamilyNameMatchesFontNames,\n CheckCanonicalWeights,\n CheckPostScriptNameMatchesWeight,\n CheckFontWeightSameAsInMetadata,\n CheckFullNameEqualCanonicalName,\n CheckCanonicalStyles,\n CheckCanonicalFilenames\n ]\n\n for testcase in testcases:\n\n testcase.operator = TestCaseOperator(path)\n testcase.apply_fix = apply_autofix\n\n if getattr(testcase, 'skipUnless', False):\n if testcase.skipUnless():\n continue\n\n if getattr(testcase, '__generateTests__', None):\n testcase.__generateTests__()\n \n for test in unittest.defaultTestLoader.loadTestsFromTestCase(testcase):\n suite.addTest(test)\n\n return suite",
"metadata": "root.get_suite",
"header": "['module', '___EOS___']",
"index": 752
}
]
| [
{
"span": "import requests",
"start_line": 22,
"start_column": 0,
"end_line": 22,
"end_column": 15
},
{
"span": "from bakery_cli.fonts_public_pb2 import FontProto, FamilyProto",
"start_line": 24,
"start_column": 0,
"end_line": 24,
"end_column": 62
},
{
"span": "from bakery_lint.base import BakeryTestCase as TestCase, tags, autofix",
"start_line": 26,
"start_column": 0,
"end_line": 26,
"end_column": 70
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\"\"\"",
" ",
"Contain",
"s",
" ",
"Test",
"Case",
"s",
" ",
"for",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"2013",
" ",
"The",
" ",
"Font",
" ",
"Bak",
"ery",
" ",
"Author",
"s",
".",
" ",
"All",
" ",
"Rig",
"hts",
" ",
"Reserve",
"d",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"License",
"d",
" ",
"under",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"License",
",",
" ",
"Version",
" ",
"2.0",
" ",
"(",
"the",
" ",
"\"",
"License",
"\");",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"you",
" ",
"may",
" ",
"not",
" ",
"use",
" ",
"this",
" ",
"file",
" ",
"except",
" ",
"in",
" ",
"compli",
"anc",
"e",
" ",
"with",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"You",
" ",
"may",
" ",
"obtain",
" ",
"a",
" ",
"copy",
" ",
"of",
" ",
"the",
" ",
"License",
" ",
"at_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"http",
"://",
"www",
".",
"apa",
"che",
".",
"org",
"/",
"license",
"s",
"/",
"LICENSE",
"-",
"2.0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Un",
"less",
" ",
"require",
"d",
" ",
"by",
" ",
"applica",
"ble",
" ",
"law",
" ",
"or",
" ",
"agree",
"d",
" ",
"to",
" ",
"in",
" ",
"writ",
"ing",
",",
" ",
"software",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"distributed",
" ",
"under",
" ",
"the",
" ",
"License",
" ",
"is",
" ",
"distributed",
" ",
"on",
" ",
"an",
" ",
"\"",
"AS",
" ",
"IS",
"\"",
" ",
"BAS",
"IS",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"WITH",
"OUT",
" ",
"WAR",
"RAN",
"TIES",
" ",
"OR",
" ",
"CONDITION",
"S",
" ",
"OF",
" ",
"ANY",
" ",
"KIND",
",",
" ",
"eit",
"her",
" ",
"express",
" ",
"or",
" ",
"impli",
"ed",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"See",
" ",
"the",
" ",
"License",
" ",
"for",
" ",
"the",
" ",
"specific",
" ",
"language",
" ",
"govern",
"ing",
" ",
"permissi",
"ons",
" ",
"and_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"limit",
"ation",
"s",
" ",
"under",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"See",
" ",
"AUTHOR",
"S",
".",
"txt",
" ",
"for",
" ",
"the",
" ",
"list",
" ",
"of",
" ",
"Author",
"s",
" ",
"and",
" ",
"LICENSE",
".",
"txt",
" ",
"for",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"magic_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"._",
"path_",
"as_",
"op_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"requests_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"google_",
"._",
"protobuf_",
"import_",
"text",
"\\u",
"format_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bake",
"ry",
"\\u",
"cli_",
"._",
"font",
"s",
"\\u",
"public",
"\\u",
"pb2_",
"import_",
"Font",
"Proto_",
",_",
"Famil",
"y",
"Proto_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bake",
"ry",
"\\u",
"cli_",
"._",
"tt",
"font_",
"import_",
"Font_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bake",
"ry",
"\\u",
"lint_",
"._",
"base_",
"import_",
"Bak",
"ery",
"Test",
"Case_",
"as_",
"Test",
"Case_",
",_",
"tags_",
",_",
"autof",
"ix_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bake",
"ry",
"\\u",
"lint_",
"._",
"base_",
"import_",
"Test",
"Case",
"Operator_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"weights_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Thin",
"'_",
":_",
"100_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Thin",
"Italic",
"'_",
":_",
"100_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Extra",
"Light",
"'_",
":_",
"200_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Extra",
"Light",
"Italic",
"'_",
":_",
"200_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Light",
"'_",
":_",
"300_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Light",
"Italic",
"'_",
":_",
"300_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Regula",
"r",
"'_",
":_",
"400_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Italic",
"'_",
":_",
"400_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Medi",
"um",
"'_",
":_",
"500_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Medi",
"um",
"Italic",
"'_",
":_",
"500_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Semi",
"Bol",
"d",
"'_",
":_",
"600_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Semi",
"Bol",
"d",
"Italic",
"'_",
":_",
"600_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Bol",
"d",
"'_",
":_",
"700_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Bol",
"d",
"Italic",
"'_",
":_",
"700_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Extra",
"Bol",
"d",
"'_",
":_",
"800_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Extra",
"Bol",
"d",
"Italic",
"'_",
":_",
"800_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Black",
"'_",
":_",
"900_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Black",
"Italic",
"'_",
":_",
"900_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"get",
"\\u",
"test\\u",
"subse",
"t",
"\\u",
"function_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"function_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"op_",
"._",
"exists_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'%",
"s",
" ",
"subse",
"t",
" ",
"doe",
"s",
" ",
"not",
" ",
"exist",
"'_",
"%_",
"op_",
"._",
"basename_",
"(_",
"path_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"magic_",
"._",
"from",
"\\u",
"file_",
"(_",
"path_",
")_",
"!=_",
"'",
"Tru",
"e",
"Type",
" ",
"font",
" ",
"data",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u_",
"=_",
"'%",
"s",
" ",
"doe",
"s",
" ",
"not",
" ",
"see",
"m",
" ",
"to",
" ",
"be",
" ",
"true",
"type",
" ",
"font",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"\\u_",
"%_",
"op_",
"._",
"basename_",
"(_",
"path_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"function_",
"._",
"tags_",
"=_",
"[_",
"'",
"require",
"d",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"function_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"metadata_",
"=_",
"Famil",
"y",
"Proto_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"text",
"\\u",
"data_",
"=_",
"open_",
"(_",
"path_",
",_",
"\"",
"rb",
"\"_",
")_",
"._",
"read_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"text",
"\\u",
"format_",
"._",
"Merge_",
"(_",
"text",
"\\u",
"data_",
",_",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"metadata_",
"\\u\\u\\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_",
"Meta",
"data",
"Subset",
"s",
"List",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"METAD",
"ATA",
".",
"pb",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Meta",
"data",
"Subset",
"s",
"List",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"classmethod_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"generat",
"e",
"Test",
"s\\u\\u_",
"(_",
"cls_",
")_",
":_",
"\\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 ",
" _",
"metadata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"cls_",
"._",
"operator_",
"._",
"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 ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"font_",
"in_",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"for",
" ",
"subse",
"t",
" ",
"in",
" ",
"metadata",
".",
"subsets",
".",
"extend",
"([",
"'",
"menu",
"'])",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"subset_",
"in_",
"metadata_",
"._",
"subsets",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"path_",
"=_",
"op_",
"._",
"join_",
"(_",
"op_",
"._",
"dirname_",
"(_",
"cls_",
"._",
"operator_",
"._",
"path_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font_",
"._",
"filename_",
"[_",
":_",
"-_",
"3_",
"]_",
"+_",
"subset_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"subse",
"tid_",
"=_",
"re_",
"._",
"sub_",
"(_",
"r",
"'\\\\",
"W",
"'_",
",_",
"'\\u'_",
",_",
"subset_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"cls",
".",
"opera",
"tor",
".",
"debug",
"('",
"cls",
".",
"test\\u",
"charset",
"\\u{",
"0",
"}",
" ",
"=",
" ",
"get",
"\\u",
"test\\u",
"subse",
"t",
"\\u",
"function",
"(\"",
"{",
"1",
"}\"",
")'",
".",
"format",
"(",
"subse",
"tid",
",",
" ",
"path",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"cls",
".",
"opera",
"tor",
".",
"debug",
"('",
"cls",
".",
"test\\u",
"charset",
"\\u{",
"0",
"}.",
"\\u\\u",
"func",
"\\u\\u",
".\\u",
"\\u",
"doc",
"\\u\\u",
" ",
"=",
" ",
"\"{",
"1",
"}",
" ",
"is",
" ",
"real",
" ",
"Tru",
"e",
"Type",
" ",
"file",
"\"'",
".",
"format",
"(",
"subse",
"tid",
",",
" ",
"font",
".",
"get",
"('",
"filename",
"')",
"[:",
"-",
"3",
"]",
" ",
"+",
" ",
"subse",
"t",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"exec_",
"'",
"cls",
".",
"test\\u",
"charset",
"\\u{",
"0",
"}",
" ",
"=",
" ",
"get",
"\\u",
"test\\u",
"subse",
"t",
"\\u",
"function",
"(\"",
"{",
"1",
"}\"",
")'_",
"._",
"format_",
"(_",
"subse",
"tid_",
",_",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"exec_",
"'",
"cls",
".",
"test\\u",
"charset",
"\\u{",
"0",
"}.",
"\\u\\u",
"func",
"\\u\\u",
".\\u",
"\\u",
"doc",
"\\u\\u",
" ",
"=",
" ",
"\"{",
"1",
"}",
" ",
"is",
" ",
"real",
" ",
"Tru",
"e",
"Type",
" ",
"file",
"\"'_",
"._",
"format_",
"(_",
"subse",
"tid_",
",_",
"font_",
"._",
"filename_",
"[_",
":_",
"-_",
"3_",
"]_",
"+_",
"subset_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"Font",
"On",
"Disk",
"Famil",
"y",
"Equal",
"To",
"Meta",
"data",
"Proto",
"Buf_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Font",
"On",
"Disk",
"Famil",
"y",
"Equal",
"To",
"Meta",
"data",
"Proto",
"Buf_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
",_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"font",
"\\u",
"on",
"\\u",
"disk",
"\\u",
"famil",
"y",
"\\u",
"equal",
"\\u",
"in",
"\\u",
"metadata",
"\\u",
"protobuf_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Font",
" ",
"on",
" ",
"disk",
" ",
"and",
" ",
"in",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"have",
" ",
"the",
" ",
"same",
" ",
"famil",
"y",
" ",
"name",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"metadata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"unmatched",
"\\u",
"fonts_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"metadata_",
"._",
"fonts_",
":_",
"\\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 ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
")_",
"\\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 ",
" _",
"continue_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"font_",
"._",
"famil",
"yname",
"_",
"!=_",
"font",
"\\u",
"metadata_",
"._",
"name_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"unmatched",
"\\u",
"fonts_",
"._",
"append_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"unmatched",
"\\u",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'",
"Unma",
"tche",
"d",
" ",
"famil",
"y",
" ",
"name",
" ",
"are",
" ",
"in",
" ",
"font",
"s",
":",
" ",
"{}'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"._",
"format_",
"(_",
"',",
" ",
"'_",
"._",
"join_",
"(_",
"unmatched",
"\\u",
"fonts_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"Post",
"Script",
"Name",
"In",
"Meta",
"data",
"Equal",
"Font",
"On",
"Disk_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Post",
"Script",
"Name",
"In",
"Meta",
"data",
"Equal",
"Font",
"On",
"Disk_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"posts",
"cript",
"name",
"\\u",
"in",
"\\u",
"metadata",
"\\u",
"equal",
"\\u",
"to",
"\\u",
"font",
"\\u",
"on",
"\\u",
"disk_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
"s",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"'",
"post",
"Script",
"Name",
"'",
" ",
"matche",
"s",
" ",
"TT",
"F",
" ",
"'",
"post",
"Script",
"Name",
"'",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"metadata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"metadata_",
"._",
"fonts_",
":_",
"\\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 ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\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 ",
" _",
"continue_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"font_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
"!=_",
"font",
"\\u",
"metadata_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'",
"In",
" ",
"METAD",
"ATA",
" ",
"post",
"Script",
"Name",
"=\"",
"{",
"0",
"}\"",
",",
" ",
"but",
" ",
"in",
" ",
"TT",
"F",
" ",
"\"{",
"1",
"}\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"._",
"format_",
"(_",
"font_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
"._",
"post",
"\\u",
"script",
"\\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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"metadata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"famil",
"y",
"\\u",
"values",
"\\u",
"are",
"\\u",
"all",
"\\u",
"the",
"\\u",
"same_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
" ",
"tha",
"t",
" ",
"METAD",
"ATA",
" ",
"famil",
"y",
" ",
"values",
" ",
"are",
" ",
"all",
" ",
"the",
" ",
"same",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"name_",
"and_",
"font",
"\\u",
"metadata_",
"._",
"name_",
"!=_",
"name_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'",
"Famil",
"y",
" ",
"name",
" ",
"in",
" ",
"metadata",
" ",
"font",
"s",
" ",
"items",
" ",
"not",
" ",
"the",
" ",
"same",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"name_",
"=_",
"font",
"\\u",
"metadata_",
"._",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"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",
"metadata",
"\\u",
"font",
"\\u",
"have",
"\\u",
"regular",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Acco",
"rdin",
"g",
" ",
"GW",
"F",
" ",
"stand",
"arts",
" ",
"font",
" ",
"shou",
"ld",
" ",
"have",
" ",
"Regula",
"r",
" ",
"style",
".",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"this",
" ",
"tests",
" ",
"will",
" ",
"appear",
" ",
"in",
" ",
"each",
" ",
"font_",
"\\u\\u\\uNL\\u\\u\\u_",
"have_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"i_",
"._",
"weight_",
"==_",
"400_",
"and_",
"i_",
"._",
"style_",
"==_",
"'",
"normal",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"have_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"have_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"regular",
"\\u",
"is",
"\\u",
"400_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Regula",
"r",
" ",
"shou",
"ld",
" ",
"be",
" ",
"400",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"have_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"i_",
"._",
"filename_",
"._",
"endswith_",
"(_",
"'",
"Regula",
"r",
".",
"tt",
"f",
"'_",
")_",
"and_",
"i_",
"._",
"weight_",
"==_",
"400_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"have_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"have_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"METAD",
"ATA",
".",
"pb",
" ",
"doe",
"s",
" ",
"not",
" ",
"contain",
" ",
"Regula",
"r",
" ",
"font",
".",
" ",
"At",
" ",
"leas",
"t",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"one",
" ",
"font",
" ",
"must",
" ",
"be",
" ",
"Regula",
"r",
" ",
"and",
" ",
"its",
" ",
"weight",
" ",
"must",
" ",
"be",
" ",
"400",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"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",
"metadata",
"\\u",
"regular",
"\\u",
"is",
"\\u",
"normal_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Us",
"ual",
"ly",
" ",
"Regula",
"r",
" ",
"shou",
"ld",
" ",
"be",
" ",
"normal",
" ",
"style",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"have_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"x_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"x_",
"._",
"full",
"\\u",
"name_",
"._",
"endswith_",
"(_",
"'",
"Regula",
"r",
"'_",
")_",
"and_",
"x_",
"._",
"style_",
"==_",
"'",
"normal",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"have_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"have_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"filename",
"\\u",
"matche",
"s",
"\\u",
"posts",
"cript",
"name_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"`",
"filename",
"`",
" ",
"matche",
"s",
" ",
"`",
"post",
"Script",
"Name",
"`",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"regex_",
"=_",
"re_",
"._",
"compile_",
"(_",
"r",
"'\\\\",
"W",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"fonts_",
"=_",
"[_",
"font_",
"for_",
"font_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"font_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
"._",
"endswith_",
"(_",
"'-",
"Regula",
"r",
"'_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"x_",
"in_",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"post",
"\\u",
"script",
"\\u",
"name_",
"=_",
"regex_",
"._",
"sub_",
"(_",
"''_",
",_",
"x_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"filename_",
"=_",
"regex_",
"._",
"sub_",
"(_",
"''_",
",_",
"os_",
"._",
"path_",
"._",
"splitext_",
"(_",
"x_",
"._",
"filename_",
")_",
"[_",
"0_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"filename_",
"!=_",
"post",
"\\u",
"script",
"\\u",
"name_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'\"{",
"0",
"}\"",
" ",
"doe",
"s",
" ",
"not",
" ",
"match",
" ",
"\"{",
"1",
"}\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"._",
"format_",
"(_",
"x_",
"._",
"filename_",
",_",
"x_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"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_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"full",
"name",
"\\u",
"matche",
"s",
"\\u",
"post",
"Script",
"Name_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"`",
"full",
"Name",
"`",
" ",
"matche",
"s",
" ",
"`",
"post",
"Script",
"Name",
"`",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"regex_",
"=_",
"re_",
"._",
"compile_",
"(_",
"r",
"'\\\\",
"W",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"x_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"post",
"\\u",
"script",
"\\u",
"name_",
"=_",
"regex_",
"._",
"sub_",
"(_",
"''_",
",_",
"x_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fullname_",
"=_",
"regex_",
"._",
"sub_",
"(_",
"''_",
",_",
"x_",
"._",
"full",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"fullname_",
"!=_",
"post",
"\\u",
"script",
"\\u",
"name_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'\"{",
"0",
"}\"",
" ",
"doe",
"s",
" ",
"not",
" ",
"match",
" ",
"\"{",
"1",
"}\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"._",
"format_",
"(_",
"x_",
"._",
"full",
"\\u",
"name_",
",_",
"x_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"full",
"name",
"\\u",
"is",
"\\u",
"equal",
"\\u",
"to",
"\\u",
"internal",
"\\u",
"font",
"\\u",
"fullname_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"'",
"full",
"name",
"'",
" ",
"value",
" ",
"matche",
"s",
" ",
"internal",
" ",
"'",
"full",
"name",
"'",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"font_",
"._",
"fullname_",
",_",
"font",
"\\u",
"metadata_",
"._",
"full",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"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",
"font",
"\\u",
"name",
"\\u",
"matche",
"s",
"\\u",
"family_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"font",
"s",
" ",
"'",
"name",
"'",
" ",
"property",
" ",
"shou",
"ld",
" ",
"be",
" ",
"same",
" ",
"as",
" ",
"font",
" ",
"famil",
"yname",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"font",
"\\u",
"metadata_",
"._",
"name_",
"!=_",
"font_",
"._",
"famil",
"yname",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'\"",
"font",
"s",
".",
"name",
"\"",
" ",
"property",
" ",
"is",
" ",
"not",
" ",
"the",
" ",
"same",
" ",
"as",
" ",
"TT",
"F",
" ",
"famil",
"yname",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"font",
"s",
"\\u",
"fields",
"\\u",
"have",
"\\u",
"font",
"name_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"font",
" ",
"item",
" ",
"fields",
" ",
"\"",
"name",
"\",",
" ",
"\"",
"post",
"Script",
"Name",
"\",",
" ",
"\"",
"full",
"Name",
"\",",
" ",
"\"",
"filename",
"\"",
" ",
"contain",
"s",
" ",
"font",
" ",
"name",
" ",
"right",
" ",
"format",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"x_",
"in_",
"self_",
"._",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"font_",
"._",
"famil",
"yname",
"_",
",_",
"x_",
"._",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"font_",
"._",
"famil",
"yname",
"_",
",_",
"x_",
"._",
"full",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"str_",
"(_",
"font_",
"._",
"famil",
"yname",
"_",
")_",
"._",
"split_",
"(_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"x_",
"._",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"str_",
"(_",
"font_",
"._",
"famil",
"yname",
"_",
")_",
"._",
"split_",
"(_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"x_",
"._",
"post",
"\\u",
"script",
"\\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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Meta",
"data",
"Contain",
"s",
"Reserve",
"d",
"Font",
"Name_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Contain",
"s",
"Reserve",
"d",
"Font",
"Name_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"info",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"copyr",
"ight",
"\\u",
"contain",
"s",
"\\u",
"correct",
"\\u",
"rf",
"n_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Copy",
"right",
" ",
"notice",
" ",
"doe",
"s",
" ",
"not",
" ",
"contain",
" ",
"Reserve",
"d",
" ",
"Font",
" ",
"Name",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"'",
"Reserve",
"d",
" ",
"Font",
" ",
"Name",
"'_",
"in_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'\"",
"%",
"s",
"\"",
" ",
"contain",
"s",
" ",
"\"",
"Reserve",
"d",
" ",
"Font",
" ",
"Name",
"\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"%_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Contain",
"s",
"Reserve",
"d",
"Font",
"Name_",
"(_",
"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_",
"@_",
"tags_",
"(_",
"'",
"info",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"copyr",
"ight",
"\\u",
"matche",
"s",
"\\u",
"pattern_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Copy",
"right",
" ",
"notice",
" ",
"matche",
"s",
" ",
"canonical",
" ",
"pattern",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"alm",
"ost",
"\\u",
"matches_",
"=_",
"re_",
"._",
"search_",
"(_",
"r",
"'(",
"Copy",
"right",
"\\\\",
"s",
"+\\\\",
"(",
"c",
"\\\\)",
"\\\\",
"s",
"+",
"20",
"\\\\",
"d",
"{",
"2",
"}.",
"*)'_",
",_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"doe",
"s",
"\\u",
"match_",
"=_",
"re_",
"._",
"search_",
"(_",
"r",
"'(",
"Copy",
"right",
"\\\\",
"s",
"+\\\\",
"(",
"c",
"\\\\)",
"\\\\",
"s",
"+",
"20",
"\\\\",
"d",
"{",
"2",
"}.",
"*\\\\",
"(.",
"*",
"@",
".*",
".*\\\\",
"))'_",
",_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"(_",
"doe",
"s",
"\\u",
"match_",
"==_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"(_",
"alm",
"ost",
"\\u",
"matches_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"fail_",
"(_",
"\"",
"Copy",
"right",
" ",
"notice",
" ",
"is",
" ",
"oka",
"y",
",",
" ",
"but",
" ",
"it",
" ",
"lack",
"s",
" ",
"an",
" ",
"email",
" ",
"address",
".",
" ",
"Expect",
"ed",
" ",
"pattern",
" ",
"is",
":",
" ",
"'",
"Copy",
"right",
" ",
"2016",
" ",
"Author",
" ",
"Name",
" ",
"(",
"name",
"@",
"site",
".",
"com",
")'",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"fail_",
"(_",
"\"",
"Copy",
"right",
" ",
"notice",
"s",
" ",
"shou",
"ld",
" ",
"match",
" ",
"the",
" ",
"fol",
"owi",
"ng",
" ",
"pattern",
":",
" ",
"'",
"Copy",
"right",
" ",
"2016",
" ",
"Author",
" ",
"Name",
" ",
"(",
"name",
"@",
"site",
".",
"com",
")'",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Contain",
"s",
"Reserve",
"d",
"Font",
"Name_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"info",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"copyr",
"ight",
"\\u",
"is",
"\\u",
"consistent",
"\\u",
"acro",
"ss",
"\\u",
"family_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Copy",
"right",
" ",
"notice",
" ",
"is",
" ",
"the",
" ",
"same",
" ",
"in",
" ",
"all",
" ",
"font",
"s",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"copyright_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"copyright_",
"and_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
"!=_",
"copyright_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'",
"Copy",
"right",
" ",
"is",
" ",
"inconsistent",
" ",
"acro",
"ss",
" ",
"famil",
"y",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"copyright_",
"=_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Contain",
"s",
"Reserve",
"d",
"Font",
"Name_",
"(_",
"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_",
"@_",
"tags_",
"(_",
"'",
"info",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"copyr",
"ight",
"\\u",
"size_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Copy",
"right",
" ",
"notice",
" ",
"shou",
"ld",
" ",
"be",
" ",
"less",
" ",
"than",
" ",
"500",
" ",
"char",
"s",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Less",
"Equal_",
"(_",
"len_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"copyright_",
")_",
",_",
"500_",
")_",
"\\u\\u\\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_",
"File_",
"(_",
"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_",
"[SEP]_",
"class_",
"File_",
"(_",
"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_",
",_",
"rootdir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"rootdir_",
"=_",
"rootdir_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"File_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"exists_",
"(_",
"self_",
",_",
"filename_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"op_",
"._",
"exists_",
"(_",
"op_",
"._",
"join_",
"(_",
"self_",
"._",
"rootdir_",
",_",
"filename_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"File_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"size_",
"(_",
"self_",
",_",
"filename_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"op_",
"._",
"getsize_",
"(_",
"op_",
"._",
"join_",
"(_",
"self_",
"._",
"rootdir_",
",_",
"filename_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"File_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"mime_",
"(_",
"self_",
",_",
"filename_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"magic_",
"._",
"from",
"\\u",
"file_",
"(_",
"op_",
"._",
"join_",
"(_",
"self_",
"._",
"rootdir_",
",_",
"filename_",
")_",
",_",
"mime_",
"=_",
"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_",
"Check",
"Mono",
"space",
"Agreement",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Mono",
"space",
"Agreement",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"monospace",
"\\u",
"agreement",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Mono",
"space",
" ",
"font",
" ",
"has",
" ",
"hh",
"ea",
".",
"advance",
"Wid",
"th",
"Max",
" ",
"equal",
" ",
"to",
" ",
"each",
" ",
"glyph",
"'",
"s",
" ",
"advance",
"Wid",
"th",
" ",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"fm_",
"._",
"category_",
"!=_",
"'",
"Mono",
"space",
"'_",
":_",
"\\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_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"prev_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"g_",
"in_",
"font_",
"._",
"glyphs_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"prev_",
"and_",
"font_",
"._",
"advance",
"\\u",
"width_",
"(_",
"g_",
")_",
"!=_",
"prev_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"Gl",
"yp",
"h",
" ",
"advance",
"Wid",
"th",
" ",
"must",
" ",
"be",
" ",
"same",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"acro",
"ss",
" ",
"all",
" ",
"glyph",
"s",
" ",
"%",
"s",
"'_",
"%_",
"prev_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"prev_",
"=_",
"font_",
"._",
"advance",
"\\u",
"width_",
"(_",
"g_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"prev_",
"!=_",
"font_",
"._",
"advance",
"\\u",
"width_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"(_",
"'\"",
"hh",
"ea",
"\"",
" ",
"table",
" ",
"advance",
"Wid",
"th",
"Max",
" ",
"property",
" ",
"differs",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"to",
" ",
"glyph",
"s",
" ",
"advance",
"Wid",
"th",
" ",
"[",
"%",
"s",
",",
" ",
"%",
"s",
"]'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"%_",
"(_",
"prev_",
",_",
"font_",
"._",
"advance",
"\\u",
"width_",
"(_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Italic",
"Style",
"Match",
"es",
"Mac",
"Style_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Italic",
"Style",
"Match",
"es",
"Mac",
"Style_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"italic",
"\\u",
"style",
"\\u",
"matche",
"s",
"\\u",
"names_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"font",
".",
"style",
" ",
"`",
"italic",
"`",
" ",
"matche",
"s",
" ",
"font",
" ",
"internals",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"family_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"family_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"font",
"\\u",
"metadata_",
"._",
"style_",
"!=_",
"'",
"italic",
"'_",
":_",
"\\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_",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"bool_",
"(_",
"font_",
"._",
"mac",
"Style_",
"&_",
"0b1",
"0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"Meta",
"data",
" ",
"style",
" ",
"has",
" ",
"bee",
"n",
" ",
"set",
" ",
"to",
" ",
"italic",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"but",
" ",
"font",
" ",
"second",
" ",
"bit",
" ",
"in",
" ",
"mac",
"Style",
" ",
"has",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"not",
" ",
"bee",
"n",
" ",
"set",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"style_",
"=_",
"font_",
"._",
"famil",
"yname",
"_",
"._",
"split_",
"(_",
"'-'_",
")_",
"[_",
"-_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"style_",
"._",
"endswith_",
"(_",
"'",
"Italic",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"mac",
"Style",
" ",
"second",
" ",
"bit",
" ",
"is",
" ",
"set",
" ",
"but",
" ",
"post",
"Script",
"Name",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"is",
" ",
"not",
" ",
"ende",
"d",
" ",
"with",
" ",
"\"",
"Italic",
"\"'_",
")_",
"%_",
"font_",
"._",
"famil",
"yname",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"style_",
"=_",
"font_",
"._",
"fullname_",
"._",
"split_",
"(_",
"'-'_",
")_",
"[_",
"-_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"style_",
"._",
"endswith_",
"(_",
"'",
"Italic",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"mac",
"Style",
" ",
"second",
" ",
"bit",
" ",
"is",
" ",
"set",
" ",
"but",
" ",
"full",
"Name",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"is",
" ",
"not",
" ",
"ende",
"d",
" ",
"with",
" ",
"\"",
"Italic",
"\"'_",
")_",
"%_",
"font_",
"._",
"fullname_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Normal",
"Style",
"Match",
"es",
"Mac",
"Style_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Normal",
"Style",
"Match",
"es",
"Mac",
"Style_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"normal",
"\\u",
"style",
"\\u",
"matche",
"s",
"\\u",
"names_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"font",
".",
"style",
" ",
"`",
"italic",
"`",
" ",
"matche",
"s",
" ",
"font",
" ",
"internal",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"family_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"family_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"font",
"\\u",
"metadata_",
"._",
"style_",
"!=_",
"'",
"normal",
"'_",
":_",
"\\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_",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"bool_",
"(_",
"font_",
"._",
"mac",
"Style_",
"&_",
"0b1",
"0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"Meta",
"data",
" ",
"style",
" ",
"has",
" ",
"bee",
"n",
" ",
"set",
" ",
"to",
" ",
"normal",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"but",
" ",
"font",
" ",
"second",
" ",
"bit",
" ",
"(",
"italic",
")",
" ",
"in",
" ",
"mac",
"Style",
" ",
"has",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"bee",
"n",
" ",
"set",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"style_",
"=_",
"font_",
"._",
"famil",
"yname",
"_",
"._",
"split_",
"(_",
"'-'_",
")_",
"[_",
"-_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"style_",
"._",
"endswith_",
"(_",
"'",
"Italic",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"mac",
"Style",
" ",
"second",
" ",
"bit",
" ",
"is",
" ",
"not",
" ",
"set",
" ",
"but",
" ",
"post",
"Script",
"Name",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"is",
" ",
"ende",
"d",
" ",
"with",
" ",
"\"",
"Italic",
"\"'_",
")_",
"%_",
"font_",
"._",
"famil",
"yname",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"style_",
"=_",
"font_",
"._",
"fullname_",
"._",
"split_",
"(_",
"'-'_",
")_",
"[_",
"-_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"style_",
"._",
"endswith_",
"(_",
"'",
"Italic",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'",
"mac",
"Style",
" ",
"second",
" ",
"bit",
" ",
"is",
" ",
"not",
" ",
"set",
" ",
"but",
" ",
"full",
"Name",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"is",
" ",
"ende",
"d",
" ",
"with",
" ",
"\"",
"Italic",
"\"'_",
")_",
"%_",
"font_",
"._",
"fullname_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Meta",
"data",
"Match",
"es",
"Name",
"Table_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Meta",
"data",
"Match",
"es",
"Name",
"Table_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"metadata",
"\\u",
"matche",
"s",
"\\u",
"name",
"table_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Meta",
"data",
" ",
"key",
"-",
"value",
" ",
"match",
" ",
"to",
" ",
"table",
" ",
"name",
" ",
"fields",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"tt",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"report_",
"=_",
"'%",
"s",
":",
" ",
"Famil",
"y",
" ",
"name",
" ",
"was",
" ",
"supposed",
" ",
"to",
" ",
"be",
" ",
"\"%",
"s",
"\"",
" ",
"but",
" ",
"is",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"report_",
"=_",
"report_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"name_",
",_",
"fm_",
"._",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"tt",
"font_",
"._",
"famil",
"yname",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"tt",
"font_",
"._",
"famil",
"yname",
"_",
",_",
"fm_",
"._",
"name_",
",_",
"report_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"tt",
"font_",
"._",
"fullname_",
",_",
"font",
"\\u",
"metadata_",
"._",
"full",
"\\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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Menu",
"Subset",
"Contain",
"s",
"Proper",
"Glyphs",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Menu",
"Subset",
"Contain",
"s",
"Proper",
"Glyphs",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"menu",
"\\u",
"contain",
"s",
"\\u",
"proper",
"\\u",
"glyphs_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
" ",
"menu",
" ",
"file",
" ",
"contain",
"s",
" ",
"proper",
" ",
"glyph",
"s",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"tf_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
",_",
"is",
"\\u",
"menu_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"check",
"\\u",
"retrieve",
"\\u",
"glyphs_",
"(_",
"tf_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Menu",
"Subset",
"Contain",
"s",
"Proper",
"Glyphs",
"_",
"(_",
"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_",
"check",
"\\u",
"retrieve",
"\\u",
"glyphs_",
"(_",
"self_",
",_",
"tt",
"font_",
",_",
"font",
"\\u",
"metadata_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cmap_",
"=_",
"tt",
"font_",
"._",
"retrieve",
"\\u",
"cmap",
"\\u",
"format\\u",
"4_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"glyphs_",
"=_",
"cmap_",
"._",
"cmap_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"missi",
"ng",
"\\u",
"glyphs_",
"=_",
"set_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"ord_",
"(_",
"'",
" ",
"'_",
")_",
"not_",
"in_",
"glyphs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"missi",
"ng",
"\\u",
"glyphs_",
"._",
"add_",
"(_",
"'",
" ",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"g_",
"in_",
"font",
"\\u",
"metadata_",
"._",
"name_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"ord_",
"(_",
"g_",
")_",
"not_",
"in_",
"glyphs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"missi",
"ng",
"\\u",
"glyphs_",
"._",
"add_",
"(_",
"g_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"missi",
"ng",
"\\u",
"glyphs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u_",
"=_",
"'%",
"s",
":",
" ",
"Menu",
" ",
"is",
" ",
"missi",
"ng",
" ",
"glyph",
"s",
":",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"report_",
"=_",
"\\u_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
",_",
"''_",
"._",
"join_",
"(_",
"missi",
"ng",
"\\u",
"glyphs_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"report_",
")_",
"\\u\\u\\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_",
"Check",
"Gl",
"yp",
"h",
"Cons",
"iste",
"nc",
"y",
"In",
"Family_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Gl",
"yp",
"h",
"Cons",
"iste",
"nc",
"y",
"In",
"Family_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"famil",
"yme",
"tad",
"ata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Gl",
"yp",
"h",
"Cons",
"iste",
"nc",
"y",
"In",
"Family_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"the",
"\\u",
"same",
"\\u",
"number",
"\\u",
"of",
"\\u",
"glyph",
"s",
"\\u",
"acro",
"ss",
"\\u",
"family_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"The",
" ",
"same",
" ",
"number",
" ",
"of",
" ",
"glyph",
"s",
" ",
"acro",
"ss",
" ",
"famil",
"y",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"glyph",
"s",
"\\u",
"count_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"self_",
"._",
"famil",
"yme",
"tad",
"ata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"tt",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"glyph",
"s",
"\\u",
"count_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"glyph",
"s",
"\\u",
"count_",
"=_",
"len_",
"(_",
"tt",
"font_",
"._",
"glyphs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"glyph",
"s",
"\\u",
"count_",
"!=_",
"len_",
"(_",
"tt",
"font_",
"._",
"glyphs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'",
"Famil",
"y",
" ",
"has",
" ",
"a",
" ",
"different",
" ",
"glyph",
"s",
"\\\\'",
"s",
" ",
"count",
" ",
"in",
" ",
"font",
"s",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Gl",
"yp",
"h",
"Cons",
"iste",
"nc",
"y",
"In",
"Family_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"the",
"\\u",
"same",
"\\u",
"names",
"\\u",
"of",
"\\u",
"glyph",
"s",
"\\u",
"acro",
"ss",
"\\u",
"family_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"The",
" ",
"same",
" ",
"names",
" ",
"of",
" ",
"glyph",
"s",
" ",
"acro",
"ss",
" ",
"famil",
"y",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"glyphs_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"self_",
"._",
"famil",
"yme",
"tad",
"ata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"tt",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"glyphs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"glyphs_",
"=_",
"len_",
"(_",
"tt",
"font_",
"._",
"glyphs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"glyphs_",
"!=_",
"len_",
"(_",
"tt",
"font_",
"._",
"glyphs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'",
"Famil",
"y",
" ",
"has",
" ",
"a",
" ",
"different",
" ",
"glyph",
"s",
"\\\\'",
"s",
" ",
"names",
" ",
"in",
" ",
"font",
"s",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Gl",
"yp",
"h",
"Cons",
"iste",
"nc",
"y",
"In",
"Family_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"the",
"\\u",
"same",
"\\u",
"encoding",
"s",
"\\u",
"of",
"\\u",
"glyph",
"s",
"\\u",
"acro",
"ss",
"\\u",
"family_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"The",
" ",
"same",
" ",
"unicode",
" ",
"encoding",
"s",
" ",
"of",
" ",
"glyph",
"s",
" ",
"acro",
"ss",
" ",
"famil",
"y",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"encoding_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"self_",
"._",
"famil",
"yme",
"tad",
"ata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"tt",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cmap_",
"=_",
"tt",
"font_",
"._",
"retrieve",
"\\u",
"cmap",
"\\u",
"format\\u",
"4_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"encoding_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"encoding_",
"=_",
"cmap_",
"._",
"plat",
"Enc",
"ID_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"encoding_",
"!=_",
"cmap_",
"._",
"plat",
"Enc",
"ID_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'",
"Famil",
"y",
" ",
"has",
" ",
"different",
" ",
"encoding",
" ",
"acro",
"ss",
" ",
"font",
"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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Font",
"Name",
"Not",
"In",
"Came",
"l",
"Case_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Font",
"Name",
"Not",
"In",
"Came",
"l",
"Case_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"font",
"name",
"\\u",
"not",
"\\u",
"in",
"\\u",
"camel",
"\\u",
"case_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
" ",
"if",
" ",
"font",
"name",
" ",
"is",
" ",
"not",
" ",
"camel",
" ",
"case",
"d",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"famil",
"yme",
"tad",
"ata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"camel",
"case",
"d\\u",
"font",
"names_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"famil",
"yme",
"tad",
"ata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"bool_",
"(_",
"re_",
"._",
"match_",
"(_",
"r",
"'(",
"[",
"A",
"-",
"Z",
"][",
"a",
"-",
"z",
"]+)",
"{",
"2",
",}",
"'_",
",_",
"font",
"\\u",
"metadata_",
"._",
"name_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"camel",
"case",
"d\\u",
"font",
"names_",
"._",
"append_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"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_",
"if_",
"camel",
"case",
"d\\u",
"font",
"names_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"(_",
"'%",
"s",
" ",
"are",
" ",
"camel",
" ",
"case",
"d",
" ",
"names",
".",
" ",
"To",
" ",
"solve",
" ",
"this",
" ",
"check",
" ",
"just",
" ",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"use",
" ",
"space",
"s",
" ",
"in",
" ",
"names",
".'_",
")_",
")_",
"\\u\\u\\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_",
"Check",
"Font",
"s",
"Menu",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Font",
"s",
"Menu",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"menu",
"file_",
"(_",
"self_",
",_",
"font",
"\\u",
"metadata_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'%",
"s",
".",
"menu",
"'_",
"%_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
"[_",
":_",
"-_",
"4_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Font",
"s",
"Menu",
"Agreement",
"s_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"menu",
"\\u",
"file",
"\\u",
"agreement",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
" ",
"font",
"s",
" ",
"have",
" ",
"correspond",
"ing",
" ",
"menu",
" ",
"files",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"menu",
"file_",
"=_",
"self_",
"._",
"menu",
"file_",
"(_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"op_",
"._",
"join_",
"(_",
"op_",
"._",
"dirname_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
",_",
"menu",
"file_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"op_",
"._",
"exists_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'%",
"s",
" ",
"doe",
"s",
" ",
"not",
" ",
"exist",
"'_",
"%_",
"menu",
"file_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"magic_",
"._",
"from",
"\\u",
"file_",
"(_",
"path_",
")_",
"!=_",
"'",
"Tru",
"e",
"Type",
" ",
"font",
" ",
"data",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'%",
"s",
" ",
"is",
" ",
"not",
" ",
"actual",
" ",
"TT",
"F",
" ",
"file",
"'_",
"%_",
"menu",
"file_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Famil",
"y",
"Name",
"Match",
"es",
"Font",
"Names_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Famil",
"y",
"Name",
"Match",
"es",
"Font",
"Names_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"famil",
"yname",
"\\u",
"matche",
"s",
"\\u",
"font",
"names_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Check",
" ",
"font",
" ",
"name",
" ",
"is",
" ",
"the",
" ",
"same",
" ",
"as",
" ",
"famil",
"y",
" ",
"name",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u_",
"=_",
"'%",
"s",
":",
" ",
"Famil",
"y",
" ",
"name",
" ",
"\"%",
"s",
"\"",
" ",
"doe",
"s",
" ",
"not",
" ",
"match",
" ",
"font",
" ",
"name",
":",
" ",
"\"%",
"s",
"\"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u_",
"=_",
"\\u_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
",_",
"fm_",
"._",
"name_",
",_",
"font",
"\\u",
"metadata_",
"._",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"name_",
",_",
"fm_",
"._",
"name_",
",_",
"\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Check",
"Canonical",
"Weights_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Canonical",
"Weights_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"canonical",
"\\u",
"weights_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Weig",
"hts",
" ",
"have",
" ",
"canonical",
" ",
"value",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"weight_",
"=_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"first",
"\\u",
"digit_",
"=_",
"weight_",
"/_",
"100_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"is",
"\\u",
"invalid_",
"=_",
"(_",
"weight_",
"%_",
"100_",
")_",
"!=_",
"0_",
"or_",
"(_",
"first",
"\\u",
"digit_",
"<_",
"1_",
"\\u\\u\\uNL\\u\\u\\u_",
"or_",
"first",
"\\u",
"digit_",
">_",
"9_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u_",
"=_",
"(_",
"\"%",
"s",
":",
" ",
"The",
" ",
"weight",
" ",
"is",
" ",
"%",
"d",
" ",
"whi",
"ch",
" ",
"is",
" ",
"not",
" ",
"a",
" ",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"multiple",
" ",
"of",
" ",
"100",
" ",
"bet",
"ween",
" ",
"1",
" ",
"and",
" ",
"9",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"is",
"\\u",
"invalid_",
",_",
"\\u_",
"%_",
"(_",
"op_",
"._",
"basename_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"tf_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u_",
"=_",
"(_",
"\"%",
"s",
":",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"overwrit",
"es",
" ",
"the",
" ",
"weight",
".",
" ",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
" ",
"The",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"weight",
" ",
"is",
" ",
"%",
"d",
" ",
"and",
" ",
"the",
" ",
"font",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
" ",
"file",
" ",
"%",
"s",
" ",
"weight",
" ",
"is",
" ",
"%",
"d",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u_",
"=_",
"\\u_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
",_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
",_",
"tf_",
"._",
"OS",
"2",
"\\u",
"us",
"Weig",
"ht",
"Class_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"tf_",
"._",
"OS",
"2",
"\\u",
"us",
"Weig",
"ht",
"Class_",
",_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Post",
"Script",
"Name",
"Match",
"es",
"Weight_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Post",
"Script",
"Name",
"Match",
"es",
"Weight_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"posts",
"cript",
"name",
"\\u",
"contain",
"s",
"\\u",
"correct",
"\\u",
"weight_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Meta",
"data",
" ",
"weight",
" ",
"matche",
"s",
" ",
"post",
"Script",
"Name",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pair_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
",_",
"weight_",
"in_",
"weights_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"weight_",
"==_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"pair_",
"._",
"append_",
"(_",
"(_",
"k_",
",_",
"weight_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"pair_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'",
"Font",
" ",
"weight",
" ",
"doe",
"s",
" ",
"not",
" ",
"match",
" ",
"for",
" ",
"\"",
"post",
"Script",
"Name",
"\"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
"._",
"endswith_",
"(_",
"'-",
"%",
"s",
"'_",
"%_",
"pair_",
"[_",
"0_",
"]_",
"[_",
"0_",
"]_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"or_",
"font",
"\\u",
"metadata_",
"._",
"post",
"\\u",
"script",
"\\u",
"name_",
"._",
"endswith_",
"(_",
"'-",
"%",
"s",
"'_",
"%_",
"pair_",
"[_",
"1_",
"]_",
"[_",
"0_",
"]_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u_",
"=_",
"(_",
"'",
"post",
"Script",
"Name",
" ",
"with",
" ",
"weight",
" ",
"%",
"s",
" ",
"must",
" ",
"be",
" ",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ende",
"d",
" ",
"with",
" ",
"\"%",
"s",
"\"",
" ",
"or",
" ",
"\"%",
"s",
"\"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"\\u_",
"%_",
"(_",
"pair_",
"[_",
"0_",
"]_",
"[_",
"1_",
"]_",
",_",
"pair_",
"[_",
"0_",
"]_",
"[_",
"0_",
"]_",
",_",
"pair_",
"[_",
"1_",
"]_",
"[_",
"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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Font",
"Weig",
"ht",
"Sam",
"e",
"As",
"In",
"Metadata_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Font",
"Weig",
"ht",
"Sam",
"e",
"As",
"In",
"Metadata_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"font",
"\\u",
"weight",
"\\u",
"same",
"\\u",
"as",
"\\u",
"in",
"\\u",
"metadata_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Font",
" ",
"weight",
" ",
"matche",
"s",
" ",
"metadata",
".",
"pb",
" ",
"value",
" ",
"of",
" ",
"key",
" ",
"\"",
"weight",
"\"",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"font_",
"._",
"OS",
"2",
"\\u",
"us",
"Weig",
"ht",
"Class_",
"!=_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"'",
"METAD",
"ATA",
".",
"pb",
" ",
"has",
" ",
"weight",
" ",
"%",
"s",
" ",
"but",
" ",
"in",
" ",
"TT",
"F",
" ",
"it",
" ",
"is",
" ",
"%",
"s",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
",_",
"font_",
"._",
"OS",
"2",
"\\u",
"us",
"Weig",
"ht",
"Class_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Full",
"Name",
"Equal",
"Canonical",
"Name_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Full",
"Name",
"Equal",
"Canonical",
"Name_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"metadata",
"\\u",
"contain",
"s",
"\\u",
"current",
"\\u",
"font_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"METAD",
"ATA",
".",
"pb",
" ",
"lists",
" ",
"font",
"s",
" ",
"named",
" ",
"canonical",
"y",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"is",
"\\u",
"canonical",
"_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"weights_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"value_",
",_",
"intv",
"alue_",
"in_",
"weights_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"intv",
"alue_",
"==_",
"font_",
"._",
"OS",
"2",
"\\u",
"us",
"Weig",
"ht",
"Class_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"\\u",
"weights_",
"._",
"append_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"w_",
"in_",
"\\u",
"weights_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"current",
"\\u",
"font_",
"=_",
"\"%",
"s",
" ",
"%",
"s",
"\"_",
"%_",
"(_",
"font_",
"._",
"famil",
"yname",
"_",
",_",
"w_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"font",
"\\u",
"metadata_",
"._",
"full",
"\\u",
"name_",
"!=_",
"current",
"\\u",
"font_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"is",
"\\u",
"canonical",
"_",
"=_",
"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_",
"not_",
"is",
"\\u",
"canonical",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"v_",
"=_",
"map_",
"(_",
"lambda_",
"x_",
":_",
"font_",
"._",
"famil",
"yname",
"_",
"+_",
"'",
" ",
"'_",
"+_",
"x_",
",_",
"\\u",
"weights_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"msg_",
"=_",
"'",
"Canonical",
" ",
"name",
" ",
"in",
" ",
"font",
" ",
"expected",
":",
" ",
"[",
"%",
"s",
"]",
" ",
"but",
" ",
"%",
"s",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"msg_",
"%_",
"(_",
"v_",
",_",
"font",
"\\u",
"metadata_",
"._",
"full",
"\\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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Canonical",
"Styles",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"CAN",
"ONI",
"CAL",
"\\u",
"STYLE",
"\\u",
"VALUES_",
"=_",
"[_",
"'",
"italic",
"'_",
",_",
"'",
"normal",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ITA",
"LIC",
"\\u",
"MASK_",
"=_",
"0b1",
"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_",
"[SEP]_",
"class_",
"Check",
"Canonical",
"Styles",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"canonical",
"\\u",
"styles_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Font",
" ",
"style",
"s",
" ",
"are",
" ",
"named",
" ",
"canonical",
"ly",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fm_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"fm_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"In_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"style_",
",_",
"self_",
"._",
"CAN",
"ONI",
"CAL",
"\\u",
"STYLE",
"\\u",
"VALUES_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"is",
"\\u",
"italic",
"_",
"(_",
"font",
"\\u",
"metadata_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"font",
"\\u",
"metadata_",
"._",
"style_",
"!=_",
"'",
"italic",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"\\u_",
"=_",
"\"%",
"s",
":",
" ",
"The",
" ",
"font",
" ",
"style",
" ",
"is",
" ",
"%",
"s",
" ",
"but",
" ",
"it",
" ",
"shou",
"ld",
" ",
"be",
" ",
"italic",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"\\u_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
",_",
"font",
"\\u",
"metadata_",
"._",
"style_",
")_",
")_",
"\\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_",
"font",
"\\u",
"metadata_",
"._",
"style_",
"!=_",
"'",
"normal",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"\\u_",
"=_",
"\"%",
"s",
":",
" ",
"The",
" ",
"font",
" ",
"style",
" ",
"is",
" ",
"%",
"s",
" ",
"but",
" ",
"it",
" ",
"shou",
"ld",
" ",
"be",
" ",
"normal",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"fail_",
"(_",
"\\u_",
"%_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
",_",
"font",
"\\u",
"metadata_",
"._",
"style_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Canonical",
"Styles",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"is",
"\\u",
"italic",
"_",
"(_",
"self_",
",_",
"font",
"\\u",
"metadata_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"tt",
"font_",
"=_",
"Font_",
"._",
"get",
"\\u",
"tt",
"font",
"\\u",
"from",
"\\u",
"metadata_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"(_",
"tt",
"font_",
"._",
"mac",
"Style_",
"&_",
"self_",
"._",
"ITA",
"LIC",
"\\u",
"MASK_",
"\\u\\u\\uNL\\u\\u\\u_",
"or_",
"tt",
"font_",
"._",
"italic",
"Angle_",
"\\u\\u\\uNL\\u\\u\\u_",
"or_",
"self_",
"._",
"find",
"\\u",
"italic",
"\\u",
"in",
"\\u",
"name",
"\\u",
"table_",
"(_",
"tt",
"font_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Canonical",
"Styles",
"_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"find",
"\\u",
"italic",
"\\u",
"in",
"\\u",
"name",
"\\u",
"table_",
"(_",
"self_",
",_",
"tt",
"font_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"entry_",
"in_",
"tt",
"font_",
"._",
"names_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"'",
"italic",
"'_",
"in_",
"Font_",
"._",
"bin",
"2u",
"nist",
"ring_",
"(_",
"entry_",
")_",
"._",
"lower_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Check",
"Canonical",
"File",
"names_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"weights_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"100_",
":_",
"'",
"Thin",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"200_",
":_",
"'",
"Extra",
"Light",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"300_",
":_",
"'",
"Light",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"400_",
":_",
"''_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"500_",
":_",
"'",
"Medi",
"um",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"600_",
":_",
"'",
"Semi",
"Bol",
"d",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"700_",
":_",
"'",
"Bol",
"d",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"800_",
":_",
"'",
"Extra",
"Bol",
"d",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"900_",
":_",
"'",
"Black",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"style",
"\\u",
"names_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"normal",
"'_",
":_",
"''_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"italic",
"'_",
":_",
"'",
"Italic",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"name_",
"=_",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tool_",
"=_",
"'",
"lint",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"targets_",
"=_",
"[_",
"'",
"metadata",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Canonical",
"File",
"names_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"tags_",
"(_",
"'",
"require",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"check",
"\\u",
"canonical",
"\\u",
"filenames_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"File",
"name",
" ",
"is",
" ",
"set",
" ",
"canonical",
"ly",
"?",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"famil",
"y",
"\\u",
"metadata_",
"=_",
"get",
"\\u",
"Famil",
"y",
"Proto",
"\\u",
"Message_",
"(_",
"self_",
"._",
"operator_",
"._",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"font",
"\\u",
"metadata_",
"in_",
"famil",
"y",
"\\u",
"metadata_",
"._",
"fonts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"canonical",
"\\u",
"filename_",
"=_",
"self_",
"._",
"create",
"\\u",
"canonical",
"\\u",
"filename_",
"(_",
"font",
"\\u",
"metadata_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"canonical",
"\\u",
"filename_",
"!=_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fail_",
"(_",
"'{}",
" ",
"!=",
" ",
"{}'_",
"._",
"format_",
"(_",
"canonical",
"\\u",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"font",
"\\u",
"metadata_",
"._",
"filename_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Check",
"Canonical",
"File",
"names_",
"(_",
"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_",
"create",
"\\u",
"canonical",
"\\u",
"filename_",
"(_",
"self_",
",_",
"font",
"\\u",
"metadata_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"famil",
"yname",
"_",
"=_",
"font",
"\\u",
"metadata_",
"._",
"name_",
"._",
"replace_",
"(_",
"'",
" ",
"'_",
",_",
"''_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"style",
"\\u",
"weight_",
"=_",
"'%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"self_",
"._",
"weights_",
"._",
"get_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"weight_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"style",
"\\u",
"names_",
"._",
"get_",
"(_",
"font",
"\\u",
"metadata_",
"._",
"style_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"style",
"\\u",
"weight_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"style",
"\\u",
"weight_",
"=_",
"'",
"Regula",
"r",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"'%",
"s",
"-%",
"s",
".",
"tt",
"f",
"'_",
"%_",
"(_",
"famil",
"yname",
"_",
",_",
"style",
"\\u",
"weight_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"suite_",
"(_",
"path_",
",_",
"appl",
"y",
"\\u",
"autof",
"ix_",
"=_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"suite_",
"=_",
"unittest_",
"._",
"Test",
"Suite_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"testcases",
"_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"Meta",
"data",
"Subset",
"s",
"List",
"Test_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Meta",
"data",
"Test_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Test",
"Font",
"On",
"Disk",
"Famil",
"y",
"Equal",
"To",
"Meta",
"data",
"Proto",
"Buf_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Test",
"Post",
"Script",
"Name",
"In",
"Meta",
"data",
"Equal",
"Font",
"On",
"Disk_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Meta",
"data",
"Agreement",
"s_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Meta",
"data",
"Contain",
"s",
"Reserve",
"d",
"Font",
"Name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Mono",
"space",
"Agreement",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Italic",
"Style",
"Match",
"es",
"Mac",
"Style_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Normal",
"Style",
"Match",
"es",
"Mac",
"Style_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Meta",
"data",
"Match",
"es",
"Name",
"Table_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Menu",
"Subset",
"Contain",
"s",
"Proper",
"Glyphs",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Gl",
"yp",
"h",
"Cons",
"iste",
"nc",
"y",
"In",
"Family_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Font",
"Name",
"Not",
"In",
"Came",
"l",
"Case_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Font",
"s",
"Menu",
"Agreement",
"s_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Famil",
"y",
"Name",
"Match",
"es",
"Font",
"Names_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Canonical",
"Weights_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Post",
"Script",
"Name",
"Match",
"es",
"Weight_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Font",
"Weig",
"ht",
"Sam",
"e",
"As",
"In",
"Metadata_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Full",
"Name",
"Equal",
"Canonical",
"Name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Canonical",
"Styles",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Check",
"Canonical",
"File",
"names_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"testcase_",
"in_",
"testcases",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"testcase_",
"._",
"operator_",
"=_",
"Test",
"Case",
"Operator_",
"(_",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"testcase_",
"._",
"appl",
"y",
"\\u",
"fix_",
"=_",
"appl",
"y",
"\\u",
"autof",
"ix_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"getattr_",
"(_",
"testcase_",
",_",
"'",
"skip",
"Un",
"less",
"'_",
",_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"testcase_",
"._",
"skip",
"Unless_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"continue_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"getattr_",
"(_",
"testcase_",
",_",
"'\\u",
"\\u",
"generat",
"e",
"Test",
"s",
"\\u\\u'_",
",_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"testcase_",
"._",
"\\u\\u",
"generat",
"e",
"Test",
"s\\u\\u_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"test_",
"in_",
"unittest_",
"._",
"default",
"Test",
"Loader_",
"._",
"load",
"Test",
"s",
"Fro",
"m",
"Test",
"Case_",
"(_",
"testcase_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"suite_",
"._",
"add",
"Test_",
"(_",
"test_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\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
]
|
Imprecise assert | selfsk/nodeset.core/src/nodeset/core/stats/tests/test_metric_store.py | [
{
"content": " def test_StoreGet(self):\n self.m.update()\n \n self.assertTrue(self.m.get() == 1)\n \n om = metric.Store.get('counter1')\n \n self.assertTrue(om.get() == 1)",
"metadata": "root.MetricStoreTest.test_StoreGet",
"header": "['class', 'MetricStoreTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 8
},
{
"content": " def test_StoreUpdate(self):\n om = metric.Store.get('counter1')\n om.update()\n \n #om is the same as self.m\n self.assertTrue(self.m.get() == 1)",
"metadata": "root.MetricStoreTest.test_StoreUpdate",
"header": "['class', 'MetricStoreTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 17
},
{
"content": " def test_StoreMetric(self):\n om = metric.Store.get('counter1')\n self.assertTrue(self.m == om)",
"metadata": "root.MetricStoreTest.test_StoreMetric",
"header": "['class', 'MetricStoreTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 25
}
]
| [
{
"span": "self.assertTrue(self.m.get() == 1)",
"start_line": 11,
"start_column": 8,
"end_line": 11,
"end_column": 42
},
{
"span": "self.assertTrue(om.get() == 1)",
"start_line": 15,
"start_column": 8,
"end_line": 15,
"end_column": 38
},
{
"span": "self.assertTrue(self.m.get() == 1)",
"start_line": 22,
"start_column": 8,
"end_line": 22,
"end_column": 42
},
{
"span": "self.assertTrue(self.m == om)",
"start_line": 27,
"start_column": 8,
"end_line": 27,
"end_column": 37
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Met",
"ric",
"Stor",
"e",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"Stor",
"e",
"Get_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"m_",
"._",
"update_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"self_",
"._",
"m_",
"._",
"get_",
"(_",
")_",
"==_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"om_",
"=_",
"metric_",
"._",
"Store_",
"._",
"get_",
"(_",
"'",
"counter",
"1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"om_",
"._",
"get_",
"(_",
")_",
"==_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Met",
"ric",
"Stor",
"e",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"Stor",
"e",
"Update_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"om_",
"=_",
"metric_",
"._",
"Store_",
"._",
"get_",
"(_",
"'",
"counter",
"1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"om_",
"._",
"update_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"om",
" ",
"is",
" ",
"the",
" ",
"same",
" ",
"as",
" ",
"self",
".",
"m_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"self_",
"._",
"m_",
"._",
"get_",
"(_",
")_",
"==_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Met",
"ric",
"Stor",
"e",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"Stor",
"e",
"Metric_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"om_",
"=_",
"metric_",
"._",
"Store_",
"._",
"get_",
"(_",
"'",
"counter",
"1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"self_",
"._",
"m_",
"==_",
"om_",
")_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
]
|
Except block handles 'BaseException' | CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.5/pymel/internal/parsers.py | [
{
"content": "def mayaIsRunning():\n \"\"\"\n Returns True if maya.cmds have False otherwise.\n\n Early in interactive startup it is possible for commands to exist but for Maya to not yet be initialized.\n\n :rtype: bool\n \"\"\"\n\n # Implementation is essentially just a wrapper for getRunningMayaVersionString -\n # this function was included for clearer / more readable code\n\n try :\n from maya.cmds import about\n about(version=True)\n return True\n except :\n return False",
"metadata": "root.mayaIsRunning",
"header": "['module', '___EOS___']",
"index": 17
},
{
"content": " def parseEnums(self, proto):\n enumValues={}\n enumDocs={}\n for em in proto.findNextSiblings( 'div', limit=1)[0].findAll( 'em'):\n enumKey = str(em.contents[-1])\n try:\n enumVal = getattr(self.apiClass, enumKey)\n except:\n _logger.warn( \"%s.%s of enum %s does not exist\" % ( self.apiClassName, enumKey, self.currentMethod))\n enumVal = None\n enumValues[ enumKey ] = enumVal\n # TODO:\n # do we want to feed the docstrings to the Enum object itself\n # (which seems to have support for docstrings)? Currently, we're\n # not...\n docItem = em.next.next.next.next.next\n\n if isinstance( docItem, NavigableString ):\n enumDocs[enumKey] = str(docItem).strip()\n else:\n enumDocs[enumKey] = str(docItem.contents[0]).strip()\n\n apiEnum = util.Enum(self.currentMethod, enumValues, multiKeys=True)\n apiToPymelNames = self._apiEnumNamesToPymelEnumNames(apiEnum)\n pymelEnum = self._apiEnumToPymelEnum(apiEnum,\n apiToPymelNames=apiToPymelNames)\n for apiName, pymelName in apiToPymelNames.iteritems():\n apiDoc = enumDocs.get(apiName)\n if apiDoc is not None:\n enumDocs[pymelName] = apiDoc\n\n enumInfo = {'values' : apiEnum,\n 'valueDocs' : enumDocs,\n\n #'doc' : methodDoc\n }\n return enumInfo, pymelEnum",
"metadata": "root.ApiDocParser.parseEnums",
"header": "['class', 'ApiDocParser', '(', 'object', ')', ':', '___EOS___']",
"index": 761
}
]
| [
{
"span": "except :",
"start_line": 33,
"start_column": 4,
"end_line": 33,
"end_column": 12
},
{
"span": "except:",
"start_line": 768,
"start_column": 12,
"end_line": 768,
"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_",
"def_",
"maya",
"Is",
"Running_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
" ",
"Tru",
"e",
" ",
"if",
" ",
"maya",
".",
"cmds",
" ",
"have",
" ",
" ",
"Fal",
"se",
" ",
"other",
"wis",
"e",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Earl",
"y",
" ",
"in",
" ",
"interactive",
" ",
"start",
"up",
" ",
"it",
" ",
"is",
" ",
"possib",
"le",
" ",
"for",
" ",
"command",
"s",
" ",
"to",
" ",
"exist",
" ",
"but",
" ",
"for",
" ",
"Maya",
" ",
"to",
" ",
"not",
" ",
"ye",
"t",
" ",
"be",
" ",
"initialize",
"d",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"rty",
"pe",
":",
" ",
"bool",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Implementation",
" ",
"is",
" ",
"essential",
"ly",
" ",
"just",
" ",
"a",
" ",
"wrapp",
"er",
" ",
"for",
" ",
"get",
"Run",
"ning",
"Maya",
"Version",
"String",
" ",
"-_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"this",
" ",
"function",
" ",
"was",
" ",
"include",
"d",
" ",
"for",
" ",
"clear",
"er",
" ",
"/",
" ",
"more",
" ",
"reada",
"ble",
" ",
"code_",
"\\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 ",
" _",
"from_",
"maya",
"_",
"._",
"cmds_",
"import_",
"about_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"about_",
"(_",
"version_",
"=_",
"True_",
")_",
"\\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_",
"Ap",
"i",
"Doc",
"Parser_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"parse",
"Enum",
"s_",
"(_",
"self_",
",_",
"proto_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"enum",
"Values_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"enum",
"Docs",
"_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"em_",
"in_",
"proto_",
"._",
"find",
"Ne",
"xt",
"Sibling",
"s_",
"(_",
"'",
"div",
"'_",
",_",
"limit_",
"=_",
"1_",
")_",
"[_",
"0_",
"]_",
"._",
"find",
"All_",
"(_",
"'",
"em",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"enum",
"Key_",
"=_",
"str_",
"(_",
"em_",
"._",
"contents_",
"[_",
"-_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"enum",
"Val_",
"=_",
"getattr_",
"(_",
"self_",
"._",
"api",
"Class_",
",_",
"enum",
"Key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"logger_",
"._",
"warn_",
"(_",
"\"%",
"s",
".",
"%",
"s",
" ",
"of",
" ",
"enum",
" ",
"%",
"s",
" ",
"doe",
"s",
" ",
"not",
" ",
"exist",
"\"_",
"%_",
"(_",
"self_",
"._",
"api",
"Class",
"Name_",
",_",
"enum",
"Key_",
",_",
"self_",
"._",
"current",
"Method_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"enum",
"Val_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"enum",
"Values_",
"[_",
"enum",
"Key_",
"]_",
"=_",
"enum",
"Val_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"do",
" ",
"we",
" ",
"want",
" ",
"to",
" ",
"feed",
" ",
"the",
" ",
"docstrings",
" ",
"to",
" ",
"the",
" ",
"Enum",
" ",
"object",
" ",
"its",
"elf_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"(",
"whi",
"ch",
" ",
"see",
"ms",
" ",
"to",
" ",
"have",
" ",
"support",
" ",
"for",
" ",
"docstrings",
")?",
" ",
"Curr",
"ent",
"ly",
",",
" ",
"we",
"'",
"re_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"not",
"..._",
"\\u\\u\\uNL\\u\\u\\u_",
"doc",
"Item_",
"=_",
"em_",
"._",
"next_",
"._",
"next_",
"._",
"next_",
"._",
"next_",
"._",
"next_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"doc",
"Item_",
",_",
"Nav",
"iga",
"ble",
"String_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"enum",
"Docs",
"_",
"[_",
"enum",
"Key_",
"]_",
"=_",
"str_",
"(_",
"doc",
"Item_",
")_",
"._",
"strip_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"enum",
"Docs",
"_",
"[_",
"enum",
"Key_",
"]_",
"=_",
"str_",
"(_",
"doc",
"Item_",
"._",
"contents_",
"[_",
"0_",
"]_",
")_",
"._",
"strip_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"api",
"Enum_",
"=_",
"util_",
"._",
"Enum_",
"(_",
"self_",
"._",
"current",
"Method_",
",_",
"enum",
"Values_",
",_",
"multi",
"Keys_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"api",
"To",
"Py",
"mel",
"Names_",
"=_",
"self_",
"._",
"\\u",
"api",
"Enum",
"Names",
"To",
"Py",
"mel",
"Enum",
"Names_",
"(_",
"api",
"Enum_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pym",
"el",
"Enum_",
"=_",
"self_",
"._",
"\\u",
"api",
"Enum",
"To",
"Py",
"mel",
"Enum_",
"(_",
"api",
"Enum_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"api",
"To",
"Py",
"mel",
"Names_",
"=_",
"api",
"To",
"Py",
"mel",
"Names_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"api",
"Name_",
",_",
"pym",
"el",
"Name_",
"in_",
"api",
"To",
"Py",
"mel",
"Names_",
"._",
"iteritems_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"api",
"Doc_",
"=_",
"enum",
"Docs",
"_",
"._",
"get_",
"(_",
"api",
"Name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"api",
"Doc_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"enum",
"Docs",
"_",
"[_",
"pym",
"el",
"Name_",
"]_",
"=_",
"api",
"Doc_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"enum",
"Info_",
"=_",
"{_",
"'",
"values",
"'_",
":_",
"api",
"Enum_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"value",
"Docs",
"'_",
":_",
"enum",
"Docs",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#'",
"doc",
"'",
" ",
":",
" ",
"method",
"Doc_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"enum",
"Info_",
",_",
"pym",
"el",
"Enum_",
"\\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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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
]
|
Unused import | cloudera/impyla/impala/compat.py | [
{
"content": "# Copyright 2015 Cloudera 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# pylint: disable=unused-import,wrong-import-position\n\nfrom __future__ import absolute_import\n\nimport six\n\nif six.PY3:\n\n from decimal import Decimal\nelif six.PY2:\n lzip = zip\n\n try:\n from cdecimal import Decimal\n except ImportError:\n from decimal import Decimal # noqa\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": " def lzip(*x):\n return list(zip(*x))",
"metadata": "root.lzip",
"header": "['module', '___EOS___']",
"index": 21
}
]
| [
{
"span": "from decimal import Decimal",
"start_line": 24,
"start_column": 4,
"end_line": 24,
"end_column": 31
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"201",
"5",
" ",
"Cloud",
"era",
" ",
"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_",
"#",
" ",
"pylint",
":",
" ",
"disable",
"=",
"unu",
"sed",
"-",
"import",
",",
"wrong",
"-",
"import",
"-",
"position_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"\\u\\u",
"future\\u\\u_",
"import_",
"abs",
"olute",
"\\u",
"import_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"six_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"six_",
"._",
"PY",
"3_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"from_",
"decimal_",
"import_",
"Decimal_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"six_",
"._",
"PY",
"2_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"lz",
"ip_",
"=_",
"zip_",
"\\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_",
"cde",
"cim",
"al_",
"import_",
"Decimal_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Import",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"decimal_",
"import_",
"Decimal_",
"#",
" ",
"no",
"qa_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"lz",
"ip_",
"(_",
"*_",
"x_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"list_",
"(_",
"zip_",
"(_",
"*_",
"x_",
")_",
")_",
"\\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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Signature mismatch in overriding method | truemped/dopplr/vows/solr/dismax_vows.py | [
{
"content": "@Vows.batch\nclass WithTheDisMax(Vows.Context):\n\n class WithDefaultParams(Vows.Context):\n\n def topic(self):\n q = DisMax('title^2 body^1', edismax=False)\n return q.get_params()\n\n def theDefTypeMustMatch(self, topic):\n expect(topic).to_include(('defType', 'dismax'))\n\n def theQueryFieldsMatch(self, topic):\n expect(topic).to_include(('qf', 'title^2 body^1'))\n\n def noUnexpectedArgs(self, topic):\n expect(topic).to_length(2)\n\n class WithOptionalParameters(WithDefaultParams):\n\n def topic(self):\n valid_params = [\n 'alt',\n 'mm',\n 'pf',\n 'ps',\n 'qs',\n 'tie',\n 'bq',\n 'bf'\n ]\n\n for v in valid_params:\n kwargs = {v: 'a'}\n q = DisMax('title^2 body^1', edismax=False, **kwargs)\n yield (v, q.get_params())\n\n def theDefTypeMustMatch(self, (field, params)):\n expect(params).to_include(('defType', 'dismax'))\n\n def theQueryFieldsMatch(self, (field, params)):\n expect(params).to_include(('qf', 'title^2 body^1'))\n\n def noUnexpectedArgs(self, (field, params)):\n expect(params).to_length(3)\n\n def theQueryMustMatch(self, (field, params)):\n if field == 'alt':\n field = 'q.alt'\n expect(params).to_include((field, 'a'))",
"metadata": "root.WithTheDisMax",
"header": "['module', '___EOS___']",
"index": 23
},
{
"content": "@Vows.batch\nclass WithTheEDisMax(Vows.Context):\n\n class WithDefaultParams(Vows.Context):\n\n def topic(self):\n q = DisMax('title^2 body^1')\n return q.get_params()\n\n def theDefTypeMustMatch(self, topic):\n expect(topic).to_include(('defType', 'edismax'))\n\n def theQueryFieldsMatch(self, topic):\n expect(topic).to_include(('qf', 'title^2 body^1'))\n\n def noUnexpectedArgs(self, topic):\n expect(topic).to_length(2)\n\n class WithOptionalParameters(WithDefaultParams):\n\n def topic(self):\n valid_params = [\n 'alt',\n 'mm',\n 'pf',\n 'ps',\n 'qs',\n 'tie',\n 'bq',\n 'bf'\n ]\n\n for v in valid_params:\n kwargs = {v: 'a'}\n q = DisMax('title^2 body^1', **kwargs)\n yield (v, q.get_params())\n\n def theDefTypeMustMatch(self, (field, params)):\n expect(params).to_include(('defType', 'edismax'))\n\n def theQueryFieldsMatch(self, (field, params)):\n expect(params).to_include(('qf', 'title^2 body^1'))\n\n def noUnexpectedArgs(self, (field, params)):\n expect(params).to_length(3)\n\n def theQueryMustMatch(self, (field, params)):\n if field == 'alt':\n field = 'q.alt'\n expect(params).to_include((field, 'a'))",
"metadata": "root.WithTheEDisMax",
"header": "['module', '___EOS___']",
"index": 75
}
]
| [
{
"span": "def theDefTypeMustMatch(self, (field, params)):",
"start_line": 60,
"start_column": 8,
"end_line": 60,
"end_column": 55
},
{
"span": "def theQueryFieldsMatch(self, (field, params)):",
"start_line": 63,
"start_column": 8,
"end_line": 63,
"end_column": 55
},
{
"span": "def noUnexpectedArgs(self, (field, params)):",
"start_line": 66,
"start_column": 8,
"end_line": 66,
"end_column": 52
},
{
"span": "def theDefTypeMustMatch(self, (field, params)):",
"start_line": 112,
"start_column": 8,
"end_line": 112,
"end_column": 55
},
{
"span": "def theQueryFieldsMatch(self, (field, params)):",
"start_line": 115,
"start_column": 8,
"end_line": 115,
"end_column": 55
},
{
"span": "def noUnexpectedArgs(self, (field, params)):",
"start_line": 118,
"start_column": 8,
"end_line": 118,
"end_column": 52
}
]
| [
{
"span": "def theDefTypeMustMatch(self, topic):",
"start_line": 32,
"start_column": 8,
"end_line": 32,
"end_column": 45
},
{
"span": "def theQueryFieldsMatch(self, topic):",
"start_line": 35,
"start_column": 8,
"end_line": 35,
"end_column": 45
},
{
"span": "def noUnexpectedArgs(self, topic):",
"start_line": 38,
"start_column": 8,
"end_line": 38,
"end_column": 42
},
{
"span": "def theDefTypeMustMatch(self, topic):",
"start_line": 84,
"start_column": 8,
"end_line": 84,
"end_column": 45
},
{
"span": "def theQueryFieldsMatch(self, topic):",
"start_line": 87,
"start_column": 8,
"end_line": 87,
"end_column": 45
},
{
"span": "def noUnexpectedArgs(self, topic):",
"start_line": 90,
"start_column": 8,
"end_line": 90,
"end_column": 42
}
]
| 1 | false | [
"[CLS]_",
"Signature_",
"mismatch_",
"in_",
"overrid",
"ing_",
"method_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"Vo",
"ws_",
"._",
"batch_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"class_",
"With",
"The",
"Dis",
"Max_",
"(_",
"Vo",
"ws_",
"._",
"Context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"class_",
"With",
"Default",
"Params_",
"(_",
"Vo",
"ws_",
"._",
"Context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"topic_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"q_",
"=_",
"Dis",
"Max_",
"(_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
",_",
"edi",
"sma",
"x_",
"=_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"q_",
"._",
"get",
"\\u",
"params_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Def",
"Type",
"Mus",
"t",
"Match_",
"(_",
"self_",
",_",
"topic_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"topic_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"def",
"Type",
"'_",
",_",
"'",
"dis",
"max",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Query",
"Field",
"s",
"Match_",
"(_",
"self_",
",_",
"topic_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"topic_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"qf",
"'_",
",_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"no",
"Une",
"xpe",
"cte",
"d",
"Args_",
"(_",
"self_",
",_",
"topic_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"topic_",
")_",
"._",
"to",
"\\u",
"length_",
"(_",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"With",
"Optio",
"nal",
"Parameters_",
"(_",
"With",
"Default",
"Params_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"topic_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"valid",
"\\u",
"params_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"alt",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"mm",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"pf",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ps",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"qs",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tie",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"bq",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"bf",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"v_",
"in_",
"valid",
"\\u",
"params_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"kwargs_",
"=_",
"{_",
"v_",
":_",
"'",
"a",
"'_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"q_",
"=_",
"Dis",
"Max_",
"(_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
",_",
"edi",
"sma",
"x_",
"=_",
"False_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"(_",
"v_",
",_",
"q_",
"._",
"get",
"\\u",
"params_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Def",
"Type",
"Mus",
"t",
"Match_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"def",
"Type",
"'_",
",_",
"'",
"dis",
"max",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Query",
"Field",
"s",
"Match_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"qf",
"'_",
",_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"no",
"Une",
"xpe",
"cte",
"d",
"Args_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"length_",
"(_",
"3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Query",
"Mus",
"t",
"Match_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"field_",
"==_",
"'",
"alt",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"field_",
"=_",
"'",
"q",
".",
"alt",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"field_",
",_",
"'",
"a",
"'_",
")_",
")_",
"\\u\\u\\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_",
"@_",
"Vo",
"ws_",
"._",
"batch_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"class_",
"With",
"The",
"ED",
"is",
"Max_",
"(_",
"Vo",
"ws_",
"._",
"Context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"class_",
"With",
"Default",
"Params_",
"(_",
"Vo",
"ws_",
"._",
"Context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"topic_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"q_",
"=_",
"Dis",
"Max_",
"(_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"q_",
"._",
"get",
"\\u",
"params_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Def",
"Type",
"Mus",
"t",
"Match_",
"(_",
"self_",
",_",
"topic_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"topic_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"def",
"Type",
"'_",
",_",
"'",
"edi",
"sma",
"x",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Query",
"Field",
"s",
"Match_",
"(_",
"self_",
",_",
"topic_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"topic_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"qf",
"'_",
",_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"no",
"Une",
"xpe",
"cte",
"d",
"Args_",
"(_",
"self_",
",_",
"topic_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"topic_",
")_",
"._",
"to",
"\\u",
"length_",
"(_",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"With",
"Optio",
"nal",
"Parameters_",
"(_",
"With",
"Default",
"Params_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"topic_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"valid",
"\\u",
"params_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"alt",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"mm",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"pf",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ps",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"qs",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tie",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"bq",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"bf",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"v_",
"in_",
"valid",
"\\u",
"params_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"kwargs_",
"=_",
"{_",
"v_",
":_",
"'",
"a",
"'_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"q_",
"=_",
"Dis",
"Max_",
"(_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"(_",
"v_",
",_",
"q_",
"._",
"get",
"\\u",
"params_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Def",
"Type",
"Mus",
"t",
"Match_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"def",
"Type",
"'_",
",_",
"'",
"edi",
"sma",
"x",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Query",
"Field",
"s",
"Match_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"'",
"qf",
"'_",
",_",
"'",
"title",
"^",
"2",
" ",
"body",
"^",
"1",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"no",
"Une",
"xpe",
"cte",
"d",
"Args_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"length_",
"(_",
"3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"the",
"Query",
"Mus",
"t",
"Match_",
"(_",
"self_",
",_",
"(_",
"field_",
",_",
"params_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"field_",
"==_",
"'",
"alt",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"field_",
"=_",
"'",
"q",
".",
"alt",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"expect_",
"(_",
"params_",
")_",
"._",
"to",
"\\u",
"include_",
"(_",
"(_",
"field_",
",_",
"'",
"a",
"'_",
")_",
")_"
]
| [
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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raph import Paragraph\nfrom reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\nfrom reportlab.lib.colors import Color\nfrom reportlab.platypus.flowables import _listWrapOn, _FUZZ\nfrom wordaxe.rl.NewParagraph import Paragraph\nfrom wordaxe.rl.styles import ParagraphStyle, getSampleStyleSheet\n\n\n\ngo()\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def go():\n styles = getSampleStyleSheet()\n style=styles['Normal']\n \n p1 = Paragraph('This is a paragraph', style )\n print p1.wrap(500,701)\n print p1._cache['avail']\n print len(p1.split(500,701))\n print p1.wrap(500,700)\n print len(p1.split(500,700))",
"metadata": "root.go",
"header": "['module', '___EOS___']",
"index": 10
}
]
| [
{
"span": "from reportlab.platypus import SimpleDocTemplate",
"start_line": 1,
"start_column": 0,
"end_line": 1,
"end_column": 48
},
{
"span": "from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 68
},
{
"span": "from reportlab.lib.colors import Color",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 38
},
{
"span": "from reportlab.platypus.flowables import _listWrapOn, _FUZZ",
"start_line": 5,
"start_column": 0,
"end_line": 5,
"end_column": 59
},
{
"span": "from wordaxe.rl.styles import ParagraphStyle, getSampleStyleSheet",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 65
}
]
| []
| 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_",
"reportlab_",
"._",
"plat",
"yp",
"us_",
"import_",
"Simple",
"Doc",
"Template_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"reportlab_",
"._",
"plat",
"yp",
"us_",
"._",
"paragraph_",
"import_",
"Paragraph_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"reportlab_",
"._",
"lib_",
"._",
"styles_",
"import_",
"get",
"Sampl",
"e",
"Style",
"Sheet_",
",_",
"Para",
"graph",
"Style_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"reportlab_",
"._",
"lib_",
"._",
"colors_",
"import_",
"Color_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"reportlab_",
"._",
"plat",
"yp",
"us_",
"._",
"flow",
"ables_",
"import_",
"\\u",
"list",
"Wra",
"p",
"On_",
",_",
"\\u",
"FU",
"ZZ",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"word",
"axe",
"_",
"._",
"rl_",
"._",
"New",
"Paragraph_",
"import_",
"Paragraph_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"word",
"axe",
"_",
"._",
"rl_",
"._",
"styles_",
"import_",
"Para",
"graph",
"Style_",
",_",
"get",
"Sampl",
"e",
"Style",
"Sheet_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"go_",
"(_",
")_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"go_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"styles_",
"=_",
"get",
"Sampl",
"e",
"Style",
"Sheet_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"style_",
"=_",
"styles_",
"[_",
"'",
"Normal",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"p1_",
"=_",
"Paragraph_",
"(_",
"'",
"Thi",
"s",
" ",
"is",
" ",
"a",
" ",
"paragraph",
"'_",
",_",
"style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"p1_",
"._",
"wrap_",
"(_",
"500_",
",_",
"701",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"p1_",
"._",
"\\u",
"cache_",
"[_",
"'",
"avail",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"len_",
"(_",
"p1_",
"._",
"split_",
"(_",
"500_",
",_",
"701",
"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"p1_",
"._",
"wrap_",
"(_",
"500_",
",_",
"700_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"len_",
"(_",
"p1_",
"._",
"split_",
"(_",
"500_",
",_",
"700_",
")_",
")_",
"\\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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
0,
1,
1,
1,
1,
1,
1,
1,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | caktus/django-scribbler/scribbler/tests/test_utils.py | [
{
"content": " def test_returned_variable(self):\n \"\"\"Assure get_variables returns variables unique to the context.\"\"\"\n context = self._get_context({})\n with context_context_manager(context):\n variables = get_variables(context)\n self.assertTrue('a' not in variables)\n\n context = self._get_context({'a': 3})\n with context_context_manager(context):\n variables = get_variables(context)\n self.assertTrue('a' in variables)",
"metadata": "root.GetVariablesTestCase.test_returned_variable",
"header": "['class', 'GetVariablesTestCase', '(', 'BaseViewTestCase', ')', ':', '___EOS___']",
"index": 85
},
{
"content": " def test_custom_processors(self):\n context = self._get_context({}, processors=[])\n with context_context_manager(context):\n variables = get_variables(context)\n self.assertTrue('custom_processor_var' not in variables)\n context = self._get_context({}, processors=[test_processor])\n with context_context_manager(context):\n variables = get_variables(context)\n self.assertTrue('custom_processor_var' in variables)",
"metadata": "root.GetVariablesTestCase.test_custom_processors",
"header": "['class', 'GetVariablesTestCase', '(', 'BaseViewTestCase', ')', ':', '___EOS___']",
"index": 97
}
]
| [
{
"span": "self.assertTrue('a' not in variables)",
"start_line": 90,
"start_column": 12,
"end_line": 90,
"end_column": 49
},
{
"span": "self.assertTrue('a' in variables)",
"start_line": 95,
"start_column": 12,
"end_line": 95,
"end_column": 45
},
{
"span": "self.assertTrue('custom_processor_var' not in variables)",
"start_line": 101,
"start_column": 12,
"end_line": 101,
"end_column": 68
},
{
"span": "self.assertTrue('custom_processor_var' in variables)",
"start_line": 105,
"start_column": 12,
"end_line": 105,
"end_column": 64
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Get",
"Varia",
"bles",
"Test",
"Case_",
"(_",
"Base",
"View",
"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",
"return",
"ed",
"\\u",
"variable_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Assu",
"re",
" ",
"get",
"\\u",
"variab",
"les",
" ",
"return",
"s",
" ",
"variab",
"les",
" ",
"unique",
" ",
"to",
" ",
"the",
" ",
"context",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"context_",
"=_",
"self_",
"._",
"\\u",
"get",
"\\u",
"context_",
"(_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"with_",
"context",
"\\u",
"context",
"\\u",
"manager_",
"(_",
"context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"variables_",
"=_",
"get",
"\\u",
"variables_",
"(_",
"context_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"a",
"'_",
"not_",
"in_",
"variables_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"context_",
"=_",
"self_",
"._",
"\\u",
"get",
"\\u",
"context_",
"(_",
"{_",
"'",
"a",
"'_",
":_",
"3_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"with_",
"context",
"\\u",
"context",
"\\u",
"manager_",
"(_",
"context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"variables_",
"=_",
"get",
"\\u",
"variables_",
"(_",
"context_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"a",
"'_",
"in_",
"variables_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Get",
"Varia",
"bles",
"Test",
"Case_",
"(_",
"Base",
"View",
"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",
"custom",
"\\u",
"processors_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"context_",
"=_",
"self_",
"._",
"\\u",
"get",
"\\u",
"context_",
"(_",
"{_",
"}_",
",_",
"processors_",
"=_",
"[_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"with_",
"context",
"\\u",
"context",
"\\u",
"manager_",
"(_",
"context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"variables_",
"=_",
"get",
"\\u",
"variables_",
"(_",
"context_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"custom",
"\\u",
"process",
"or",
"\\u",
"var",
"'_",
"not_",
"in_",
"variables_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"context_",
"=_",
"self_",
"._",
"\\u",
"get",
"\\u",
"context_",
"(_",
"{_",
"}_",
",_",
"processors_",
"=_",
"[_",
"test\\u",
"processor_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"with_",
"context",
"\\u",
"context",
"\\u",
"manager_",
"(_",
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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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
]
|
Testing equality to None | grundprinzip/pyxplorer/pyxplorer/loader.py | [
{
"content": " def load(self):\n # Check data to see which kind it is\n files = self._client.ls([self._path])\n\n files = [f for f in files if f['file_type'] == 'f']\n if len(files) == 0:\n raise Exception(\"Cannot load empty directory\")\n\n # Pick the first file and assume that it has the same content as the others\n data = self.head(files[0]['path'])\n res = self.check_separator(data)\n if res == None:\n # We cant load the data and better abort here\n print(\"cant load data, cannot find a separator\")\n return\n\n sep = res[0]\n num_cols = res[1]\n\n # Build table statement\n table_statement, table_name = self._create_table(self._path, sep, num_cols)\n cursor = self._hive.cursor()\n cursor.execute(table_statement)\n\n return self._db, table_name",
"metadata": "root.Loader.load",
"header": "['class', 'Loader', ':', '___EOS___']",
"index": 31
}
]
| [
{
"span": "res == None:",
"start_line": 42,
"start_column": 11,
"end_line": 42,
"end_column": 22
}
]
| []
| 1 | true | [
"[CLS]_",
"Test",
"ing_",
"equality",
"_",
"to_",
"None_",
"[SEP]_",
"class_",
"Loader_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"load_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Check",
" ",
"data",
" ",
"to",
" ",
"see",
" ",
"whi",
"ch",
" ",
"kind",
" ",
"it",
" ",
"is_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"files_",
"=_",
"self_",
"._",
"\\u",
"client_",
"._",
"ls_",
"(_",
"[_",
"self_",
"._",
"\\u",
"path_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"files_",
"=_",
"[_",
"f_",
"for_",
"f_",
"in_",
"files_",
"if_",
"f_",
"[_",
"'",
"file",
"\\u",
"type",
"'_",
"]_",
"==_",
"'",
"f",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"len_",
"(_",
"files_",
")_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Exception_",
"(_",
"\"",
"Cann",
"ot",
" ",
"load",
" ",
"empty",
" ",
"director",
"y",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Pick",
" ",
"the",
" ",
"first",
" ",
"file",
" ",
"and",
" ",
"assume",
" ",
"tha",
"t",
" ",
"it",
" ",
"has",
" ",
"the",
" ",
"same",
" ",
"content",
" ",
"as",
" ",
"the",
" ",
"others_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"data_",
"=_",
"self_",
"._",
"head_",
"(_",
"files_",
"[_",
"0_",
"]_",
"[_",
"'",
"path",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"res_",
"=_",
"self_",
"._",
"check",
"\\u",
"separator_",
"(_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"res_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"We",
" ",
"cant",
" ",
"load",
" ",
"the",
" ",
"data",
" ",
"and",
" ",
"bett",
"er",
" ",
"abort",
" ",
"here_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"cant",
" ",
"load",
" ",
"data",
",",
" ",
"cann",
"ot",
" ",
"find",
" ",
"a",
" ",
"separator",
"\"_",
")_",
"\\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_",
"sep_",
"=_",
"res_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"num",
"\\u",
"cols_",
"=_",
"res_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Build",
" ",
"table",
" ",
"statement_",
"\\u\\u\\uNL\\u\\u\\u_",
"table",
"\\u",
"statement_",
",_",
"table",
"\\u",
"name_",
"=_",
"self_",
"._",
"\\u",
"create",
"\\u",
"table_",
"(_",
"self_",
"._",
"\\u",
"path_",
",_",
"sep_",
",_",
"num",
"\\u",
"cols_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cursor_",
"=_",
"self_",
"._",
"\\u",
"hive",
"_",
"._",
"cursor_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cursor_",
"._",
"execute_",
"(_",
"table",
"\\u",
"statement_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"db_",
",_",
"table",
"\\u",
"name_",
"\\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,
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
]
|
Unused import | EricssonResearch/calvin-base/calvin/actorstore/devactors/usr/SocketClient.py | [
{
"content": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2015 Ericsson AB\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\nfrom calvin.actor.actor import Actor, ActionResult, manage, condition, guard\nfrom calvin.runtime.north.calvin_token import EOSToken\n\nfrom calvin.utilities.calvinlogger import get_logger\n\n_log = get_logger(__name__)\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class SocketClient(Actor):\n \"\"\"\n Etablish a TCP/UDP connection and forward all tokens.\n Any recevied data on the TCP/UDP connection is forwarded according to protocol.\n\n Input:\n inData : Each received token will be sent out through the TCP/UDP connection.\n inControl : Each received token will be sent out through the TCP/UDP connection.\n Output:\n outData : Data received on the TCP/UDP connection will be sent as tokens.\n outControl : Data received on the TCP/UDP connection will be sent as tokens.\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n action_priority = (receive_control, receive, send, send_control)\n requires = ['calvinsys.io.socketclienthandler']",
"metadata": "root.SocketClient",
"header": "['module', '___EOS___']",
"index": 24
},
{
"content": " @manage(['address', 'port', 'protocol', 'type_', 'delimiter'])\n def init(self, address=None, port=None, protocol='raw', type_=\"TCP\", delimiter='\\r\\n'):\n self.address = address\n self.port = port\n self.protocol = protocol\n self.type_ = type_\n self.delimiter = delimiter\n self.EOST_token_received = False\n self.cc = None\n self.use('calvinsys.io.socketclienthandler', shorthand='socket')\n\n # Connect\n if address is not None:\n self.connect()",
"metadata": "root.SocketClient.init",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 37
},
{
"content": " def connect(self):\n self.cc = self['socket'].connect(self.address, self.port, self.protocol, self.type_, self.delimiter)",
"metadata": "root.SocketClient.connect",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 52
},
{
"content": " def will_migrate(self):\n self.cc.disconnect()",
"metadata": "root.SocketClient.will_migrate",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 55
},
{
"content": " def did_migrate(self):\n self.connect()",
"metadata": "root.SocketClient.did_migrate",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 58
},
{
"content": " @condition(action_input=['inData'])\n @guard(lambda self, token: self.cc and self.cc.is_connected())\n def send(self, token):\n self.cc.send(token)\n return ActionResult(production=())",
"metadata": "root.SocketClient.send",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 61
},
{
"content": " @condition(action_output=['outData'])\n @guard(lambda self: self.cc and self.cc.is_connected() and self.cc.have_data())\n def receive(self):\n data = self.cc.get_data()\n return ActionResult(production=(data,))",
"metadata": "root.SocketClient.receive",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 67
},
{
"content": " @condition(action_input=['inControl'])\n @guard(lambda self, token: True)\n def receive_control(self, token):\n if token[0] == \"connect\":\n if not self.cc:\n # TODO: validate these\n self.address = token[1]['addr']\n self.port = token[0]['port']\n self.connect()\n if token[0] == \"disconnect\":\n if self.cc:\n self.cc.disconnect()\n self.cc = None\n return ActionResult(production=())",
"metadata": "root.SocketClient.receive_control",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 73
},
{
"content": " @condition(action_output=['outControl'])\n @guard(lambda self: self.cc and self.cc.have_control())\n def send_control(self):\n data = self.cc.get_control()\n return ActionResult(production=(data,))",
"metadata": "root.SocketClient.send_control",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 88
},
{
"content": " def exception_handler(self, action, args, context):\n \"\"\"Handler ExceptionTokens\"\"\"\n self.EOST_token_received = True\n return ActionResult(production=())",
"metadata": "root.SocketClient.exception_handler",
"header": "['class', 'SocketClient', '(', 'Actor', ')', ':', '___EOS___']",
"index": 94
}
]
| [
{
"span": "from calvin.runtime.north.calvin_token import EOSToken",
"start_line": 17,
"start_column": 0,
"end_line": 17,
"end_column": 54
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"201",
"5",
" ",
"Eri",
"css",
"on",
" ",
"AB_",
"\\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_",
"from_",
"cal",
"vin_",
"._",
"actor_",
"._",
"actor_",
"import_",
"Actor_",
",_",
"Action",
"Result_",
",_",
"manage_",
",_",
"condition_",
",_",
"guard_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"runtime_",
"._",
"north_",
"._",
"cal",
"vin",
"\\u",
"token_",
"import_",
"EOS",
"Token_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"cal",
"vin_",
"._",
"utilities_",
"._",
"cal",
"vin",
"logger_",
"import_",
"get",
"\\u",
"logger_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"log_",
"=_",
"get",
"\\u",
"logger_",
"(_",
"\\u\\u",
"name\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Eta",
"blis",
"h",
" ",
"a",
" ",
"TC",
"P",
"/",
"UD",
"P",
" ",
"connecti",
"on",
" ",
"and",
" ",
"forward",
" ",
"all",
" ",
"token",
"s",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Any",
" ",
"rece",
"vie",
"d",
" ",
"data",
" ",
"on",
" ",
"the",
" ",
"TC",
"P",
"/",
"UD",
"P",
" ",
"connecti",
"on",
" ",
"is",
" ",
"forwarded",
" ",
"according",
" ",
"to",
" ",
"protoc",
"ol",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Inp",
"ut",
":",
"\\",
"10",
";",
" ",
" ",
"in",
"Data",
" ",
" ",
" ",
" ",
":",
" ",
"Ea",
"ch",
" ",
"receive",
"d",
" ",
"token",
" ",
"will",
" ",
"be",
" ",
"sent",
" ",
"out",
" ",
"through",
" ",
"the",
" ",
"TC",
"P",
"/",
"UD",
"P",
" ",
"connecti",
"on",
".",
"\\",
"10",
";",
" ",
" ",
"in",
"Control",
" ",
":",
" ",
"Ea",
"ch",
" ",
"receive",
"d",
" ",
"token",
" ",
"will",
" ",
"be",
" ",
"sent",
" ",
"out",
" ",
"through",
" ",
"the",
" ",
"TC",
"P",
"/",
"UD",
"P",
" ",
"connecti",
"on",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Output",
":",
"\\",
"10",
";",
" ",
" ",
"out",
"Data",
" ",
" ",
" ",
" ",
":",
" ",
"Data",
" ",
"receive",
"d",
" ",
"on",
" ",
"the",
" ",
"TC",
"P",
"/",
"UD",
"P",
" ",
"connecti",
"on",
" ",
"will",
" ",
"be",
" ",
"sent",
" ",
"as",
" ",
"token",
"s",
".",
"\\",
"10",
";",
" ",
" ",
"out",
"Control",
" ",
":",
" ",
"Data",
" ",
"receive",
"d",
" ",
"on",
" ",
"the",
" ",
"TC",
"P",
"/",
"UD",
"P",
" ",
"connecti",
"on",
" ",
"will",
" ",
"be",
" ",
"sent",
" ",
"as",
" ",
"token",
"s",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"action",
"\\u",
"priority_",
"=_",
"(_",
"receive",
"\\u",
"control_",
",_",
"receive_",
",_",
"send_",
",_",
"send",
"\\u",
"control_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"requires_",
"=_",
"[_",
"'",
"cal",
"vin",
"sys",
".",
"io",
".",
"socket",
"client",
"handler",
"'_",
"]_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"manage_",
"(_",
"[_",
"'",
"address",
"'_",
",_",
"'",
"port",
"'_",
",_",
"'",
"protoc",
"ol",
"'_",
",_",
"'",
"type",
"\\u'_",
",_",
"'",
"delimiter",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"init_",
"(_",
"self_",
",_",
"address_",
"=_",
"None_",
",_",
"port_",
"=_",
"None_",
",_",
"protocol_",
"=_",
"'",
"raw",
"'_",
",_",
"type\\u_",
"=_",
"\"",
"TC",
"P",
"\"_",
",_",
"delimiter_",
"=_",
"'\\\\",
"r",
"\\\\",
"n",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"address_",
"=_",
"address_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"port_",
"=_",
"port_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"protocol_",
"=_",
"protocol_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"type\\u_",
"=_",
"type\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"delimiter_",
"=_",
"delimiter_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"EOS",
"T",
"\\u",
"token",
"\\u",
"received_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"cc_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"use_",
"(_",
"'",
"cal",
"vin",
"sys",
".",
"io",
".",
"socket",
"client",
"handler",
"'_",
",_",
"short",
"hand_",
"=_",
"'",
"socket",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Connect_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"address_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"connect_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\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_",
"connect_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cc_",
"=_",
"self_",
"[_",
"'",
"socket",
"'_",
"]_",
"._",
"connect_",
"(_",
"self_",
"._",
"address_",
",_",
"self_",
"._",
"port_",
",_",
"self_",
"._",
"protocol_",
",_",
"self_",
"._",
"type\\u_",
",_",
"self_",
"._",
"delimiter_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"will",
"\\u",
"migrate_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cc_",
"._",
"disconnect_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"did",
"\\u",
"migrate_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"connect_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"condition_",
"(_",
"action",
"\\u",
"input_",
"=_",
"[_",
"'",
"in",
"Data",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"@_",
"guard_",
"(_",
"lambda_",
"self_",
",_",
"token_",
":_",
"self_",
"._",
"cc_",
"and_",
"self_",
"._",
"cc_",
"._",
"is",
"\\u",
"connected_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"send_",
"(_",
"self_",
",_",
"token_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cc_",
"._",
"send_",
"(_",
"token_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Action",
"Result_",
"(_",
"production_",
"=_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"condition_",
"(_",
"action",
"\\u",
"output_",
"=_",
"[_",
"'",
"out",
"Data",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"@_",
"guard_",
"(_",
"lambda_",
"self_",
":_",
"self_",
"._",
"cc_",
"and_",
"self_",
"._",
"cc_",
"._",
"is",
"\\u",
"connected_",
"(_",
")_",
"and_",
"self_",
"._",
"cc_",
"._",
"have",
"\\u",
"data_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"receive_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"self_",
"._",
"cc_",
"._",
"get",
"\\u",
"data_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Action",
"Result_",
"(_",
"production_",
"=_",
"(_",
"data_",
",_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"condition_",
"(_",
"action",
"\\u",
"input_",
"=_",
"[_",
"'",
"in",
"Control",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"@_",
"guard_",
"(_",
"lambda_",
"self_",
",_",
"token_",
":_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"receive",
"\\u",
"control_",
"(_",
"self_",
",_",
"token_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"token_",
"[_",
"0_",
"]_",
"==_",
"\"",
"connect",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"self_",
"._",
"cc_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"validat",
"e",
" ",
"these",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"address_",
"=_",
"token_",
"[_",
"1_",
"]_",
"[_",
"'",
"addr",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"port_",
"=_",
"token_",
"[_",
"0_",
"]_",
"[_",
"'",
"port",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"connect_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"token_",
"[_",
"0_",
"]_",
"==_",
"\"",
"discon",
"nect",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"self_",
"._",
"cc_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cc_",
"._",
"disconnect_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"cc_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"Action",
"Result_",
"(_",
"production_",
"=_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"condition_",
"(_",
"action",
"\\u",
"output_",
"=_",
"[_",
"'",
"out",
"Control",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"@_",
"guard_",
"(_",
"lambda_",
"self_",
":_",
"self_",
"._",
"cc_",
"and_",
"self_",
"._",
"cc_",
"._",
"have",
"\\u",
"control_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"send",
"\\u",
"control_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"self_",
"._",
"cc_",
"._",
"get",
"\\u",
"control_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Action",
"Result_",
"(_",
"production_",
"=_",
"(_",
"data_",
",_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sock",
"et",
"Client_",
"(_",
"Actor_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"exception",
"\\u",
"handler_",
"(_",
"self_",
",_",
"action_",
",_",
"args_",
",_",
"context_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Handle",
"r",
" ",
"Except",
"ion",
"Token",
"s",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"EOS",
"T",
"\\u",
"token",
"\\u",
"received_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Action",
"Result_",
"(_",
"production_",
"=_",
"(_",
")_",
")_",
"\\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,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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,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Except block handles 'BaseException' | SheffieldML/GPy/setup.py | [
{
"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n#===============================================================================\n# Copyright (c) 2012 - 2014, GPy authors (see AUTHORS.txt).\n# Copyright (c) 2014, James Hensman, Max Zwiessele\n# Copyright (c) 2015, Max Zwiessele\n#\n# All rights reserved.\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, this\n# list of conditions and the following disclaimer.\n#\n# * Redistributions in binary form must reproduce the above copyright notice,\n# this list of conditions and the following disclaimer in the documentation\n# and/or other materials provided with the distribution.\n#\n# * Neither the name of GPy nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\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 ARE\n# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#===============================================================================\n\nfrom __future__ import print_function\nimport os\nimport sys\nfrom setuptools import setup, Extension\nimport numpy as np\nimport codecs\n\n\n\ndesc = \"\"\"\n\n- `GPy homepage <http://sheffieldml.github.io/GPy/>`_\n- `Tutorial notebooks <http://nbviewer.ipython.org/github/SheffieldML/notebook/blob/master/GPy/index.ipynb>`_\n- `User mailing-list <https://lists.shef.ac.uk/sympa/subscribe/gpy-users>`_\n- `Developer documentation <http://gpy.readthedocs.org/en/devel/>`_\n- `Travis-CI unit-tests <https://travis-ci.org/SheffieldML/GPy>`_\n- `License <https://opensource.org/licenses/BSD-3-Clause>`_\n\nFor full description and installation instructions please refer to the github page.\n\n\"\"\"\n\nversion_dummy = {}\nexec(read('GPy/__version__.py'), version_dummy)\n__version__ = version_dummy['__version__']\ndel version_dummy\n\n#Mac OS X Clang doesn't support OpenMP at the current time.\n#This detects if we are building on a Mac\n\nif ismac():\n compile_flags = [ '-O3', ]\n link_args = []\nelse:\n compile_flags = [ '-fopenmp', '-O3']\n link_args = ['-lgomp' ]\n\next_mods = [Extension(name='GPy.kern.src.stationary_cython',\n sources=['GPy/kern/src/stationary_cython.c',\n 'GPy/kern/src/stationary_utils.c'],\n include_dirs=[np.get_include(),'.'],\n extra_compile_args=compile_flags,\n extra_link_args = link_args),\n Extension(name='GPy.util.choleskies_cython',\n sources=['GPy/util/choleskies_cython.c'],\n include_dirs=[np.get_include(),'.'],\n extra_link_args = link_args,\n extra_compile_args=compile_flags),\n Extension(name='GPy.util.linalg_cython',\n sources=['GPy/util/linalg_cython.c'],\n include_dirs=[np.get_include(),'.'],\n extra_compile_args=compile_flags),\n Extension(name='GPy.kern.src.coregionalize_cython',\n sources=['GPy/kern/src/coregionalize_cython.c'],\n include_dirs=[np.get_include(),'.'],\n extra_compile_args=compile_flags),\n Extension(name='GPy.models.state_space_cython',\n sources=['GPy/models/state_space_cython.c'],\n include_dirs=[np.get_include(),'.'],\n extra_compile_args=compile_flags)]\n\nsetup(name = 'GPy',\n version = __version__,\n author = read_to_rst('AUTHORS.txt'),\n author_email = \"[email protected]\",\n description = (\"The Gaussian Process Toolbox\"),\n license = \"BSD 3-clause\",\n keywords = \"machine-learning gaussian-processes kernels\",\n url = \"http://sheffieldml.github.com/GPy/\",\n ext_modules = ext_mods,\n packages = [\"GPy\",\n \"GPy.core\",\n \"GPy.core.parameterization\",\n \"GPy.kern\",\n \"GPy.kern.src\",\n \"GPy.kern.src.psi_comp\",\n \"GPy.models\",\n \"GPy.inference\",\n \"GPy.inference.optimization\",\n \"GPy.inference.mcmc\",\n \"GPy.inference.latent_function_inference\",\n \"GPy.likelihoods\",\n \"GPy.mappings\",\n \"GPy.examples\",\n \"GPy.testing\",\n \"GPy.util\",\n \"GPy.plotting\",\n \"GPy.plotting.gpy_plot\",\n \"GPy.plotting.matplot_dep\",\n \"GPy.plotting.matplot_dep.controllers\",\n \"GPy.plotting.plotly_dep\",\n ],\n package_dir={'GPy': 'GPy'},\n #package_data = {'GPy': ['defaults.cfg', 'installation.cfg',\n # 'util/data_resources.json',\n # 'util/football_teams.json',\n # 'testing/plotting_tests/baseline/*.png'\n # ]},\n #data_files=[('GPy/testing/plotting_tests/baseline', 'testing/plotting_tests/baseline/*.png'),\n # ('GPy/testing/', 'GPy/testing/pickle_test.pickle'),\n # ],\n include_package_data = True,\n py_modules = ['GPy.__init__'],\n test_suite = 'GPy.testing',\n long_description=desc,\n install_requires=['numpy>=1.7', 'scipy>=0.16', 'six', 'paramz>=0.5.2'],\n extras_require = {'docs':['sphinx'],\n 'optional':['mpi4py',\n 'ipython>=4.0.0',\n ],\n 'plotting':['matplotlib >= 1.3',\n 'plotly >= 1.8.6'],\n 'notebook':['jupyter_client >= 4.0.6',\n 'ipywidgets >= 4.0.3',\n 'ipykernel >= 4.1.0',\n 'notebook >= 4.0.5',\n ],\n },\n classifiers=['License :: OSI Approved :: BSD License',\n 'Natural Language :: English',\n 'Operating System :: MacOS :: MacOS X',\n 'Operating System :: Microsoft :: Windows',\n 'Operating System :: POSIX :: Linux',\n 'Programming Language :: Python :: 2.7',\n 'Programming Language :: Python :: 3.3',\n 'Programming Language :: Python :: 3.4',\n 'Programming Language :: Python :: 3.5',\n ]\n )\n\n\n# Check config files and settings:\nlocal_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'GPy', 'installation.cfg'))\nhome = os.getenv('HOME') or os.getenv('USERPROFILE')\nuser_file = os.path.join(home,'.config', 'GPy', 'user.cfg')\n\nprint(\"\")\ntry:\n if not os.path.exists(user_file):\n # Does an old config exist?\n old_user_file = os.path.join(home,'.gpy_user.cfg')\n if os.path.exists(old_user_file):\n # Move it to new location:\n print(\"GPy: Found old config file, moving to new location {}\".format(user_file))\n if not os.path.exists(os.path.dirname(user_file)):\n os.makedirs(os.path.dirname(user_file))\n os.rename(old_user_file, user_file)\n else:\n # No config file exists, save informative stub to user config folder:\n print(\"GPy: Saving user configuration file to {}\".format(user_file))\n if not os.path.exists(os.path.dirname(user_file)):\n os.makedirs(os.path.dirname(user_file))\n with open(user_file, 'w') as f:\n with open(local_file, 'r') as l:\n tmp = l.read()\n f.write(tmp)\n else:\n print(\"GPy: User configuration file at location {}\".format(user_file))\nexcept:\n print(\"GPy: Could not write user configuration file {}\".format(user_file))\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "except:",
"start_line": 210,
"start_column": 0,
"end_line": 210,
"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_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"==============",
"==============",
"==============",
"==============",
"==============",
"=========",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"2012",
" ",
"-",
" ",
"2014",
",",
" ",
"GP",
"y",
" ",
"author",
"s",
" ",
"(",
"see",
" ",
"AUTHOR",
"S",
".",
"txt",
").",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"2014",
",",
" ",
"Jam",
"es",
" ",
"Hen",
"sman",
",",
" ",
"Max",
" ",
"Zw",
"ies",
"sele",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"201",
"5",
",",
" ",
"Max",
" ",
"Zw",
"ies",
"sele",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\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",
",",
" ",
"this_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"list",
" ",
"of",
" ",
"condition",
"s",
" ",
"and",
" ",
"the",
" ",
"follow",
"ing",
" ",
"discl",
"aime",
"r",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"*",
" ",
"Redistributi",
"ons",
" ",
"in",
" ",
"binar",
"y",
" ",
"form",
" ",
"must",
" ",
"reproduce",
" ",
"the",
" ",
"above",
" ",
"copyr",
"ight",
" ",
"notice",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"this",
" ",
"list",
" ",
"of",
" ",
"condition",
"s",
" ",
"and",
" ",
"the",
" ",
"follow",
"ing",
" ",
"discl",
"aime",
"r",
" ",
"in",
" ",
"the",
" ",
"documentation",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"and",
"/",
"or",
" ",
"other",
" ",
"material",
"s",
" ",
"provided",
" ",
"with",
" ",
"the",
" ",
"distribu",
"tion",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"*",
" ",
"Nei",
"ther",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"GP",
"y",
" ",
"nor",
" ",
"the",
" ",
"names",
" ",
"of",
" ",
"its_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"contributor",
"s",
" ",
"may",
" ",
"be",
" ",
"used",
" ",
"to",
" ",
"endo",
"rse",
" ",
"or",
" ",
"promote",
" ",
"products",
" ",
"derive",
"d",
" ",
"from_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"this",
" ",
"software",
" ",
"with",
"out",
" ",
"specific",
" ",
"prior",
" ",
"writt",
"en",
" ",
"permissi",
"on",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"THIS",
" ",
"SOFT",
"WARE",
" ",
"IS",
" ",
"PROVI",
"DED",
" ",
"BY",
" ",
"THE",
" ",
"COPY",
"RIG",
"HT",
" ",
"HOLD",
"ERS",
" ",
"AND",
" ",
"CONTRIB",
"UTO",
"RS",
" ",
"\"",
"AS",
" ",
"IS",
"\"_",
"\\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",
" ",
"ARE",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"DISC",
"LAI",
"MED",
".",
" ",
"IN",
" ",
"NO",
" ",
"EVENT",
" ",
"SHA",
"LL",
" ",
"THE",
" ",
"COPY",
"RIG",
"HT",
" ",
"HOLD",
"ER",
" ",
"OR",
" ",
"CONTRIB",
"UTO",
"RS",
" ",
"BE",
" ",
"LI",
"ABLE_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"FOR",
" ",
"ANY",
" ",
"DIRECT",
",",
" ",
"INDI",
"RECT",
",",
" ",
"INC",
"IDENT",
"AL",
",",
" ",
"SPECIAL",
",",
" ",
"EXE",
"MPL",
"ARY",
",",
" ",
"OR",
" ",
"CONS",
"EQU",
"ENTI",
"AL_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"DA",
"MAGE",
"S",
" ",
"(",
"INC",
"LU",
"DING",
",",
" ",
"BUT",
" ",
"NOT",
" ",
"LIMIT",
"ED",
" ",
"TO",
",",
" ",
"PROC",
"URE",
"MENT",
" ",
"OF",
" ",
"SUBST",
"ITU",
"TE",
" ",
"GOOD",
"S",
" ",
"OR_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"SERVICES",
";",
" ",
"LOSS",
" ",
"OF",
" ",
"USE",
",",
" ",
"DATA",
",",
" ",
"OR",
" ",
"PROF",
"IT",
"S",
";",
" ",
"OR",
" ",
"BUS",
"INE",
"SS",
" ",
"INTER",
"RU",
"PTION",
")",
" ",
"HO",
"WE",
"VER_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"CAU",
"SED",
" ",
"AND",
" ",
"ON",
" ",
"ANY",
" ",
"THE",
"ORY",
" ",
"OF",
" ",
"LI",
"ABI",
"LIT",
"Y",
",",
" ",
"WHE",
"THER",
" ",
"IN",
" ",
"CONTR",
"ACT",
",",
" ",
"STRI",
"CT",
" ",
"LI",
"ABI",
"LIT",
"Y",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"OR",
" ",
"TOR",
"T",
" ",
"(",
"INC",
"LU",
"DING",
" ",
"NEG",
"LIG",
"ENCE",
" ",
"OR",
" ",
"OTHER",
"WI",
"SE",
")",
" ",
"ARI",
"SIN",
"G",
" ",
"IN",
" ",
"ANY",
" ",
"WAY",
" ",
"OUT",
" ",
"OF",
" ",
"THE",
" ",
"USE",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"OF",
" ",
"THIS",
" ",
"SOFT",
"WARE",
",",
" ",
"EVE",
"N",
" ",
"IF",
" ",
"ADV",
"ISE",
"D",
" ",
"OF",
" ",
"THE",
" ",
"POS",
"SIB",
"ILI",
"TY",
" ",
"OF",
" ",
"SUC",
"H",
" ",
"DA",
"MAGE",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"==============",
"==============",
"==============",
"==============",
"==============",
"=========",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"\\u\\u",
"future\\u\\u_",
"import_",
"print",
"\\u",
"function_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"setuptools_",
"import_",
"setup_",
",_",
"Extension_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"numpy_",
"as_",
"np_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"codecs_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"desc_",
"=_",
"\"\"\"",
"\\",
"10",
";",
"\\",
"10",
";",
"-",
" ",
"`",
"GP",
"y",
" ",
"home",
"page",
" ",
"<",
"http",
"://",
"she",
"ffi",
"eld",
"ml",
".",
"git",
"hub",
".",
"io",
"/",
"GP",
"y",
"/>",
"`\\u",
"\\",
"10",
";",
"-",
" ",
"`",
"Tu",
"tori",
"al",
" ",
"notebook",
"s",
" ",
"<",
"http",
"://",
"nb",
"viewer",
".",
"ipython",
".",
"org",
"/",
"git",
"hub",
"/",
"She",
"ffi",
"eld",
"ML",
"/",
"notebook",
"/",
"blob",
"/",
"master",
"/",
"GP",
"y",
"/",
"index",
".",
"ipynb",
">`\\u",
"\\",
"10",
";",
"-",
" ",
"`",
"User",
" ",
"mailing",
"-",
"list",
" ",
"<",
"https",
"://",
"lists",
".",
"she",
"f",
".",
"ac",
".",
"uk",
"/",
"symp",
"a",
"/",
"subscribe",
"/",
"gp",
"y",
"-",
"users",
">`\\u",
"\\",
"10",
";",
"-",
" ",
"`",
"Dev",
"elope",
"r",
" ",
"documentation",
" ",
"<",
"http",
"://",
"gp",
"y",
".",
"read",
"the",
"docs",
".",
"org",
"/",
"en",
"/",
"deve",
"l",
"/>",
"`\\u",
"\\",
"10",
";",
"-",
" ",
"`",
"Tra",
"vis",
"-",
"CI",
" ",
"unit",
"-",
"tests",
" ",
"<",
"https",
"://",
"travis",
"-",
"ci",
".",
"org",
"/",
"She",
"ffi",
"eld",
"ML",
"/",
"GP",
"y",
">`\\u",
"\\",
"10",
";",
"-",
" ",
"`",
"License",
" ",
"<",
"https",
"://",
"opens",
"ource",
".",
"org",
"/",
"license",
"s",
"/",
"BS",
"D",
"-",
"3",
"-",
"Cla",
"use",
">`\\u",
"\\",
"10",
";",
"\\",
"10",
";",
"For",
" ",
"full",
" ",
"description",
" ",
"and",
" ",
"installation",
" ",
"instruct",
"ion",
"s",
" ",
"plea",
"se",
" ",
"refer",
" ",
"to",
" ",
"the",
" ",
"git",
"hub",
" ",
"page",
".",
"\\",
"10",
";",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"version",
"\\u",
"dummy_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"exec_",
"(_",
"read_",
"(_",
"'",
"GP",
"y",
"/\\u",
"\\u",
"version",
"\\u\\u",
".",
"py",
"'_",
")_",
",_",
"version",
"\\u",
"dummy_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u",
"version\\u\\u_",
"=_",
"version",
"\\u",
"dummy_",
"[_",
"'\\u",
"\\u",
"version",
"\\u\\u'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"del_",
"version",
"\\u",
"dummy_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Mac",
" ",
"OS",
" ",
"X",
" ",
"Clan",
"g",
" ",
"doe",
"sn",
"'",
"t",
" ",
"support",
" ",
"Open",
"MP",
" ",
"at",
" ",
"the",
" ",
"current",
" ",
"time",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Thi",
"s",
" ",
"detect",
"s",
" ",
"if",
" ",
"we",
" ",
"are",
" ",
"buildi",
"ng",
" ",
"on",
" ",
"a",
" ",
"Mac",
"_",
"\\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_",
"isma",
"c_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"compile",
"\\u",
"flags_",
"=_",
"[_",
"'-",
"O",
"3",
"'_",
",_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"link",
"\\u",
"args_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"compile",
"\\u",
"flags_",
"=_",
"[_",
"'-",
"fop",
"en",
"mp",
"'_",
",_",
"'-",
"O",
"3",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"link",
"\\u",
"args_",
"=_",
"[_",
"'-",
"lg",
"omp",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"ext",
"\\u",
"mods_",
"=_",
"[_",
"Extension_",
"(_",
"name_",
"=_",
"'",
"GP",
"y",
".",
"kern",
".",
"src",
".",
"station",
"ary",
"\\u",
"cython",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sources_",
"=_",
"[_",
"'",
"GP",
"y",
"/",
"kern",
"/",
"src",
"/",
"station",
"ary",
"\\u",
"cython",
".",
"c",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"GP",
"y",
"/",
"kern",
"/",
"src",
"/",
"station",
"ary",
"\\u",
"util",
"s",
".",
"c",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"include",
"\\u",
"dirs_",
"=_",
"[_",
"np_",
"._",
"get",
"\\u",
"include_",
"(_",
")_",
",_",
"'.'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"compile",
"\\u",
"args_",
"=_",
"compile",
"\\u",
"flags_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"link",
"\\u",
"args_",
"=_",
"link",
"\\u",
"args_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Extension_",
"(_",
"name_",
"=_",
"'",
"GP",
"y",
".",
"util",
".",
"choles",
"kie",
"s",
"\\u",
"cython",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sources_",
"=_",
"[_",
"'",
"GP",
"y",
"/",
"util",
"/",
"choles",
"kie",
"s",
"\\u",
"cython",
".",
"c",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"include",
"\\u",
"dirs_",
"=_",
"[_",
"np_",
"._",
"get",
"\\u",
"include_",
"(_",
")_",
",_",
"'.'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"link",
"\\u",
"args_",
"=_",
"link",
"\\u",
"args_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"compile",
"\\u",
"args_",
"=_",
"compile",
"\\u",
"flags_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Extension_",
"(_",
"name_",
"=_",
"'",
"GP",
"y",
".",
"util",
".",
"linalg",
"\\u",
"cython",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sources_",
"=_",
"[_",
"'",
"GP",
"y",
"/",
"util",
"/",
"linalg",
"\\u",
"cython",
".",
"c",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"include",
"\\u",
"dirs_",
"=_",
"[_",
"np_",
"._",
"get",
"\\u",
"include_",
"(_",
")_",
",_",
"'.'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"compile",
"\\u",
"args_",
"=_",
"compile",
"\\u",
"flags_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Extension_",
"(_",
"name_",
"=_",
"'",
"GP",
"y",
".",
"kern",
".",
"src",
".",
"core",
"gion",
"alize",
"\\u",
"cython",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sources_",
"=_",
"[_",
"'",
"GP",
"y",
"/",
"kern",
"/",
"src",
"/",
"core",
"gion",
"alize",
"\\u",
"cython",
".",
"c",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"include",
"\\u",
"dirs_",
"=_",
"[_",
"np_",
"._",
"get",
"\\u",
"include_",
"(_",
")_",
",_",
"'.'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"compile",
"\\u",
"args_",
"=_",
"compile",
"\\u",
"flags_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Extension_",
"(_",
"name_",
"=_",
"'",
"GP",
"y",
".",
"model",
"s",
".",
"state",
"\\u",
"space",
"\\u",
"cython",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sources_",
"=_",
"[_",
"'",
"GP",
"y",
"/",
"model",
"s",
"/",
"state",
"\\u",
"space",
"\\u",
"cython",
".",
"c",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"include",
"\\u",
"dirs_",
"=_",
"[_",
"np_",
"._",
"get",
"\\u",
"include_",
"(_",
")_",
",_",
"'.'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"\\u",
"compile",
"\\u",
"args_",
"=_",
"compile",
"\\u",
"flags_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"setup_",
"(_",
"name_",
"=_",
"'",
"GP",
"y",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"version_",
"=_",
"\\u\\u",
"version\\u\\u_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"author_",
"=_",
"read",
"\\u",
"to",
"\\u",
"rst_",
"(_",
"'",
"AUTHOR",
"S",
".",
"txt",
"'_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"author",
"\\u",
"email_",
"=_",
"\"",
"gp",
"y",
".",
"author",
"s",
"@",
"gma",
"il",
".",
"com",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"description_",
"=_",
"(_",
"\"",
"The",
" ",
"Gaussian",
" ",
"Process",
" ",
"Toolb",
"ox",
"\"_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"license_",
"=_",
"\"",
"BS",
"D",
" ",
"3",
"-",
"clause",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"keywords_",
"=_",
"\"",
"machine",
"-",
"learn",
"ing",
" ",
"gauss",
"ian",
"-",
"process",
"es",
" ",
"kernels",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"url_",
"=_",
"\"",
"http",
"://",
"she",
"ffi",
"eld",
"ml",
".",
"git",
"hub",
".",
"com",
"/",
"GP",
"y",
"/\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"ext",
"\\u",
"modules_",
"=_",
"ext",
"\\u",
"mods_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"packages_",
"=_",
"[_",
"\"",
"GP",
"y",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"core",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"core",
".",
"parameter",
"izatio",
"n",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"kern",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"kern",
".",
"src",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"kern",
".",
"src",
".",
"psi",
"\\u",
"comp",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"model",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"infer",
"ence",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"infer",
"ence",
".",
"optimization",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"infer",
"ence",
".",
"mcmc",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"infer",
"ence",
".",
"latent",
"\\u",
"function",
"\\u",
"infer",
"ence",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"likelihood",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"mapping",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"example",
"s",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"testi",
"ng",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"util",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"plott",
"ing",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"plott",
"ing",
".",
"gp",
"y",
"\\u",
"plot",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"plott",
"ing",
".",
"mat",
"plot",
"\\u",
"dep",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"plott",
"ing",
".",
"mat",
"plot",
"\\u",
"dep",
".",
"controlle",
"rs",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"GP",
"y",
".",
"plott",
"ing",
".",
"plotly",
"\\u",
"dep",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"package",
"\\u",
"dir_",
"=_",
"{_",
"'",
"GP",
"y",
"'_",
":_",
"'",
"GP",
"y",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"package",
"\\u",
"data",
" ",
"=",
" ",
"{",
"'",
"GP",
"y",
"':",
" ",
"['",
"default",
"s",
".",
"cfg",
"',",
" ",
"'",
"installation",
".",
"cfg",
"',",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"'",
"util",
"/",
"data\\u",
"resource",
"s",
".",
"json",
"',",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"'",
"util",
"/",
"foot",
"bal",
"l\\u",
"team",
"s",
".",
"json",
"',",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"'",
"testi",
"ng",
"/",
"plott",
"ing",
"\\u",
"tests",
"/",
"baseline",
"/*",
".",
"png",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"]},",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"data\\u",
"files",
"=[",
"('",
"GP",
"y",
"/",
"testi",
"ng",
"/",
"plott",
"ing",
"\\u",
"tests",
"/",
"baseline",
"',",
" ",
"'",
"testi",
"ng",
"/",
"plott",
"ing",
"\\u",
"tests",
"/",
"baseline",
"/*",
".",
"png",
"')",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"('",
"GP",
"y",
"/",
"testi",
"ng",
"/'",
",",
" ",
"'",
"GP",
"y",
"/",
"testi",
"ng",
"/",
"pickle",
"\\u",
"test",
".",
"pickle",
"')",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
" ",
"],",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"include",
"\\u",
"package",
"\\u",
"data_",
"=_",
"True_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"py",
"\\u",
"modules_",
"=_",
"[_",
"'",
"GP",
"y",
".\\u",
"\\u",
"init",
"\\u\\u'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"test\\u",
"suite_",
"=_",
"'",
"GP",
"y",
".",
"testi",
"ng",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"long",
"\\u",
"description_",
"=_",
"desc_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"install",
"\\u",
"requires_",
"=_",
"[_",
"'",
"nump",
"y",
">=",
"1.7",
"'_",
",_",
"'",
"sci",
"py",
">=",
"0.16",
"'_",
",_",
"'",
"si",
"x",
"'_",
",_",
"'",
"param",
"z",
">=",
"0.",
"5.2",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"extra",
"s",
"\\u",
"require_",
"=_",
"{_",
"'",
"docs",
"'_",
":_",
"[_",
"'",
"sphinx",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"option",
"al",
"'_",
":_",
"[_",
"'",
"mpi",
"4",
"py",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ipython",
">=",
"4.0",
".0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"plott",
"ing",
"'_",
":_",
"[_",
"'",
"mat",
"plotlib",
" ",
">=",
" ",
"1.3",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"plotly",
" ",
">=",
" ",
"1.8",
".6",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"notebook",
"'_",
":_",
"[_",
"'",
"jup",
"yte",
"r",
"\\u",
"client",
" ",
">=",
" ",
"4.0",
".6",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ipy",
"widget",
"s",
" ",
">=",
" ",
"4.0",
".3",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ipy",
"kernel",
" ",
">=",
" ",
"4.1",
".0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"notebook",
" ",
">=",
" ",
"4.0",
".5",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"classifiers_",
"=_",
"[_",
"'",
"License",
" ",
"::",
" ",
"OSI",
" ",
"Appro",
"ved",
" ",
"::",
" ",
"BS",
"D",
" ",
"License",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Nat",
"ural",
" ",
"Lang",
"ua",
"ge",
" ",
"::",
" ",
"Eng",
"lish",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Opera",
"ting",
" ",
"System",
" ",
"::",
" ",
"Mac",
"OS",
" ",
"::",
" ",
"Mac",
"OS",
" ",
"X",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Opera",
"ting",
" ",
"System",
" ",
"::",
" ",
"Micro",
"soft",
" ",
"::",
" ",
"Window",
"s",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Opera",
"ting",
" ",
"System",
" ",
"::",
" ",
"POSI",
"X",
" ",
"::",
" ",
"Lin",
"ux",
"'_",
",_",
"\\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.3",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Programm",
"ing",
" ",
"Lang",
"ua",
"ge",
" ",
"::",
" ",
"Pyth",
"on",
" ",
"::",
" ",
"3.4",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Programm",
"ing",
" ",
"Lang",
"ua",
"ge",
" ",
"::",
" ",
"Pyth",
"on",
" ",
"::",
" ",
"3.5",
"'_",
",_",
"\\u\\u\\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_",
"#",
" ",
"Check",
" ",
"config",
" ",
"files",
" ",
"and",
" ",
"settings",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"local",
"\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"abspath_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
",_",
"'",
"GP",
"y",
"'_",
",_",
"'",
"installation",
".",
"cfg",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"home_",
"=_",
"os_",
"._",
"getenv_",
"(_",
"'",
"HOM",
"E",
"'_",
")_",
"or_",
"os_",
"._",
"getenv_",
"(_",
"'",
"USER",
"PROFILE",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"user",
"\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"home_",
",_",
"'.",
"config",
"'_",
",_",
"'",
"GP",
"y",
"'_",
",_",
"'",
"user",
".",
"cfg",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"user",
"\\u",
"file_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Do",
"es",
" ",
"an",
" ",
"old",
" ",
"config",
" ",
"exist",
"?",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"old",
"\\u",
"user",
"\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"home_",
",_",
"'.",
"gp",
"y",
"\\u",
"user",
".",
"cfg",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"old",
"\\u",
"user",
"\\u",
"file_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Move",
" ",
"it",
" ",
"to",
" ",
"new",
" ",
"location",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"GP",
"y",
":",
" ",
"Foun",
"d",
" ",
"old",
" ",
"config",
" ",
"file",
",",
" ",
"movin",
"g",
" ",
"to",
" ",
"new",
" ",
"location",
" ",
"{}\"_",
"._",
"format_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"makedirs_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"os_",
"._",
"rename_",
"(_",
"old",
"\\u",
"user",
"\\u",
"file_",
",_",
"user",
"\\u",
"file_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"No",
" ",
"config",
" ",
"file",
" ",
"exist",
"s",
",",
" ",
"save",
" ",
"informati",
"ve",
" ",
"stub",
" ",
"to",
" ",
"user",
" ",
"config",
" ",
"folder",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"GP",
"y",
":",
" ",
"Sav",
"ing",
" ",
"user",
" ",
"configura",
"tion",
" ",
"file",
" ",
"to",
" ",
"{}\"_",
"._",
"format_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"makedirs_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"user",
"\\u",
"file_",
",_",
"'",
"w",
"'_",
")_",
"as_",
"f_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"with_",
"open_",
"(_",
"local",
"\\u",
"file_",
",_",
"'",
"r",
"'_",
")_",
"as_",
"l_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"tmp_",
"=_",
"l_",
"._",
"read_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"f_",
"._",
"write_",
"(_",
"tmp_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"GP",
"y",
":",
" ",
"User",
" ",
"configura",
"tion",
" ",
"file",
" ",
"at",
" ",
"location",
" ",
"{}\"_",
"._",
"format_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
"\\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_",
"(_",
"\"",
"GP",
"y",
":",
" ",
"Cou",
"ld",
" ",
"not",
" ",
"write",
" ",
"user",
" ",
"configura",
"tion",
" ",
"file",
" ",
"{}\"_",
"._",
"format_",
"(_",
"user",
"\\u",
"file_",
")_",
")_",
"\\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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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,
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
]
|
Unused import | zbyte64/django-dockit/dockit/datataps.py | [
{
"content": "from optparse import OptionParser\nfrom collections import deque\n\nfrom django.core.files import File\n\nfrom dockit import schema\nfrom dockit.schema.loading import get_documents, get_document\nfrom dockit.core.serializers.python import Serializer, Deserializer\n\nfrom datatap.loading import register_datatap\nfrom datatap.datataps.base import DataTap\n\n\n\n\nregister_datatap('Document', DocumentDataTap)\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class FileAwareSerializer(Serializer):",
"metadata": "root.FileAwareSerializer",
"header": "['module', '___EOS___']",
"index": 13
},
{
"content": " def start_object(self, obj):\n #TODO set files in self._current\n return super(FileAwareSerializer, self).start_object(obj)",
"metadata": "root.FileAwareSerializer.start_object",
"header": "['class', 'FileAwareSerializer', '(', 'Serializer', ')', ':', '___EOS___']",
"index": 14
},
{
"content": "class DocumentDataTap(DataTap):\n '''\n Reads and writes from DocKit's Collections\n '''\n \n \n \n \n \n \n ",
"metadata": "root.DocumentDataTap",
"header": "['module', '___EOS___']",
"index": 18
},
{
"content": " def __init__(self, instream=None, track_uncommitted=True, **kwargs):\n #this is so we can view objects and then easily commit\n if track_uncommitted:\n self.deserialized_objects = deque()\n else:\n self.deserialized_objects = None\n super(DocumentDataTap, self).__init__(instream, **kwargs)",
"metadata": "root.DocumentDataTap.__init__",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 22
},
{
"content": " def get_domain(self):\n if self.instream is None: #no instream, I guess we write?\n return 'deserialized_document'\n if isinstance(self.instream, (list, tuple)):\n return 'primitive'\n if self.instream.domain == 'primitive':\n return 'deserialized_document'",
"metadata": "root.DocumentDataTap.get_domain",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 30
},
{
"content": " def get_instance_stream(self, instream):\n for source in instream:\n try:\n is_doc = issubclass(source, schema.Document)\n is_instance = False\n except TypeError:\n is_doc = False\n is_instance = isinstance(source, schema.Document)\n \n if is_doc:\n queryset = source.objects.all().iterator()\n elif is_instance:\n queryset = [source]\n else:\n if hasattr(source, 'iterator'):\n queryset = source.iterator()\n else:\n queryset = source\n for item in queryset:\n yield item",
"metadata": "root.DocumentDataTap.get_instance_stream",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 38
},
{
"content": " def get_primitive_stream(self, instream):\n '''\n Convert various model sources to primitive objects\n '''\n serializer = FileAwareSerializer()\n instances = self.get_instance_stream(instream)\n return serializer.serialize(instances)",
"metadata": "root.DocumentDataTap.get_primitive_stream",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 59
},
{
"content": " def get_deserialized_document_stream(self, instream):\n '''\n Convert primitive objects to deserialized document instances\n '''\n for deserialized_object in Deserializer(instream):\n if self.deserialized_objects is not None:\n self.deserialized_objects.append(deserialized_object)\n yield deserialized_object",
"metadata": "root.DocumentDataTap.get_deserialized_document_stream",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 67
},
{
"content": " def get_document_stream(self, instream):\n '''\n Convert primitive objects to saved document instances\n '''\n for item in self.get_deserialized_document_stream(instream):\n item.save()\n yield item",
"metadata": "root.DocumentDataTap.get_document_stream",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 76
},
{
"content": " def commit(self):\n while self.deserialized_objects:\n instance = self.deserialized_objects.popleft()\n instance.save()\n self.deserialized_objects = None\n for instance in self:\n instance.save()",
"metadata": "root.DocumentDataTap.commit",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 84
},
{
"content": " @classmethod\n def load_from_command_line(cls, arglist, instream=None):\n '''\n usage::\n \n manage.py datatap Document [<app label>, ...] [<collection name>, ...]\n '''\n parser = OptionParser(option_list=cls.command_option_list)\n options, args = parser.parse_args(arglist)\n document_sources = list()\n for arg in args: #list of apps and collection names\n if '.' in arg:\n document_sources.append(get_document(*arg.rsplit(\".\", 1)))\n else:\n #get docs from appname\n document_sources.extend(get_documents(arg))\n return cls(instream=document_sources, **options.__dict__)",
"metadata": "root.DocumentDataTap.load_from_command_line",
"header": "['class', 'DocumentDataTap', '(', 'DataTap', ')', ':', '___EOS___']",
"index": 92
}
]
| [
{
"span": "from django.core.files import File",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 34
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"from_",
"optparse_",
"import_",
"Optio",
"n",
"Parser_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"collections_",
"import_",
"deque_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"django_",
"._",
"core_",
"._",
"files_",
"import_",
"File_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"dock",
"it_",
"import_",
"schema_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"dock",
"it_",
"._",
"schema_",
"._",
"loading_",
"import_",
"get",
"\\u",
"documents_",
",_",
"get",
"\\u",
"document_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"dock",
"it_",
"._",
"core_",
"._",
"serializers_",
"._",
"python_",
"import_",
"Serializer_",
",_",
"Deserializ",
"er_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"datata",
"p_",
"._",
"loading_",
"import_",
"register",
"\\u",
"datata",
"p_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"datata",
"p_",
"._",
"datata",
"ps_",
"._",
"base_",
"import_",
"Data",
"Tap",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"register",
"\\u",
"datata",
"p_",
"(_",
"'",
"Document",
"'_",
",_",
"Document",
"Data",
"Tap",
"_",
")_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"File",
"Awa",
"re",
"Serializer_",
"(_",
"Serializer_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"File",
"Awa",
"re",
"Serializer_",
"(_",
"Serializer_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"start",
"\\u",
"object_",
"(_",
"self_",
",_",
"obj_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"TOD",
"O",
" ",
"set",
" ",
"files",
" ",
"in",
" ",
"self",
".\\u",
"current_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"super_",
"(_",
"File",
"Awa",
"re",
"Serializer_",
",_",
"self_",
")_",
"._",
"start",
"\\u",
"object_",
"(_",
"obj_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Read",
"s",
" ",
"and",
" ",
"writes",
" ",
"from",
" ",
"Doc",
"Kit",
"'",
"s",
" ",
"Collections",
"\\",
"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_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"instr",
"eam_",
"=_",
"None_",
",_",
"track",
"\\u",
"uncomm",
"itte",
"d_",
"=_",
"True_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"this",
" ",
"is",
" ",
"so",
" ",
"we",
" ",
"can",
" ",
"view",
" ",
"object",
"s",
" ",
"and",
" ",
"then",
" ",
"easi",
"ly",
" ",
"commit_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"track",
"\\u",
"uncomm",
"itte",
"d_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"deserialized",
"\\u",
"objects_",
"=_",
"deque_",
"(_",
")_",
"\\u\\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_",
"._",
"deserialized",
"\\u",
"objects_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"super_",
"(_",
"Document",
"Data",
"Tap",
"_",
",_",
"self_",
")_",
"._",
"\\u\\u",
"init\\u\\u_",
"(_",
"instr",
"eam_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"domain_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"self_",
"._",
"instr",
"eam_",
"is_",
"None_",
":_",
"#",
"no",
" ",
"instr",
"eam",
",",
" ",
"I",
" ",
"guess",
" ",
"we",
" ",
"write",
"?",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'",
"deserialized",
"\\u",
"document",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"self_",
"._",
"instr",
"eam_",
",_",
"(_",
"list_",
",_",
"tuple_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'",
"primi",
"tiv",
"e",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"instr",
"eam_",
"._",
"domain_",
"==_",
"'",
"primi",
"tiv",
"e",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"'",
"deserialized",
"\\u",
"document",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\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",
"instance",
"\\u",
"stream_",
"(_",
"self_",
",_",
"instr",
"eam_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"source_",
"in_",
"instr",
"eam_",
":_",
"\\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 ",
" _",
"is",
"\\u",
"doc_",
"=_",
"issubclass_",
"(_",
"source_",
",_",
"schema_",
"._",
"Document_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"is",
"\\u",
"instance_",
"=_",
"False_",
"\\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 ",
" _",
"is",
"\\u",
"doc_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"is",
"\\u",
"instance_",
"=_",
"isinstance_",
"(_",
"source_",
",_",
"schema_",
"._",
"Document_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"is",
"\\u",
"doc_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"queryset_",
"=_",
"source_",
"._",
"objects_",
"._",
"all_",
"(_",
")_",
"._",
"iterator_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"is",
"\\u",
"instance_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"queryset_",
"=_",
"[_",
"source_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"source_",
",_",
"'",
"iter",
"ator",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"queryset_",
"=_",
"source_",
"._",
"iterator_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"queryset_",
"=_",
"source_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"item_",
"in_",
"queryset_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"yield_",
"item_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\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",
"\\u",
"primi",
"tiv",
"e\\u",
"stream_",
"(_",
"self_",
",_",
"instr",
"eam_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Convert",
" ",
"vari",
"ous",
" ",
"model",
" ",
"source",
"s",
" ",
"to",
" ",
"primi",
"tiv",
"e",
" ",
"object",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"serializer_",
"=_",
"File",
"Awa",
"re",
"Serializer_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"instances_",
"=_",
"self_",
"._",
"get",
"\\u",
"instance",
"\\u",
"stream_",
"(_",
"instr",
"eam_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"serializer_",
"._",
"serialize_",
"(_",
"instances_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"deserialized",
"\\u",
"document",
"\\u",
"stream_",
"(_",
"self_",
",_",
"instr",
"eam_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Convert",
" ",
"primi",
"tiv",
"e",
" ",
"object",
"s",
" ",
"to",
" ",
"deserialized",
" ",
"document",
" ",
"instance",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"deserialized",
"\\u",
"object_",
"in_",
"Deserializ",
"er_",
"(_",
"instr",
"eam_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"self_",
"._",
"deserialized",
"\\u",
"objects_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"deserialized",
"\\u",
"objects_",
"._",
"append_",
"(_",
"deserialized",
"\\u",
"object_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"yield_",
"deserialized",
"\\u",
"object_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\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",
"document",
"\\u",
"stream_",
"(_",
"self_",
",_",
"instr",
"eam_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Convert",
" ",
"primi",
"tiv",
"e",
" ",
"object",
"s",
" ",
"to",
" ",
"saved",
" ",
"document",
" ",
"instance",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"item_",
"in_",
"self_",
"._",
"get",
"\\u",
"deserialized",
"\\u",
"document",
"\\u",
"stream_",
"(_",
"instr",
"eam_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"item_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"item_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\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_",
"commit_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"while_",
"self_",
"._",
"deserialized",
"\\u",
"objects_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"instance_",
"=_",
"self_",
"._",
"deserialized",
"\\u",
"objects_",
"._",
"popleft_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"instance_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"deserialized",
"\\u",
"objects_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"instance_",
"in_",
"self_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"instance_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Document",
"Data",
"Tap",
"_",
"(_",
"Data",
"Tap",
"_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"classmethod_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"load",
"\\u",
"from",
"\\u",
"command",
"\\u",
"line_",
"(_",
"cls_",
",_",
"arglist_",
",_",
"instr",
"eam_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"usage",
"::",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"manage",
".",
"py",
" ",
"datata",
"p",
" ",
"Document",
" ",
"[",
"<",
"app",
" ",
"label",
">",
",",
" ",
"...]",
" ",
"[",
"<",
"collection",
" ",
"name",
">",
",",
" ",
"...]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"=_",
"Optio",
"n",
"Parser_",
"(_",
"option",
"\\u",
"list_",
"=_",
"cls_",
"._",
"command",
"\\u",
"option",
"\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"options_",
",_",
"args_",
"=_",
"parser_",
"._",
"parse",
"\\u",
"args_",
"(_",
"arglist_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"document",
"\\u",
"sources_",
"=_",
"list_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"arg_",
"in_",
"args_",
":_",
"#",
"list",
" ",
"of",
" ",
"apps",
" ",
"and",
" ",
"collection",
" ",
"names_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"'.'_",
"in_",
"arg_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"document",
"\\u",
"sources_",
"._",
"append_",
"(_",
"get",
"\\u",
"document_",
"(_",
"*_",
"arg_",
"._",
"rsplit_",
"(_",
"\".\"_",
",_",
"1_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"get",
" ",
"docs",
" ",
"from",
" ",
"appname_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"document",
"\\u",
"sources_",
"._",
"extend_",
"(_",
"get",
"\\u",
"documents_",
"(_",
"arg_",
")_",
")_",
"\\u\\u\\uNEW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or/twitterapi/twitter.py | [
{
"content": " def GetCachedTime(self, key):\n entry = _DbCacheEntry.get_by_key_name(key)\n if entry:\n try:\n # All cached data must be valid JSON, and if we mistakenly cache\n # error response, we should ignore them\n data = simplejson.loads(entry.value)\n if isinstance(data, dict) and data.has_key('error'):\n return None\n except:\n return None\n\n return time.mktime(entry.timestamp.timetuple())\n else:\n return None\n\n return None",
"metadata": "root._DbCache.GetCachedTime",
"header": "['class', '_DbCache', '(', 'object', ')', ':', '___EOS___']",
"index": 2224
}
]
| [
{
"span": "return None",
"start_line": 2240,
"start_column": 4,
"end_line": 2240,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Unrea",
"chab",
"le_",
"code_",
"[SEP]_",
"class_",
"\\u",
"Db",
"Cache_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"Get",
"Cache",
"d",
"Time_",
"(_",
"self_",
",_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"entry_",
"=_",
"\\u",
"Db",
"Cache",
"Entry_",
"._",
"get",
"\\u",
"by",
"\\u",
"key",
"\\u",
"name_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"entry_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"All",
" ",
"cache",
"d",
" ",
"data",
" ",
"must",
" ",
"be",
" ",
"valid",
" ",
"JSO",
"N",
",",
" ",
"and",
" ",
"if",
" ",
"we",
" ",
"mist",
"ake",
"nl",
"y",
" ",
"cache_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"error",
" ",
"response",
",",
" ",
"we",
" ",
"shou",
"ld",
" ",
"ignore",
" ",
"them",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"simplejson_",
"._",
"loads_",
"(_",
"entry_",
"._",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"data_",
",_",
"dict_",
")_",
"and_",
"data_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"error",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"time_",
"._",
"mktime_",
"(_",
"entry_",
"._",
"timestamp_",
"._",
"timetuple_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"None_"
]
| [
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,
0,
1,
1
]
|
Unused import | pysb/pysb/pysb/examples/earm_1_3.py | [
{
"content": "\"\"\"EARM 1.3 (extrinsic apoptosis reaction model)\n\nGaudet S, Spencer SL, Chen WW, Sorger PK (2012) Exploring the Contextual\nSensitivity of Factors that Determine Cell-to-Cell Variability in\nReceptor-Mediated Apoptosis. PLoS Comput Biol 8(4): e1002482.\ndoi:10.1371/journal.pcbi.1002482\n\nhttp://www.ploscompbiol.org/article/info:doi/10.1371/journal.pcbi.1002482\n\"\"\"\n\n# This model is mostly an extension to EARM 1.0 from Albeck et al. Instead of\n# duplicating the body of that model here, we'll start this model off as a copy\n# of that one then modify and add components as necessary.\n\nfrom __future__ import print_function\nimport re\nfrom pysb import *\nimport pysb.bng\nimport pysb.examples.earm_1_0\n\n# Start from EARM 1.0 as a base\n# ==========\nModel(base=pysb.examples.earm_1_0.model)\nAnnotation(model, 'http://identifiers.org/doi/10.1371/journal.pcbi.1002482',\n 'isDescribedBy')\n\n# Rename all instances of Bcl2c to Mcl1, which was determined as a more accurate\n# description of that monomer based on its role in the model\n# ==========\n\n# monomer\nBcl2c.rename('Mcl1')\n# initial condition parameter\nBcl2c_0.rename('Mcl1_0')\n# rule\ninhibit_tBid_by_Bcl2c.rename('inhibit_tBid_by_Mcl1')\n\n# Add one novel reaction\n# ==========\n\n# degrade DISC\nParameter('kf31', 0.001)\nRule('DISC_deg', DISC(b=None) >> L(b=None) + pR(b=None), kf31)\n# NOTE: In the original model this is a reversible reaction with kr31 as its\n# reverse rate constant, but kr31 was set to 0. This was ostensibly done so all\n# reactions had the same symmetric form, but I see no reason not to make it\n# irreversible here and eliminate kr31. -JLM\n\n# Change some initial condition values\n# ==========\n\npR_0.value = 1000\nflip_0.value = 2000\npC8_0.value = 10000\nBid_0.value = 60000\nBax_0.value = 80000\nBcl2_0.value = 30000\n\n# Change some rate constants\n# ==========\n\nv = 0.01\n\nkr1.value = 1e-6\nkc1.value = 1e-2\nkf3.value = 1e-7\nkf6.value = 1e-7\nkf7.value = 1e-7\nkr9.value = 0.001\nkc9.value = 20\nkr13.value = 1\nkf14.value = 1e-6 / v\nkf15.value = 1e-6 * 2 / v\nkf16.value = 1e-6 / v\nkf17.value = 1e-6 * 2 / v\nkf18.value = 1e-6 / v\nkf19.value = 1e-6 / v\nkf20.value = 2e-6 / v\nkf21.value = 2e-6 / v\nkf22.value = 1\nkf26.value = 1\n\n# Add synthesis and degradation rules and parameters\n# ==========\n\n# generate species list and make a copy\npysb.bng.generate_equations(model)\nall_species = list(model.species)\nmodel.reset_equations()\n\n\n\n# almost all degradation rates use this one value\nkdeg_generic = 2.9e-6\n# and these are the three exceptions\nParameter('kdeg_Mcl1', 0.0001)\nParameter('kdeg_AMito', 0.0001)\nParameter('kdeg_C3_U', 0)\n# fraction by which synthesis rates should be scaled (to mimic the effects of\n# treating HeLa cells wth 2.5 ug/ml of cycloheximide as per Table S2, Note 2)\nsyn_base = 0.15\n# synthesis rates are all syn_base*kdeg*IC, except for L which is 0\nParameter('ks_L', 0)\n\n# Even though the degradation of AMito is counted as a degradation reaction, it\n# is different from the others in that the reactant species is not destroyed but\n# rather converted to another species. So we have to declare this one\n# explicitly.\nRule('AMito_deg', AMito(b=None) >> Mito(b=None), kdeg_AMito)\n\n# loop over all species and create associated synthesis and degradation rates\n# and reactions\nfor species in all_species:\n species_name = '_'.join(mp.monomer.name for mp in species.monomer_patterns)\n ks_name = 'ks_' + species_name\n kdeg_name = 'kdeg_' + species_name\n syn_rule_name = species_name + '_syn'\n deg_rule_name = species_name + '_deg'\n ic_name = species_name + '_0'\n ks = model.parameters.get(ks_name)\n kdeg = model.parameters.get(kdeg_name)\n syn_rule = model.rules.get(syn_rule_name)\n deg_rule = model.rules.get(deg_rule_name)\n ic = model.parameters.get(ic_name)\n if kdeg is None:\n kdeg = Parameter(kdeg_name, kdeg_generic)\n if ks is None:\n ks_value = 0\n if ic is not None:\n ks_value = syn_base * kdeg.value * ic.value\n ks = Parameter(ks_name, ks_value)\n if syn_rule is None:\n synthesize(syn_rule_name, species, ks)\n if deg_rule is None:\n degrade(deg_rule_name, species, kdeg)\n\n\n# ========================================\n\n\n\n\n\nif __name__ == '__main__':\n print(__doc__, \"\\n\", model)\n print(\"\"\"\nInitial species concentrations and synthesis/degradation rates\n==========\n(compare to supporting text S3, table S2 from Gaudet et al.,\nhowever note that the numbering and ordering is different.)\"\"\")\n show_species()\n print(\"\\n\")\n\n print(\"\"\"\nKinetic rate parameters\n==========\n(compare to supporting text S3, table S4 from Gaudet et al.,\nhowever note that kf14-kf21 are off by a factor of 'v' (%g) as\nthis volume scaling factor has been moved from the ODEs to the\nrate values in this implementation)\n\"\"\" % v)\n show_rates()\n print(\"\"\"\n\nNOTE: This model code is designed to be imported and programatically\nmanipulated, not executed directly. The above output is merely a\ndiagnostic aid.\"\"\")\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def synthesize(name, species, ks):\n \"\"\"Synthesize species with rate ks\"\"\"\n Rule(name, None >> species, ks)",
"metadata": "root.synthesize",
"header": "['module', '___EOS___']",
"index": 90
},
{
"content": "def degrade(name, species, kdeg):\n \"\"\"Degrade species with rate kdeg\"\"\"\n Rule(name, species >> None, kdeg)",
"metadata": "root.degrade",
"header": "['module', '___EOS___']",
"index": 94
},
{
"content": "def show_species():\n \"\"\"Print a table of species like Table S2\"\"\"\n print(' | %-12s %8s %20s %10s' %\n ('species', 'initial', 'synth rate', 'deg rate'))\n print('-' * (5 + 12 + 1 + 8 + 1 + 20 + 1 + 10))\n for i, species in enumerate(all_species, 1):\n mp_names = [mp.monomer.name for mp in species.monomer_patterns]\n name = '_'.join(mp_names)\n display_name = ':'.join(mp_names)\n ks = model.parameters.get('ks_' + name)\n kdeg = model.parameters.get('kdeg_' + name)\n ic = model.parameters.get(name + '_0')\n if ic is not None:\n ic_value = ic.value\n else:\n ic_value = 0\n if ks.value != 0 and kdeg.value != 0:\n ic_calc = round(ks.value/kdeg.value/syn_base)\n ks_expr = '%4.2f*kdeg*%7d' % (syn_base, ic_calc)\n else:\n ks_expr = '0'\n values = (i, display_name, ic_value, ks_expr, kdeg.value)\n print('%2d | %-12s %8d %20s %10g' % values)",
"metadata": "root.show_species",
"header": "['module', '___EOS___']",
"index": 146
},
{
"content": "def show_rates():\n \"\"\"Print a table of rate parameters like Table S4\"\"\"\n # FIXME kf14-kf21 need to be un-scaled by v to make the table look right\n print((\"%-20s \" * 3) % ('forward', 'reverse', 'catalytic'))\n print('-' * (9 + 11 + 7) * 3)\n for i in list(range(1,29)) + [31]:\n for t in ('f', 'r', 'c'):\n n = 'k%s%d' % (t,i)\n p = model.parameters.get(n)\n if p is not None:\n print(\"%-9s%11g \" % (p.name, p.value), end=' ')\n print()",
"metadata": "root.show_rates",
"header": "['module', '___EOS___']",
"index": 170
}
]
| [
{
"span": "import re",
"start_line": 15,
"start_column": 0,
"end_line": 15,
"end_column": 9
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\"\"\"",
"EAR",
"M",
" ",
"1.3",
" ",
"(",
"extr",
"insi",
"c",
" ",
"apo",
"pto",
"sis",
" ",
"reacti",
"on",
" ",
"model",
")",
"\\",
"10",
";",
"\\",
"10",
";",
"Gau",
"det",
" ",
"S",
",",
" ",
"Spe",
"nce",
"r",
" ",
"SL",
",",
" ",
"Chen",
" ",
"WW",
",",
" ",
"So",
"rge",
"r",
" ",
"PK",
" ",
"(",
"2012",
")",
" ",
"Explo",
"ring",
" ",
"the",
" ",
"Context",
"ual",
"\\",
"10",
";",
"Sensitiv",
"it",
"y",
" ",
"of",
" ",
"Factor",
"s",
" ",
"tha",
"t",
" ",
"Det",
"erm",
"ine",
" ",
"Cel",
"l",
"-",
"to",
"-",
"Cel",
"l",
" ",
"Varia",
"bilit",
"y",
" ",
"in",
"\\",
"10",
";",
"Rece",
"pto",
"r",
"-",
"Media",
"ted",
" ",
"Ap",
"opt",
"osi",
"s",
".",
" ",
"PL",
"o",
"S",
" ",
"Comp",
"ut",
" ",
"Bio",
"l",
" ",
"8",
"(",
"4",
"):",
" ",
"e1",
"002",
"482",
".",
"\\",
"10",
";",
"doi",
":",
"10.1",
"371",
"/",
"journal",
".",
"pc",
"bi",
".1",
"002",
"482",
"\\",
"10",
";",
"\\",
"10",
";",
"http",
"://",
"www",
".",
"plo",
"sco",
"mp",
"biol",
".",
"org",
"/",
"article",
"/",
"info",
":",
"doi",
"/",
"10.1",
"371",
"/",
"journal",
".",
"pc",
"bi",
".1",
"002",
"482",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"model",
" ",
"is",
" ",
"most",
"ly",
" ",
"an",
" ",
"extensi",
"on",
" ",
"to",
" ",
"EAR",
"M",
" ",
"1.0",
" ",
"from",
" ",
"Alb",
"eck",
" ",
"et",
" ",
"al",
".",
" ",
"Ins",
"tea",
"d",
" ",
"of_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"duplicat",
"ing",
" ",
"the",
" ",
"body",
" ",
"of",
" ",
"tha",
"t",
" ",
"model",
" ",
"here",
",",
" ",
"we",
"'",
"ll",
" ",
"start",
" ",
"this",
" ",
"model",
" ",
"off",
" ",
"as",
" ",
"a",
" ",
"copy_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"of",
" ",
"tha",
"t",
" ",
"one",
" ",
"then",
" ",
"modif",
"y",
" ",
"and",
" ",
"add",
" ",
"component",
"s",
" ",
"as",
" ",
"necessar",
"y",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"\\u\\u",
"future\\u\\u_",
"import_",
"print",
"\\u",
"function_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"pys",
"b_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"pys",
"b_",
"._",
"bn",
"g_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"pys",
"b_",
"._",
"examples_",
"._",
"ear",
"m",
"\\u",
"1",
"\\u",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Start",
" ",
"from",
" ",
"EAR",
"M",
" ",
"1.0",
" ",
"as",
" ",
"a",
" ",
"base_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=========",
"=_",
"\\u\\u\\uNL\\u\\u\\u_",
"Model_",
"(_",
"base_",
"=_",
"pys",
"b_",
"._",
"examples_",
"._",
"ear",
"m",
"\\u",
"1",
"\\u",
"0_",
"._",
"model_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Annotation_",
"(_",
"model_",
",_",
"'",
"http",
"://",
"identifi",
"ers",
".",
"org",
"/",
"doi",
"/",
"10.1",
"371",
"/",
"journal",
".",
"pc",
"bi",
".1",
"002",
"482",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"is",
"Describe",
"d",
"By",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Rename",
" ",
"all",
" ",
"instance",
"s",
" ",
"of",
" ",
"Bc",
"l2",
"c",
" ",
"to",
" ",
"Mc",
"l1",
",",
" ",
"whi",
"ch",
" ",
"was",
" ",
"dete",
"rmin",
"ed",
" ",
"as",
" ",
"a",
" ",
"more",
" ",
"accurate",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"description",
" ",
"of",
" ",
"tha",
"t",
" ",
"monom",
"er",
" ",
"based",
" ",
"on",
" ",
"its",
" ",
"role",
" ",
"in",
" ",
"the",
" ",
"model_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=========",
"=_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"monom",
"er_",
"\\u\\u\\uNL\\u\\u\\u_",
"Bc",
"l2",
"c_",
"._",
"rename_",
"(_",
"'",
"Mc",
"l1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"initial",
" ",
"condition",
" ",
"parameter_",
"\\u\\u\\uNL\\u\\u\\u_",
"Bc",
"l2",
"c\\u",
"0_",
"._",
"rename_",
"(_",
"'",
"Mc",
"l1",
"\\u",
"0",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"rule_",
"\\u\\u\\uNL\\u\\u\\u_",
"inhibit",
"\\u",
"t",
"Bid",
"\\u",
"by",
"\\u",
"Bc",
"l2",
"c_",
"._",
"rename_",
"(_",
"'",
"inhibit",
"\\u",
"t",
"Bid",
"\\u",
"by",
"\\u",
"Mc",
"l1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Add",
" ",
"one",
" ",
"novel",
" ",
"reaction_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=========",
"=_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"degr",
"ade",
" ",
"DISC",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"Parameter_",
"(_",
"'",
"kf",
"3",
"1",
"'_",
",_",
"0.001_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Rule_",
"(_",
"'",
"DISC",
"\\u",
"deg",
"'_",
",_",
"DISC",
"_",
"(_",
"b_",
"=_",
"None_",
")_",
">>_",
"L_",
"(_",
"b_",
"=_",
"None_",
")_",
"+_",
"p",
"R_",
"(_",
"b_",
"=_",
"None_",
")_",
",_",
"kf",
"31_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"NOTE",
":",
" ",
"In",
" ",
"the",
" ",
"original",
" ",
"model",
" ",
"this",
" ",
"is",
" ",
"a",
" ",
"reversi",
"ble",
" ",
"reacti",
"on",
" ",
"with",
" ",
"kr",
"3",
"1",
" ",
"as",
" ",
"its_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"reverse",
" ",
"rate",
" ",
"constant",
",",
" ",
"but",
" ",
"kr",
"3",
"1",
" ",
"was",
" ",
"set",
" ",
"to",
" ",
"0.",
" ",
"Thi",
"s",
" ",
"was",
" ",
"ost",
"ensi",
"bly",
" ",
"don",
"e",
" ",
"so",
" ",
"all_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"reacti",
"ons",
" ",
"had",
" ",
"the",
" ",
"same",
" ",
"symmetric",
" ",
"form",
",",
" ",
"but",
" ",
"I",
" ",
"see",
" ",
"no",
" ",
"reason",
" ",
"not",
" ",
"to",
" ",
"make",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"irre",
"versi",
"ble",
" ",
"here",
" ",
"and",
" ",
"eliminat",
"e",
" ",
"kr",
"31.",
" ",
"-",
"JL",
"M_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Change",
" ",
"some",
" ",
"initial",
" ",
"condition",
" ",
"values_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=========",
"=_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"p",
"R",
"\\u",
"0_",
"._",
"value_",
"=_",
"1000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"flip",
"\\u",
"0_",
"._",
"value_",
"=_",
"2000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p",
"C8",
"\\u",
"0_",
"._",
"value_",
"=_",
"10000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Bid",
"\\u",
"0_",
"._",
"value_",
"=_",
"60000",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Ba",
"x",
"\\u",
"0_",
"._",
"value_",
"=_",
"80000",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Bc",
"l2",
"\\u",
"0_",
"._",
"value_",
"=_",
"30000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Change",
" ",
"some",
" ",
"rate",
" ",
"constants_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=========",
"=_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"v_",
"=_",
"0.01_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"kr",
"1_",
"._",
"value_",
"=_",
"1e-6_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kc",
"1_",
"._",
"value_",
"=_",
"1e-2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"3_",
"._",
"value_",
"=_",
"1e-",
"7_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"6_",
"._",
"value_",
"=_",
"1e-",
"7_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"7_",
"._",
"value_",
"=_",
"1e-",
"7_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kr",
"9_",
"._",
"value_",
"=_",
"0.001_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kc",
"9_",
"._",
"value_",
"=_",
"20_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kr",
"13_",
"._",
"value_",
"=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"14_",
"._",
"value_",
"=_",
"1e-6_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"15_",
"._",
"value_",
"=_",
"1e-6_",
"*_",
"2_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"16_",
"._",
"value_",
"=_",
"1e-6_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"17_",
"._",
"value_",
"=_",
"1e-6_",
"*_",
"2_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"18_",
"._",
"value_",
"=_",
"1e-6_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"19_",
"._",
"value_",
"=_",
"1e-6_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"20_",
"._",
"value_",
"=_",
"2e-",
"6_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"21_",
"._",
"value_",
"=_",
"2e-",
"6_",
"/_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"22_",
"._",
"value_",
"=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kf",
"26_",
"._",
"value_",
"=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Add",
" ",
"synthesi",
"s",
" ",
"and",
" ",
"degr",
"adat",
"ion",
" ",
"rule",
"s",
" ",
"and",
" ",
"parameters_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=========",
"=_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"generat",
"e",
" ",
"specie",
"s",
" ",
"list",
" ",
"and",
" ",
"make",
" ",
"a",
" ",
"copy_",
"\\u\\u\\uNL\\u\\u\\u_",
"pys",
"b_",
"._",
"bn",
"g_",
"._",
"generat",
"e\\u",
"equation",
"s_",
"(_",
"model_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"all",
"\\u",
"species_",
"=_",
"list_",
"(_",
"model_",
"._",
"species_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"model_",
"._",
"reset",
"\\u",
"equation",
"s_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"alm",
"ost",
" ",
"all",
" ",
"degr",
"adat",
"ion",
" ",
"rate",
"s",
" ",
"use",
" ",
"this",
" ",
"one",
" ",
"value_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"kde",
"g",
"\\u",
"generic_",
"=_",
"2.9",
"e-6_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"and",
" ",
"these",
" ",
"are",
" ",
"the",
" ",
"three",
" ",
"exceptions_",
"\\u\\u\\uNL\\u\\u\\u_",
"Parameter_",
"(_",
"'",
"kde",
"g",
"\\u",
"Mc",
"l1",
"'_",
",_",
"0.0001_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Parameter_",
"(_",
"'",
"kde",
"g",
"\\u",
"AM",
"ito",
"'_",
",_",
"0.0001_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Parameter_",
"(_",
"'",
"kde",
"g",
"\\u",
"C3",
"\\u",
"U",
"'_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"fract",
"ion",
" ",
"by",
" ",
"whi",
"ch",
" ",
"synthesi",
"s",
" ",
"rate",
"s",
" ",
"shou",
"ld",
" ",
"be",
" ",
"scale",
"d",
" ",
"(",
"to",
" ",
"mimic",
" ",
"the",
" ",
"effect",
"s",
" ",
"of_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"treat",
"ing",
" ",
"He",
"La",
" ",
"cells",
" ",
"wt",
"h",
" ",
"2.5",
" ",
"ug",
"/",
"ml",
" ",
"of",
" ",
"cycl",
"oh",
"exi",
"mid",
"e",
" ",
"as",
" ",
"per",
" ",
"Table",
" ",
"S2",
",",
" ",
"Not",
"e",
" ",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"syn",
"\\u",
"base_",
"=_",
"0.15_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"synthesi",
"s",
" ",
"rate",
"s",
" ",
"are",
" ",
"all",
" ",
"syn",
"\\u",
"base",
"*",
"kde",
"g",
"*",
"IC",
",",
" ",
"except",
" ",
"for",
" ",
"L",
" ",
"whi",
"ch",
" ",
"is",
" ",
"0_",
"\\u\\u\\uNL\\u\\u\\u_",
"Parameter_",
"(_",
"'",
"ks",
"\\u",
"L",
"'_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Even",
" ",
"tho",
"ugh",
" ",
"the",
" ",
"degr",
"adat",
"ion",
" ",
"of",
" ",
"AM",
"ito",
" ",
"is",
" ",
"counted",
" ",
"as",
" ",
"a",
" ",
"degr",
"adat",
"ion",
" ",
"reacti",
"on",
",",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"is",
" ",
"different",
" ",
"from",
" ",
"the",
" ",
"other",
"s",
" ",
"in",
" ",
"tha",
"t",
" ",
"the",
" ",
"reactant",
" ",
"specie",
"s",
" ",
"is",
" ",
"not",
" ",
"destroy",
"ed",
" ",
"but",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"rat",
"her",
" ",
"convert",
"ed",
" ",
"to",
" ",
"anot",
"her",
" ",
"specie",
"s",
".",
" ",
"So",
" ",
"we",
" ",
"have",
" ",
"to",
" ",
"declar",
"e",
" ",
"this",
" ",
"one_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"explicit",
"ly",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"Rule_",
"(_",
"'",
"AM",
"ito",
"\\u",
"deg",
"'_",
",_",
"AM",
"ito",
"_",
"(_",
"b_",
"=_",
"None_",
")_",
">>_",
"Mit",
"o_",
"(_",
"b_",
"=_",
"None_",
")_",
",_",
"kde",
"g",
"\\u",
"AM",
"ito",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"loop",
" ",
"over",
" ",
"all",
" ",
"specie",
"s",
" ",
"and",
" ",
"create",
" ",
"associate",
"d",
" ",
"synthesi",
"s",
" ",
"and",
" ",
"degr",
"adat",
"ion",
" ",
"rates_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"and",
" ",
"reactions_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"species_",
"in_",
"all",
"\\u",
"species_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"specie",
"s",
"\\u",
"name_",
"=_",
"'\\u'_",
"._",
"join_",
"(_",
"mp_",
"._",
"monom",
"er_",
"._",
"name_",
"for_",
"mp_",
"in_",
"species_",
"._",
"monom",
"er",
"\\u",
"patterns_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ks",
"\\u",
"name_",
"=_",
"'",
"ks",
"\\u'_",
"+_",
"specie",
"s",
"\\u",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kde",
"g",
"\\u",
"name_",
"=_",
"'",
"kde",
"g",
"\\u'_",
"+_",
"specie",
"s",
"\\u",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"syn",
"\\u",
"rule",
"\\u",
"name_",
"=_",
"specie",
"s",
"\\u",
"name_",
"+_",
"'\\u",
"syn",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deg",
"\\u",
"rule",
"\\u",
"name_",
"=_",
"specie",
"s",
"\\u",
"name_",
"+_",
"'\\u",
"deg",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ic",
"\\u",
"name_",
"=_",
"specie",
"s",
"\\u",
"name_",
"+_",
"'\\u",
"0",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ks_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"ks",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kde",
"g_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"kde",
"g",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"syn",
"\\u",
"rule_",
"=_",
"model_",
"._",
"rules_",
"._",
"get_",
"(_",
"syn",
"\\u",
"rule",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deg",
"\\u",
"rule_",
"=_",
"model_",
"._",
"rules_",
"._",
"get_",
"(_",
"deg",
"\\u",
"rule",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ic_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"ic",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"kde",
"g_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"kde",
"g_",
"=_",
"Parameter_",
"(_",
"kde",
"g",
"\\u",
"name_",
",_",
"kde",
"g",
"\\u",
"generic_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"ks_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ks",
"\\u",
"value_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"ic_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ks",
"\\u",
"value_",
"=_",
"syn",
"\\u",
"base_",
"*_",
"kde",
"g_",
"._",
"value_",
"*_",
"ic_",
"._",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"ks_",
"=_",
"Parameter_",
"(_",
"ks",
"\\u",
"name_",
",_",
"ks",
"\\u",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"syn",
"\\u",
"rule_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"synthesi",
"ze_",
"(_",
"syn",
"\\u",
"rule",
"\\u",
"name_",
",_",
"species_",
",_",
"ks_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"deg",
"\\u",
"rule_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"degr",
"ade_",
"(_",
"deg",
"\\u",
"rule",
"\\u",
"name_",
",_",
"species_",
",_",
"kde",
"g_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"==============",
"==============",
"============",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\\u\\u",
"name\\u\\u_",
"==_",
"'\\u",
"\\u",
"main",
"\\u\\u'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\\u\\u",
"doc\\u\\u_",
",_",
"\"\\\\",
"n",
"\"_",
",_",
"model_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"\"\"",
"\\",
"10",
";",
"Initial",
" ",
"specie",
"s",
" ",
"concentration",
"s",
" ",
"and",
" ",
"synthesi",
"s",
"/",
"degr",
"adat",
"ion",
" ",
"rate",
"s",
"\\",
"10",
";",
"=========",
"=",
"\\",
"10",
";",
"(",
"compare",
" ",
"to",
" ",
"support",
"ing",
" ",
"text",
" ",
"S",
"3",
",",
" ",
"table",
" ",
"S2",
" ",
"from",
" ",
"Gau",
"det",
" ",
"et",
" ",
"al",
".,",
"\\",
"10",
";",
"how",
"ever",
" ",
"note",
" ",
"tha",
"t",
" ",
"the",
" ",
"numbering",
" ",
"and",
" ",
"orderi",
"ng",
" ",
"is",
" ",
"different",
".)",
"\"\"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"show",
"\\u",
"species_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"\\\\",
"n",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"\"\"",
"\\",
"10",
";",
"Kine",
"tic",
" ",
"rate",
" ",
"parameter",
"s",
"\\",
"10",
";",
"=========",
"=",
"\\",
"10",
";",
"(",
"compare",
" ",
"to",
" ",
"support",
"ing",
" ",
"text",
" ",
"S",
"3",
",",
" ",
"table",
" ",
"S4",
" ",
"from",
" ",
"Gau",
"det",
" ",
"et",
" ",
"al",
".,",
"\\",
"10",
";",
"how",
"ever",
" ",
"note",
" ",
"tha",
"t",
" ",
"kf",
"14",
"-",
"kf",
"21",
" ",
"are",
" ",
"off",
" ",
"by",
" ",
"a",
" ",
"factor",
" ",
"of",
" ",
"'",
"v",
"'",
" ",
"(%",
"g",
")",
" ",
"as",
"\\",
"10",
";",
"this",
" ",
"volume",
" ",
"scal",
"ing",
" ",
"factor",
" ",
"has",
" ",
"bee",
"n",
" ",
"moved",
" ",
"from",
" ",
"the",
" ",
"ODE",
"s",
" ",
"to",
" ",
"the",
"\\",
"10",
";",
"rate",
" ",
"values",
" ",
"in",
" ",
"this",
" ",
"implementation",
")",
"\\",
"10",
";\"\"\"_",
"%_",
"v_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"show",
"\\u",
"rates_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"\"\"",
"\\",
"10",
";",
"\\",
"10",
";",
"NOTE",
":",
" ",
"Thi",
"s",
" ",
"model",
" ",
"code",
" ",
"is",
" ",
"design",
"ed",
" ",
"to",
" ",
"be",
" ",
"import",
"ed",
" ",
"and",
" ",
"programa",
"tica",
"ll",
"y",
"\\",
"10",
";",
"manipulate",
"d",
",",
" ",
"not",
" ",
"executed",
" ",
"direct",
"ly",
".",
" ",
"The",
" ",
"above",
" ",
"output",
" ",
"is",
" ",
"mer",
"el",
"y",
" ",
"a",
"\\",
"10",
";",
"diagnostic",
" ",
"aid",
".\"\"\"_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"synthesi",
"ze_",
"(_",
"name_",
",_",
"species_",
",_",
"ks_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Synthe",
"size",
" ",
"specie",
"s",
" ",
"with",
" ",
"rate",
" ",
"ks",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Rule_",
"(_",
"name_",
",_",
"None_",
">>_",
"species_",
",_",
"ks_",
")_",
"\\u\\u\\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_",
"degr",
"ade_",
"(_",
"name_",
",_",
"species_",
",_",
"kde",
"g_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Deg",
"rade",
" ",
"specie",
"s",
" ",
"with",
" ",
"rate",
" ",
"kde",
"g",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Rule_",
"(_",
"name_",
",_",
"species_",
">>_",
"None_",
",_",
"kde",
"g_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"show",
"\\u",
"species_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Print",
" ",
"a",
" ",
"table",
" ",
"of",
" ",
"specie",
"s",
" ",
"like",
" ",
"Table",
" ",
"S2",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"'",
" ",
" ",
" ",
"|",
" ",
"%",
"-1",
"2s",
" ",
"%",
"8s",
" ",
"%",
"20",
"s",
" ",
"%",
"10",
"s",
"'_",
"%_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"specie",
"s",
"'_",
",_",
"'",
"initial",
"'_",
",_",
"'",
"synth",
" ",
"rate",
"'_",
",_",
"'",
"deg",
" ",
"rate",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"'-'_",
"*_",
"(_",
"5_",
"+_",
"12_",
"+_",
"1_",
"+_",
"8_",
"+_",
"1_",
"+_",
"20_",
"+_",
"1_",
"+_",
"10_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
",_",
"species_",
"in_",
"enumerate_",
"(_",
"all",
"\\u",
"species_",
",_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"mp",
"\\u",
"names_",
"=_",
"[_",
"mp_",
"._",
"monom",
"er_",
"._",
"name_",
"for_",
"mp_",
"in_",
"species_",
"._",
"monom",
"er",
"\\u",
"patterns_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"'\\u'_",
"._",
"join_",
"(_",
"mp",
"\\u",
"names_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"display",
"\\u",
"name_",
"=_",
"':'_",
"._",
"join_",
"(_",
"mp",
"\\u",
"names_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ks_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"'",
"ks",
"\\u'_",
"+_",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kde",
"g_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"'",
"kde",
"g",
"\\u'_",
"+_",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ic_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"name_",
"+_",
"'\\u",
"0",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"ic_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ic",
"\\u",
"value_",
"=_",
"ic_",
"._",
"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 ",
" _",
"ic",
"\\u",
"value_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"ks_",
"._",
"value_",
"!=_",
"0_",
"and_",
"kde",
"g_",
"._",
"value_",
"!=_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ic",
"\\u",
"calc_",
"=_",
"round_",
"(_",
"ks_",
"._",
"value_",
"/_",
"kde",
"g_",
"._",
"value_",
"/_",
"syn",
"\\u",
"base_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ks",
"\\u",
"expr_",
"=_",
"'%",
"4.2",
"f",
"*",
"kde",
"g",
"*",
"%",
"7d",
"'_",
"%_",
"(_",
"syn",
"\\u",
"base_",
",_",
"ic",
"\\u",
"calc_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ks",
"\\u",
"expr_",
"=_",
"'",
"0",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"values_",
"=_",
"(_",
"i_",
",_",
"display",
"\\u",
"name_",
",_",
"ic",
"\\u",
"value_",
",_",
"ks",
"\\u",
"expr_",
",_",
"kde",
"g_",
"._",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"'%",
"2d",
" ",
"|",
" ",
"%",
"-1",
"2s",
" ",
"%",
"8d",
" ",
"%",
"20",
"s",
" ",
"%",
"10",
"g",
"'_",
"%_",
"values_",
")_",
"\\u\\u\\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_",
"show",
"\\u",
"rates_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Print",
" ",
"a",
" ",
"table",
" ",
"of",
" ",
"rate",
" ",
"parameter",
"s",
" ",
"like",
" ",
"Table",
" ",
"S4",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"FIX",
"ME",
" ",
"kf",
"14",
"-",
"kf",
"21",
" ",
"need",
" ",
"to",
" ",
"be",
" ",
"un",
"-",
"scale",
"d",
" ",
"by",
" ",
"v",
" ",
"to",
" ",
"make",
" ",
"the",
" ",
"table",
" ",
"look",
" ",
"right_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"(_",
"\"%",
"-",
"20",
"s",
" ",
" ",
" ",
" ",
"\"_",
"*_",
"3_",
")_",
"%_",
"(_",
"'",
"forward",
"'_",
",_",
"'",
"reverse",
"'_",
",_",
"'",
"catal",
"yti",
"c",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"'-'_",
"*_",
"(_",
"9_",
"+_",
"11_",
"+_",
"7_",
")_",
"*_",
"3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"list_",
"(_",
"range_",
"(_",
"1_",
",_",
"29_",
")_",
")_",
"+_",
"[_",
"31_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"t_",
"in_",
"(_",
"'",
"f",
"'_",
",_",
"'",
"r",
"'_",
",_",
"'",
"c",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"n_",
"=_",
"'",
"k",
"%",
"s",
"%",
"d",
"'_",
"%_",
"(_",
"t_",
",_",
"i_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p_",
"=_",
"model_",
"._",
"parameters_",
"._",
"get_",
"(_",
"n_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"p_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"%",
"-",
"9",
"s",
"%",
"11",
"g",
" ",
" ",
" ",
"\"_",
"%_",
"(_",
"p_",
"._",
"name_",
",_",
"p_",
"._",
"value_",
")_",
",_",
"end_",
"=_",
"'",
" ",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"(_",
")_",
"\\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,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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
]
|
Testing equality to None | acil-bwh/SlicerCIP/Scripted/LungRegistration/LungRegistration.py | [
{
"content": " def hasImageData(self,volumeNode):\n \"\"\"This is a dummy logic method that \n returns true if the passed in volume\n node has valid image data\n \"\"\"\n if not volumeNode:\n print('no volume node')\n return False\n if volumeNode.GetImageData() == None:\n print('no image data')\n return False\n return True",
"metadata": "root.LungRegistrationLogic.hasImageData",
"header": "['class', 'LungRegistrationLogic', ':', '___EOS___']",
"index": 294
}
]
| [
{
"span": "volumeNode.GetImageData() == None:",
"start_line": 302,
"start_column": 7,
"end_line": 302,
"end_column": 40
}
]
| []
| 1 | true | [
"[CLS]_",
"Test",
"ing_",
"equality",
"_",
"to_",
"None_",
"[SEP]_",
"class_",
"Lun",
"g",
"Registration",
"Logic_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"has",
"Image",
"Data_",
"(_",
"self_",
",_",
"volume",
"Node_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Thi",
"s",
" ",
"is",
" ",
"a",
" ",
"dummy",
" ",
"logic",
" ",
"method",
" ",
"tha",
"t",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"return",
"s",
" ",
"true",
" ",
"if",
" ",
"the",
" ",
"pass",
"ed",
" ",
"in",
" ",
"volume",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"node",
" ",
"has",
" ",
"valid",
" ",
"image",
" ",
"data",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"volume",
"Node_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"no",
" ",
"volume",
" ",
"node",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"volume",
"Node_",
"._",
"Get",
"Image",
"Data_",
"(_",
")_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"no",
" ",
"image",
" ",
"data",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
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
]
|
Except block handles 'BaseException' | CollabQ/CollabQ/common/appengine_utilities/cache.py | [
{
"content": "# Copyright 2010 http://www.collabq.com\n# -*- coding: utf-8 -*-\n\"\"\"\nCopyright (c) 2008, appengine-utilities project\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n- Neither the name of the appengine-utilities project nor the names of its\n contributors may be used to endorse or promote products derived from this\n software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\"\"\"\n\n# main python imports\nimport datetime\nimport pickle\nimport random\nimport __main__\n\n# google appengine import\nfrom google.appengine.ext import db\nfrom google.appengine.api import memcache\n\n# settings\ntry:\n import settings\nexcept:\n import settings_default as settings\n \n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": " def add(self, key = None, value = None, timeout = None):\n \"\"\"\n Adds an entry to the cache, if one does not already exist. If they key\n already exists, KeyError will be raised.\n\n Args:\n key: Key name of the cache object\n value: Value of the cache object\n timeout: timeout value for the cache object.\n\n Returns the cache object.\n \"\"\"\n self._validate_key(key)\n self._validate_value(value)\n timeout = self._validate_timeout(timeout)\n\n if key in self:\n raise KeyError\n\n cacheEntry = _AppEngineUtilities_Cache()\n cacheEntry.cachekey = key\n cacheEntry.value = pickle.dumps(value)\n cacheEntry.timeout = timeout\n\n # try to put the entry, if it fails silently pass\n # failures may happen due to timeouts, the datastore being read\n # only for maintenance or other applications. However, cache\n # not being able to write to the datastore should not\n # break the application\n try:\n cacheEntry.put()\n except:\n pass\n\n memcache_timeout = timeout - datetime.datetime.now()\n memcache.set('cache-%s' % (key), value, int(memcache_timeout.seconds))\n\n if 'AEU_Events' in __main__.__dict__:\n __main__.AEU_Events.fire_event('cacheAdded')\n\n return self.get(key)",
"metadata": "root.Cache.add",
"header": "['class', 'Cache', '(', 'object', ')', ':', '___EOS___']",
"index": 160
},
{
"content": " def set(self, key = None, value = None, timeout = None):\n \"\"\"\n Sets an entry to the cache, overwriting an existing value\n if one already exists.\n\n Args:\n key: Key name of the cache object\n value: Value of the cache object\n timeout: timeout value for the cache object.\n\n Returns the cache object.\n \"\"\"\n self._validate_key(key)\n self._validate_value(value)\n timeout = self._validate_timeout(timeout)\n\n cacheEntry = self._read(key)\n if not cacheEntry:\n cacheEntry = _AppEngineUtilities_Cache()\n cacheEntry.cachekey = key\n cacheEntry.value = pickle.dumps(value)\n cacheEntry.timeout = timeout\n\n try:\n cacheEntry.put()\n except:\n pass\n\n memcache_timeout = timeout - datetime.datetime.now()\n memcache.set('cache-%s' % (key), value, int(memcache_timeout.seconds))\n\n if 'AEU_Events' in __main__.__dict__:\n __main__.AEU_Events.fire_event('cacheSet')\n\n return self.get(key)",
"metadata": "root.Cache.set",
"header": "['class', 'Cache', '(', 'object', ')', ':', '___EOS___']",
"index": 202
}
]
| [
{
"span": "except:",
"start_line": 42,
"start_column": 0,
"end_line": 42,
"end_column": 7
},
{
"span": "except:",
"start_line": 191,
"start_column": 8,
"end_line": 191,
"end_column": 15
},
{
"span": "except:",
"start_line": 227,
"start_column": 8,
"end_line": 227,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"2010",
" ",
"http",
"://",
"www",
".",
"colla",
"bq",
".",
"com_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"2008",
",",
" ",
"appengine",
"-",
"util",
"iti",
"es",
" ",
"project",
"\\",
"10",
";",
"All",
" ",
"rights",
" ",
"reserve",
"d",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"Redistributi",
"on",
" ",
"and",
" ",
"use",
" ",
"in",
" ",
"source",
" ",
"and",
" ",
"binar",
"y",
" ",
"forms",
",",
" ",
"with",
" ",
"or",
" ",
"with",
"out",
"\\",
"10",
";",
"modification",
",",
" ",
"are",
" ",
"permit",
"ted",
" ",
"provided",
" ",
"tha",
"t",
" ",
"the",
" ",
"follow",
"ing",
" ",
"condition",
"s",
" ",
"are",
" ",
"met",
":",
"\\",
"10",
";",
"-",
" ",
"Redistributi",
"ons",
" ",
"of",
" ",
"source",
" ",
"code",
" ",
"must",
" ",
"retain",
" ",
"the",
" ",
"above",
" ",
"copyr",
"ight",
" ",
"notice",
",",
" ",
"this",
"\\",
"10",
";",
" ",
" ",
"list",
" ",
"of",
" ",
"condition",
"s",
" ",
"and",
" ",
"the",
" ",
"follow",
"ing",
" ",
"discl",
"aime",
"r",
".",
"\\",
"10",
";",
"-",
" ",
"Redistributi",
"ons",
" ",
"in",
" ",
"binar",
"y",
" ",
"form",
" ",
"must",
" ",
"reproduce",
" ",
"the",
" ",
"above",
" ",
"copyr",
"ight",
" ",
"notice",
",",
"\\",
"10",
";",
" ",
" ",
"this",
" ",
"list",
" ",
"of",
" ",
"condition",
"s",
" ",
"and",
" ",
"the",
" ",
"follow",
"ing",
" ",
"discl",
"aime",
"r",
" ",
"in",
" ",
"the",
" ",
"documentation",
"\\",
"10",
";",
" ",
" ",
"and",
"/",
"or",
" ",
"other",
" ",
"material",
"s",
" ",
"provided",
" ",
"with",
" ",
"the",
" ",
"distribu",
"tion",
".",
"\\",
"10",
";",
"-",
" ",
"Nei",
"ther",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"the",
" ",
"appengine",
"-",
"util",
"iti",
"es",
" ",
"project",
" ",
"nor",
" ",
"the",
" ",
"names",
" ",
"of",
" ",
"its",
"\\",
"10",
";",
" ",
" ",
"contributor",
"s",
" ",
"may",
" ",
"be",
" ",
"used",
" ",
"to",
" ",
"endo",
"rse",
" ",
"or",
" ",
"promote",
" ",
"products",
" ",
"derive",
"d",
" ",
"from",
" ",
"this",
"\\",
"10",
";",
" ",
" ",
"software",
" ",
"with",
"out",
" ",
"specific",
" ",
"prior",
" ",
"writt",
"en",
" ",
"permissi",
"on",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"THIS",
" ",
"SOFT",
"WARE",
" ",
"IS",
" ",
"PROVI",
"DED",
" ",
"BY",
" ",
"THE",
" ",
"COPY",
"RIG",
"HT",
" ",
"HOLD",
"ERS",
" ",
"AND",
" ",
"CONTRIB",
"UTO",
"RS",
" ",
"\"",
"AS",
" ",
"IS",
"\"",
" ",
"AND",
"\\",
"10",
";",
"ANY",
" ",
"EXPR",
"ESS",
" ",
"OR",
" ",
"IMPL",
"IED",
" ",
"WAR",
"RAN",
"TIES",
",",
" ",
"INC",
"LU",
"DING",
",",
" ",
"BUT",
" ",
"NOT",
" ",
"LIMIT",
"ED",
" ",
"TO",
",",
" ",
"THE",
" ",
"IMPL",
"IED",
"\\",
"10",
";",
"WAR",
"RAN",
"TIES",
" ",
"OF",
" ",
"MER",
"CHAN",
"TAB",
"ILI",
"TY",
" ",
"AND",
" ",
"FIT",
"NESS",
" ",
"FOR",
" ",
"A",
" ",
"PARTI",
"CUL",
"AR",
" ",
"PUR",
"POS",
"E",
" ",
"ARE",
"\\",
"10",
";",
"DISC",
"LAI",
"MED",
".",
" ",
"IN",
" ",
"NO",
" ",
"EVENT",
" ",
"SHA",
"LL",
" ",
"THE",
" ",
"COPY",
"RIG",
"HT",
" ",
"OWNER",
" ",
"OR",
" ",
"CONTRIB",
"UTO",
"RS",
" ",
"BE",
" ",
"LI",
"AB",
"LE",
" ",
"FOR",
"\\",
"10",
";",
"ANY",
" ",
"DIRECT",
",",
" ",
"INDI",
"RECT",
",",
" ",
"INC",
"IDENT",
"AL",
",",
" ",
"SPECIAL",
",",
" ",
"EXE",
"MPL",
"ARY",
",",
" ",
"OR",
" ",
"CONS",
"EQU",
"ENTI",
"AL",
" ",
"DA",
"MAGE",
"S",
"\\",
"10",
";",
"(",
"INC",
"LU",
"DING",
",",
" ",
"BUT",
" ",
"NOT",
" ",
"LIMIT",
"ED",
" ",
"TO",
",",
" ",
"PROC",
"URE",
"MENT",
" ",
"OF",
" ",
"SUBST",
"ITU",
"TE",
" ",
"GOOD",
"S",
" ",
"OR",
" ",
"SERVICES",
";",
"\\",
"10",
";",
"LOSS",
" ",
"OF",
" ",
"USE",
",",
" ",
"DATA",
",",
" ",
"OR",
" ",
"PROF",
"IT",
"S",
";",
" ",
"OR",
" ",
"BUS",
"INE",
"SS",
" ",
"INTER",
"RU",
"PTION",
")",
" ",
"HO",
"WE",
"VER",
" ",
"CAU",
"SED",
" ",
"AND",
" ",
"ON",
"\\",
"10",
";",
"ANY",
" ",
"THE",
"ORY",
" ",
"OF",
" ",
"LI",
"ABI",
"LIT",
"Y",
",",
" ",
"WHE",
"THER",
" ",
"IN",
" ",
"CONTR",
"ACT",
",",
" ",
"STRI",
"CT",
" ",
"LI",
"ABI",
"LIT",
"Y",
",",
" ",
"OR",
" ",
"TOR",
"T",
"\\",
"10",
";",
"(",
"INC",
"LU",
"DING",
" ",
"NEG",
"LIG",
"ENCE",
" ",
"OR",
" ",
"OTHER",
"WI",
"SE",
")",
" ",
"ARI",
"SIN",
"G",
" ",
"IN",
" ",
"ANY",
" ",
"WAY",
" ",
"OUT",
" ",
"OF",
" ",
"THE",
" ",
"USE",
" ",
"OF",
" ",
"THIS",
"\\",
"10",
";",
"SOFT",
"WARE",
",",
" ",
"EVE",
"N",
" ",
"IF",
" ",
"ADV",
"ISE",
"D",
" ",
"OF",
" ",
"THE",
" ",
"POS",
"SIB",
"ILI",
"TY",
" ",
"OF",
" ",
"SUC",
"H",
" ",
"DA",
"MAGE",
".",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"main",
" ",
"python",
" ",
"imports_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"pickle_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"random_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"\\u\\u",
"main\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"google",
" ",
"appengine",
" ",
"import_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"google_",
"._",
"appengine_",
"._",
"ext_",
"import_",
"db_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"google_",
"._",
"appengine_",
"._",
"api_",
"import_",
"memcache_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"settings_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"import_",
"settings_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"import_",
"settings",
"\\u",
"default_",
"as_",
"settings_",
"\\u\\u\\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_",
"[SEP]_",
"class_",
"Cache_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"add_",
"(_",
"self_",
",_",
"key_",
"=_",
"None_",
",_",
"value_",
"=_",
"None_",
",_",
"timeout_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Add",
"s",
" ",
"an",
" ",
"entry",
" ",
"to",
" ",
"the",
" ",
"cache",
",",
" ",
"if",
" ",
"one",
" ",
"doe",
"s",
" ",
"not",
" ",
"alr",
"ead",
"y",
" ",
"exist",
".",
" ",
"If",
" ",
"the",
"y",
" ",
"key",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"alr",
"ead",
"y",
" ",
"exist",
"s",
",",
" ",
"Key",
"Error",
" ",
"will",
" ",
"be",
" ",
"raise",
"d",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Arg",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"key",
":",
" ",
"Key",
" ",
"name",
" ",
"of",
" ",
"the",
" ",
"cache",
" ",
"object",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"value",
":",
" ",
"Value",
" ",
"of",
" ",
"the",
" ",
"cache",
" ",
"object",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"timeo",
"ut",
":",
" ",
"timeo",
"ut",
" ",
"value",
" ",
"for",
" ",
"the",
" ",
"cache",
" ",
"object",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
" ",
"the",
" ",
"cache",
" ",
"object",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"validat",
"e\\u",
"key_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"validat",
"e\\u",
"value_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"timeout_",
"=_",
"self_",
"._",
"\\u",
"validat",
"e\\u",
"timeout_",
"(_",
"timeout_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"key_",
"in_",
"self_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Key",
"Error_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"cache",
"Entry_",
"=_",
"\\u",
"App",
"Engine",
"Utili",
"ties",
"\\u",
"Cache_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cache",
"Entry_",
"._",
"cache",
"key_",
"=_",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cache",
"Entry_",
"._",
"value_",
"=_",
"pickle_",
"._",
"dumps_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cache",
"Entry_",
"._",
"timeout_",
"=_",
"timeout_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"try",
" ",
"to",
" ",
"put",
" ",
"the",
" ",
"entry",
",",
" ",
"if",
" ",
"it",
" ",
"fail",
"s",
" ",
"silently",
" ",
"pass_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"fail",
"ure",
"s",
" ",
"may",
" ",
"happ",
"en",
" ",
"due",
" ",
"to",
" ",
"timeouts",
",",
" ",
"the",
" ",
"datast",
"ore",
" ",
"bei",
"ng",
" ",
"read_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"only",
" ",
"for",
" ",
"maintenance",
" ",
"or",
" ",
"other",
" ",
"applica",
"tion",
"s",
".",
" ",
"Ho",
"we",
"ver",
",",
" ",
"cache_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"not",
" ",
"bei",
"ng",
" ",
"able",
" ",
"to",
" ",
"write",
" ",
"to",
" ",
"the",
" ",
"datast",
"ore",
" ",
"shou",
"ld",
" ",
"not_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"break",
" ",
"the",
" ",
"application_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cache",
"Entry_",
"._",
"put_",
"(_",
")_",
"\\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_",
"memc",
"ache",
"\\u",
"timeout_",
"=_",
"timeout_",
"-_",
"datetime_",
"._",
"datetime_",
"._",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"memcache_",
"._",
"set_",
"(_",
"'",
"cache",
"-%",
"s",
"'_",
"%_",
"(_",
"key_",
")_",
",_",
"value_",
",_",
"int_",
"(_",
"memc",
"ache",
"\\u",
"timeout_",
"._",
"seconds_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"'",
"AE",
"U",
"\\u",
"Event",
"s",
"'_",
"in_",
"\\u\\u",
"main\\u\\u_",
"._",
"\\u\\u",
"dict\\u\\u_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u\\u",
"main\\u\\u_",
"._",
"AE",
"U",
"\\u",
"Events_",
"._",
"fire",
"\\u",
"event_",
"(_",
"'",
"cache",
"Added",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"self_",
"._",
"get_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Cache_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set_",
"(_",
"self_",
",_",
"key_",
"=_",
"None_",
",_",
"value_",
"=_",
"None_",
",_",
"timeout_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Set",
"s",
" ",
"an",
" ",
"entry",
" ",
"to",
" ",
"the",
" ",
"cache",
",",
" ",
"overwrit",
"ing",
" ",
"an",
" ",
"exist",
"ing",
" ",
"value",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"if",
" ",
"one",
" ",
"alr",
"ead",
"y",
" ",
"exist",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Arg",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"key",
":",
" ",
"Key",
" ",
"name",
" ",
"of",
" ",
"the",
" ",
"cache",
" ",
"object",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"value",
":",
" ",
"Value",
" ",
"of",
" ",
"the",
" ",
"cache",
" ",
"object",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"timeo",
"ut",
":",
" ",
"timeo",
"ut",
" ",
"value",
" ",
"for",
" ",
"the",
" ",
"cache",
" ",
"object",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
" ",
"the",
" ",
"cache",
" ",
"object",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"validat",
"e\\u",
"key_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"validat",
"e\\u",
"value_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"timeout_",
"=_",
"self_",
"._",
"\\u",
"validat",
"e\\u",
"timeout_",
"(_",
"timeout_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"cache",
"Entry_",
"=_",
"self_",
"._",
"\\u",
"read_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"cache",
"Entry_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cache",
"Entry_",
"=_",
"\\u",
"App",
"Engine",
"Utili",
"ties",
"\\u",
"Cache_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cache",
"Entry_",
"._",
"cache",
"key_",
"=_",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"cache",
"Entry_",
"._",
"value_",
"=_",
"pickle_",
"._",
"dumps_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cache",
"Entry_",
"._",
"timeout_",
"=_",
"timeout_",
"\\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 ",
" _",
"cache",
"Entry_",
"._",
"put_",
"(_",
")_",
"\\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_",
"memc",
"ache",
"\\u",
"timeout_",
"=_",
"timeout_",
"-_",
"datetime_",
"._",
"datetime_",
"._",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"memcache_",
"._",
"set_",
"(_",
"'",
"cache",
"-%",
"s",
"'_",
"%_",
"(_",
"key_",
")_",
",_",
"value_",
",_",
"int_",
"(_",
"memc",
"ache",
"\\u",
"timeout_",
"._",
"seconds_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"'",
"AE",
"U",
"\\u",
"Event",
"s",
"'_",
"in_",
"\\u\\u",
"main\\u\\u_",
"._",
"\\u\\u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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
]
|
Unreachable code | Suor/funcy/tests/test_flow.py | [
{
"content": "def test_suppress():\n with suppress(Exception):\n raise Exception\n with suppress(Exception):\n raise MyError\n\n with pytest.raises(TypeError):\n with suppress(MyError):\n raise TypeError\n\n with suppress(TypeError, MyError):\n raise MyError",
"metadata": "root.test_suppress",
"header": "['module', '___EOS___']",
"index": 41
}
]
| [
{
"span": "with suppress(Exception):",
"start_line": 44,
"start_column": 4,
"end_line": 44,
"end_column": 29
}
]
| []
| 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_",
"test\\u",
"suppress_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"with_",
"suppress_",
"(_",
"Exception_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Exception_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"suppress_",
"(_",
"Exception_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"My",
"Error_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"pytest_",
"._",
"raises_",
"(_",
"Type",
"Error_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"with_",
"suppress_",
"(_",
"My",
"Error_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Type",
"Error_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"suppress_",
"(_",
"Type",
"Error_",
",_",
"My",
"Error_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"My",
"Error_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | fxdemolisher/frano/frano/main/demo.py | [
{
"content": "# Copyright (c) 2011 Gennadiy Shafranovich\n# Licensed under the MIT license\n# see LICENSE file for copying permission.\n\nfrom datetime import datetime\nfrom datetime import timedelta\nfrom math import ceil\nfrom math import floor\nfrom random import choice\nfrom random import randint\nfrom random import random\nfrom random import sample\n\nfrom quotes.models import CASH_SYMBOL\nfrom quotes.models import quotes_by_symbols\nfrom transactions.models import Transaction\n\n#-------------\\\n# CONSTANTS |\n#-------------/\n\n# set of instruments a demo portfolio will choose from\nDEMO_INSTRUMENTS = [\n 'AA', # Alcoa\n 'AAPL', # Apple\n 'ACWI', # MSCI ACWI\n 'AGG', # Barclays Aggregate Bond Fund\n 'BND', # Vanguard Total Bond Market\n 'DBC', # PowerShares DB Commodity Index\n 'DBO', # PowerShares DB Oil Fund\n 'DIA', # Dow Jones Industrial Average\n 'EEM', # MSCI Emerging Markets\n 'EFA', # MSCI EAFE\n 'EMB', # JP Morgan USD Emerging Markets\n 'FFNOX', # Fidelity Four-in-One\n 'GE', # General Electric\n 'GLD', # GLD Trust\n 'GOOG', # Google\n 'IJH', # S&P MidCap 400\n 'INTC', # Intel\n 'IWM', # Rusell 2000\n 'IWV', # Russell 3000\n 'IYR', # Dow Jones US Real Estate\n 'MSFT', # Microsoft\n 'QQQ', # PowerShares QQQ (Nasdaq)\n 'SCZ', # MSCI EAFE Small Cap\n 'SLV', # Silver Trust\n 'SPY', # S&P 500\n 'TIP', # Barclays TIPS Bond fund\n 'XOM', # Exxon Mobil\n 'YACKX', # Yacktman Fund\n]\n\n# demo portfolio commissions, chosen at random once per portfolio\nDEMO_COMMISSIONS = [ 4.5, 7.99, 9.99 ]\n\n# Min/max number of instruments in a demo portfolio\nDEMO_MIN_INSTRUMENTS = 4\nDEMO_MAX_INSTRUMENTS = 8\n\n# Min/max investment in a demo portfolio\nDEMO_MIN_INVESTMENT = 10000\nDEMO_MAX_INVESTMENT = 100000\n\n# Number of demo portfolios to generate\nDEMO_PORTFOLIOS = 10\n\n# Nunmber of days to go back in history to make the demo portfolios\nDEMO_DAYS_CUTOFF = 365\n\n# Approximate number of transactions to have in a demo portfolios\nDEMO_TARGET_TRANSACTIONS = 40\n\n# Approximate number of deposits in a demo portfolio\nDEMO_TARGET_DEPOSITS = 5\n\n# Ratio of buys vs. sells\nDEMO_BUY_SELL_RATIO = 4\n\n# List of lists of demo transactions\nDEMO = []\n\n#------------\\\n# SERVICES |\n#------------/\n\n\n#-------------------\\\n# LOCAL FUNCTIONS |\n#-------------------/\n\n \n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def get_demo_transactions():\n global DEMO\n if len(DEMO) == 0:\n print '==============GEN==============='\n DEMO = _generate_demo_portfolios(DEMO_PORTFOLIOS)\n\n \n return choice(DEMO)",
"metadata": "root.get_demo_transactions",
"header": "['module', '___EOS___']",
"index": 86
},
{
"content": "def _generate_demo_portfolios(count):\n out = []\n for i in range(count):\n instruments = sample(DEMO_INSTRUMENTS, randint(DEMO_MIN_INSTRUMENTS, DEMO_MAX_INSTRUMENTS))\n total_investment = randint(DEMO_MIN_INVESTMENT, DEMO_MAX_INVESTMENT)\n commission = choice(DEMO_COMMISSIONS)\n out.append(_generate_random_transactions(instruments, \n total_investment, \n commission)\n )\n \n return out",
"metadata": "root._generate_demo_portfolios",
"header": "['module', '___EOS___']",
"index": 99
},
{
"content": "def _generate_random_transactions(instruments, total_amount, commission):\n \n # Load historic prices\n quotes = quotes_by_symbols(instruments)\n \n cutoff_date = datetime.now().date() - timedelta(days = DEMO_DAYS_CUTOFF)\n prices = dict([ (quote.symbol, {}) for quote in quotes ])\n dates = set([])\n quote_map = { }\n for quote in quotes:\n quote_map[quote.symbol] = quote\n for history in quote.pricehistory_set.filter(as_of_date__gte = cutoff_date).order_by('as_of_date'):\n cur_date = history.as_of_date.date()\n prices.get(quote.symbol)[cur_date] = history.price\n dates.add(cur_date)\n\n # portfolio probabilities\n transaction_probability = DEMO_TARGET_TRANSACTIONS / float(len(dates))\n deposit_probability = DEMO_TARGET_DEPOSITS / float(DEMO_TARGET_TRANSACTIONS)\n buy_sell_probability = DEMO_BUY_SELL_RATIO / float(DEMO_BUY_SELL_RATIO + 1)\n\n # generate transactions\n transactions = []\n quantities = dict([ (symbol, 0.0) for symbol in instruments ])\n undeposited_cash = total_amount\n cash = 0\n for date in sorted(dates):\n sell_candidates = [ q[0] for q in quantities.items() if q[1] > 0 ]\n \n # see if there is a transaction today or if we are just starting out\n if random() <= transaction_probability or len(transactions) == 0:\n \n # deposits\n if undeposited_cash > 1 and random() <= deposit_probability:\n deposit = min([ undeposited_cash, round(undeposited_cash * (randint(10, 100) / 100.0), -2), total_amount * 0.5 ])\n undeposited_cash -= deposit\n cash += deposit\n transactions.append(Transaction(type = 'DEPOSIT',\n as_of_date = date,\n symbol = CASH_SYMBOL,\n quantity = deposit,\n price = 1.0,\n total = deposit,\n ))\n \n # buys - if we have any cash\n elif random() <= buy_sell_probability:\n amount = min([ cash, round(cash * (randint(20, 100) / 100.0)), total_amount * 0.1 ])\n symbol = choice(instruments)\n price = (prices.get(symbol).get(date) if not quote_map.get(symbol).cash_equivalent else 1.0)\n quantity = floor((amount - commission) / price)\n if quantity > 0:\n total = (quantity * price) + commission\n cash -= total\n quantities[symbol] = quantities.get(symbol) + quantity\n transactions.append(Transaction(type = 'BUY',\n as_of_date = date,\n symbol = symbol,\n quantity = quantity,\n price = price,\n total = total,\n ))\n \n # sells - if there is anything to sell\n elif len(sell_candidates) > 0:\n symbol = choice(sell_candidates)\n price = (prices.get(symbol).get(date) if not quote_map.get(symbol).cash_equivalent else 1.0)\n available_quantity = quantities.get(symbol)\n quantity = min(available_quantity, round(available_quantity * (randint(20, 100) / 100.0)))\n if quantity > 0:\n total = (quantity * price) - commission\n cash += total\n quantities[symbol] = quantities.get(symbol) - quantity\n transactions.append(Transaction(type = 'SELL',\n as_of_date = date,\n symbol = symbol,\n quantity = quantity,\n price = price,\n total = total,\n ))\n\n return transactions",
"metadata": "root._generate_random_transactions",
"header": "['module', '___EOS___']",
"index": 112
}
]
| [
{
"span": "from math import ceil",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 21
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"2011",
" ",
"Gen",
"nad",
"iy",
" ",
"Sha",
"fran",
"ovi",
"ch_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"License",
"d",
" ",
"under",
" ",
"the",
" ",
"MIT",
" ",
"license_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"see",
" ",
"LICENSE",
" ",
"file",
" ",
"for",
" ",
"copy",
"ing",
" ",
"permissi",
"on",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"datetime_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"datetime_",
"import_",
"timedelta_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"math_",
"import_",
"ceil_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"math_",
"import_",
"floor_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"random_",
"import_",
"choice_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"random_",
"import_",
"randint_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"random_",
"import_",
"random_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"random_",
"import_",
"sample_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"quotes_",
"._",
"models_",
"import_",
"CAS",
"H",
"\\u",
"SYMBOL_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"quotes_",
"._",
"models_",
"import_",
"quote",
"s",
"\\u",
"by",
"\\u",
"symbols_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"transactions_",
"._",
"models_",
"import_",
"Transaction_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#-",
"------------",
"\\\\_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"CONSTANT",
"S",
" ",
" ",
"|_",
"\\u\\u\\uNL\\u\\u\\u_",
"#-",
"------------",
"/_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"set",
" ",
"of",
" ",
"instrument",
"s",
" ",
"a",
" ",
"demo",
" ",
"portfolio",
" ",
"will",
" ",
"choose",
" ",
"from_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"INSTRU",
"MENTS_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"AA",
"'_",
",_",
"#",
" ",
"Al",
"coa",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"AA",
"PL",
"'_",
",_",
"#",
" ",
"Apple",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"AC",
"WI",
"'_",
",_",
"#",
" ",
"MS",
"CI",
" ",
"AC",
"WI",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"AGG",
"'_",
",_",
"#",
" ",
"Barc",
"lay",
"s",
" ",
"Aggregate",
" ",
"Bond",
" ",
"Fund",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"BN",
"D",
"'_",
",_",
"#",
" ",
"Van",
"guard",
" ",
"Total",
" ",
"Bond",
" ",
"Market",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"DB",
"C",
"'_",
",_",
"#",
" ",
"Power",
"Share",
"s",
" ",
"DB",
" ",
"Comm",
"odi",
"ty",
" ",
"Index_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"DB",
"O",
"'_",
",_",
"#",
" ",
"Power",
"Share",
"s",
" ",
"DB",
" ",
"Oi",
"l",
" ",
"Fund",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"DIA",
"'_",
",_",
"#",
" ",
"Do",
"w",
" ",
"Jones",
" ",
"Industr",
"ial",
" ",
"Average",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"EE",
"M",
"'_",
",_",
"#",
" ",
"MS",
"CI",
" ",
"Em",
"erg",
"ing",
" ",
"Market",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"EF",
"A",
"'_",
",_",
"#",
" ",
"MS",
"CI",
" ",
"EA",
"FE",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"EM",
"B",
"'_",
",_",
"#",
" ",
"JP",
" ",
"Mor",
"gan",
" ",
"US",
"D",
" ",
"Em",
"erg",
"ing",
" ",
"Market",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"FF",
"NO",
"X",
"'_",
",_",
"#",
" ",
"Fi",
"deli",
"ty",
" ",
"Four",
"-",
"in",
"-",
"One_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"GE",
"'_",
",_",
"#",
" ",
"General",
" ",
"Electric",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"GL",
"D",
"'_",
",_",
"#",
" ",
"GL",
"D",
" ",
"Trust",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"GO",
"OG",
"'_",
",_",
"#",
" ",
"Goo",
"gle_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"IJ",
"H",
"'_",
",_",
"#",
" ",
"S",
"&",
"P",
" ",
"Mid",
"Cap",
" ",
"400_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"INT",
"C",
"'_",
",_",
"#",
" ",
"Intel",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"IW",
"M",
"'_",
",_",
"#",
" ",
"Rus",
"ell",
" ",
"2000_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"IW",
"V",
"'_",
",_",
"#",
" ",
"Rus",
"sell",
" ",
"3000_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"I",
"YR",
"'_",
",_",
"#",
" ",
"Do",
"w",
" ",
"Jones",
" ",
"US",
" ",
"Real",
" ",
"Esta",
"te_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"MS",
"FT",
"'_",
",_",
"#",
" ",
"Micro",
"soft",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"QQ",
"Q",
"'_",
",_",
"#",
" ",
"Power",
"Share",
"s",
" ",
"QQ",
"Q",
" ",
"(",
"Nas",
"da",
"q",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"SC",
"Z",
"'_",
",_",
"#",
" ",
"MS",
"CI",
" ",
"EA",
"FE",
" ",
"Small",
" ",
"Cap",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"SL",
"V",
"'_",
",_",
"#",
" ",
"Sil",
"ver",
" ",
"Trust",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"SP",
"Y",
"'_",
",_",
"#",
" ",
"S",
"&",
"P",
" ",
"500_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"TIP",
"'_",
",_",
"#",
" ",
"Barc",
"lay",
"s",
" ",
"TIP",
"S",
" ",
"Bond",
" ",
"fund",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"XO",
"M",
"'_",
",_",
"#",
" ",
"Ex",
"xon",
" ",
"Mob",
"il_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"YA",
"CK",
"X",
"'_",
",_",
"#",
" ",
"Ya",
"ck",
"tma",
"n",
" ",
"Fund",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"demo",
" ",
"portfolio",
" ",
"commission",
"s",
",",
" ",
"chosen",
" ",
"at",
" ",
"random",
" ",
"onc",
"e",
" ",
"per",
" ",
"portfolio_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"COMM",
"ISS",
"IONS",
"_",
"=_",
"[_",
"4.5_",
",_",
"7.9",
"9_",
",_",
"9.9",
"9_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Min",
"/",
"max",
" ",
"number",
" ",
"of",
" ",
"instrument",
"s",
" ",
"in",
" ",
"a",
" ",
"demo",
" ",
"portfolio_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"MIN",
"\\u",
"INSTRU",
"MENTS_",
"=_",
"4_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DEMO",
"\\u",
"MAX",
"\\u",
"INSTRU",
"MENTS_",
"=_",
"8_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Min",
"/",
"max",
" ",
"investment",
" ",
"in",
" ",
"a",
" ",
"demo",
" ",
"portfolio_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"MIN",
"\\u",
"INVE",
"STM",
"ENT_",
"=_",
"10000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DEMO",
"\\u",
"MAX",
"\\u",
"INVE",
"STM",
"ENT_",
"=_",
"100000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Number",
" ",
"of",
" ",
"demo",
" ",
"portfolio",
"s",
" ",
"to",
" ",
"generate_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"PORT",
"FOL",
"IO",
"S_",
"=_",
"10_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Nu",
"nm",
"ber",
" ",
"of",
" ",
"day",
"s",
" ",
"to",
" ",
"go",
" ",
"back",
" ",
"in",
" ",
"histo",
"ry",
" ",
"to",
" ",
"make",
" ",
"the",
" ",
"demo",
" ",
"portfolio",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"DAY",
"S",
"\\u",
"CUT",
"OFF_",
"=_",
"365_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Approx",
"imat",
"e",
" ",
"number",
" ",
"of",
" ",
"transaction",
"s",
" ",
"to",
" ",
"have",
" ",
"in",
" ",
"a",
" ",
"demo",
" ",
"portfolio",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"TARGET",
"\\u",
"TRANSACTION",
"S_",
"=_",
"40_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Approx",
"imat",
"e",
" ",
"number",
" ",
"of",
" ",
"deposit",
"s",
" ",
"in",
" ",
"a",
" ",
"demo",
" ",
"portfolio_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"TARGET",
"\\u",
"DEP",
"OSI",
"TS_",
"=_",
"5_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Rati",
"o",
" ",
"of",
" ",
"buy",
"s",
" ",
"vs",
".",
" ",
"sell",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"\\u",
"BU",
"Y",
"\\u",
"SEL",
"L",
"\\u",
"RATIO",
"_",
"=_",
"4_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"List",
" ",
"of",
" ",
"lists",
" ",
"of",
" ",
"demo",
" ",
"transactions_",
"\\u\\u\\uNL\\u\\u\\u_",
"DEMO",
"_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#-",
"-----------",
"\\\\_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"SERVICES",
" ",
" ",
"|_",
"\\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_",
"#",
" ",
" ",
"LOCAL",
" ",
"FUNCTIONS",
" ",
" ",
"|_",
"\\u\\u\\uNL\\u\\u\\u_",
"#-",
"--------------",
"----",
"/_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"get",
"\\u",
"demo",
"\\u",
"transactions_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"global_",
"DEMO",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"len_",
"(_",
"DEMO",
"_",
")_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"'===",
"=========",
"==",
"GEN",
"==============",
"='_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DEMO",
"_",
"=_",
"\\u",
"generat",
"e\\u",
"demo",
"\\u",
"portfolio",
"s_",
"(_",
"DEMO",
"\\u",
"PORT",
"FOL",
"IO",
"S_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"choice_",
"(_",
"DEMO",
"_",
")_",
"\\u\\u\\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",
"generat",
"e\\u",
"demo",
"\\u",
"portfolio",
"s_",
"(_",
"count_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"out_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"count_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"instruments_",
"=_",
"sample_",
"(_",
"DEMO",
"\\u",
"INSTRU",
"MENTS_",
",_",
"randint_",
"(_",
"DEMO",
"\\u",
"MIN",
"\\u",
"INSTRU",
"MENTS_",
",_",
"DEMO",
"\\u",
"MAX",
"\\u",
"INSTRU",
"MENTS_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"total",
"\\u",
"investment",
"_",
"=_",
"randint_",
"(_",
"DEMO",
"\\u",
"MIN",
"\\u",
"INVE",
"STM",
"ENT_",
",_",
"DEMO",
"\\u",
"MAX",
"\\u",
"INVE",
"STM",
"ENT_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"commission",
"_",
"=_",
"choice_",
"(_",
"DEMO",
"\\u",
"COMM",
"ISS",
"IONS",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"out_",
"._",
"append_",
"(_",
"\\u",
"generat",
"e\\u",
"random",
"\\u",
"transactions_",
"(_",
"instruments_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"total",
"\\u",
"investment",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"commission",
"_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"out_",
"\\u\\u\\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",
"generat",
"e\\u",
"random",
"\\u",
"transactions_",
"(_",
"instruments_",
",_",
"total",
"\\u",
"amount_",
",_",
"commission",
"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Load",
" ",
"histori",
"c",
" ",
"prices_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"quotes_",
"=_",
"quote",
"s",
"\\u",
"by",
"\\u",
"symbols_",
"(_",
"instruments_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"cuto",
"ff",
"\\u",
"date_",
"=_",
"datetime_",
"._",
"now_",
"(_",
")_",
"._",
"date_",
"(_",
")_",
"-_",
"timedelta_",
"(_",
"days_",
"=_",
"DEMO",
"\\u",
"DAY",
"S",
"\\u",
"CUT",
"OFF_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"prices_",
"=_",
"dict_",
"(_",
"[_",
"(_",
"quote_",
"._",
"symbol_",
",_",
"{_",
"}_",
")_",
"for_",
"quote_",
"in_",
"quotes_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"dates_",
"=_",
"set_",
"(_",
"[_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"quote",
"\\u",
"map_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"quote_",
"in_",
"quotes_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"quote",
"\\u",
"map_",
"[_",
"quote_",
"._",
"symbol_",
"]_",
"=_",
"quote_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"history_",
"in_",
"quote_",
"._",
"price",
"histo",
"ry",
"\\u",
"set_",
"._",
"filter_",
"(_",
"as",
"\\u",
"of",
"\\u",
"date",
"\\u\\u",
"gte_",
"=_",
"cuto",
"ff",
"\\u",
"date_",
")_",
"._",
"order",
"\\u",
"by_",
"(_",
"'",
"as",
"\\u",
"of",
"\\u",
"date",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cur",
"\\u",
"date_",
"=_",
"history_",
"._",
"as",
"\\u",
"of",
"\\u",
"date_",
"._",
"date_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"prices_",
"._",
"get_",
"(_",
"quote_",
"._",
"symbol_",
")_",
"[_",
"cur",
"\\u",
"date_",
"]_",
"=_",
"history_",
"._",
"price_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"dates_",
"._",
"add_",
"(_",
"cur",
"\\u",
"date_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"portfolio",
" ",
"probabilities_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"transaction",
"\\u",
"probability_",
"=_",
"DEMO",
"\\u",
"TARGET",
"\\u",
"TRANSACTION",
"S_",
"/_",
"float_",
"(_",
"len_",
"(_",
"dates_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deposit",
"\\u",
"probability_",
"=_",
"DEMO",
"\\u",
"TARGET",
"\\u",
"DEP",
"OSI",
"TS_",
"/_",
"float_",
"(_",
"DEMO",
"\\u",
"TARGET",
"\\u",
"TRANSACTION",
"S_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"buy",
"\\u",
"sell",
"\\u",
"probability_",
"=_",
"DEMO",
"\\u",
"BU",
"Y",
"\\u",
"SEL",
"L",
"\\u",
"RATIO",
"_",
"/_",
"float_",
"(_",
"DEMO",
"\\u",
"BU",
"Y",
"\\u",
"SEL",
"L",
"\\u",
"RATIO",
"_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"generat",
"e",
" ",
"transactions_",
"\\u\\u\\uNL\\u\\u\\u_",
"transactions_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"quantities",
"_",
"=_",
"dict_",
"(_",
"[_",
"(_",
"symbol_",
",_",
"0.0_",
")_",
"for_",
"symbol_",
"in_",
"instruments_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"unde",
"posit",
"ed",
"\\u",
"cash_",
"=_",
"total",
"\\u",
"amount_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cash_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"date_",
"in_",
"sorted_",
"(_",
"dates_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"sell",
"\\u",
"candidates_",
"=_",
"[_",
"q_",
"[_",
"0_",
"]_",
"for_",
"q_",
"in_",
"quantities",
"_",
"._",
"items_",
"(_",
")_",
"if_",
"q_",
"[_",
"1_",
"]_",
">_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"see",
" ",
"if",
" ",
"there",
" ",
"is",
" ",
"a",
" ",
"transaction",
" ",
"toda",
"y",
" ",
"or",
" ",
"if",
" ",
"we",
" ",
"are",
" ",
"just",
" ",
"startin",
"g",
" ",
"out_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"random_",
"(_",
")_",
"<=_",
"transaction",
"\\u",
"probability_",
"or_",
"len_",
"(_",
"transactions_",
")_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"deposit",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"unde",
"posit",
"ed",
"\\u",
"cash_",
">_",
"1_",
"and_",
"random_",
"(_",
")_",
"<=_",
"deposit",
"\\u",
"probability_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"deposit_",
"=_",
"min_",
"(_",
"[_",
"unde",
"posit",
"ed",
"\\u",
"cash_",
",_",
"round_",
"(_",
"unde",
"posit",
"ed",
"\\u",
"cash_",
"*_",
"(_",
"randint_",
"(_",
"10_",
",_",
"100_",
")_",
"/_",
"100.0_",
")_",
",_",
"-_",
"2_",
")_",
",_",
"total",
"\\u",
"amount_",
"*_",
"0.5_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"unde",
"posit",
"ed",
"\\u",
"cash_",
"-=_",
"deposit_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cash_",
"+=_",
"deposit_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"transactions_",
"._",
"append_",
"(_",
"Transaction_",
"(_",
"type_",
"=_",
"'",
"DEP",
"OSI",
"T",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"as",
"\\u",
"of",
"\\u",
"date_",
"=_",
"date_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"symbol_",
"=_",
"CAS",
"H",
"\\u",
"SYMBOL_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"quantity_",
"=_",
"deposit_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"price_",
"=_",
"1.0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"total_",
"=_",
"deposit_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"buy",
"s",
" ",
"-",
" ",
"if",
" ",
"we",
" ",
"have",
" ",
"any",
" ",
"cash_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"random_",
"(_",
")_",
"<=_",
"buy",
"\\u",
"sell",
"\\u",
"probability_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"amount_",
"=_",
"min_",
"(_",
"[_",
"cash_",
",_",
"round_",
"(_",
"cash_",
"*_",
"(_",
"randint_",
"(_",
"20_",
",_",
"100_",
")_",
"/_",
"100.0_",
")_",
")_",
",_",
"total",
"\\u",
"amount_",
"*_",
"0.1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"symbol_",
"=_",
"choice_",
"(_",
"instruments_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"price_",
"=_",
"(_",
"prices_",
"._",
"get_",
"(_",
"symbol_",
")_",
"._",
"get_",
"(_",
"date_",
")_",
"if_",
"not_",
"quote",
"\\u",
"map_",
"._",
"get_",
"(_",
"symbol_",
")_",
"._",
"cash",
"\\u",
"equivalent",
"_",
"else_",
"1.0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"quantity_",
"=_",
"floor_",
"(_",
"(_",
"amount_",
"-_",
"commission",
"_",
")_",
"/_",
"price_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"quantity_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"total_",
"=_",
"(_",
"quantity_",
"*_",
"price_",
")_",
"+_",
"commission",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cash_",
"-=_",
"total_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"quantities",
"_",
"[_",
"symbol_",
"]_",
"=_",
"quantities",
"_",
"._",
"get_",
"(_",
"symbol_",
")_",
"+_",
"quantity_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"transactions_",
"._",
"append_",
"(_",
"Transaction_",
"(_",
"type_",
"=_",
"'",
"BU",
"Y",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"as",
"\\u",
"of",
"\\u",
"date_",
"=_",
"date_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"symbol_",
"=_",
"symbol_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"quantity_",
"=_",
"quantity_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"price_",
"=_",
"price_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"total_",
"=_",
"total_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"sell",
"s",
" ",
"-",
" ",
"if",
" ",
"there",
" ",
"is",
" ",
"anyt",
"hing",
" ",
"to",
" ",
"sell",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"len_",
"(_",
"sell",
"\\u",
"candidates_",
")_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"symbol_",
"=_",
"choice_",
"(_",
"sell",
"\\u",
"candidates_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"price_",
"=_",
"(_",
"prices_",
"._",
"get_",
"(_",
"symbol_",
")_",
"._",
"get_",
"(_",
"date_",
")_",
"if_",
"not_",
"quote",
"\\u",
"map_",
"._",
"get_",
"(_",
"symbol_",
")_",
"._",
"cash",
"\\u",
"equivalent",
"_",
"else_",
"1.0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"avail",
"able",
"\\u",
"quantity_",
"=_",
"quantities",
"_",
"._",
"get_",
"(_",
"symbol_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"quantity_",
"=_",
"min_",
"(_",
"avail",
"able",
"\\u",
"quantity_",
",_",
"round_",
"(_",
"avail",
"able",
"\\u",
"quantity_",
"*_",
"(_",
"randint_",
"(_",
"20_",
",_",
"100_",
")_",
"/_",
"100.0_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"quantity_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"total_",
"=_",
"(_",
"quantity_",
"*_",
"price_",
")_",
"-_",
"commission",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cash_",
"+=_",
"total_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"quantities",
"_",
"[_",
"symbol_",
"]_",
"=_",
"quantities",
"_",
"._",
"get_",
"(_",
"symbol_",
")_",
"-_",
"quantity_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"transactions_",
"._",
"append_",
"(_",
"Transaction_",
"(_",
"type_",
"=_",
"'",
"SEL",
"L",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"as",
"\\u",
"of",
"\\u",
"date_",
"=_",
"date_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"symbol_",
"=_",
"symbol_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"quantity_",
"=_",
"quantity_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"price_",
"=_",
"price_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"total_",
"=_",
"total_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\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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
]
|
Unused import | jkossen/imposter/dbmanage.py | [
{
"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Description {{{\n\"\"\"\n imposter.dbmanage\n ~~~~~~~~~~~~~~~~~\n\n Application for maintaining the imposter database\n\n It's mostly used for updating the database schema and data when upgrading\n to newer imposter versions.\n\n :copyright: (c) 2010 by Jochem Kossen.\n :license: BSD, see LICENSE.txt for more details.\n\"\"\"\n# }}}\n\nfrom flask import Flask\nfrom migrate.versioning.api import version_control, upgrade, downgrade, db_version, version\nfrom sqlalchemy.sql import and_\nfrom models import User, Tag, Status, Format, Post, post_tags\nfrom database import DB\nfrom flaskjk import encrypt_password, slugify\nfrom datetime import datetime\n\nimport sys\nimport getpass\nimport datamigrations\n\napp = Flask(__name__, static_path=None)\napp.config.from_pyfile('config_admin.py')\napp.config.from_envvar('IMPOSTER_DBMANAGE_CONFIG', silent=True)\ndb = app.config['DATABASE']\nrepo = 'migrations/'\n\n\n\n\n\n\n\n\n#---------------------------------------------------------------------------\n# MAIN RUN LOOP\nif __name__ == '__main__':\n if len(sys.argv) < 2:\n usage()\n sys.exit(1)\n\n if sys.argv[1] == 'install':\n install_db()\n elif sys.argv[1] == 'upgrade':\n upgrade_db()\n elif sys.argv[1] == 'downgrade' and len(sys.argv) == 3:\n downgrade_db(sys.argv[2])\n else:\n usage()\n sys.exit(1)\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def vc_db():\n \"\"\"install SQLAlchemy-migrate versioning tables into database\"\"\"\n version_control(url=db, repository=repo)",
"metadata": "root.vc_db",
"header": "['module', '___EOS___']",
"index": 36
},
{
"content": "def upgrade_db(v=None):\n \"\"\"upgrade database schema to latest version\"\"\"\n from_version = db_version(url=db, repository=repo)\n to_version = v\n if to_version is None:\n to_version = version(repository=repo)\n\n print(\"Upgrading db from version %d to %d. \" % (from_version, to_version))\n print(\"Schema upgrade ... \")\n upgrade(url=db, repository=repo, version=v)\n print(\"Data upgrade ... \")\n datamigrations.run_upgrade_scripts(app, from_version, to_version)\n print(\"Done!\")",
"metadata": "root.upgrade_db",
"header": "['module', '___EOS___']",
"index": 40
},
{
"content": "def downgrade_db(v):\n \"\"\"downgrade database schema to specified version\"\"\"\n from_version = db_version(url=db, repository=repo)\n to_version = int(v)\n\n print(\"Downgrading db from version %d to %d. \" % (from_version, to_version))\n print(\"Schema upgrade ... \")\n downgrade(url=db, repository=repo, version=v)\n print(\"Data upgrade ... \")\n datamigrations.run_downgrade_scripts(app, from_version, to_version)\n print(\"Done!\")",
"metadata": "root.downgrade_db",
"header": "['module', '___EOS___']",
"index": 55
},
{
"content": "def add_initial_data():\n \"\"\"Insert initial data into the database\"\"\"\n # open database session\n db_session = DB(db).get_session()\n\n # ask user for an admin username and password\n username = raw_input('Please enter the admin username: ')\n password = getpass.getpass(prompt='Please enter the admin password: ')\n\n # add user to database\n u = User(username, encrypt_password(app.config['SECRET_KEY'], password))\n db_session.add(u)\n\n # create statuses\n s1 = Status('draft')\n s2 = Status('private')\n s3 = Status('public')\n db_session.add(s1)\n db_session.add(s2)\n db_session.add(s3)\n\n # create formats\n f = Format('rest')\n f2 = Format('markdown')\n db_session.add(f)\n db_session.add(f2)\n\n # Tags\n t1 = Tag('imposter')\n t2 = Tag('weblog')\n\n # build initial post and put it in the database\n initial_post_summary = \"\"\"\nInstalled Correctly!\n\"\"\"\n initial_post_content = \"\"\"\nImposter was installed correctly!\n\nThis is just a sample post to show Imposter works.\n\n**Have a lot of fun blogging!**\n\"\"\"\n p1 = Post('Welcome to Imposter!', initial_post_summary, initial_post_content)\n p1.slug = slugify(p1.title)\n p1.createdate = datetime.now()\n p1.lastmoddate = datetime.now()\n p1.pubdate = datetime.now()\n p1.format = f\n p1.status = s3\n p1.user = u\n p1.tags = [t1, t2]\n p1.compile()\n db_session.add(p1)\n db_session.commit()",
"metadata": "root.add_initial_data",
"header": "['module', '___EOS___']",
"index": 67
},
{
"content": "def install_db():\n \"\"\"Initialize new Imposter database\"\"\"\n vc_db()\n upgrade_db()\n add_initial_data()",
"metadata": "root.install_db",
"header": "['module', '___EOS___']",
"index": 122
},
{
"content": "def usage():\n \"\"\"show dbmanage.py usage\"\"\"\n print 'usage: dbmanage.py install|upgrade|downgrade version'",
"metadata": "root.usage",
"header": "['module', '___EOS___']",
"index": 128
}
]
| [
{
"span": "from sqlalchemy.sql import and_",
"start_line": 20,
"start_column": 0,
"end_line": 20,
"end_column": 31
},
{
"span": "from models import User, Tag, Status, Format, Post, post_tags",
"start_line": 21,
"start_column": 0,
"end_line": 21,
"end_column": 61
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#!",
"/",
"usr",
"/",
"bin",
"/",
"env",
" ",
"python_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Descripti",
"on",
" ",
"{{",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"impos",
"ter",
".",
"dbm",
"anag",
"e",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"~~~~~~~~~~~",
"~~~~~",
"~",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Applica",
"tion",
" ",
"for",
" ",
"maintain",
"ing",
" ",
"the",
" ",
"impos",
"ter",
" ",
"databa",
"se",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"It",
"'",
"s",
" ",
"most",
"ly",
" ",
"used",
" ",
"for",
" ",
"updat",
"ing",
" ",
"the",
" ",
"databa",
"se",
" ",
"schema",
" ",
"and",
" ",
"data",
" ",
"whe",
"n",
" ",
"up",
"gradi",
"ng",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"to",
" ",
"newe",
"r",
" ",
"impos",
"ter",
" ",
"version",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"copyr",
"ight",
":",
" ",
"(",
"c",
")",
" ",
"2010",
" ",
"by",
" ",
"Jo",
"chem",
" ",
"Ko",
"sse",
"n",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"license",
":",
" ",
"BS",
"D",
",",
" ",
"see",
" ",
"LICENSE",
".",
"txt",
" ",
"for",
" ",
"more",
" ",
"deta",
"il",
"s",
".",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"}}}",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"flask_",
"import_",
"Flask_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"migrate_",
"._",
"versioning",
"_",
"._",
"api_",
"import_",
"version",
"\\u",
"control_",
",_",
"upgrade_",
",_",
"downgrade_",
",_",
"db",
"\\u",
"version_",
",_",
"version_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"sqlalchemy_",
"._",
"sql_",
"import_",
"and\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"models_",
"import_",
"User_",
",_",
"Tag_",
",_",
"Status_",
",_",
"Format_",
",_",
"Post_",
",_",
"post",
"\\u",
"tags_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"database_",
"import_",
"DB_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"fla",
"sk",
"jk",
"_",
"import_",
"encrypt",
"\\u",
"password_",
",_",
"slugify_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"datetime_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"getpass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"datam",
"igra",
"tions_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"app_",
"=_",
"Flask_",
"(_",
"\\u\\u",
"name\\u\\u_",
",_",
"static",
"\\u",
"path_",
"=_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"app_",
"._",
"config_",
"._",
"from",
"\\u",
"pyfi",
"le_",
"(_",
"'",
"config",
"\\u",
"admin",
".",
"py",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"app_",
"._",
"config_",
"._",
"from",
"\\u",
"envvar",
"_",
"(_",
"'",
"IMP",
"OST",
"ER",
"\\u",
"DB",
"MANAGE",
"\\u",
"CONFIG",
"'_",
",_",
"silent_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db_",
"=_",
"app_",
"._",
"config_",
"[_",
"'",
"DATA",
"BASE",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"repo_",
"=_",
"'",
"migrati",
"ons",
"/'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#-",
"--------------",
"--------------",
"--------------",
"--------------",
"--------------",
"----",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"MAIN",
" ",
"RUN",
" ",
"LOOP",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\\u\\u",
"name\\u\\u_",
"==_",
"'\\u",
"\\u",
"main",
"\\u\\u'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"len_",
"(_",
"sys_",
"._",
"argv_",
")_",
"<_",
"2_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"usage_",
"(_",
")_",
"\\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_",
"if_",
"sys_",
"._",
"argv_",
"[_",
"1_",
"]_",
"==_",
"'",
"install",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"install",
"\\u",
"db_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"sys_",
"._",
"argv_",
"[_",
"1_",
"]_",
"==_",
"'",
"upgrade",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"upgrade",
"\\u",
"db_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"sys_",
"._",
"argv_",
"[_",
"1_",
"]_",
"==_",
"'",
"down",
"grade",
"'_",
"and_",
"len_",
"(_",
"sys_",
"._",
"argv_",
")_",
"==_",
"3_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"down",
"grade",
"\\u",
"db_",
"(_",
"sys_",
"._",
"argv_",
"[_",
"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 ",
" _",
"usage_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"sys_",
"._",
"exit_",
"(_",
"1_",
")_",
"\\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_",
"vc",
"\\u",
"db_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"install",
" ",
"SQL",
"Al",
"chem",
"y",
"-",
"migr",
"ate",
" ",
"versioning",
" ",
"tables",
" ",
"int",
"o",
" ",
"databa",
"se",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"version",
"\\u",
"control_",
"(_",
"url_",
"=_",
"db_",
",_",
"repository_",
"=_",
"repo_",
")_",
"\\u\\u\\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_",
"upgrade",
"\\u",
"db_",
"(_",
"v_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"upgrade",
" ",
"databa",
"se",
" ",
"schema",
" ",
"to",
" ",
"late",
"st",
" ",
"version",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from",
"\\u",
"version_",
"=_",
"db",
"\\u",
"version_",
"(_",
"url_",
"=_",
"db_",
",_",
"repository_",
"=_",
"repo_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"to",
"\\u",
"version_",
"=_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"to",
"\\u",
"version_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"to",
"\\u",
"version_",
"=_",
"version_",
"(_",
"repository_",
"=_",
"repo_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"(_",
"\"",
"Up",
"gradi",
"ng",
" ",
"db",
" ",
"from",
" ",
"version",
" ",
"%",
"d",
" ",
"to",
" ",
"%",
"d",
".",
" ",
"\"_",
"%_",
"(_",
"from",
"\\u",
"version_",
",_",
"to",
"\\u",
"version_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Schema",
" ",
"upgrade",
" ",
"...",
" ",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"upgrade_",
"(_",
"url_",
"=_",
"db_",
",_",
"repository_",
"=_",
"repo_",
",_",
"version_",
"=_",
"v_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Data",
" ",
"upgrade",
" ",
"...",
" ",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"datam",
"igra",
"tions_",
"._",
"run",
"\\u",
"upgrade",
"\\u",
"scripts_",
"(_",
"app_",
",_",
"from",
"\\u",
"version_",
",_",
"to",
"\\u",
"version_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Don",
"e",
"!\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"down",
"grade",
"\\u",
"db_",
"(_",
"v_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"down",
"grade",
" ",
"databa",
"se",
" ",
"schema",
" ",
"to",
" ",
"specified",
" ",
"version",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from",
"\\u",
"version_",
"=_",
"db",
"\\u",
"version_",
"(_",
"url_",
"=_",
"db_",
",_",
"repository_",
"=_",
"repo_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"to",
"\\u",
"version_",
"=_",
"int_",
"(_",
"v_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Down",
"gradi",
"ng",
" ",
"db",
" ",
"from",
" ",
"version",
" ",
"%",
"d",
" ",
"to",
" ",
"%",
"d",
".",
" ",
"\"_",
"%_",
"(_",
"from",
"\\u",
"version_",
",_",
"to",
"\\u",
"version_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Schema",
" ",
"upgrade",
" ",
"...",
" ",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"downgrade_",
"(_",
"url_",
"=_",
"db_",
",_",
"repository_",
"=_",
"repo_",
",_",
"version_",
"=_",
"v_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Data",
" ",
"upgrade",
" ",
"...",
" ",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"datam",
"igra",
"tions_",
"._",
"run",
"\\u",
"down",
"grade",
"\\u",
"scripts_",
"(_",
"app_",
",_",
"from",
"\\u",
"version_",
",_",
"to",
"\\u",
"version_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"\"",
"Don",
"e",
"!\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"add",
"\\u",
"initial",
"\\u",
"data_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Insert",
" ",
"initial",
" ",
"data",
" ",
"int",
"o",
" ",
"the",
" ",
"databa",
"se",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"open",
" ",
"databa",
"se",
" ",
"session_",
"\\u\\u\\uNL\\u\\u\\u_",
"db",
"\\u",
"session_",
"=_",
"DB_",
"(_",
"db_",
")_",
"._",
"get",
"\\u",
"session_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"ask",
" ",
"user",
" ",
"for",
" ",
"an",
" ",
"admin",
" ",
"user",
"name",
" ",
"and",
" ",
"password_",
"\\u\\u\\uNL\\u\\u\\u_",
"username_",
"=_",
"raw",
"\\u",
"input_",
"(_",
"'",
"Ple",
"ase",
" ",
"enter",
" ",
"the",
" ",
"admin",
" ",
"user",
"name",
":",
" ",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"password_",
"=_",
"getpass_",
"._",
"getpass_",
"(_",
"prompt_",
"=_",
"'",
"Ple",
"ase",
" ",
"enter",
" ",
"the",
" ",
"admin",
" ",
"password",
":",
" ",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"add",
" ",
"user",
" ",
"to",
" ",
"database_",
"\\u\\u\\uNL\\u\\u\\u_",
"u_",
"=_",
"User_",
"(_",
"username_",
",_",
"encrypt",
"\\u",
"password_",
"(_",
"app_",
"._",
"config_",
"[_",
"'",
"SEC",
"RET",
"\\u",
"KEY",
"'_",
"]_",
",_",
"password_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"create",
" ",
"statuses_",
"\\u\\u\\uNL\\u\\u\\u_",
"s1_",
"=_",
"Status_",
"(_",
"'",
"draft",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s2_",
"=_",
"Status_",
"(_",
"'",
"private",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"s3_",
"=_",
"Status_",
"(_",
"'",
"public",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"s1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"s2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"s3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"create",
" ",
"formats_",
"\\u\\u\\uNL\\u\\u\\u_",
"f_",
"=_",
"Format_",
"(_",
"'",
"rest",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"f2_",
"=_",
"Format_",
"(_",
"'",
"mark",
"down",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"f_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"f2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Tags_",
"\\u\\u\\uNL\\u\\u\\u_",
"t1_",
"=_",
"Tag_",
"(_",
"'",
"impos",
"ter",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"t2_",
"=_",
"Tag_",
"(_",
"'",
"web",
"log",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"build",
" ",
"initial",
" ",
"post",
" ",
"and",
" ",
"put",
" ",
"it",
" ",
"in",
" ",
"the",
" ",
"database_",
"\\u\\u\\uNL\\u\\u\\u_",
"initial",
"\\u",
"post",
"\\u",
"summary_",
"=_",
"\"\"\"",
"\\",
"10",
";",
"Install",
"ed",
" ",
"Correct",
"ly",
"!",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"initial",
"\\u",
"post",
"\\u",
"content_",
"=_",
"\"\"\"",
"\\",
"10",
";",
"Imp",
"ost",
"er",
" ",
"was",
" ",
"install",
"ed",
" ",
"correct",
"ly",
"!",
"\\",
"10",
";",
"\\",
"10",
";",
"Thi",
"s",
" ",
"is",
" ",
"just",
" ",
"a",
" ",
"sample",
" ",
"post",
" ",
"to",
" ",
"show",
" ",
"Imp",
"ost",
"er",
" ",
"works",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"**",
"Ha",
"ve",
" ",
"a",
" ",
"lot",
" ",
"of",
" ",
"fun",
" ",
"blog",
"ging",
"!*",
"*",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"=_",
"Post_",
"(_",
"'",
"Wel",
"come",
" ",
"to",
" ",
"Imp",
"ost",
"er",
"!'_",
",_",
"initial",
"\\u",
"post",
"\\u",
"summary_",
",_",
"initial",
"\\u",
"post",
"\\u",
"content_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"slug_",
"=_",
"slugify_",
"(_",
"p1_",
"._",
"title_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"created",
"ate_",
"=_",
"datetime_",
"._",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"lastm",
"odd",
"ate_",
"=_",
"datetime_",
"._",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"pub",
"date_",
"=_",
"datetime_",
"._",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"format_",
"=_",
"f_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"status_",
"=_",
"s3_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"user_",
"=_",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"tags_",
"=_",
"[_",
"t1_",
",_",
"t2_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
"._",
"compile_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"add_",
"(_",
"p1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"db",
"\\u",
"session_",
"._",
"commit_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"install",
"\\u",
"db_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Initializ",
"e",
" ",
"new",
" ",
"Imp",
"ost",
"er",
" ",
"databa",
"se",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"vc",
"\\u",
"db_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"upgrade",
"\\u",
"db_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"add",
"\\u",
"initial",
"\\u",
"data_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"usage_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"show",
" ",
"dbm",
"anag",
"e",
".",
"py",
" ",
"usage",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"usage",
":",
" ",
"dbm",
"anag",
"e",
".",
"py",
" ",
"install",
"|",
"upgrade",
"|",
"down",
"grade",
" ",
"version",
"'_",
"\\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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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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused local variable | djangonauts/django-rest-framework-gis/tests/django_restframework_gis_tests/test_filters.py | [
{
"content": " @skipIf(has_spatialite, 'Skipped test for spatialite backend: missing feature \"dwithin\"')\n def test_DistanceToPointFilter_filtering(self):\n \"\"\"\n Checks that the DistancFilter returns only objects within the given distance of the\n given geometry defined by the URL parameters\n \"\"\"\n self.assertEqual(Location.objects.count(), 0)\n\n # Filter parameters\n distance = 5000 # meters\n point_inside_ggpark = [-122.49034881591797, 37.76949349270407]\n point_on_golden_gate_bridge = [-122.47894, 37.8199]\n point_on_alcatraz = [-122.4222, 37.82667]\n point_on_treasure_island = [-122.3692, 37.8244]\n point_on_angel_island = [-122.4326, 37.86091]\n\n url_params = '?dist=%0.4f&point=hello&format=json' % (distance)\n response = self.client.get('%s%s' % (self.location_within_distance_of_point_list_url, url_params))\n self.assertEqual(response.status_code, 400)\n\n url_params = '?dist=%0.4f&point=%0.4f,%0.4f&format=json' % (distance, point_on_alcatraz[0], point_on_alcatraz[1])\n\n treasure_island_geojson = \"\"\"{\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -122.44640350341795,\n 37.86103094116189\n ],\n [\n -122.44262695312501,\n 37.85506751416839\n ],\n [\n -122.43481636047363,\n 37.853305500228025\n ],\n [\n -122.42975234985352,\n 37.854660899304704\n ],\n [\n -122.41953849792479,\n 37.852627791344894\n ],\n [\n -122.41807937622069,\n 37.853305500228025\n ],\n [\n -122.41868019104004,\n 37.86211514878027\n ],\n [\n -122.42391586303711,\n 37.870584971740065\n ],\n [\n -122.43035316467285,\n 37.8723465726078\n ],\n [\n -122.43515968322752,\n 37.86963639998042\n ],\n [\n -122.43953704833984,\n 37.86882332875222\n ],\n [\n -122.44640350341795,\n 37.86103094116189\n ]\n ]\n ]\n }\"\"\"\n\n treasure_island_geom = GEOSGeometry(treasure_island_geojson)\n treasure_island = Location()\n treasure_island.name = \"Treasure Island\"\n treasure_island.geometry = treasure_island_geom\n treasure_island.full_clean()\n treasure_island.save()\n\n ggpark_geojson = \"\"\"{\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -122.5111198425293,\n 37.77125750792944\n ],\n [\n -122.51026153564452,\n 37.76447260365713\n ],\n [\n -122.45309829711913,\n 37.76677954095475\n ],\n [\n -122.45481491088867,\n 37.77424266859531\n ],\n [\n -122.5111198425293,\n 37.77125750792944\n ]\n ]\n ]\n }\"\"\"\n ggpark_geom = GEOSGeometry(ggpark_geojson)\n ggpark = Location()\n ggpark.name = \"Golden Gate Park\"\n ggpark.geometry = ggpark_geom\n ggpark.save()\n\n # Make sure we only get back the ones within the distance\n response = self.client.get('%s%s' % (self.location_within_distance_of_point_list_url, url_params))\n self.assertEqual(len(response.data['features']), 1)\n for result in response.data['features']:\n self.assertEqual(result['properties']['name'] in (treasure_island.name), True)\n\n # Make sure we get back all the ones within the distance\n distance = 7000\n url_params = '?dist=%0.4f&point=%0.4f,%0.4f&format=json' % (distance, point_on_alcatraz[0], point_on_alcatraz[1])\n response = self.client.get('%s%s' % (self.location_within_distance_of_point_list_url, url_params))\n self.assertEqual(len(response.data['features']), 2)\n for result in response.data['features']:\n self.assertEqual(result['properties']['name'] in (ggpark.name, treasure_island.name), True)\n\n # Make sure we only get back the ones within the distance\n degrees = .05\n url_params = '?dist=%0.4f&point=%0.4f,%0.4f&format=json' % (degrees, point_on_alcatraz[0], point_on_alcatraz[1])\n response = self.client.get(self.location_within_degrees_of_point_list_url + url_params)\n self.assertEqual(len(response.data['features']), 1)\n for result in response.data['features']:\n self.assertEqual(result['properties']['name'] in (treasure_island.name), True)",
"metadata": "root.TestRestFrameworkGisFilters.test_DistanceToPointFilter_filtering",
"header": "['class', 'TestRestFrameworkGisFilters', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 128
}
]
| [
{
"span": "point_inside_ggpark ",
"start_line": 138,
"start_column": 8,
"end_line": 138,
"end_column": 27
},
{
"span": "point_on_golden_gate_bridge ",
"start_line": 139,
"start_column": 8,
"end_line": 139,
"end_column": 35
},
{
"span": "point_on_treasure_island ",
"start_line": 141,
"start_column": 8,
"end_line": 141,
"end_column": 32
},
{
"span": "point_on_angel_island ",
"start_line": 142,
"start_column": 8,
"end_line": 142,
"end_column": 29
}
]
| []
| 1 | true | [
"[CLS]_",
"Un",
"used_",
"local_",
"variable_",
"[SEP]_",
"class_",
"Test",
"Rest",
"Frame",
"work",
"Gis",
"Filters_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"skip",
"If_",
"(_",
"has",
"\\u",
"spat",
"iali",
"te_",
",_",
"'",
"Skipped",
" ",
"test",
" ",
"for",
" ",
"spat",
"iali",
"te",
" ",
"back",
"end",
":",
" ",
"missi",
"ng",
" ",
"feature",
" ",
"\"",
"dwi",
"thin",
"\"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"test\\u",
"Distan",
"ce",
"To",
"Point",
"Filter",
"\\u",
"filtering",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Check",
"s",
" ",
"tha",
"t",
" ",
"the",
" ",
"Distan",
"c",
"Filter",
" ",
"return",
"s",
" ",
"only",
" ",
"object",
"s",
" ",
"within",
" ",
"the",
" ",
"give",
"n",
" ",
"distance",
" ",
"of",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"give",
"n",
" ",
"geom",
"etry",
" ",
"defin",
"ed",
" ",
"by",
" ",
"the",
" ",
"URL",
" ",
"parameter",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"Location_",
"._",
"objects_",
"._",
"count_",
"(_",
")_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Filter",
" ",
"parameters_",
"\\u\\u\\uNL\\u\\u\\u_",
"distance_",
"=_",
"5000_",
"#",
" ",
"meters_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"point",
"\\u",
"insi",
"de",
"\\u",
"gg",
"park",
"_",
"=_",
"[_",
"-_",
"122.",
"490",
"348",
"815",
"917",
"97_",
",_",
"37.",
"769",
"493",
"492",
"704",
"07_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"point",
"\\u",
"on",
"\\u",
"golden",
"\\u",
"gate",
"\\u",
"bridge_",
"=_",
"[_",
"-_",
"122.",
"478",
"94_",
",_",
"37.",
"819",
"9_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"=_",
"[_",
"-_",
"122.",
"422",
"2_",
",_",
"37.",
"826",
"67_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"point",
"\\u",
"on",
"\\u",
"trea",
"sure",
"\\u",
"island",
"_",
"=_",
"[_",
"-_",
"122.",
"369",
"2_",
",_",
"37.",
"824",
"4_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"point",
"\\u",
"on",
"\\u",
"ange",
"l\\u",
"island",
"_",
"=_",
"[_",
"-_",
"122.",
"432",
"6_",
",_",
"37.",
"860",
"91_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"url",
"\\u",
"params_",
"=_",
"'?",
"dist",
"=",
"%",
"0.",
"4f",
"&",
"point",
"=",
"hell",
"o",
"&",
"format",
"=",
"json",
"'_",
"%_",
"(_",
"distance_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"response_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"'%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"self_",
"._",
"location",
"\\u",
"within",
"\\u",
"distance",
"\\u",
"of",
"\\u",
"point",
"\\u",
"list",
"\\u",
"url_",
",_",
"url",
"\\u",
"params_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"response_",
"._",
"status",
"\\u",
"code_",
",_",
"400_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"url",
"\\u",
"params_",
"=_",
"'?",
"dist",
"=",
"%",
"0.",
"4f",
"&",
"point",
"=",
"%",
"0.",
"4f",
",%",
"0.",
"4f",
"&",
"format",
"=",
"json",
"'_",
"%_",
"(_",
"distance_",
",_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"[_",
"0_",
"]_",
",_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"[_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"\\u",
"geojson_",
"=_",
"\"\"\"{",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"type",
"\":",
" ",
"\"",
"Polygon",
"\",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"coordinate",
"s",
"\":",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"446",
"403",
"503",
"417",
"9",
"5",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"861",
"030",
"941",
"161",
"89",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"442",
"626",
"953",
"1250",
"1",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"855",
"067",
"514",
"168",
"3",
"9",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"434",
"816",
"360",
"473",
"6",
"3",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"853",
"305",
"500",
"228",
"025",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"429",
"752",
"349",
"853",
"5",
"2",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"854",
"660",
"899",
"304",
"704",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"419",
"538",
"497",
"924",
"7",
"9",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"852",
"627",
"791",
"344",
"894",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"418",
"079",
"376",
"220",
"6",
"9",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"853",
"305",
"500",
"228",
"025",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"418",
"680",
"191",
"0400",
"4",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"862",
"115",
"148",
"780",
"2",
"7",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"423",
"915",
"863",
"037",
"11",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"870",
"584",
"971",
"740",
"065",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"430",
"353",
"164",
"672",
"85",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"872",
"346",
"572",
"607",
"8",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"435",
"159",
"683",
"227",
"5",
"2",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"869",
"636",
"399",
"980",
"4",
"2",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"439",
"537",
"048",
"339",
"84",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"868",
"823",
"328",
"752",
"2",
"2",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"446",
"403",
"503",
"417",
"9",
"5",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"861",
"030",
"941",
"161",
"89",
"\\",
"10",
";",
" ",
" ",
"]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"}\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"\\u",
"geom_",
"=_",
"GEO",
"SG",
"eom",
"etry",
"_",
"(_",
"trea",
"sure",
"\\u",
"island",
"\\u",
"geojson_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"_",
"=_",
"Location_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"name_",
"=_",
"\"",
"Tre",
"asu",
"re",
" ",
"Isl",
"and",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"geometry_",
"=_",
"trea",
"sure",
"\\u",
"island",
"\\u",
"geom_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"full",
"\\u",
"clean_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"gg",
"park",
"\\u",
"geojson_",
"=_",
"\"\"\"{",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"type",
"\":",
" ",
"\"",
"Polygon",
"\",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"coordinate",
"s",
"\":",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"511",
"119",
"842",
"529",
"3",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"771",
"257",
"507",
"929",
"4",
"4",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"510",
"261",
"535",
"644",
"5",
"2",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"764",
"472",
"603",
"657",
"13",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"453",
"098",
"297",
"119",
"13",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"766",
"779",
"540",
"954",
"7",
"5",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"454",
"814",
"910",
"888",
"6",
"7",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"774",
"242",
"668",
"595",
"3",
"1",
"\\",
"10",
";",
" ",
" ",
"],",
"\\",
"10",
";",
" ",
" ",
"[",
"\\",
"10",
";",
" ",
" ",
"-1",
"22.",
"511",
"119",
"842",
"529",
"3",
",",
"\\",
"10",
";",
" ",
" ",
"37.",
"771",
"257",
"507",
"929",
"4",
"4",
"\\",
"10",
";",
" ",
" ",
"]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"]",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"}\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"gg",
"park",
"\\u",
"geom_",
"=_",
"GEO",
"SG",
"eom",
"etry",
"_",
"(_",
"gg",
"park",
"\\u",
"geojson_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"gg",
"park",
"_",
"=_",
"Location_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"gg",
"park",
"_",
"._",
"name_",
"=_",
"\"",
"Gold",
"en",
" ",
"Gat",
"e",
" ",
"Park",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"gg",
"park",
"_",
"._",
"geometry_",
"=_",
"gg",
"park",
"\\u",
"geom_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"gg",
"park",
"_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Make",
" ",
"sure",
" ",
"we",
" ",
"only",
" ",
"get",
" ",
"back",
" ",
"the",
" ",
"ones",
" ",
"within",
" ",
"the",
" ",
"distance_",
"\\u\\u\\uNL\\u\\u\\u_",
"response_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"'%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"self_",
"._",
"location",
"\\u",
"within",
"\\u",
"distance",
"\\u",
"of",
"\\u",
"point",
"\\u",
"list",
"\\u",
"url_",
",_",
"url",
"\\u",
"params_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"len_",
"(_",
"response_",
"._",
"data_",
"[_",
"'",
"features",
"'_",
"]_",
")_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"result_",
"in_",
"response_",
"._",
"data_",
"[_",
"'",
"features",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Equal_",
"(_",
"result_",
"[_",
"'",
"proper",
"ties",
"'_",
"]_",
"[_",
"'",
"name",
"'_",
"]_",
"in_",
"(_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"name_",
")_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Make",
" ",
"sure",
" ",
"we",
" ",
"get",
" ",
"back",
" ",
"all",
" ",
"the",
" ",
"ones",
" ",
"within",
" ",
"the",
" ",
"distance_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"distance_",
"=_",
"7000",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"url",
"\\u",
"params_",
"=_",
"'?",
"dist",
"=",
"%",
"0.",
"4f",
"&",
"point",
"=",
"%",
"0.",
"4f",
",%",
"0.",
"4f",
"&",
"format",
"=",
"json",
"'_",
"%_",
"(_",
"distance_",
",_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"[_",
"0_",
"]_",
",_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"[_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"response_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"'%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"self_",
"._",
"location",
"\\u",
"within",
"\\u",
"distance",
"\\u",
"of",
"\\u",
"point",
"\\u",
"list",
"\\u",
"url_",
",_",
"url",
"\\u",
"params_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"len_",
"(_",
"response_",
"._",
"data_",
"[_",
"'",
"features",
"'_",
"]_",
")_",
",_",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"result_",
"in_",
"response_",
"._",
"data_",
"[_",
"'",
"features",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Equal_",
"(_",
"result_",
"[_",
"'",
"proper",
"ties",
"'_",
"]_",
"[_",
"'",
"name",
"'_",
"]_",
"in_",
"(_",
"gg",
"park",
"_",
"._",
"name_",
",_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"name_",
")_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Make",
" ",
"sure",
" ",
"we",
" ",
"only",
" ",
"get",
" ",
"back",
" ",
"the",
" ",
"ones",
" ",
"within",
" ",
"the",
" ",
"distance_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"degrees_",
"=_",
".05_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"url",
"\\u",
"params_",
"=_",
"'?",
"dist",
"=",
"%",
"0.",
"4f",
"&",
"point",
"=",
"%",
"0.",
"4f",
",%",
"0.",
"4f",
"&",
"format",
"=",
"json",
"'_",
"%_",
"(_",
"degrees_",
",_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"[_",
"0_",
"]_",
",_",
"point",
"\\u",
"on",
"\\u",
"alc",
"atr",
"az_",
"[_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"response_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"self_",
"._",
"location",
"\\u",
"within",
"\\u",
"degr",
"ees",
"\\u",
"of",
"\\u",
"point",
"\\u",
"list",
"\\u",
"url_",
"+_",
"url",
"\\u",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"len_",
"(_",
"response_",
"._",
"data_",
"[_",
"'",
"features",
"'_",
"]_",
")_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"result_",
"in_",
"response_",
"._",
"data_",
"[_",
"'",
"features",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Equal_",
"(_",
"result_",
"[_",
"'",
"proper",
"ties",
"'_",
"]_",
"[_",
"'",
"name",
"'_",
"]_",
"in_",
"(_",
"trea",
"sure",
"\\u",
"island",
"_",
"._",
"name_",
")_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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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
]
|
Except block handles 'BaseException' | cloudera/impyla/impala/_thrift_gen/ExecStats/ttypes.py | [
{
"content": "#\n# Autogenerated by Thrift Compiler (0.9.1)\n#\n# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n#\n# options string: py:new_style\n#\n\nfrom thrift.Thrift import TType, TMessageType, TException, TApplicationException\nimport impala._thrift_gen.Status.ttypes\nimport impala._thrift_gen.Types.ttypes\n\n\nfrom thrift.transport import TTransport\nfrom thrift.protocol import TBinaryProtocol, TProtocol\ntry:\n from thrift.protocol import fastbinary\nexcept:\n fastbinary = None\n\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "except:",
"start_line": 17,
"start_column": 0,
"end_line": 17,
"end_column": 7
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Auto",
"generat",
"ed",
" ",
"by",
" ",
"Thri",
"ft",
" ",
"Compil",
"er",
" ",
"(",
"0.",
"9.1",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"DO",
" ",
"NOT",
" ",
"EDIT",
" ",
"UNL",
"ESS",
" ",
"YOU",
" ",
"ARE",
" ",
"SUR",
"E",
" ",
"THA",
"T",
" ",
"YOU",
" ",
"KN",
"OW",
" ",
"WH",
"AT",
" ",
"YOU",
" ",
"ARE",
" ",
"DOI",
"NG_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
"options",
" ",
"string",
":",
" ",
"py",
":",
"new",
"\\u",
"style_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"thrift",
"_",
"._",
"Thri",
"ft_",
"import_",
"TT",
"ype_",
",_",
"TM",
"essage",
"Type_",
",_",
"TE",
"xcept",
"ion_",
",_",
"TA",
"ppl",
"ication",
"Exception_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"impala",
"_",
"._",
"\\u",
"thrift",
"\\u",
"gen_",
"._",
"Status_",
"._",
"ttype",
"s_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"impala",
"_",
"._",
"\\u",
"thrift",
"\\u",
"gen_",
"._",
"Types_",
"._",
"ttype",
"s_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"thrift",
"_",
"._",
"transport_",
"import_",
"TT",
"rans",
"port_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"thrift",
"_",
"._",
"protocol_",
"import_",
"TB",
"inary",
"Protocol_",
",_",
"TP",
"roto",
"col_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"thrift",
"_",
"._",
"protocol_",
"import_",
"fastbinary_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\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django-floppyforms/tests/test_deprecations.py | [
{
"content": " def test_model_form_is_deprecated(self):\n class RegistrationModelForm(forms.ModelForm):\n class Meta:\n model = Registration\n fields = (\n 'firstname',\n 'lastname',\n 'username',\n 'age',\n )\n\n with warnings.catch_warnings(record=True) as w:\n modelform = RegistrationModelForm()\n self.assertEqual(len(w), 1)\n self.assertTrue(w[0].category is FutureWarning)\n\n self.assertFalse(isinstance(modelform.base_fields['firstname'], forms.CharField))\n self.assertIsInstance(modelform.base_fields['firstname'], django.forms.CharField)",
"metadata": "root.ModelFormDeprecationTests.test_model_form_is_deprecated",
"header": "['class', 'ModelFormDeprecationTests', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 10
}
]
| [
{
"span": "self.assertTrue(w[0].category is FutureWarning)",
"start_line": 24,
"start_column": 12,
"end_line": 24,
"end_column": 59
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Model",
"Form",
"Dep",
"reca",
"tion",
"Tests_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"test\\u",
"model",
"\\u",
"form",
"\\u",
"is",
"\\u",
"deprecated_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"class_",
"Registration",
"Model",
"Form_",
"(_",
"forms_",
"._",
"Model",
"Form_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"class_",
"Meta_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"model_",
"=_",
"Registration",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"fields_",
"=_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"first",
"name",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"last",
"name",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"name",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"age",
"'_",
",_",
"\\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_",
"with_",
"warnings_",
"._",
"catch",
"\\u",
"warnings_",
"(_",
"record_",
"=_",
"True_",
")_",
"as_",
"w_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"modelf",
"orm_",
"=_",
"Registration",
"Model",
"Form_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"len_",
"(_",
"w_",
")_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"w_",
"[_",
"0_",
"]_",
"._",
"category_",
"is_",
"Fu",
"ture",
"Warning_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"isinstance_",
"(_",
"modelf",
"orm_",
"._",
"base",
"\\u",
"fields_",
"[_",
"'",
"first",
"name",
"'_",
"]_",
",_",
"forms_",
"._",
"Char",
"Field_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Is",
"Instance_",
"(_",
"modelf",
"orm_",
"._",
"base",
"\\u",
"fields_",
"[_",
"'",
"first",
"name",
"'_",
"]_",
",_",
"django_",
"._",
"forms_",
"._",
"Char",
"Field_",
")_"
]
| [
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused local variable | tyiannak/pyAudioAnalysis/audioVisualization.py | [
{
"content": "def textListToColors(names):\n\t'''\n\tGenerates a list of colors based on a list of names (strings). Similar strings correspond to similar colors.\n\t'''\n\t# STEP A: compute strings distance between all combnations of strings\n\tDnames = np.zeros( (len(names), len(names)) )\n\tfor i in range(len(names)):\n\t\tfor j in range(len(names)):\n\t\t\tDnames[i,j] = 1 - 2.0 * levenshtein(names[i], names[j]) / float(len(names[i]+names[j]))\n\n\t# STEP B: pca dimanesionality reduction to a single-dimension (from the distance space)\n\tpca = mlpy.PCA(method='cov') \n\tpca.learn(Dnames)\n\tcoeff = pca.coeff()\n\t\n\t# STEP C: mapping of 1-dimensional values to colors in a jet-colormap\n\ttextToColor = pca.transform(Dnames, k=1)\n\ttextToColor = 255 * (textToColor - textToColor.min()) / (textToColor.max() - textToColor.min())\n\ttextmaps = generateColorMap();\n\tcolors = [textmaps[int(c)] for c in textToColor]\n\treturn colors",
"metadata": "root.textListToColors",
"header": "['module', '___EOS___']",
"index": 39
},
{
"content": "def visualizeFeaturesFolder(folder, dimReductionMethod, priorKnowledge = \"none\"):\n\t'''\n\tThis function generates a chordial visualization for the recordings of the provided path.\n\tARGUMENTS:\n\t\t- folder:\t\tpath of the folder that contains the WAV files to be processed\n\t\t- dimReductionMethod:\tmethod used to reduce the dimension of the initial feature space before computing the similarity.\n\t\t- priorKnowledge:\tif this is set equal to \"artist\"\n\t'''\n\tif dimReductionMethod==\"pca\":\n\t\tallMtFeatures, wavFilesList = aF.dirWavFeatureExtraction(folder, 30.0, 30.0, 0.050, 0.050, computeBEAT = True)\n\t\tif allMtFeatures.shape[0]==0:\n\t\t\tprint \"Error: No data found! Check input folder\"\n\t\t\treturn\n\t\t\n\t\tnamesCategoryToVisualize = [ntpath.basename(w).replace('.wav','').split(\" --- \")[0] for w in wavFilesList]; \n\t\tnamesToVisualize \t = [ntpath.basename(w).replace('.wav','') for w in wavFilesList]; \n\n\t\t(F, MEAN, STD) = aT.normalizeFeatures([allMtFeatures])\n\t\tF = np.concatenate(F)\n\t\tpca = mlpy.PCA(method='cov') # pca (eigenvalue decomposition)\n\t\tpca.learn(F)\n\t\tcoeff = pca.coeff()\n\t\t\n\t\t# check that the new PCA dimension is at most equal to the number of samples\n\t\tK1 = 2\n\t\tK2 = 10\n\t\tif K1 > F.shape[0]:\n\t\t\tK1 = F.shape[0]\n\t\tif K2 > F.shape[0]:\n\t\t\tK2 = F.shape[0]\n\n\t\tfinalDims = pca.transform(F, k=K1)\n\t\tfinalDims2 = pca.transform(F, k=K2)\n\telse:\t\n\t\tallMtFeatures, Ys, wavFilesList = aF.dirWavFeatureExtractionNoAveraging(folder, 20.0, 5.0, 0.040, 0.040) # long-term statistics cannot be applied in this context (LDA needs mid-term features)\n\t\tif allMtFeatures.shape[0]==0:\n\t\t\tprint \"Error: No data found! Check input folder\"\n\t\t\treturn\n\t\t\n\t\tnamesCategoryToVisualize = [ntpath.basename(w).replace('.wav','').split(\" --- \")[0] for w in wavFilesList]; \n\t\tnamesToVisualize \t = [ntpath.basename(w).replace('.wav','') for w in wavFilesList]; \n\n\t\tldaLabels = Ys\n\t\tif priorKnowledge==\"artist\":\n\t\t\tuNamesCategoryToVisualize = list(set(namesCategoryToVisualize))\n\t\t\tYsNew = np.zeros( Ys.shape )\n\t\t\tfor i, uname in enumerate(uNamesCategoryToVisualize):\t\t# for each unique artist name:\n\t\t\t\tindicesUCategories = [j for j, x in enumerate(namesCategoryToVisualize) if x == uname]\n\t\t\t\tfor j in indicesUCategories:\n\t\t\t\t\tindices = np.nonzero(Ys==j)\n\t\t\t\t\tYsNew[indices] = i\n\t\t\tldaLabels = YsNew\n\n\t\t(F, MEAN, STD) = aT.normalizeFeatures([allMtFeatures])\n\t\tF = np.array(F[0])\n\n\t\tclf = LDA(n_components=10)\n\t\tclf.fit(F, ldaLabels)\t\n\t\treducedDims = clf.transform(F)\n\n\t\tpca = mlpy.PCA(method='cov') # pca (eigenvalue decomposition)\n\t\tpca.learn(reducedDims)\n\t\tcoeff = pca.coeff()\n\t\treducedDims = pca.transform(reducedDims, k=2)\n\n\t\t# TODO: CHECK THIS ... SHOULD LDA USED IN SEMI-SUPERVISED ONLY????\n\n\t\tuLabels = np.sort(np.unique((Ys)))\t\t# uLabels must have as many labels as the number of wavFilesList elements\n\t\treducedDimsAvg = np.zeros( (uLabels.shape[0], reducedDims.shape[1] ) )\n\t\tfinalDims = np.zeros( (uLabels.shape[0], 2) ) \n\t\tfor i, u in enumerate(uLabels):\n\t\t\tindices = [j for j, x in enumerate(Ys) if x == u]\n\t\t\tf = reducedDims[indices, :]\n\t\t\tfinalDims[i, :] = f.mean(axis=0)\n\t\tfinalDims2 = reducedDims\n\n\tfor i in range(finalDims.shape[0]):\t\t\t\n\t\tplt.text(finalDims[i,0], finalDims[i,1], ntpath.basename(wavFilesList[i].replace('.wav','')), horizontalalignment='center', verticalalignment='center', fontsize=10)\n\t\tplt.plot(finalDims[i,0], finalDims[i,1], '*r')\n\tplt.xlim([1.2*finalDims[:,0].min(), 1.2*finalDims[:,0].max()])\n\tplt.ylim([1.2*finalDims[:,1].min(), 1.2*finalDims[:,1].max()])\t\t\t\n\tplt.show()\n\n\tSM = 1.0 - distance.squareform(distance.pdist(finalDims2, 'cosine'))\n\tfor i in range(SM.shape[0]):\n\t\tSM[i,i] = 0.0;\n\n\n\tchordialDiagram(\"visualization\", SM, 0.50, namesToVisualize, namesCategoryToVisualize)\n\n\tSM = 1.0 - distance.squareform(distance.pdist(F, 'cosine'))\n\tfor i in range(SM.shape[0]):\n\t\tSM[i,i] = 0.0;\n\tchordialDiagram(\"visualizationInitial\", SM, 0.50, namesToVisualize, namesCategoryToVisualize)\n\n\t# plot super-categories (i.e. artistname\n\tuNamesCategoryToVisualize = sort(list(set(namesCategoryToVisualize)))\n\tfinalDimsGroup = np.zeros( (len(uNamesCategoryToVisualize), finalDims2.shape[1] ) )\n\tfor i, uname in enumerate(uNamesCategoryToVisualize):\n\t\tindices = [j for j, x in enumerate(namesCategoryToVisualize) if x == uname]\n\t\tf = finalDims2[indices, :]\n\t\tfinalDimsGroup[i, :] = f.mean(axis=0)\n\n\tSMgroup = 1.0 - distance.squareform(distance.pdist(finalDimsGroup, 'cosine'))\n\tfor i in range(SMgroup.shape[0]):\n\t\tSMgroup[i,i] = 0.0;\n\tchordialDiagram(\"visualizationGroup\", SMgroup, 0.50, uNamesCategoryToVisualize, uNamesCategoryToVisualize)",
"metadata": "root.visualizeFeaturesFolder",
"header": "['module', '___EOS___']",
"index": 107
}
]
| [
{
"span": "coeff ",
"start_line": 52,
"start_column": 1,
"end_line": 52,
"end_column": 6
},
{
"span": "coeff ",
"start_line": 128,
"start_column": 2,
"end_line": 128,
"end_column": 7
},
{
"span": "coeff ",
"start_line": 169,
"start_column": 2,
"end_line": 169,
"end_column": 7
},
{
"span": "reducedDimsAvg ",
"start_line": 175,
"start_column": 2,
"end_line": 175,
"end_column": 16
}
]
| []
| 1 | true | [
"[CLS]_",
"Un",
"used_",
"local_",
"variable_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"text",
"List",
"To",
"Colors_",
"(_",
"names_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"_",
"'''",
"\\",
"10",
";",
"\t",
"Generate",
"s",
" ",
"a",
" ",
"list",
" ",
"of",
" ",
"colors",
" ",
"based",
" ",
"on",
" ",
"a",
" ",
"list",
" ",
"of",
" ",
"names",
" ",
"(",
"string",
"s",
").",
" ",
"Simil",
"ar",
" ",
"string",
"s",
" ",
"correspond",
" ",
"to",
" ",
"similar",
" ",
"colors",
".",
"\\",
"10",
";",
"\t",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"STEP",
" ",
"A",
":",
" ",
"compute",
" ",
"string",
"s",
" ",
"distance",
" ",
"bet",
"ween",
" ",
"all",
" ",
"comb",
"nati",
"ons",
" ",
"of",
" ",
"strings_",
"\\u\\u\\uNL\\u\\u\\u_",
"Dn",
"ames_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"(_",
"len_",
"(_",
"names_",
")_",
",_",
"len_",
"(_",
"names_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"len_",
"(_",
"names_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"for_",
"j_",
"in_",
"range_",
"(_",
"len_",
"(_",
"names_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"Dn",
"ames_",
"[_",
"i_",
",_",
"j_",
"]_",
"=_",
"1_",
"-_",
"2.0_",
"*_",
"leve",
"nsh",
"tein",
"_",
"(_",
"names_",
"[_",
"i_",
"]_",
",_",
"names_",
"[_",
"j_",
"]_",
")_",
"/_",
"float_",
"(_",
"len_",
"(_",
"names_",
"[_",
"i_",
"]_",
"+_",
"names_",
"[_",
"j_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"STEP",
" ",
"B",
":",
" ",
"pca",
" ",
"dim",
"ane",
"sion",
"ality",
" ",
"reduc",
"tion",
" ",
"to",
" ",
"a",
" ",
"single",
"-",
"dimension",
" ",
"(",
"from",
" ",
"the",
" ",
"distance",
" ",
"space",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"pca_",
"=_",
"mlp",
"y_",
"._",
"PCA",
"_",
"(_",
"method_",
"=_",
"'",
"cov",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pca_",
"._",
"learn_",
"(_",
"Dn",
"ames_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"coeff_",
"=_",
"pca_",
"._",
"coeff_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"STEP",
" ",
"C",
":",
" ",
"mapping",
" ",
"of",
" ",
"1",
"-",
"dimension",
"al",
" ",
"values",
" ",
"to",
" ",
"colors",
" ",
"in",
" ",
"a",
" ",
"jet",
"-",
"colormap_",
"\\u\\u\\uNL\\u\\u\\u_",
"text",
"To",
"Color_",
"=_",
"pca_",
"._",
"transform_",
"(_",
"Dn",
"ames_",
",_",
"k_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"text",
"To",
"Color_",
"=_",
"255_",
"*_",
"(_",
"text",
"To",
"Color_",
"-_",
"text",
"To",
"Color_",
"._",
"min_",
"(_",
")_",
")_",
"/_",
"(_",
"text",
"To",
"Color_",
"._",
"max_",
"(_",
")_",
"-_",
"text",
"To",
"Color_",
"._",
"min_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"text",
"maps_",
"=_",
"generat",
"e",
"Color",
"Map_",
"(_",
")_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"colors_",
"=_",
"[_",
"text",
"maps_",
"[_",
"int_",
"(_",
"c_",
")_",
"]_",
"for_",
"c_",
"in_",
"text",
"To",
"Color_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"colors_",
"\\u\\u\\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_",
"visualize",
"Feature",
"s",
"Folder_",
"(_",
"folder_",
",_",
"dim",
"Redu",
"ction",
"Method_",
",_",
"prior",
"Knowledge",
"_",
"=_",
"\"",
"none",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"_",
"'''",
"\\",
"10",
";",
"\t",
"Thi",
"s",
" ",
"function",
" ",
"generat",
"es",
" ",
"a",
" ",
"chord",
"ial",
" ",
"visualization",
" ",
"for",
" ",
"the",
" ",
"recordings",
" ",
"of",
" ",
"the",
" ",
"provided",
" ",
"path",
".",
"\\",
"10",
";",
"\t",
"ARGUMENT",
"S",
":",
"\\",
"10",
";",
"\t",
"\t",
"-",
" ",
"folder",
":",
"\t",
"\t",
"path",
" ",
"of",
" ",
"the",
" ",
"folder",
" ",
"tha",
"t",
" ",
"contain",
"s",
" ",
"the",
" ",
"WA",
"V",
" ",
"files",
" ",
"to",
" ",
"be",
" ",
"process",
"ed",
"\\",
"10",
";",
"\t",
"\t",
"-",
" ",
"dim",
"Redu",
"ction",
"Meth",
"od",
":",
"\t",
"method",
" ",
"used",
" ",
"to",
" ",
"reduce",
" ",
"the",
" ",
"dimension",
" ",
"of",
" ",
"the",
" ",
"initial",
" ",
"feature",
" ",
"space",
" ",
"bef",
"ore",
" ",
"compu",
"ting",
" ",
"the",
" ",
"similar",
"it",
"y",
".",
"\\",
"10",
";",
"\t",
"\t",
"-",
" ",
"prior",
"Knowledge",
":",
"\t",
"if",
" ",
"this",
" ",
"is",
" ",
"set",
" ",
"equal",
" ",
"to",
" ",
"\"",
"artist",
"\"",
"\\",
"10",
";",
"\t",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"dim",
"Redu",
"ction",
"Method_",
"==_",
"\"",
"pca",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"all",
"Mt",
"Features_",
",_",
"wav",
"Files",
"List_",
"=_",
"a",
"F_",
"._",
"dir",
"Wa",
"v",
"Feature",
"Extraction",
"_",
"(_",
"folder_",
",_",
"30.0_",
",_",
"30.0_",
",_",
"0.05",
"0_",
",_",
"0.05",
"0_",
",_",
"compute",
"BEA",
"T_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"all",
"Mt",
"Features_",
"._",
"shape_",
"[_",
"0_",
"]_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"print_",
"\"",
"Error",
":",
" ",
"No",
" ",
"data",
" ",
"found",
"!",
" ",
"Check",
" ",
"input",
" ",
"folder",
"\"_",
"\\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_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
"=_",
"[_",
"ntpath",
"_",
"._",
"basename_",
"(_",
"w_",
")_",
"._",
"replace_",
"(_",
"'.",
"wav",
"'_",
",_",
"''_",
")_",
"._",
"split_",
"(_",
"\"",
" ",
"---",
" ",
"\"_",
")_",
"[_",
"0_",
"]_",
"for_",
"w_",
"in_",
"wav",
"Files",
"List_",
"]_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"names",
"To",
"Visuali",
"ze_",
"=_",
"[_",
"ntpath",
"_",
"._",
"basename_",
"(_",
"w_",
")_",
"._",
"replace_",
"(_",
"'.",
"wav",
"'_",
",_",
"''_",
")_",
"for_",
"w_",
"in_",
"wav",
"Files",
"List_",
"]_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"F_",
",_",
"MEAN",
"_",
",_",
"STD",
"_",
")_",
"=_",
"a",
"T_",
"._",
"normali",
"ze",
"Features_",
"(_",
"[_",
"all",
"Mt",
"Features_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"F_",
"=_",
"np_",
"._",
"concatenate_",
"(_",
"F_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pca_",
"=_",
"mlp",
"y_",
"._",
"PCA",
"_",
"(_",
"method_",
"=_",
"'",
"cov",
"'_",
")_",
"#",
" ",
"pca",
" ",
"(",
"eigen",
"value",
" ",
"decomposition",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pca_",
"._",
"learn_",
"(_",
"F_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"coeff_",
"=_",
"pca_",
"._",
"coeff_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"check",
" ",
"tha",
"t",
" ",
"the",
" ",
"new",
" ",
"PCA",
" ",
"dimension",
" ",
"is",
" ",
"at",
" ",
"most",
" ",
"equal",
" ",
"to",
" ",
"the",
" ",
"number",
" ",
"of",
" ",
"samples_",
"\\u\\u\\uNL\\u\\u\\u_",
"K1",
"_",
"=_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"K2",
"_",
"=_",
"10_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"K1",
"_",
">_",
"F_",
"._",
"shape_",
"[_",
"0_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"K1",
"_",
"=_",
"F_",
"._",
"shape_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"K2",
"_",
">_",
"F_",
"._",
"shape_",
"[_",
"0_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"K2",
"_",
"=_",
"F_",
"._",
"shape_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"final",
"Dims",
"_",
"=_",
"pca_",
"._",
"transform_",
"(_",
"F_",
",_",
"k_",
"=_",
"K1",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"Dims",
"2_",
"=_",
"pca_",
"._",
"transform_",
"(_",
"F_",
",_",
"k_",
"=_",
"K2",
"_",
")_",
"\\u\\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_",
"all",
"Mt",
"Features_",
",_",
"Ys",
"_",
",_",
"wav",
"Files",
"List_",
"=_",
"a",
"F_",
"._",
"dir",
"Wa",
"v",
"Feature",
"Extraction",
"No",
"Ave",
"rag",
"ing_",
"(_",
"folder_",
",_",
"20.0_",
",_",
"5.0_",
",_",
"0.04",
"0_",
",_",
"0.04",
"0_",
")_",
"#",
" ",
"long",
"-",
"term",
" ",
"statistic",
"s",
" ",
"cann",
"ot",
" ",
"be",
" ",
"applied",
" ",
"in",
" ",
"this",
" ",
"context",
" ",
"(",
"LDA",
" ",
"need",
"s",
" ",
"mid",
"-",
"term",
" ",
"features",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"all",
"Mt",
"Features_",
"._",
"shape_",
"[_",
"0_",
"]_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"print_",
"\"",
"Error",
":",
" ",
"No",
" ",
"data",
" ",
"found",
"!",
" ",
"Check",
" ",
"input",
" ",
"folder",
"\"_",
"\\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_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
"=_",
"[_",
"ntpath",
"_",
"._",
"basename_",
"(_",
"w_",
")_",
"._",
"replace_",
"(_",
"'.",
"wav",
"'_",
",_",
"''_",
")_",
"._",
"split_",
"(_",
"\"",
" ",
"---",
" ",
"\"_",
")_",
"[_",
"0_",
"]_",
"for_",
"w_",
"in_",
"wav",
"Files",
"List_",
"]_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"names",
"To",
"Visuali",
"ze_",
"=_",
"[_",
"ntpath",
"_",
"._",
"basename_",
"(_",
"w_",
")_",
"._",
"replace_",
"(_",
"'.",
"wav",
"'_",
",_",
"''_",
")_",
"for_",
"w_",
"in_",
"wav",
"Files",
"List_",
"]_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"lda",
"Labels_",
"=_",
"Ys",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"prior",
"Knowledge",
"_",
"==_",
"\"",
"artist",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"u",
"Names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
"=_",
"list_",
"(_",
"set_",
"(_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Ys",
"New_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"Ys",
"_",
"._",
"shape_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
",_",
"uname_",
"in_",
"enumerate_",
"(_",
"u",
"Names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
":_",
"#",
" ",
"for",
" ",
"each",
" ",
"unique",
" ",
"artist",
" ",
"name",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t\t_",
"indice",
"s",
"UC",
"ate",
"gori",
"es_",
"=_",
"[_",
"j_",
"for_",
"j_",
",_",
"x_",
"in_",
"enumerate_",
"(_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
"if_",
"x_",
"==_",
"uname_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"j_",
"in_",
"indice",
"s",
"UC",
"ate",
"gori",
"es_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t\t\t_",
"indices_",
"=_",
"np_",
"._",
"nonzero_",
"(_",
"Ys",
"_",
"==_",
"j_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Ys",
"New_",
"[_",
"indices_",
"]_",
"=_",
"i_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"lda",
"Labels_",
"=_",
"Ys",
"New_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"(_",
"F_",
",_",
"MEAN",
"_",
",_",
"STD",
"_",
")_",
"=_",
"a",
"T_",
"._",
"normali",
"ze",
"Features_",
"(_",
"[_",
"all",
"Mt",
"Features_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"F_",
"=_",
"np_",
"._",
"array_",
"(_",
"F_",
"[_",
"0_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"clf_",
"=_",
"LDA",
"_",
"(_",
"n",
"\\u",
"components_",
"=_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"clf_",
"._",
"fit_",
"(_",
"F_",
",_",
"lda",
"Labels_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"reduce",
"d",
"Dims",
"_",
"=_",
"clf_",
"._",
"transform_",
"(_",
"F_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"pca_",
"=_",
"mlp",
"y_",
"._",
"PCA",
"_",
"(_",
"method_",
"=_",
"'",
"cov",
"'_",
")_",
"#",
" ",
"pca",
" ",
"(",
"eigen",
"value",
" ",
"decomposition",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pca_",
"._",
"learn_",
"(_",
"reduce",
"d",
"Dims",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"coeff_",
"=_",
"pca_",
"._",
"coeff_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"reduce",
"d",
"Dims",
"_",
"=_",
"pca_",
"._",
"transform_",
"(_",
"reduce",
"d",
"Dims",
"_",
",_",
"k_",
"=_",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"CHECK",
" ",
"THIS",
" ",
"...",
" ",
"SHO",
"UL",
"D",
" ",
"LDA",
" ",
"USED",
" ",
"IN",
" ",
"SEMI",
"-",
"SUPER",
"VIS",
"ED",
" ",
"ONL",
"Y",
"???",
"?",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"u",
"Labels_",
"=_",
"np_",
"._",
"sort_",
"(_",
"np_",
"._",
"unique_",
"(_",
"(_",
"Ys",
"_",
")_",
")_",
")_",
"#",
" ",
"u",
"Label",
"s",
" ",
"must",
" ",
"have",
" ",
"as",
" ",
"many",
" ",
"labels",
" ",
"as",
" ",
"the",
" ",
"number",
" ",
"of",
" ",
"wav",
"Files",
"List",
" ",
"elements_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"reduce",
"d",
"Dims",
"Avg_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"(_",
"u",
"Labels_",
"._",
"shape_",
"[_",
"0_",
"]_",
",_",
"reduce",
"d",
"Dims",
"_",
"._",
"shape_",
"[_",
"1_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"Dims",
"_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"(_",
"u",
"Labels_",
"._",
"shape_",
"[_",
"0_",
"]_",
",_",
"2_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
",_",
"u_",
"in_",
"enumerate_",
"(_",
"u",
"Labels_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"indices_",
"=_",
"[_",
"j_",
"for_",
"j_",
",_",
"x_",
"in_",
"enumerate_",
"(_",
"Ys",
"_",
")_",
"if_",
"x_",
"==_",
"u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"f_",
"=_",
"reduce",
"d",
"Dims",
"_",
"[_",
"indices_",
",_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"Dims",
"_",
"[_",
"i_",
",_",
":_",
"]_",
"=_",
"f_",
"._",
"mean_",
"(_",
"axis_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"final",
"Dims",
"2_",
"=_",
"reduce",
"d",
"Dims",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"final",
"Dims",
"_",
"._",
"shape_",
"[_",
"0_",
"]_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"plt_",
"._",
"text_",
"(_",
"final",
"Dims",
"_",
"[_",
"i_",
",_",
"0_",
"]_",
",_",
"final",
"Dims",
"_",
"[_",
"i_",
",_",
"1_",
"]_",
",_",
"ntpath",
"_",
"._",
"basename_",
"(_",
"wav",
"Files",
"List_",
"[_",
"i_",
"]_",
"._",
"replace_",
"(_",
"'.",
"wav",
"'_",
",_",
"''_",
")_",
")_",
",_",
"horizon",
"tal",
"alignment_",
"=_",
"'",
"center",
"'_",
",_",
"vertical",
"alignment_",
"=_",
"'",
"center",
"'_",
",_",
"fontsize_",
"=_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plt_",
"._",
"plot_",
"(_",
"final",
"Dims",
"_",
"[_",
"i_",
",_",
"0_",
"]_",
",_",
"final",
"Dims",
"_",
"[_",
"i_",
",_",
"1_",
"]_",
",_",
"'*",
"r",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"plt_",
"._",
"xlim_",
"(_",
"[_",
"1.2_",
"*_",
"final",
"Dims",
"_",
"[_",
":_",
",_",
"0_",
"]_",
"._",
"min_",
"(_",
")_",
",_",
"1.2_",
"*_",
"final",
"Dims",
"_",
"[_",
":_",
",_",
"0_",
"]_",
"._",
"max_",
"(_",
")_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plt_",
"._",
"ylim_",
"(_",
"[_",
"1.2_",
"*_",
"final",
"Dims",
"_",
"[_",
":_",
",_",
"1_",
"]_",
"._",
"min_",
"(_",
")_",
",_",
"1.2_",
"*_",
"final",
"Dims",
"_",
"[_",
":_",
",_",
"1_",
"]_",
"._",
"max_",
"(_",
")_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plt_",
"._",
"show_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"SM_",
"=_",
"1.0_",
"-_",
"distance_",
"._",
"square",
"form_",
"(_",
"distance_",
"._",
"pdi",
"st_",
"(_",
"final",
"Dims",
"2_",
",_",
"'",
"cosine",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"SM_",
"._",
"shape_",
"[_",
"0_",
"]_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"SM_",
"[_",
"i_",
",_",
"i_",
"]_",
"=_",
"0.0_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"chord",
"ial",
"Diagram",
"_",
"(_",
"\"",
"visualization",
"\"_",
",_",
"SM_",
",_",
"0.50",
"_",
",_",
"names",
"To",
"Visuali",
"ze_",
",_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"SM_",
"=_",
"1.0_",
"-_",
"distance_",
"._",
"square",
"form_",
"(_",
"distance_",
"._",
"pdi",
"st_",
"(_",
"F_",
",_",
"'",
"cosine",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"SM_",
"._",
"shape_",
"[_",
"0_",
"]_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"SM_",
"[_",
"i_",
",_",
"i_",
"]_",
"=_",
"0.0_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"chord",
"ial",
"Diagram",
"_",
"(_",
"\"",
"visualization",
"Initial",
"\"_",
",_",
"SM_",
",_",
"0.50",
"_",
",_",
"names",
"To",
"Visuali",
"ze_",
",_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"plot",
" ",
"super",
"-",
"categor",
"ies",
" ",
"(",
"i",
".",
"e",
".",
" ",
"artist",
"name_",
"\\u\\u\\uNL\\u\\u\\u_",
"u",
"Names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
"=_",
"sort_",
"(_",
"list_",
"(_",
"set_",
"(_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"Dims",
"Group_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"(_",
"len_",
"(_",
"u",
"Names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
",_",
"final",
"Dims",
"2_",
"._",
"shape_",
"[_",
"1_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
",_",
"uname_",
"in_",
"enumerate_",
"(_",
"u",
"Names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"indices_",
"=_",
"[_",
"j_",
"for_",
"j_",
",_",
"x_",
"in_",
"enumerate_",
"(_",
"names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
")_",
"if_",
"x_",
"==_",
"uname_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"f_",
"=_",
"final",
"Dims",
"2_",
"[_",
"indices_",
",_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"Dims",
"Group_",
"[_",
"i_",
",_",
":_",
"]_",
"=_",
"f_",
"._",
"mean_",
"(_",
"axis_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"SM",
"group_",
"=_",
"1.0_",
"-_",
"distance_",
"._",
"square",
"form_",
"(_",
"distance_",
"._",
"pdi",
"st_",
"(_",
"final",
"Dims",
"Group_",
",_",
"'",
"cosine",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"SM",
"group_",
"._",
"shape_",
"[_",
"0_",
"]_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"SM",
"group_",
"[_",
"i_",
",_",
"i_",
"]_",
"=_",
"0.0_",
";_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"chord",
"ial",
"Diagram",
"_",
"(_",
"\"",
"visualization",
"Group",
"\"_",
",_",
"SM",
"group_",
",_",
"0.50",
"_",
",_",
"u",
"Names",
"Cate",
"gory",
"To",
"Visuali",
"ze_",
",_",
"u",
"Names",
"Cate",
"gory",
"To",
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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
]
|
Unused import | jmg/elixir/tests/db1/__init__.py | [
{
"content": "import a, b, c\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "import a, b, c",
"start_line": 0,
"start_column": 0,
"end_line": 0,
"end_column": 14
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"a_",
",_",
"b_",
",_",
"c_"
]
| [
4,
4,
4,
4,
4,
2,
2,
0,
1,
1,
1,
1,
1
]
|
Variable defined multiple times | tyiannak/pyAudioAnalysis/audioFeatureExtraction.py | [
{
"content": "def stChromaFeatures(X, fs, nChroma, nFreqsPerChroma):\n #TODO: 1 complexity\n #TODO: 2 bug with large windows\n\n chromaNames = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']\n spec = X**2\n C = numpy.zeros((nChroma.shape[0],))\n C[nChroma] = spec\n C /= nFreqsPerChroma[nChroma]\n finalC = numpy.zeros((12, 1))\n newD = int(numpy.ceil(C.shape[0] / 12.0) * 12)\n C2 = numpy.zeros((newD, ))\n C2[0:C.shape[0]] = C\n C2 = C2.reshape(C2.shape[0]/12, 12)\n #for i in range(12):\n # finalC[i] = numpy.sum(C[i:C.shape[0]:12])\n finalC = numpy.matrix(numpy.sum(C2, axis=0)).T\n finalC /= spec.sum()\n\n# ax = plt.gca()\n# plt.hold(False)\n# plt.plot(finalC)\n# ax.set_xticks(range(len(chromaNames)))\n# ax.set_xticklabels(chromaNames)\n# xaxis = numpy.arange(0, 0.02, 0.01);\n# ax.set_yticks(range(len(xaxis)))\n# ax.set_yticklabels(xaxis)\n# plt.show(block=False)\n# plt.draw()\n\n return chromaNames, finalC",
"metadata": "root.stChromaFeatures",
"header": "['module', '___EOS___']",
"index": 258
},
{
"content": "def stFeatureSpeed(signal, Fs, Win, Step):\n\n signal = numpy.double(signal)\n signal = signal / (2.0 ** 15)\n DC = signal.mean()\n MAX = (numpy.abs(signal)).max()\n signal = (signal - DC) / MAX\n # print (numpy.abs(signal)).max()\n\n N = len(signal) # total number of signals\n curPos = 0\n countFrames = 0\n\n lowfreq = 133.33\n linsc = 200/3.\n logsc = 1.0711703\n nlinfil = 13\n nlogfil = 27\n nceps = 13\n nfil = nlinfil + nlogfil\n nfft = Win / 2\n if Fs < 8000:\n nlogfil = 5\n nfil = nlinfil + nlogfil\n nfft = Win / 2\n\n # compute filter banks for mfcc:\n [fbank, freqs] = mfccInitFilterBanks(Fs, nfft, lowfreq, linsc, logsc, nlinfil, nlogfil)\n\n numOfTimeSpectralFeatures = 8\n numOfHarmonicFeatures = 1\n totalNumOfFeatures = numOfTimeSpectralFeatures + nceps + numOfHarmonicFeatures\n #stFeatures = numpy.array([], dtype=numpy.float64)\n stFeatures = []\n\n while (curPos + Win - 1 < N):\n countFrames += 1\n x = signal[curPos:curPos + Win]\n curPos = curPos + Step\n X = abs(fft(x))\n X = X[0:nfft]\n X = X / len(X)\n Ex = 0.0\n El = 0.0\n X[0:4] = 0\n# M = numpy.round(0.016 * fs) - 1\n# R = numpy.correlate(frame, frame, mode='full')\n stFeatures.append(stHarmonic(x, Fs))\n# for i in range(len(X)):\n #if (i < (len(X) / 8)) and (i > (len(X)/40)):\n # Ex += X[i]*X[i]\n #El += X[i]*X[i]\n# stFeatures.append(Ex / El)\n# stFeatures.append(numpy.argmax(X))\n# if curFV[numOfTimeSpectralFeatures+nceps+1]>0:\n# print curFV[numOfTimeSpectralFeatures+nceps], curFV[numOfTimeSpectralFeatures+nceps+1]\n return numpy.array(stFeatures)",
"metadata": "root.stFeatureSpeed",
"header": "['module', '___EOS___']",
"index": 633
}
]
| [
{
"span": "finalC ",
"start_line": 267,
"start_column": 4,
"end_line": 267,
"end_column": 10
},
{
"span": "nfil ",
"start_line": 652,
"start_column": 4,
"end_line": 652,
"end_column": 8
}
]
| [
{
"span": "finalC ",
"start_line": 274,
"start_column": 4,
"end_line": 274,
"end_column": 10
},
{
"span": "nfil ",
"start_line": 656,
"start_column": 8,
"end_line": 656,
"end_column": 12
}
]
| 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_",
"st",
"Chrom",
"a",
"Features_",
"(_",
"X_",
",_",
"fs_",
",_",
"n",
"Chrom",
"a_",
",_",
"n",
"Freq",
"s",
"Per",
"Chrom",
"a_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"TOD",
"O",
":",
" ",
"1",
" ",
"complex",
"ity_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"TOD",
"O",
":",
" ",
"2",
" ",
"bug",
" ",
"with",
" ",
"large",
" ",
"windows_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"chroma",
"Names_",
"=_",
"[_",
"'",
"A",
"'_",
",_",
"'",
"A",
"#'_",
",_",
"'",
"B",
"'_",
",_",
"'",
"C",
"'_",
",_",
"'",
"C",
"#'_",
",_",
"'",
"D",
"'_",
",_",
"'",
"D",
"#'_",
",_",
"'",
"E",
"'_",
",_",
"'",
"F",
"'_",
",_",
"'",
"F",
"#'_",
",_",
"'",
"G",
"'_",
",_",
"'",
"G",
"#'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"spec_",
"=_",
"X_",
"**_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"C_",
"=_",
"numpy_",
"._",
"zeros_",
"(_",
"(_",
"n",
"Chrom",
"a_",
"._",
"shape_",
"[_",
"0_",
"]_",
",_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"C_",
"[_",
"n",
"Chrom",
"a_",
"]_",
"=_",
"spec_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"C_",
"/=_",
"n",
"Freq",
"s",
"Per",
"Chrom",
"a_",
"[_",
"n",
"Chrom",
"a_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"C_",
"=_",
"numpy_",
"._",
"zeros_",
"(_",
"(_",
"12_",
",_",
"1_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"new",
"D_",
"=_",
"int_",
"(_",
"numpy_",
"._",
"ceil_",
"(_",
"C_",
"._",
"shape_",
"[_",
"0_",
"]_",
"/_",
"12.0_",
")_",
"*_",
"12_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"C2_",
"=_",
"numpy_",
"._",
"zeros_",
"(_",
"(_",
"new",
"D_",
",_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"C2_",
"[_",
"0_",
":_",
"C_",
"._",
"shape_",
"[_",
"0_",
"]_",
"]_",
"=_",
"C_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"C2_",
"=_",
"C2_",
"._",
"reshape_",
"(_",
"C2_",
"._",
"shape_",
"[_",
"0_",
"]_",
"/_",
"12_",
",_",
"12_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"for",
" ",
"i",
" ",
"in",
" ",
"range",
"(",
"1",
"2",
"):",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"final",
"C",
"[",
"i",
"]",
" ",
"=",
" ",
"nump",
"y",
".",
"sum",
"(",
"C",
"[",
"i",
":",
"C",
".",
"shape",
"[",
"0",
"]:",
"1",
"2",
"])",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"final",
"C_",
"=_",
"numpy_",
"._",
"matrix_",
"(_",
"numpy_",
"._",
"sum_",
"(_",
"C2_",
",_",
"axis_",
"=_",
"0_",
")_",
")_",
"._",
"T_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"final",
"C_",
"/=_",
"spec_",
"._",
"sum_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"ax",
" ",
"=",
" ",
"plt",
".",
"gca",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"plt",
".",
"hold",
"(",
"Fal",
"se",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"plt",
".",
"plot",
"(",
"final",
"C",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"ax",
".",
"set\\u",
"xtick",
"s",
"(",
"range",
"(",
"len",
"(",
"chroma",
"Names",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"ax",
".",
"set\\u",
"xtick",
"labels",
"(",
"chroma",
"Names",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"xaxis",
" ",
"=",
" ",
"nump",
"y",
".",
"aran",
"ge",
"(",
"0",
",",
" ",
"0.02",
",",
" ",
"0.01",
");",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"ax",
".",
"set\\u",
"ytick",
"s",
"(",
"range",
"(",
"len",
"(",
"xaxis",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"ax",
".",
"set\\u",
"ytick",
"labels",
"(",
"xaxis",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"plt",
".",
"show",
"(",
"block",
"=",
"Fal",
"se",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"plt",
".",
"draw",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"chroma",
"Names_",
",_",
"final",
"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_",
"st",
"Feature",
"Speed_",
"(_",
"signal_",
",_",
"Fs_",
",_",
"Win_",
",_",
"Step_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"signal_",
"=_",
"numpy_",
"._",
"double_",
"(_",
"signal_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"signal_",
"=_",
"signal_",
"/_",
"(_",
"2.0_",
"**_",
"15_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DC_",
"=_",
"signal_",
"._",
"mean_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"MAX_",
"=_",
"(_",
"numpy_",
"._",
"abs_",
"(_",
"signal_",
")_",
")_",
"._",
"max_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"signal_",
"=_",
"(_",
"signal_",
"-_",
"DC_",
")_",
"/_",
"MAX_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"print",
" ",
"(",
"nump",
"y",
".",
"abs",
"(",
"signal",
"))",
".",
"max",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"N_",
"=_",
"len_",
"(_",
"signal_",
")_",
"#",
" ",
"total",
" ",
"number",
" ",
"of",
" ",
"signals_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cur",
"Pos_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"count",
"Frames_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"low",
"freq_",
"=_",
"133",
".3",
"3_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"lins",
"c_",
"=_",
"200_",
"/_",
"3._",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"logs",
"c_",
"=_",
"1.0",
"711",
"703",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nli",
"nfi",
"l_",
"=_",
"13_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nlo",
"gf",
"il_",
"=_",
"27_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nce",
"ps_",
"=_",
"13_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nfi",
"l_",
"=_",
"nli",
"nfi",
"l_",
"+_",
"nlo",
"gf",
"il_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nff",
"t_",
"=_",
"Win_",
"/_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"Fs_",
"<_",
"8000_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"nlo",
"gf",
"il_",
"=_",
"5_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nfi",
"l_",
"=_",
"nli",
"nfi",
"l_",
"+_",
"nlo",
"gf",
"il_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nff",
"t_",
"=_",
"Win_",
"/_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"compute",
" ",
"filter",
" ",
"banks",
" ",
"for",
" ",
"mfc",
"c",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[_",
"fba",
"nk_",
",_",
"freqs_",
"]_",
"=_",
"mfc",
"c",
"Ini",
"t",
"Filter",
"Bank",
"s_",
"(_",
"Fs_",
",_",
"nff",
"t_",
",_",
"low",
"freq_",
",_",
"lins",
"c_",
",_",
"logs",
"c_",
",_",
"nli",
"nfi",
"l_",
",_",
"nlo",
"gf",
"il_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"num",
"Of",
"Time",
"Spectra",
"l",
"Features_",
"=_",
"8_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"num",
"Of",
"Harm",
"onic",
"Features_",
"=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"total",
"Num",
"Of",
"Features_",
"=_",
"num",
"Of",
"Time",
"Spectra",
"l",
"Features_",
"+_",
"nce",
"ps_",
"+_",
"num",
"Of",
"Harm",
"onic",
"Features_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"st",
"Feature",
"s",
" ",
"=",
" ",
"nump",
"y",
".",
"array",
"([",
"],",
" ",
"dt",
"ype",
"=",
"nump",
"y",
".",
"float",
"64",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"st",
"Features_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"while_",
"(_",
"cur",
"Pos_",
"+_",
"Win_",
"-_",
"1_",
"<_",
"N_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"count",
"Frames_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x_",
"=_",
"signal_",
"[_",
"cur",
"Pos_",
":_",
"cur",
"Pos_",
"+_",
"Win_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cur",
"Pos_",
"=_",
"cur",
"Pos_",
"+_",
"Step_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"X_",
"=_",
"abs_",
"(_",
"fft_",
"(_",
"x_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"X_",
"=_",
"X_",
"[_",
"0_",
":_",
"nff",
"t_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"X_",
"=_",
"X_",
"/_",
"len_",
"(_",
"X_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Ex_",
"=_",
"0.0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"El",
"_",
"=_",
"0.0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"X_",
"[_",
"0_",
":_",
"4_",
"]_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"M",
" ",
"=",
" ",
"nump",
"y",
".",
"round",
"(",
"0.016",
" ",
"*",
" ",
"fs",
")",
" ",
"-",
" ",
"1_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"R",
" ",
"=",
" ",
"nump",
"y",
".",
"correlate",
"(",
"frame",
",",
" ",
"frame",
",",
" ",
"mode",
"='",
"full",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"st",
"Features_",
"._",
"append_",
"(_",
"st",
"Harm",
"onic",
"_",
"(_",
"x_",
",_",
"Fs_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"for",
" ",
"i",
" ",
"in",
" ",
"range",
"(",
"len",
"(",
"X",
"))",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"if",
" ",
"(",
"i",
" ",
"<",
" ",
"(",
"len",
"(",
"X",
")",
" ",
"/",
" ",
"8",
"))",
" ",
"and",
" ",
"(",
"i",
" ",
">",
" ",
"(",
"len",
"(",
"X",
")/",
"40",
"))",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"Ex",
" ",
"+=",
" ",
"X",
"[",
"i",
"]*",
"X",
"[",
"i",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"El",
" ",
"+=",
" ",
"X",
"[",
"i",
"]*",
"X",
"[",
"i",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"st",
"Feature",
"s",
".",
"append",
"(",
"Ex",
" ",
"/",
" ",
"El",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"st",
"Feature",
"s",
".",
"append",
"(",
"nump",
"y",
".",
"argm",
"ax",
"(",
"X",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"if",
" ",
"cur",
"FV",
"[",
"num",
"Of",
"Time",
"Spectra",
"l",
"Feature",
"s",
"+",
"nce",
"ps",
"+",
"1",
"]>",
"0",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"print",
" ",
"cur",
"FV",
"[",
"num",
"Of",
"Time",
"Spectra",
"l",
"Feature",
"s",
"+",
"nce",
"ps",
"],",
" ",
"cur",
"FV",
"[",
"num",
"Of",
"Time",
"Spectra",
"l",
"Feature",
"s",
"+",
"nce",
"ps",
"+",
"1",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"numpy_",
"._",
"array_",
"(_",
"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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
]
|
Variable defined multiple times | hpk42/p4p/attic/friend_client.py | [
{
"content": "def main(args=None):\n from wsgiref import simple_server\n parser = argparse.ArgumentParser()\n parser.add_argument(\n '--lookup', default='http://teta.local:8080',\n help='lookup service url')\n parser.add_argument(\n '-p', '--port', default=8090, type=int,\n help='the port i am listening on for communication')\n parser.add_argument(\"myid\", help=\"id to connect as\")\n parser.add_argument(\"otherid\", help=\"id to connect to\", default=None, nargs=\"?\")\n if args is None:\n args = sys.argv[1:]\n args = parser.parse_args()\n my_hostname = subprocess.check_output(\"hostname\").strip()\n if not my_hostname.endswith(\".local\"):\n my_hostname += \".local\"\n my_url = \"http://%s:%s\"% (my_hostname, args.port)\n lookup = LookupService(args.lookup)\n uithread = InputThread(args.myid, lookup)\n uithread.setDaemon(True)\n if args.otherid is not None:\n uithread.add_id(args.otherid)\n uithread.start()\n app = ReceiveApp(uithread)\n server = simple_server.make_server(my_hostname, args.port, app)\n print ('Serving on http://%s:%s' % (my_hostname, args.port))\n lookup.announce_presence(args.myid, my_url)\n server.serve_forever()",
"metadata": "root.main",
"header": "['module', '___EOS___']",
"index": 32
}
]
| [
{
"span": "args ",
"start_line": 44,
"start_column": 8,
"end_line": 44,
"end_column": 12
}
]
| [
{
"span": "args ",
"start_line": 45,
"start_column": 4,
"end_line": 45,
"end_column": 8
}
]
| 1 | true | [
"[CLS]_",
"Variable_",
"defined_",
"multiple_",
"times_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"main_",
"(_",
"args_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"wsgi",
"ref_",
"import_",
"simple",
"\\u",
"server_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"=_",
"argparse_",
"._",
"Arg",
"ument",
"Parser_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"argument_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'--",
"look",
"up",
"'_",
",_",
"default_",
"=_",
"'",
"http",
"://",
"tet",
"a",
".",
"local",
":",
"808",
"0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"'",
"look",
"up",
" ",
"service",
" ",
"url",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"argument_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'-",
"p",
"'_",
",_",
"'--",
"port",
"'_",
",_",
"default_",
"=_",
"809",
"0_",
",_",
"type_",
"=_",
"int_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"'",
"the",
" ",
"port",
" ",
"i",
" ",
"am",
" ",
"listen",
"ing",
" ",
"on",
" ",
"for",
" ",
"communication",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"argument_",
"(_",
"\"",
"myid",
"\"_",
",_",
"help_",
"=_",
"\"",
"id",
" ",
"to",
" ",
"connect",
" ",
"as",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"argument_",
"(_",
"\"",
"other",
"id",
"\"_",
",_",
"help_",
"=_",
"\"",
"id",
" ",
"to",
" ",
"connect",
" ",
"to",
"\"_",
",_",
"default_",
"=_",
"None_",
",_",
"nargs_",
"=_",
"\"?\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"args_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"args_",
"=_",
"sys_",
"._",
"argv_",
"[_",
"1_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"args_",
"=_",
"parser_",
"._",
"parse",
"\\u",
"args_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"my",
"\\u",
"hostname_",
"=_",
"subprocess_",
"._",
"check",
"\\u",
"output_",
"(_",
"\"",
"host",
"name",
"\"_",
")_",
"._",
"strip_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"my",
"\\u",
"hostname_",
"._",
"endswith_",
"(_",
"\".",
"local",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"my",
"\\u",
"hostname_",
"+=_",
"\".",
"local",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"my",
"\\u",
"url_",
"=_",
"\"",
"http",
"://",
"%",
"s",
":",
"%",
"s",
"\"_",
"%_",
"(_",
"my",
"\\u",
"hostname_",
",_",
"args_",
"._",
"port_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"lookup_",
"=_",
"Look",
"up",
"Service_",
"(_",
"args_",
"._",
"lookup_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"uit",
"hread",
"_",
"=_",
"Inp",
"ut",
"Thread_",
"(_",
"args_",
"._",
"myid",
"_",
",_",
"lookup_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"uit",
"hread",
"_",
"._",
"set",
"Daemon_",
"(_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"args_",
"._",
"other",
"id_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"uit",
"hread",
"_",
"._",
"add",
"\\u",
"id_",
"(_",
"args_",
"._",
"other",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"uit",
"hread",
"_",
"._",
"start_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"app_",
"=_",
"Receive",
"App_",
"(_",
"uit",
"hread",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"server_",
"=_",
"simple",
"\\u",
"server_",
"._",
"make",
"\\u",
"server_",
"(_",
"my",
"\\u",
"hostname_",
",_",
"args_",
"._",
"port_",
",_",
"app_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"(_",
"'",
"Servi",
"ng",
" ",
"on",
" ",
"http",
"://",
"%",
"s",
":",
"%",
"s",
"'_",
"%_",
"(_",
"my",
"\\u",
"hostname_",
",_",
"args_",
"._",
"port_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"lookup_",
"._",
"announce",
"\\u",
"presence_",
"(_",
"args_",
"._",
"myid",
"_",
",_",
"my",
"\\u",
"url_",
")_",
"\\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
]
|
Variable defined multiple times | shinymud/ShinyMUD/src/shinymud/commands/commands.py | [
{
"content": " def execute(self):\n if not self.args:\n self.pc.update_output('Try: \"give <item> to <person>\", or type \"help give\".')\n return\n exp = r'(?P<amount>\\d+)?([ ]+)?(?P<thing>.*?)([ ]+)(to[ ]+)?(?P<givee>\\w+)'\n match = re.match(exp, self.args, re.I)\n if not match:\n self.pc.update_output('Try: \"give <item> to <person>\", or type \"help give\".')\n elif not self.pc.location:\n self.pc.update_output('You are alone in the void; there\\'s no one to give anything to.\\n')\n else:\n amount, thing, person = match.group('amount', 'thing', 'givee')\n #check that the person we're giving to exists\n givee = self.pc.location.get_player(person)\n if not givee:\n givee = self.pc.location.get_npc_by_kw(person)\n if not givee:\n self.pc.update_output('%s isn\\'t here.' % person.capitalize())\n return\n #check for giving an item\n thing_name = 'something'\n item = self.pc.check_inv_for_keyword(thing)\n if item:\n self.pc.item_remove(item)\n givee.item_add(item)\n thing_name = item.name\n #check for giving currency\n elif not item and thing == CURRENCY:\n if not amount:\n amount = 1\n else:\n amount = int(amount)\n if self.pc.currency < amount:\n self.pc.update_output('You don\\'t have that much ' + CURRENCY + '.')\n return\n else:\n self.pc.currency -= amount\n givee.currency += amount\n thing_name = str(amount) + ' ' + CURRENCY\n else:\n self.pc.update_output('You don\\'t have %s.' % thing)\n return\n \n #We've completed the giving process, now tell everyone about it.\n self.pc.update_output('You give %s to %s.' % (thing_name, givee.fancy_name()))\n givee.update_output('%s gives you %s.' % (self.pc.fancy_name(), thing_name))\n self.pc.location.tell_room('%s gives %s to %s.' % (self.pc.fancy_name(),\n thing_name,\n givee.fancy_name()),\n [self.pc.name, givee.name])\n if item and givee.is_npc():\n givee.notify('given_item', {'giver': self.pc, \n 'item': item})",
"metadata": "root.Give.execute",
"header": "['class', 'Give', '(', 'BaseCommand', ')', ':', '___EOS___']",
"index": 586
},
{
"content": " def execute(self):\n item = self.pc.check_inv_for_keyword(self.args)\n message = ''\n if not self.args:\n message = 'What do you want to unequip?\\n'\n elif not item: \n message = 'You don\\'t have that!\\n'\n equip_type = item.item_types.get('equippable')\n if not equip_type:\n message = 'That item is not equippable.\\n'\n elif not self.pc.equipped[equip_type.equip_slot]:\n message = 'You aren\\'t using anything in that slot.\\n'\n else:\n self.pc.equipped[equip_type.equip_slot] = ''\n self.pc.isequipped.remove(item)\n equip_type.on_unequip()\n message = 'You remove ' + item.name + '.\\n'\n self.pc.update_output(message)",
"metadata": "root.Unequip.execute",
"header": "['class', 'Unequip', '(', 'BaseCommand', ')', ':', '___EOS___']",
"index": 897
},
{
"content": "class Award(BaseCommand):\n \"\"\"Award an item to a player.\"\"\"\n required_permissions = required_permissions = DM | ADMIN\n help = (\n \"\"\"<title>Award (Command)</title>\n\\nThe Award command allows a DM or an Admin to award an item to a player. Note\nthat you must have the item you wish to award in your inventory for the Award\ncommand to work, and you must also be in the same room as the person you wish\nto award the item to.\n\\nRequired Permissions: ADMIN, DM\n\\nUSAGE:\nTo award an item to a player:\n award <item-keyword> to <player-name> [\"<actor-message>\":\"<room-message>\"]\n\\nThe actor-message is the message you want the player to see upon receipt of\nyour item. The room-message is the message you want everyone else in the same\nroom to hear upon the player's receipt of the item. Neither message is\nrequired, and if they are not given then the item will be awarded to the\nplayer silently.\n\\nEXAMPLES:\nSay for example that you would like to award the player Jameson a medal to\ncelebrate the quest he just completed. First you would make sure the medal was\nin your inventory (easily done by using the Load command). Then you would type\nthe following (which would normally be on one line -- in this case it is \nlinewrapped for readibility):\n award medal to jameson \"You receive a medal for your fine work.\":\n \"#actor receives a medal for his fine work.\"\n\\nJameson would have the medal added to his inventory and receive the message\n\"You receive a medal for your fine work.\" Anyone else in the room would see\nthe message \"Jameson receives a medal for his fine work.\"\n \"\"\"\n )",
"metadata": "root.Award",
"header": "['module', '___EOS___']",
"index": 1727
}
]
| [
{
"span": "thing_name ",
"start_line": 606,
"start_column": 12,
"end_line": 606,
"end_column": 22
},
{
"span": "message ",
"start_line": 901,
"start_column": 12,
"end_line": 901,
"end_column": 19
},
{
"span": "message ",
"start_line": 903,
"start_column": 12,
"end_line": 903,
"end_column": 19
},
{
"span": "required_permissions ",
"start_line": 1729,
"start_column": 4,
"end_line": 1729,
"end_column": 24
}
]
| [
{
"span": "thing_name ",
"start_line": 611,
"start_column": 16,
"end_line": 611,
"end_column": 26
},
{
"span": "thing_name ",
"start_line": 624,
"start_column": 20,
"end_line": 624,
"end_column": 30
},
{
"span": "message ",
"start_line": 906,
"start_column": 12,
"end_line": 906,
"end_column": 19
},
{
"span": "message ",
"start_line": 908,
"start_column": 12,
"end_line": 908,
"end_column": 19
},
{
"span": "message ",
"start_line": 913,
"start_column": 12,
"end_line": 913,
"end_column": 19
},
{
"span": "required_permissions ",
"start_line": 1729,
"start_column": 27,
"end_line": 1729,
"end_column": 47
}
]
| 1 | true | [
"[CLS]_",
"Variable_",
"defined_",
"multiple_",
"times_",
"[SEP]_",
"class_",
"Give",
"_",
"(_",
"Base",
"Command_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"execute_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"self_",
"._",
"args_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'",
"Tr",
"y",
":",
" ",
"\"",
"give",
" ",
"<",
"item",
">",
" ",
"to",
" ",
"<",
"person",
">\"",
",",
" ",
"or",
" ",
"type",
" ",
"\"",
"help",
" ",
"give",
"\".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"exp_",
"=_",
"r",
"'(",
"?",
"P",
"<",
"amo",
"unt",
">\\\\",
"d",
"+)?",
"([",
" ",
"]+)",
"?(?",
"P",
"<",
"thing",
">.*?",
")(",
"[",
" ",
"]+)",
"(",
"to",
"[",
" ",
"]+)",
"?(?",
"P",
"<",
"give",
"e",
">\\\\",
"w",
"+)'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"match_",
"=_",
"re_",
"._",
"match_",
"(_",
"exp_",
",_",
"self_",
"._",
"args_",
",_",
"re_",
"._",
"I_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"match_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'",
"Tr",
"y",
":",
" ",
"\"",
"give",
" ",
"<",
"item",
">",
" ",
"to",
" ",
"<",
"person",
">\"",
",",
" ",
"or",
" ",
"type",
" ",
"\"",
"help",
" ",
"give",
"\".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"not_",
"self_",
"._",
"pc_",
"._",
"location_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'",
"You",
" ",
"are",
" ",
"alo",
"ne",
" ",
"in",
" ",
"the",
" ",
"voi",
"d",
";",
" ",
"there",
"\\\\'",
"s",
" ",
"no",
" ",
"one",
" ",
"to",
" ",
"give",
" ",
"anyt",
"hing",
" ",
"to",
".\\\\",
"n",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"amount_",
",_",
"thing_",
",_",
"person_",
"=_",
"match_",
"._",
"group_",
"(_",
"'",
"amo",
"unt",
"'_",
",_",
"'",
"thing",
"'_",
",_",
"'",
"give",
"e",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"check",
" ",
"tha",
"t",
" ",
"the",
" ",
"person",
" ",
"we",
"'",
"re",
" ",
"gi",
"ving",
" ",
"to",
" ",
"exists_",
"\\u\\u\\uNL\\u\\u\\u_",
"give",
"e_",
"=_",
"self_",
"._",
"pc_",
"._",
"location_",
"._",
"get",
"\\u",
"player_",
"(_",
"person_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"give",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"give",
"e_",
"=_",
"self_",
"._",
"pc_",
"._",
"location_",
"._",
"get",
"\\u",
"npc",
"\\u",
"by",
"\\u",
"kw_",
"(_",
"person_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"give",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'%",
"s",
" ",
"isn",
"\\\\'",
"t",
" ",
"here",
".'_",
"%_",
"person_",
"._",
"capitalize_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"check",
" ",
"for",
" ",
"gi",
"ving",
" ",
"an",
" ",
"item_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"thing",
"\\u",
"name_",
"=_",
"'",
"somet",
"hing",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"item_",
"=_",
"self_",
"._",
"pc_",
"._",
"check",
"\\u",
"inv",
"\\u",
"for",
"\\u",
"keyword_",
"(_",
"thing_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"item_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"pc_",
"._",
"item",
"\\u",
"remove_",
"(_",
"item_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"give",
"e_",
"._",
"item",
"\\u",
"add_",
"(_",
"item_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"thing",
"\\u",
"name_",
"=_",
"item_",
"._",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"check",
" ",
"for",
" ",
"gi",
"ving",
" ",
"currency_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"not_",
"item_",
"and_",
"thing_",
"==_",
"CURREN",
"CY",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"amount_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"amount_",
"=_",
"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 ",
" ",
"_",
"amount_",
"=_",
"int_",
"(_",
"amount_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"pc_",
"._",
"currency_",
"<_",
"amount_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'",
"You",
" ",
"don",
"\\\\'",
"t",
" ",
"have",
" ",
"tha",
"t",
" ",
"muc",
"h",
" ",
"'_",
"+_",
"CURREN",
"CY",
"_",
"+_",
"'.'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"pc_",
"._",
"currency_",
"-=_",
"amount_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"give",
"e_",
"._",
"currency_",
"+=_",
"amount_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"thing",
"\\u",
"name_",
"=_",
"str_",
"(_",
"amount_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"CURREN",
"CY",
"_",
"\\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_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'",
"You",
" ",
"don",
"\\\\'",
"t",
" ",
"have",
" ",
"%",
"s",
".'_",
"%_",
"thing_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"We",
"'",
"ve",
" ",
"complete",
"d",
" ",
"the",
" ",
"gi",
"ving",
" ",
"process",
",",
" ",
"now",
" ",
"tell",
" ",
"everyone",
" ",
"abo",
"ut",
" ",
"it",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"'",
"You",
" ",
"give",
" ",
"%",
"s",
" ",
"to",
" ",
"%",
"s",
".'_",
"%_",
"(_",
"thing",
"\\u",
"name_",
",_",
"give",
"e_",
"._",
"fancy",
"\\u",
"name_",
"(_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"give",
"e_",
"._",
"update",
"\\u",
"output_",
"(_",
"'%",
"s",
" ",
"give",
"s",
" ",
"you",
" ",
"%",
"s",
".'_",
"%_",
"(_",
"self_",
"._",
"pc_",
"._",
"fancy",
"\\u",
"name_",
"(_",
")_",
",_",
"thing",
"\\u",
"name_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"pc_",
"._",
"location_",
"._",
"tell",
"\\u",
"room_",
"(_",
"'%",
"s",
" ",
"give",
"s",
" ",
"%",
"s",
" ",
"to",
" ",
"%",
"s",
".'_",
"%_",
"(_",
"self_",
"._",
"pc_",
"._",
"fancy",
"\\u",
"name_",
"(_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"thing",
"\\u",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"give",
"e_",
"._",
"fancy",
"\\u",
"name_",
"(_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"[_",
"self_",
"._",
"pc_",
"._",
"name_",
",_",
"give",
"e_",
"._",
"name_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"item_",
"and_",
"give",
"e_",
"._",
"is",
"\\u",
"npc_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"give",
"e_",
"._",
"notify_",
"(_",
"'",
"give",
"n",
"\\u",
"item",
"'_",
",_",
"{_",
"'",
"give",
"r",
"'_",
":_",
"self_",
"._",
"pc_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"item",
"'_",
":_",
"item_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Une",
"qui",
"p_",
"(_",
"Base",
"Command_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"execute_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"item_",
"=_",
"self_",
"._",
"pc_",
"._",
"check",
"\\u",
"inv",
"\\u",
"for",
"\\u",
"keyword_",
"(_",
"self_",
"._",
"args_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"message_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"self_",
"._",
"args_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"'",
"What",
" ",
"do",
" ",
"you",
" ",
"want",
" ",
"to",
" ",
"une",
"qui",
"p",
"?\\\\",
"n",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"not_",
"item_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"'",
"You",
" ",
"don",
"\\\\'",
"t",
" ",
"have",
" ",
"tha",
"t",
"!\\\\",
"n",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"equip",
"\\u",
"type_",
"=_",
"item_",
"._",
"item",
"\\u",
"types_",
"._",
"get_",
"(_",
"'",
"equip",
"pab",
"le",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"equip",
"\\u",
"type_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"'",
"Tha",
"t",
" ",
"item",
" ",
"is",
" ",
"not",
" ",
"equip",
"pab",
"le",
".\\\\",
"n",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"not_",
"self_",
"._",
"pc_",
"._",
"equip",
"ped_",
"[_",
"equip",
"\\u",
"type_",
"._",
"equip",
"\\u",
"slot_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"'",
"You",
" ",
"are",
"n",
"\\\\'",
"t",
" ",
"usi",
"ng",
" ",
"anyt",
"hing",
" ",
"in",
" ",
"tha",
"t",
" ",
"slot",
".\\\\",
"n",
"'_",
"\\u\\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_",
"._",
"pc_",
"._",
"equip",
"ped_",
"[_",
"equip",
"\\u",
"type_",
"._",
"equip",
"\\u",
"slot_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"pc_",
"._",
"ise",
"qui",
"pped",
"_",
"._",
"remove_",
"(_",
"item_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"equip",
"\\u",
"type_",
"._",
"on",
"\\u",
"une",
"qui",
"p_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"message_",
"=_",
"'",
"You",
" ",
"remove",
" ",
"'_",
"+_",
"item_",
"._",
"name_",
"+_",
"'.",
"\\\\",
"n",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"pc_",
"._",
"update",
"\\u",
"output_",
"(_",
"message_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Award",
"_",
"(_",
"Base",
"Command_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Award",
" ",
"an",
" ",
"item",
" ",
"to",
" ",
"a",
" ",
"player",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"require",
"d\\u",
"permissions_",
"=_",
"require",
"d\\u",
"permissions_",
"=_",
"DM_",
"|_",
"ADMIN_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"help_",
"=_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"<",
"title",
">",
"Award",
" ",
"(",
"Command",
")<",
"/",
"title",
">",
"\\",
"10",
";\\\\",
"n",
"The",
" ",
"Award",
" ",
"command",
" ",
"allow",
"s",
" ",
"a",
" ",
"DM",
" ",
"or",
" ",
"an",
" ",
"Admi",
"n",
" ",
"to",
" ",
"award",
" ",
"an",
" ",
"item",
" ",
"to",
" ",
"a",
" ",
"player",
".",
" ",
"Not",
"e",
"\\",
"10",
";",
"tha",
"t",
" ",
"you",
" ",
"must",
" ",
"have",
" ",
"the",
" ",
"item",
" ",
"you",
" ",
"wish",
" ",
"to",
" ",
"award",
" ",
"in",
" ",
"your",
" ",
"inventor",
"y",
" ",
"for",
" ",
"the",
" ",
"Award",
"\\",
"10",
";",
"command",
" ",
"to",
" ",
"work",
",",
" ",
"and",
" ",
"you",
" ",
"must",
" ",
"als",
"o",
" ",
"be",
" ",
"in",
" ",
"the",
" ",
"same",
" ",
"room",
" ",
"as",
" ",
"the",
" ",
"person",
" ",
"you",
" ",
"wish",
"\\",
"10",
";",
"to",
" ",
"award",
" ",
"the",
" ",
"item",
" ",
"to",
".",
"\\",
"10",
";\\\\",
"n",
"Requ",
"ired",
" ",
"Permi",
"ssion",
"s",
":",
" ",
"ADM",
"IN",
",",
" ",
"DM",
"\\",
"10",
";\\\\",
"n",
"USAGE",
":",
"\\",
"10",
";",
"To",
" ",
"award",
" ",
"an",
" ",
"item",
" ",
"to",
" ",
"a",
" ",
"player",
":",
"\\",
"10",
";",
" ",
" ",
"award",
" ",
"<",
"item",
"-",
"keyw",
"ord",
">",
" ",
"to",
" ",
"<",
"player",
"-",
"name",
">",
" ",
"[\"",
"<",
"actor",
"-",
"message",
">\"",
":\"",
"<",
"room",
"-",
"message",
">\"",
"]",
"\\",
"10",
";\\\\",
"n",
"The",
" ",
"actor",
"-",
"message",
" ",
"is",
" ",
"the",
" ",
"message",
" ",
"you",
" ",
"want",
" ",
"the",
" ",
"player",
" ",
"to",
" ",
"see",
" ",
"upo",
"n",
" ",
"receipt",
" ",
"of",
"\\",
"10",
";",
"your",
" ",
"item",
".",
" ",
"The",
" ",
"room",
"-",
"message",
" ",
"is",
" ",
"the",
" ",
"message",
" ",
"you",
" ",
"want",
" ",
"everyone",
" ",
"else",
" ",
"in",
" ",
"the",
" ",
"same",
"\\",
"10",
";",
"room",
" ",
"to",
" ",
"hear",
" ",
"upo",
"n",
" ",
"the",
" ",
"player",
"'",
"s",
" ",
"receipt",
" ",
"of",
" ",
"the",
" ",
"item",
".",
" ",
"Nei",
"ther",
" ",
"message",
" ",
"is",
"\\",
"10",
";",
"require",
"d",
",",
" ",
"and",
" ",
"if",
" ",
"the",
"y",
" ",
"are",
" ",
"not",
" ",
"give",
"n",
" ",
"then",
" ",
"the",
" ",
"item",
" ",
"will",
" ",
"be",
" ",
"award",
"ed",
" ",
"to",
" ",
"the",
"\\",
"10",
";",
"player",
" ",
"silently",
".",
"\\",
"10",
";\\\\",
"n",
"EXAMPLES",
":",
"\\",
"10",
";",
"Say",
" ",
"for",
" ",
"example",
" ",
"tha",
"t",
" ",
"you",
" ",
"wou",
"ld",
" ",
"like",
" ",
"to",
" ",
"award",
" ",
"the",
" ",
"player",
" ",
"Jam",
"eso",
"n",
" ",
"a",
" ",
"med",
"al",
" ",
"to",
"\\",
"10",
";",
"cele",
"bra",
"te",
" ",
"the",
" ",
"quest",
" ",
"he",
" ",
"just",
" ",
"complete",
"d",
".",
" ",
"Fi",
"rst",
" ",
"you",
" ",
"wou",
"ld",
" ",
"make",
" ",
"sure",
" ",
"the",
" ",
"med",
"al",
" ",
"was",
"\\",
"10",
";",
"in",
" ",
"your",
" ",
"inventor",
"y",
" ",
"(",
"easi",
"ly",
" ",
"don",
"e",
" ",
"by",
" ",
"usi",
"ng",
" ",
"the",
" ",
"Load",
" ",
"command",
").",
" ",
"The",
"n",
" ",
"you",
" ",
"wou",
"ld",
" ",
"type",
"\\",
"10",
";",
"the",
" ",
"follow",
"ing",
" ",
"(",
"whi",
"ch",
" ",
"wou",
"ld",
" ",
"normal",
"ly",
" ",
"be",
" ",
"on",
" ",
"one",
" ",
"line",
" ",
"--",
" ",
"in",
" ",
"this",
" ",
"case",
" ",
"it",
" ",
"is",
" ",
"\\",
"10",
";",
"line",
"wrapp",
"ed",
" ",
"for",
" ",
"readi",
"bilit",
"y",
"):",
"\\",
"10",
";",
" ",
" ",
"award",
" ",
"med",
"al",
" ",
"to",
" ",
"jam",
"eso",
"n",
" ",
"\"",
"You",
" ",
"receive",
" ",
"a",
" ",
"med",
"al",
" ",
"for",
" ",
"your",
" ",
"fine",
" ",
"work",
".\"",
":",
"\\",
"10",
";",
" ",
" ",
"\"#",
"actor",
" ",
"receive",
"s",
" ",
"a",
" ",
"med",
"al",
" ",
"for",
" ",
"his",
" ",
"fine",
" ",
"work",
".\"",
"\\",
"10",
";\\\\",
"n",
"Jam",
"eso",
"n",
" ",
"wou",
"ld",
" ",
"have",
" ",
"the",
" ",
"med",
"al",
" ",
"adde",
"d",
" ",
"to",
" ",
"his",
" ",
"inventor",
"y",
" ",
"and",
" ",
"receive",
" ",
"the",
" ",
"message",
"\\",
"10",
";",
"\"",
"You",
" ",
"receive",
" ",
"a",
" ",
"med",
"al",
" ",
"for",
" ",
"your",
" ",
"fine",
" ",
"work",
".\"",
" ",
"Any",
"one",
" ",
"else",
" ",
"in",
" ",
"the",
" ",
"room",
" ",
"wou",
"ld",
" ",
"see",
"\\",
"10",
";",
"the",
" ",
"message",
" ",
"\"",
"Jam",
"eso",
"n",
" ",
"receive",
"s",
" ",
"a",
" ",
"med",
"al",
" ",
"for",
" ",
"his",
" ",
"fine",
" ",
"work",
".\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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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/classproperty.py | [
{
"content": " def __set__(self):\n \"\"\"\n Disallow overriding property.\n \"\"\"\n\n raise \"Cannot set static class property.\"",
"metadata": "root.classproperty.__set__",
"header": "['class', 'classproperty', '(', 'object', ')', ':', '# flake8: noqa', '___EOS___']",
"index": 20
},
{
"content": " def __delete__(self):\n \"\"\"\n Disallow removing property.\n \"\"\"\n\n raise \"Cannot delete static class property.\"",
"metadata": "root.classproperty.__delete__",
"header": "['class', 'classproperty', '(', 'object', ')', ':', '# flake8: noqa', '___EOS___']",
"index": 27
}
]
| [
{
"span": "raise \"Cannot set static class property.\"",
"start_line": 25,
"start_column": 8,
"end_line": 25,
"end_column": 49
},
{
"span": "raise \"Cannot delete static class property.\"",
"start_line": 32,
"start_column": 8,
"end_line": 32,
"end_column": 52
}
]
| []
| 1 | true | [
"[CLS]_",
"Il",
"lega",
"l_",
"raise_",
"[SEP]_",
"class_",
"class",
"property_",
"(_",
"object_",
")_",
":_",
"#",
" ",
"flake",
"8",
":",
" ",
"no",
"qa_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"set\\u",
"\\u_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Disa",
"llow",
" ",
"overrid",
"ing",
" ",
"property",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"raise_",
"\"",
"Cann",
"ot",
" ",
"set",
" ",
"static",
" ",
"class",
" ",
"property",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"class",
"property_",
"(_",
"object_",
")_",
":_",
"#",
" ",
"flake",
"8",
":",
" ",
"no",
"qa_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"delete",
"\\u\\u_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Disa",
"llow",
" ",
"remo",
"ving",
" ",
"property",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"raise_",
"\"",
"Cann",
"ot",
" ",
"delete",
" ",
"static",
" ",
"class",
" ",
"property",
".\"_"
]
| [
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | DataDog/datadogpy/datadog/util/compat.py | [
{
"content": "# flake8: noqa\n\n\"\"\" Imports for compatibility with Py2 and Py3\n\"\"\"\nimport sys\nimport logging\nimport socket\n\n\n\nget_input = input\n\nif is_p3k():\n import configparser\n import urllib.request as url_lib, urllib.error, urllib.parse\n from io import StringIO\n\n\n\nelse:\n get_input = raw_input\n import ConfigParser as configparser\n import urllib2 as url_lib\n from cStringIO import StringIO\n\n\n\n\ntry:\n from UserDict import IterableUserDict\nexcept ImportError:\n from collections import UserDict as IterableUserDict\n\ntry:\n from configparser import ConfigParser\nexcept ImportError:\n from ConfigParser import ConfigParser\n\ntry:\n from urllib.parse import urlparse\nexcept ImportError:\n from urlparse import urlparse\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def is_p3k():\n value = sys.version_info[0] == 3\n return value",
"metadata": "root.is_p3k",
"header": "['module', '___EOS___']",
"index": 9
},
{
"content": " def iteritems(d):\n return iter(d.items())",
"metadata": "root.iteritems",
"header": "['module', '___EOS___']",
"index": 20
},
{
"content": " def iternext(iter):\n return next(iter)",
"metadata": "root.iternext",
"header": "['module', '___EOS___']",
"index": 23
},
{
"content": " def iteritems(d):\n return d.iteritems()",
"metadata": "root.iteritems",
"header": "['module', '___EOS___']",
"index": 32
},
{
"content": " def iternext(iter):\n return iter.next()",
"metadata": "root.iternext",
"header": "['module', '___EOS___']",
"index": 35
}
]
| [
{
"span": "import logging",
"start_line": 5,
"start_column": 0,
"end_line": 5,
"end_column": 14
},
{
"span": "import socket",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 13
},
{
"span": "import configparser",
"start_line": 16,
"start_column": 4,
"end_line": 16,
"end_column": 23
},
{
"span": "import urllib.request as url_lib, urllib.error, urllib.parse",
"start_line": 17,
"start_column": 4,
"end_line": 17,
"end_column": 64
},
{
"span": "from io import StringIO",
"start_line": 18,
"start_column": 4,
"end_line": 18,
"end_column": 27
},
{
"span": "from UserDict import IterableUserDict",
"start_line": 40,
"start_column": 4,
"end_line": 40,
"end_column": 41
},
{
"span": "from collections import UserDict as IterableUserDict",
"start_line": 42,
"start_column": 4,
"end_line": 42,
"end_column": 56
},
{
"span": "from configparser import ConfigParser",
"start_line": 45,
"start_column": 4,
"end_line": 45,
"end_column": 41
},
{
"span": "from ConfigParser import ConfigParser",
"start_line": 47,
"start_column": 4,
"end_line": 47,
"end_column": 41
},
{
"span": "from urllib.parse import urlparse",
"start_line": 50,
"start_column": 4,
"end_line": 50,
"end_column": 37
},
{
"span": "from urlparse import urlparse",
"start_line": 52,
"start_column": 4,
"end_line": 52,
"end_column": 33
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"flake",
"8",
":",
" ",
"no",
"qa_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
" ",
"Imports",
" ",
"for",
" ",
"compatibility",
" ",
"with",
" ",
"Py",
"2",
" ",
"and",
" ",
"Py",
"3",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"logging_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"socket_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"get",
"\\u",
"input_",
"=_",
"input_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"is",
"\\u",
"p3",
"k_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"import_",
"configparser_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"urllib_",
"._",
"request_",
"as_",
"url",
"\\u",
"lib_",
",_",
"urllib_",
"._",
"error_",
",_",
"urllib_",
"._",
"parse_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"io_",
"import_",
"String",
"IO_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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 ",
" _",
"get",
"\\u",
"input_",
"=_",
"raw",
"\\u",
"input_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"Config",
"Parser_",
"as_",
"configparser_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"urllib2_",
"as_",
"url",
"\\u",
"lib_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"c",
"String",
"IO_",
"import_",
"String",
"IO_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"User",
"Dict_",
"import_",
"It",
"era",
"ble",
"User",
"Dict_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Import",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"collections_",
"import_",
"User",
"Dict_",
"as_",
"It",
"era",
"ble",
"User",
"Dict_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"configparser_",
"import_",
"Config",
"Parser_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Import",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"Config",
"Parser_",
"import_",
"Config",
"Parser_",
"\\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_",
"urllib_",
"._",
"parse_",
"import_",
"urlparse_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Import",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"urlparse_",
"import_",
"urlparse_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"is",
"\\u",
"p3",
"k_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"value_",
"=_",
"sys_",
"._",
"version",
"\\u",
"info_",
"[_",
"0_",
"]_",
"==_",
"3_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"iteritems_",
"(_",
"d_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"iter_",
"(_",
"d_",
"._",
"items_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"iter",
"next_",
"(_",
"iter_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"next_",
"(_",
"iter_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"iteritems_",
"(_",
"d_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"d_",
"._",
"iteritems_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"iter",
"next_",
"(_",
"iter_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"iter_",
"._",
"next_",
"(_",
")_",
"\\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,
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,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
0,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
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,
4,
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,
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,
2
]
|
Unused import | facebookarchive/git-review/src/gitreview/git/__init__.py | [
{
"content": "#!/usr/bin/python -tt\n#\n# Copyright 2009-2010 Facebook, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n#\n\"\"\"\nThis is a python package for interacting with git repositories.\n\"\"\"\n\nimport os\n\n# Import all of the constants and exception types into the current namespace\nfrom constants import *\nfrom exceptions import *\n\nimport obj\nimport commit\nimport config\nimport diff\nimport repo\n\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def is_git_dir(path):\n \"\"\"\n is_git_dir(path) --> bool\n\n Determine if the specified directory is the root of a git repository\n directory.\n \"\"\"\n # Check to see if the object directory exists.\n # This is normally a directory called \"objects\" inside the git directory,\n # but it can be overridden with the GIT_OBJECT_DIRECTORY environment\n # variable.\n if os.environ.has_key('GIT_OBJECT_DIRECTORY'):\n object_dir = os.environ['GIT_OBJECT_DIRECTORY']\n else:\n object_dir = os.path.join(path, 'objects')\n if not os.path.isdir(object_dir):\n return False\n\n # Check for the refs directory\n if not os.path.isdir(os.path.join(path, 'refs')):\n return False\n\n return True",
"metadata": "root.is_git_dir",
"header": "['module', '___EOS___']",
"index": 33
},
{
"content": "def _get_git_dir(git_dir=None, cwd=None):\n \"\"\"\n _get_git_dir(dir=None, cwd=None) --> (git_dir, working_dir)\n\n Attempt to find the git directory, similarly to the way git does.\n git_dir should be the git directory explicitly specified on the command\n line, or None if not explicitly specified.\n\n If git_dir is not explicitly specified, the GIT_DIR environment variable\n will be checked. If that is not specified, the current working directory\n and its parent directories will be searched for a git directory.\n\n Returns a tuple containing the git directory, and the default working\n directory. (The default working directory is only to be used if the\n repository is not bare, and the working directory was not specified\n explicitly via some other mechanism.) The default working directory\n may be None if there is no default working directory.\n \"\"\"\n if cwd is None:\n cwd = os.getcwd()\n\n # If git_dir wasn't explicitly specified, but GIT_DIR is set in the\n # environment, use that.\n if git_dir == None and os.environ.has_key('GIT_DIR'):\n git_dir = os.environ['GIT_DIR']\n\n # If the git directory was explicitly specified, use that.\n # The default working directory is the current working directory\n if git_dir != None:\n if not is_git_dir(git_dir):\n raise NotARepoError(git_dir)\n return (git_dir, cwd)\n\n # Otherwise, attempt to find the git directory by searching up from\n # the current working directory.\n ceiling_dirs = []\n if os.environ.has_key('GIT_CEILING_DIRECTORIES'):\n ceiling_dirs = os.environ['GIT_CEILING_DIRECTORIES'].split(':')\n ceiling_dirs.append(os.path.sep) # Add the root directory\n\n dir = os.path.normpath(cwd)\n while True:\n # Check to see if this directory contains a .git directory\n #\n # TODO: git also accepts regular files called .git that contain\n # \"gitdir: <path>\"\n git_dir = os.path.join(dir, '.git')\n if os.path.isdir(git_dir):\n if is_git_dir(git_dir):\n return (git_dir, dir)\n\n # Check to see if this directory looks like a git directory\n if is_git_dir(dir):\n return (dir, None)\n\n # Walk up to the parent directory before looping again\n (parent_dir, rest) = os.path.split(dir)\n\n # If the parent_dir is one of the ceiling directories,\n # we should stop before examining it. The current directory\n # does not appear to be inside a git repository.\n if parent_dir in ceiling_dirs:\n raise NotARepoError(cwd)\n\n dir = parent_dir",
"metadata": "root._get_git_dir",
"header": "['module', '___EOS___']",
"index": 58
},
{
"content": "def get_repo(git_dir=None, working_dir=None):\n \"\"\"\n get_repo(git_dir=None) --> Repository object\n\n Create a Repository object. The repository is found similarly to the way\n git itself works:\n - If git_dir is specified, that is used as the git directory\n - Otherwise, if the GIT_DIR environment variable is set, that is used as\n the git directory\n - Otherwise, the current working directory and its parents are searched to\n find the git directory\n \"\"\"\n # Find the git directory and the default working directory\n (git_dir, default_working_dir) = _get_git_dir(git_dir)\n\n # Load the git configuration for this repository\n git_config = config.load(git_dir)\n\n # If working_dir wasn't explicitly specified, but GIT_WORK_TREE is set in\n # the environment, use that.\n if working_dir == None and os.environ.has_key('GIT_WORK_TREE'):\n working_dir = os.environ['GIT_WORK_TREE']\n\n if working_dir == None:\n is_bare = git_config.getBool('core.bare', False)\n if is_bare:\n working_dir = None\n else:\n working_dir = git_config.get('core.worktree', default_working_dir)\n\n return repo.Repository(git_dir, working_dir, git_config)",
"metadata": "root.get_repo",
"header": "['module', '___EOS___']",
"index": 125
}
]
| [
{
"span": "import obj",
"start_line": 26,
"start_column": 0,
"end_line": 26,
"end_column": 10
},
{
"span": "import commit",
"start_line": 27,
"start_column": 0,
"end_line": 27,
"end_column": 13
},
{
"span": "import diff",
"start_line": 29,
"start_column": 0,
"end_line": 29,
"end_column": 11
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#!",
"/",
"usr",
"/",
"bin",
"/",
"python",
" ",
"-",
"tt_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"200",
"9",
"-",
"2010",
" ",
"Face",
"book",
",",
" ",
"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",
"\");",
" ",
"you",
" ",
"may",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"not",
" ",
"use",
" ",
"this",
" ",
"file",
" ",
"except",
" ",
"in",
" ",
"compli",
"anc",
"e",
" ",
"with",
" ",
"the",
" ",
"License",
".",
" ",
"You",
" ",
"may",
" ",
"obtain",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"a",
" ",
"copy",
" ",
"of",
" ",
"the",
" ",
"License",
" ",
"at_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"http",
"://",
"www",
".",
"apa",
"che",
".",
"org",
"/",
"license",
"s",
"/",
"LICENSE",
"-",
"2.0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Un",
"less",
" ",
"require",
"d",
" ",
"by",
" ",
"applica",
"ble",
" ",
"law",
" ",
"or",
" ",
"agree",
"d",
" ",
"to",
" ",
"in",
" ",
"writ",
"ing",
",",
" ",
"software",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"distributed",
" ",
"under",
" ",
"the",
" ",
"License",
" ",
"is",
" ",
"distributed",
" ",
"on",
" ",
"an",
" ",
"\"",
"AS",
" ",
"IS",
"\"",
" ",
"BAS",
"IS",
",",
" ",
"WITH",
"OUT_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"WAR",
"RAN",
"TIES",
" ",
"OR",
" ",
"CONDITION",
"S",
" ",
"OF",
" ",
"ANY",
" ",
"KIND",
",",
" ",
"eit",
"her",
" ",
"express",
" ",
"or",
" ",
"impli",
"ed",
".",
" ",
"See",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"License",
" ",
"for",
" ",
"the",
" ",
"specific",
" ",
"language",
" ",
"govern",
"ing",
" ",
"permissi",
"ons",
" ",
"and",
" ",
"limit",
"ations_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"under",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
"Thi",
"s",
" ",
"is",
" ",
"a",
" ",
"python",
" ",
"package",
" ",
"for",
" ",
"interacti",
"ng",
" ",
"with",
" ",
"git",
" ",
"repos",
"itori",
"es",
".",
"\\",
"10",
";\"\"\"_",
"\\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_",
"#",
" ",
"Import",
" ",
"all",
" ",
"of",
" ",
"the",
" ",
"constant",
"s",
" ",
"and",
" ",
"exception",
" ",
"types",
" ",
"int",
"o",
" ",
"the",
" ",
"current",
" ",
"namespace_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"constants_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"exceptions_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"obj_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"commit_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"config_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"diff_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"repo_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"is",
"\\u",
"git",
"\\u",
"dir_",
"(_",
"path_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"is",
"\\u",
"git",
"\\u",
"dir",
"(",
"path",
")",
" ",
"-->",
" ",
"bool",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Det",
"erm",
"ine",
" ",
"if",
" ",
"the",
" ",
"specified",
" ",
"director",
"y",
" ",
"is",
" ",
"the",
" ",
"root",
" ",
"of",
" ",
"a",
" ",
"git",
" ",
"repos",
"itor",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"director",
"y",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Check",
" ",
"to",
" ",
"see",
" ",
"if",
" ",
"the",
" ",
"object",
" ",
"director",
"y",
" ",
"exist",
"s",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"is",
" ",
"normal",
"ly",
" ",
"a",
" ",
"director",
"y",
" ",
"call",
"ed",
" ",
"\"",
"object",
"s",
"\"",
" ",
"insi",
"de",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"but",
" ",
"it",
" ",
"can",
" ",
"be",
" ",
"overrid",
"den",
" ",
"with",
" ",
"the",
" ",
"GIT",
"\\u",
"OBJ",
"ECT",
"\\u",
"DIRECT",
"ORY",
" ",
"environment_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"variab",
"le",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"os_",
"._",
"environ_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"GIT",
"\\u",
"OBJ",
"ECT",
"\\u",
"DIRECT",
"ORY",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"object\\u",
"dir_",
"=_",
"os_",
"._",
"environ_",
"[_",
"'",
"GIT",
"\\u",
"OBJ",
"ECT",
"\\u",
"DIRECT",
"ORY",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"object\\u",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"path_",
",_",
"'",
"object",
"s",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"isdir_",
"(_",
"object\\u",
"dir_",
")_",
":_",
"\\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_",
"#",
" ",
"Check",
" ",
"for",
" ",
"the",
" ",
"refs",
" ",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"isdir_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"path_",
",_",
"'",
"refs",
"'_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"get",
"\\u",
"git",
"\\u",
"dir_",
"(_",
"git",
"\\u",
"dir_",
"=_",
"None_",
",_",
"cwd_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\\u",
"get",
"\\u",
"git",
"\\u",
"dir",
"(",
"dir",
"=",
"Non",
"e",
",",
" ",
"cw",
"d",
"=",
"Non",
"e",
")",
" ",
"-->",
" ",
"(",
"git",
"\\u",
"dir",
",",
" ",
"working",
"\\u",
"dir",
")",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Atte",
"mpt",
" ",
"to",
" ",
"find",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
",",
" ",
"similar",
"ly",
" ",
"to",
" ",
"the",
" ",
"way",
" ",
"git",
" ",
"doe",
"s",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"git",
"\\u",
"dir",
" ",
"shou",
"ld",
" ",
"be",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
" ",
"explicit",
"ly",
" ",
"specified",
" ",
"on",
" ",
"the",
" ",
"command",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"line",
",",
" ",
"or",
" ",
"Non",
"e",
" ",
"if",
" ",
"not",
" ",
"explicit",
"ly",
" ",
"specified",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"If",
" ",
"git",
"\\u",
"dir",
" ",
"is",
" ",
"not",
" ",
"explicit",
"ly",
" ",
"specified",
",",
" ",
"the",
" ",
"GIT",
"\\u",
"DIR",
" ",
"environ",
"ment",
" ",
"variab",
"le",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"will",
" ",
"be",
" ",
"checke",
"d",
".",
" ",
" ",
"If",
" ",
"tha",
"t",
" ",
"is",
" ",
"not",
" ",
"specified",
",",
" ",
"the",
" ",
"current",
" ",
"working",
" ",
"director",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"and",
" ",
"its",
" ",
"parent",
" ",
"director",
"ies",
" ",
"will",
" ",
"be",
" ",
"searche",
"d",
" ",
"for",
" ",
"a",
" ",
"git",
" ",
"director",
"y",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
" ",
"a",
" ",
"tuple",
" ",
"contain",
"ing",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
",",
" ",
"and",
" ",
"the",
" ",
"default",
" ",
"working",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"director",
"y",
".",
" ",
" ",
"(",
"The",
" ",
"default",
" ",
"working",
" ",
"director",
"y",
" ",
"is",
" ",
"only",
" ",
"to",
" ",
"be",
" ",
"used",
" ",
"if",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"repos",
"itor",
"y",
" ",
"is",
" ",
"not",
" ",
"bare",
",",
" ",
"and",
" ",
"the",
" ",
"working",
" ",
"director",
"y",
" ",
"was",
" ",
"not",
" ",
"specified",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"explicit",
"ly",
" ",
"via",
" ",
"some",
" ",
"other",
" ",
"mechanism",
".)",
" ",
" ",
"The",
" ",
"default",
" ",
"working",
" ",
"director",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"may",
" ",
"be",
" ",
"Non",
"e",
" ",
"if",
" ",
"there",
" ",
"is",
" ",
"no",
" ",
"default",
" ",
"working",
" ",
"director",
"y",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"cwd_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cwd_",
"=_",
"os_",
"._",
"getcwd_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"If",
" ",
"git",
"\\u",
"dir",
" ",
"was",
"n",
"'",
"t",
" ",
"explicit",
"ly",
" ",
"specified",
",",
" ",
"but",
" ",
"GIT",
"\\u",
"DIR",
" ",
"is",
" ",
"set",
" ",
"in",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"environ",
"ment",
",",
" ",
"use",
" ",
"tha",
"t",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"git",
"\\u",
"dir_",
"==_",
"None_",
"and_",
"os_",
"._",
"environ_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"GIT",
"\\u",
"DIR",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"git",
"\\u",
"dir_",
"=_",
"os_",
"._",
"environ_",
"[_",
"'",
"GIT",
"\\u",
"DIR",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"If",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
" ",
"was",
" ",
"explicit",
"ly",
" ",
"specified",
",",
" ",
"use",
" ",
"tha",
"t",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"The",
" ",
"default",
" ",
"working",
" ",
"director",
"y",
" ",
"is",
" ",
"the",
" ",
"current",
" ",
"working",
" ",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"git",
"\\u",
"dir_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"is",
"\\u",
"git",
"\\u",
"dir_",
"(_",
"git",
"\\u",
"dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"AR",
"epo",
"Error_",
"(_",
"git",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"(_",
"git",
"\\u",
"dir_",
",_",
"cwd_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Ot",
"her",
"wis",
"e",
",",
" ",
"atte",
"mpt",
" ",
"to",
" ",
"find",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
" ",
"by",
" ",
"search",
"ing",
" ",
"up",
" ",
"from_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"current",
" ",
"working",
" ",
"director",
"y",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"ceil",
"ing",
"\\u",
"dirs_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"environ_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"GIT",
"\\u",
"CE",
"ILI",
"NG",
"\\u",
"DIRECT",
"ORIE",
"S",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ceil",
"ing",
"\\u",
"dirs_",
"=_",
"os_",
"._",
"environ_",
"[_",
"'",
"GIT",
"\\u",
"CE",
"ILI",
"NG",
"\\u",
"DIRECT",
"ORIE",
"S",
"'_",
"]_",
"._",
"split_",
"(_",
"':'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"ceil",
"ing",
"\\u",
"dirs_",
"._",
"append_",
"(_",
"os_",
"._",
"path_",
"._",
"sep_",
")_",
"#",
" ",
"Add",
" ",
"the",
" ",
"root",
" ",
"directory_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"normpath_",
"(_",
"cwd_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"True_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Check",
" ",
"to",
" ",
"see",
" ",
"if",
" ",
"this",
" ",
"director",
"y",
" ",
"contain",
"s",
" ",
"a",
" ",
".",
"git",
" ",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"git",
" ",
"als",
"o",
" ",
"accepts",
" ",
"regular",
" ",
"files",
" ",
"call",
"ed",
" ",
".",
"git",
" ",
"tha",
"t",
" ",
"contain",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"\"",
"git",
"dir",
":",
" ",
"<",
"path",
">\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"git",
"\\u",
"dir_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"dir_",
",_",
"'.",
"git",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"path_",
"._",
"isdir_",
"(_",
"git",
"\\u",
"dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"is",
"\\u",
"git",
"\\u",
"dir_",
"(_",
"git",
"\\u",
"dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"(_",
"git",
"\\u",
"dir_",
",_",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Check",
" ",
"to",
" ",
"see",
" ",
"if",
" ",
"this",
" ",
"director",
"y",
" ",
"look",
"s",
" ",
"like",
" ",
"a",
" ",
"git",
" ",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"is",
"\\u",
"git",
"\\u",
"dir_",
"(_",
"dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"(_",
"dir_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Walk",
" ",
"up",
" ",
"to",
" ",
"the",
" ",
"parent",
" ",
"director",
"y",
" ",
"bef",
"ore",
" ",
"looping",
" ",
"again",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"(_",
"parent",
"\\u",
"dir_",
",_",
"rest_",
")_",
"=_",
"os_",
"._",
"path_",
"._",
"split_",
"(_",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"If",
" ",
"the",
" ",
"parent",
"\\u",
"dir",
" ",
"is",
" ",
"one",
" ",
"of",
" ",
"the",
" ",
"ceil",
"ing",
" ",
"director",
"ies",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"we",
" ",
"shou",
"ld",
" ",
"stop",
" ",
"bef",
"ore",
" ",
"exam",
"inin",
"g",
" ",
"it",
".",
" ",
" ",
"The",
" ",
"current",
" ",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"doe",
"s",
" ",
"not",
" ",
"appear",
" ",
"to",
" ",
"be",
" ",
"insi",
"de",
" ",
"a",
" ",
"git",
" ",
"repos",
"itor",
"y",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"parent",
"\\u",
"dir_",
"in_",
"ceil",
"ing",
"\\u",
"dirs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Not",
"AR",
"epo",
"Error_",
"(_",
"cwd_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"dir_",
"=_",
"parent",
"\\u",
"dir_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"repo_",
"(_",
"git",
"\\u",
"dir_",
"=_",
"None_",
",_",
"working",
"\\u",
"dir_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"get",
"\\u",
"repo",
"(",
"git",
"\\u",
"dir",
"=",
"Non",
"e",
")",
" ",
"-->",
" ",
"Repos",
"itor",
"y",
" ",
"object",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Creat",
"e",
" ",
"a",
" ",
"Repos",
"itor",
"y",
" ",
"object",
".",
" ",
" ",
"The",
" ",
"repos",
"itor",
"y",
" ",
"is",
" ",
"found",
" ",
"similar",
"ly",
" ",
"to",
" ",
"the",
" ",
"way",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"git",
" ",
"its",
"elf",
" ",
"works",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"If",
" ",
"git",
"\\u",
"dir",
" ",
"is",
" ",
"specified",
",",
" ",
"tha",
"t",
" ",
"is",
" ",
"used",
" ",
"as",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"Ot",
"her",
"wis",
"e",
",",
" ",
"if",
" ",
"the",
" ",
"GIT",
"\\u",
"DIR",
" ",
"environ",
"ment",
" ",
"variab",
"le",
" ",
"is",
" ",
"set",
",",
" ",
"tha",
"t",
" ",
"is",
" ",
"used",
" ",
"as",
"\\",
"10",
";",
" ",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"Ot",
"her",
"wis",
"e",
",",
" ",
"the",
" ",
"current",
" ",
"working",
" ",
"director",
"y",
" ",
"and",
" ",
"its",
" ",
"parents",
" ",
"are",
" ",
"searche",
"d",
" ",
"to",
"\\",
"10",
";",
" ",
" ",
"find",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Fin",
"d",
" ",
"the",
" ",
"git",
" ",
"director",
"y",
" ",
"and",
" ",
"the",
" ",
"default",
" ",
"working",
" ",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"git",
"\\u",
"dir_",
",_",
"default",
"\\u",
"working",
"\\u",
"dir_",
")_",
"=_",
"\\u",
"get",
"\\u",
"git",
"\\u",
"dir_",
"(_",
"git",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Load",
" ",
"the",
" ",
"git",
" ",
"configura",
"tion",
" ",
"for",
" ",
"this",
" ",
"repository_",
"\\u\\u\\uNL\\u\\u\\u_",
"git",
"\\u",
"config_",
"=_",
"config_",
"._",
"load_",
"(_",
"git",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"If",
" ",
"working",
"\\u",
"dir",
" ",
"was",
"n",
"'",
"t",
" ",
"explicit",
"ly",
" ",
"specified",
",",
" ",
"but",
" ",
"GIT",
"\\u",
"WORK",
"\\u",
"TREE",
" ",
"is",
" ",
"set",
" ",
"in_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"environ",
"ment",
",",
" ",
"use",
" ",
"tha",
"t",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"working",
"\\u",
"dir_",
"==_",
"None_",
"and_",
"os_",
"._",
"environ_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"GIT",
"\\u",
"WORK",
"\\u",
"TREE",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"working",
"\\u",
"dir_",
"=_",
"os_",
"._",
"environ_",
"[_",
"'",
"GIT",
"\\u",
"WORK",
"\\u",
"TREE",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"working",
"\\u",
"dir_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"is",
"\\u",
"bare",
"_",
"=_",
"git",
"\\u",
"config_",
"._",
"get",
"Bool_",
"(_",
"'",
"core",
".",
"bare",
"'_",
",_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"is",
"\\u",
"bare",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"working",
"\\u",
"dir_",
"=_",
"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 ",
" _",
"working",
"\\u",
"dir_",
"=_",
"git",
"\\u",
"config_",
"._",
"get_",
"(_",
"'",
"core",
".",
"work",
"tree",
"'_",
",_",
"default",
"\\u",
"working",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
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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
]
|
Unused import | uchicago-cs/deepdish/deepdish/io/__init__.py | [
{
"content": "from __future__ import division, print_function, absolute_import\n\ntry:\n import tables\n _pytables_ok = True\n del tables\nexcept ImportError:\n _pytables_ok = False\n\nif _pytables_ok:\n from .hdf5io import load, save, ForcePickle, Compression\nelse:\n load = save = _f\n\n__all__ = ['load', 'save', 'ForcePickle', 'Compression']\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": " def _f(*args, **kwargs):\n raise ImportError(\"You need PyTables for this function\")",
"metadata": "root._f",
"header": "['module', '___EOS___']",
"index": 12
}
]
| [
{
"span": "import tables",
"start_line": 3,
"start_column": 4,
"end_line": 3,
"end_column": 17
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"from_",
"\\u\\u",
"future\\u\\u_",
"import_",
"division_",
",_",
"print",
"\\u",
"function_",
",_",
"abs",
"olute",
"\\u",
"import_",
"\\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_",
"tables_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"pyt",
"able",
"s",
"\\u",
"ok_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"del_",
"tables_",
"\\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 ",
" _",
"\\u",
"pyt",
"able",
"s",
"\\u",
"ok_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\\u",
"pyt",
"able",
"s",
"\\u",
"ok_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"._",
"hdf5",
"io_",
"import_",
"load_",
",_",
"save_",
",_",
"Force",
"Pickle_",
",_",
"Compress",
"ion_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"load_",
"=_",
"save_",
"=_",
"\\u",
"f_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u",
"all\\u\\u_",
"=_",
"[_",
"'",
"load",
"'_",
",_",
"'",
"save",
"'_",
",_",
"'",
"Force",
"Pickl",
"e",
"'_",
",_",
"'",
"Compress",
"ion",
"'_",
"]_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"\\u",
"f_",
"(_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Import",
"Error_",
"(_",
"\"",
"You",
" ",
"need",
" ",
"Py",
"Table",
"s",
" ",
"for",
" ",
"this",
" ",
"function",
"\"_",
")_",
"\\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,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | serverdensity/sdbot/limbo/plugins/alerts.py | [
{
"content": " def list_alerts(self, command, typeof, name):\n params = {\n 'filter': {'fixed': False}\n }\n valid = ['service', 'device']\n if typeof and typeof in valid:\n params['filter']['config.subjectType'] = typeof\n elif typeof == 'group':\n params['filter']['subjectGroup'] = name\n elif typeof in ['all', '']:\n pass # don't need to do anything\n else:\n text = 'Instead of `{}` you should have used `group`, `service`, `device` or `all`'.format(typeof), ''\n return text\n\n services = self.service.list()\n devices = self.device.list()\n\n if name and typeof != 'group':\n _id = name if not name else self.find_id(name, services, devices)\n params['filter']['config.subjectId'] = _id\n\n results = self.alert.triggered(params=params)\n alerts = sorted(results, key=lambda alert: alert['config']['lastTriggeredAt']['sec'], reverse=True)\n if not (typeof or name):\n # When making a standard `alerts list` we want to give a limited amount of alerts.\n stripped_alerts = alerts[:5]\n else:\n # we want to keep the entire list here\n stripped_alerts = alerts\n open_alerts = []\n\n for alert in stripped_alerts:\n field = alert['config']['fullName'].split(' > ')\n comparison = alert['config'].get('fullComparison', '')\n value = '{}{}'.format(alert['config'].get('value', ''), alert['config'].get('units', ''))\n group = alert['config'].get('group', 'Ungrouped')\n triggered_time = time.localtime(alert['config']['lastTriggeredAt']['sec'])\n\n _id = alert['config']['subjectId']\n if self._is_mongoId(_id):\n name = self.find_name(_id, services, devices)\n name = '{}: {}'.format(alert['config']['subjectType'].title(), name)\n else:\n name = 'Group: {}'.format(_id)\n\n attachment = {\n 'title': '{}'.format(name),\n 'text': '{} {} {}'.format(\n field[1],\n comparison,\n value\n ),\n 'color': COLOR,\n 'fields': [\n {\n 'title': 'Last triggered',\n 'value': time.strftime('%Y-%m-%d, %H:%M:%S', triggered_time)\n },\n # waiting on backend bugfix sd-2190\n # {\n # 'title': 'Group',\n # 'value': group,\n # 'short': True\n # }\n ]\n }\n open_alerts.append(attachment)\n if open_alerts:\n if len(alerts) > len(stripped_alerts):\n message = ('You have {} open alerts but I\\'m only showing the last {},'.format(len(alerts), len(stripped_alerts)) +\n ' do `list open alerts all` to see all of them')\n else:\n message = 'Chop chop, you\\'d better sort out these open alerts soon'\n return open_alerts, message\n else:\n return 'I could not find any open alerts for you.', ''",
"metadata": "root.Wrapper.list_alerts",
"header": "['class', 'Wrapper', '(', 'BaseWrapper', ')', ':', '___EOS___']",
"index": 60
}
]
| [
{
"span": "group ",
"start_line": 96,
"start_column": 12,
"end_line": 96,
"end_column": 17
}
]
| []
| 1 | true | [
"[CLS]_",
"Un",
"used_",
"local_",
"variable_",
"[SEP]_",
"class_",
"Wrapper_",
"(_",
"Base",
"Wrapper_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"list",
"\\u",
"alerts_",
"(_",
"self_",
",_",
"command_",
",_",
"typeof",
"_",
",_",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"params_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"filter",
"'_",
":_",
"{_",
"'",
"fixed",
"'_",
":_",
"False_",
"}_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"valid_",
"=_",
"[_",
"'",
"service",
"'_",
",_",
"'",
"device",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"typeof",
"_",
"and_",
"typeof",
"_",
"in_",
"valid_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"params_",
"[_",
"'",
"filter",
"'_",
"]_",
"[_",
"'",
"config",
".",
"subject",
"Type",
"'_",
"]_",
"=_",
"typeof",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"typeof",
"_",
"==_",
"'",
"group",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"params_",
"[_",
"'",
"filter",
"'_",
"]_",
"[_",
"'",
"subject",
"Group",
"'_",
"]_",
"=_",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"typeof",
"_",
"in_",
"[_",
"'",
"all",
"'_",
",_",
"''_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"#",
" ",
"don",
"'",
"t",
" ",
"need",
" ",
"to",
" ",
"do",
" ",
"anyt",
"hing_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"text_",
"=_",
"'",
"Ins",
"tea",
"d",
" ",
"of",
" ",
"`{}`",
" ",
"you",
" ",
"shou",
"ld",
" ",
"have",
" ",
"used",
" ",
"`",
"group",
"`",
",",
" ",
"`",
"service",
"`",
",",
" ",
"`",
"device",
"`",
" ",
"or",
" ",
"`",
"all",
"`'_",
"._",
"format_",
"(_",
"typeof",
"_",
")_",
",_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"text_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"services_",
"=_",
"self_",
"._",
"service_",
"._",
"list_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"devices_",
"=_",
"self_",
"._",
"device_",
"._",
"list_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"name_",
"and_",
"typeof",
"_",
"!=_",
"'",
"group",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"id_",
"=_",
"name_",
"if_",
"not_",
"name_",
"else_",
"self_",
"._",
"find",
"\\u",
"id_",
"(_",
"name_",
",_",
"services_",
",_",
"devices_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"params_",
"[_",
"'",
"filter",
"'_",
"]_",
"[_",
"'",
"config",
".",
"subject",
"Id",
"'_",
"]_",
"=_",
"\\u",
"id_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"results_",
"=_",
"self_",
"._",
"alert_",
"._",
"triggered_",
"(_",
"params_",
"=_",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"alerts_",
"=_",
"sorted_",
"(_",
"results_",
",_",
"key_",
"=_",
"lambda_",
"alert_",
":_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"[_",
"'",
"last",
"Trigger",
"ed",
"At",
"'_",
"]_",
"[_",
"'",
"sec",
"'_",
"]_",
",_",
"reverse_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"(_",
"typeof",
"_",
"or_",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Whe",
"n",
" ",
"mak",
"ing",
" ",
"a",
" ",
"standard",
" ",
"`",
"alert",
"s",
" ",
"list",
"`",
" ",
"we",
" ",
"want",
" ",
"to",
" ",
"give",
" ",
"a",
" ",
"limited",
" ",
"amo",
"unt",
" ",
"of",
" ",
"alert",
"s",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"strip",
"ped",
"\\u",
"alerts_",
"=_",
"alerts_",
"[_",
":_",
"5_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"we",
" ",
"want",
" ",
"to",
" ",
"keep",
" ",
"the",
" ",
"entire",
" ",
"list",
" ",
"here_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"strip",
"ped",
"\\u",
"alerts_",
"=_",
"alerts_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"open",
"\\u",
"alerts_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"alert_",
"in_",
"strip",
"ped",
"\\u",
"alerts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"field_",
"=_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"[_",
"'",
"full",
"Name",
"'_",
"]_",
"._",
"split_",
"(_",
"'",
" ",
">",
" ",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"comparison_",
"=_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"._",
"get_",
"(_",
"'",
"full",
"Compari",
"son",
"'_",
",_",
"''_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"value_",
"=_",
"'{}{}",
"'_",
"._",
"format_",
"(_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"._",
"get_",
"(_",
"'",
"value",
"'_",
",_",
"''_",
")_",
",_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"._",
"get_",
"(_",
"'",
"unit",
"s",
"'_",
",_",
"''_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"group_",
"=_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"._",
"get_",
"(_",
"'",
"group",
"'_",
",_",
"'",
"Un",
"groupe",
"d",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"trigger",
"ed",
"\\u",
"time_",
"=_",
"time_",
"._",
"localtime_",
"(_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"[_",
"'",
"last",
"Trigger",
"ed",
"At",
"'_",
"]_",
"[_",
"'",
"sec",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"id_",
"=_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"[_",
"'",
"subject",
"Id",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"\\u",
"is",
"\\u",
"mongo",
"Id_",
"(_",
"\\u",
"id_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"self_",
"._",
"find",
"\\u",
"name_",
"(_",
"\\u",
"id_",
",_",
"services_",
",_",
"devices_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"'{}",
":",
" ",
"{}'_",
"._",
"format_",
"(_",
"alert_",
"[_",
"'",
"config",
"'_",
"]_",
"[_",
"'",
"subject",
"Type",
"'_",
"]_",
"._",
"title_",
"(_",
")_",
",_",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"name_",
"=_",
"'",
"Group",
":",
" ",
"{}'_",
"._",
"format_",
"(_",
"\\u",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"attachment_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"title",
"'_",
":_",
"'{}'_",
"._",
"format_",
"(_",
"name_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"text",
"'_",
":_",
"'{}",
" ",
"{}",
" ",
"{}'_",
"._",
"format_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"field_",
"[_",
"1_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"comparison_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"value_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"color",
"'_",
":_",
"COLOR_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"fields",
"'_",
":_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"title",
"'_",
":_",
"'",
"Las",
"t",
" ",
"trigger",
"ed",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"value",
"'_",
":_",
"time_",
"._",
"strftime_",
"(_",
"'%",
"Y",
"-%",
"m",
"-%",
"d",
",",
" ",
"%",
"H",
":",
"%",
"M",
":",
"%",
"S",
"'_",
",_",
"trigger",
"ed",
"\\u",
"time_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"wait",
"ing",
" ",
"on",
" ",
"back",
"end",
" ",
"bug",
"fix",
" ",
"sd",
"-",
"219",
"0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"'",
"title",
"':",
" ",
"'",
"Group",
"',",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"'",
"value",
"':",
" ",
"group",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"'",
"short",
"':",
" ",
"True_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"}_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"open",
"\\u",
"alerts_",
"._",
"append_",
"(_",
"attachment_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"open",
"\\u",
"alerts_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"len_",
"(_",
"alerts_",
")_",
">_",
"len_",
"(_",
"strip",
"ped",
"\\u",
"alerts_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"(_",
"'",
"You",
" ",
"have",
" ",
"{}",
" ",
"open",
" ",
"alert",
"s",
" ",
"but",
" ",
"I",
"\\\\'",
"m",
" ",
"only",
" ",
"showin",
"g",
" ",
"the",
" ",
"last",
" ",
"{}",
",'_",
"._",
"format_",
"(_",
"len_",
"(_",
"alerts_",
")_",
",_",
"len_",
"(_",
"strip",
"ped",
"\\u",
"alerts_",
")_",
")_",
"+_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
" ",
"do",
" ",
"`",
"list",
" ",
"open",
" ",
"alert",
"s",
" ",
"all",
"`",
" ",
"to",
" ",
"see",
" ",
"all",
" ",
"of",
" ",
"them",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"'",
"Cho",
"p",
" ",
"chop",
",",
" ",
"you",
"\\\\'",
"d",
" ",
"bett",
"er",
" ",
"sort",
" ",
"out",
" ",
"these",
" ",
"open",
" ",
"alert",
"s",
" ",
"soo",
"n",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"open",
"\\u",
"alerts_",
",_",
"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 ",
" _",
"return_",
"'",
"I",
" ",
"coul",
"d",
" ",
"not",
" ",
"find",
" ",
"any",
" ",
"open",
" ",
"alert",
"s",
" ",
"for",
" ",
"you",
".'_",
",_",
"''_",
"\\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,
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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
]
|
Unused import | algolia/algoliasearch-client-python/algoliasearch/client.py | [
{
"content": "# -*- coding: utf-8 -*-\n\"\"\"\nCopyright (c) 2013 Algolia\nhttp://www.algolia.com/\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\"\"\"\n\nimport os\nimport json\nimport hmac\nimport hashlib\nimport base64\nimport sys\n \nAPPENGINE = 'APPENGINE_RUNTIME' in os.environ\nSSL_CERTIFICATE_DOMAIN = 'algolia.net'\n\ntry:\n from urllib import urlencode\nexcept ImportError:\n from urllib.parse import urlencode\n\nif APPENGINE:\n from google.appengine.api import urlfetch\n APPENGINE_METHODS = {\n 'GET' : urlfetch.GET,\n 'POST' : urlfetch.POST,\n 'PUT' : urlfetch.PUT,\n 'DELETE' : urlfetch.DELETE\n }\n \nfrom requests import Session\nfrom requests import exceptions\n\nfrom .version import VERSION\nfrom .index import Index\n\nfrom .helpers import AlgoliaException\nfrom .helpers import CustomJSONEncoder\nfrom .helpers import deprecated\nfrom .helpers import safe\nfrom .helpers import urlify\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class Client(object):\n \"\"\"\n Entry point in the Python Client API.\n You should instanciate a Client object with your ApplicationID, ApiKey to\n start using Algolia Search API.\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.Client",
"header": "['module', '___EOS___']",
"index": 61
},
{
"content": " def __init__(self, app_id, api_key, hosts_array=None):\n \"\"\"\n Algolia Search Client initialization\n\n @param app_id the application ID you have in your admin interface\n @param api_key a valid API key for the service\n @param hosts_array the list of hosts that you have received for the service\n \"\"\"\n if not hosts_array:\n self.read_hosts = ['%s-dsn.algolia.net' % app_id,\n '%s-1.algolianet.com' % app_id,\n '%s-2.algolianet.com' % app_id,\n '%s-3.algolianet.com' % app_id]\n self.write_hosts = ['%s.algolia.net' % app_id,\n '%s-1.algolianet.com' % app_id,\n '%s-2.algolianet.com' % app_id,\n '%s-3.algolianet.com' % app_id\n ]\n else:\n self.read_hosts = hosts_array\n self.write_hosts = hosts_array\n\n self._app_id = app_id\n self._api_key = api_key\n self.timeout = (1, 30)\n self.search_timeout = (1, 5)\n\n self._session = Session()\n self._session.verify = os.path.join(os.path.dirname(__file__),\n 'resources/ca-bundle.crt')\n self._session.headers = {\n 'X-Algolia-API-Key': self.api_key,\n 'X-Algolia-Application-Id': self.app_id,\n 'Content-Type': 'gzip',\n 'Accept-Encoding': 'gzip',\n 'User-Agent': 'Algolia Search for Python %s' % VERSION\n }\n # Fix for AppEngine bug when using urlfetch_stub\n if 'google.appengine.api.apiproxy_stub_map' in sys.modules.keys():\n self._session.headers.pop('Accept-Encoding', None)",
"metadata": "root.Client.__init__",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 68
},
{
"content": " @property\n def app_id(self):\n return self._app_id",
"metadata": "root.Client.app_id",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 109
},
{
"content": " @property\n def api_key(self):\n return self._api_key",
"metadata": "root.Client.api_key",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 113
},
{
"content": " @api_key.setter\n def api_key(self, value):\n self._api_key = value\n self.set_extra_headers(**{'X-Algolia-API-Key': value})",
"metadata": "root.Client.api_key",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 117
},
{
"content": " @deprecated\n def enableRateLimitForward(self, admin_api_key, end_user_ip,\n rate_limit_api_key):\n return self.enable_rate_limit_forward(end_user_ip, rate_limit_api_key)",
"metadata": "root.Client.enableRateLimitForward",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 122
},
{
"content": " def enable_rate_limit_forward(self, end_user_ip, rate_limit_api_key):\n \"\"\"\n Allow to use IP rate limit when you have a proxy between end-user and\n Algolia. This option will set the X-Forwarded-For HTTP header with the\n client IP and the X-Forwarded-API-Key with the API Key having rate limits.\n\n @param end_user_ip the end user IP (you can use both IPV4 or IPV6 syntax)\n @param rate_limit_api_key the API key on which you have a rate limit\n \"\"\"\n self.headers.update({\n 'X-Forwarded-For': end_user_ip,\n 'X-Forwarded-API-Key': rate_limit_api_key,\n })",
"metadata": "root.Client.enable_rate_limit_forward",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 127
},
{
"content": " def set_end_user_ip(self, end_user_ip):\n \"\"\"\n Allow to forward an end user IP to the backend for geoip geoloc.\n This option will set the X-Forwarded-For HTTP header with the client IP.\n\n @param end_user_ip the end user IP (you can use both IPV4 or IPV6 syntax)\n \"\"\"\n self.headers['X-Forwarded-For'] = end_user_ip",
"metadata": "root.Client.set_end_user_ip",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 141
},
{
"content": " @deprecated\n def disableRateLimitForward(self):\n return self.disable_rate_limit_forward()",
"metadata": "root.Client.disableRateLimitForward",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 150
},
{
"content": " def disable_rate_limit_forward(self):\n \"\"\"Disable IP rate limit.\"\"\"\n self.headers.pop('X-Forwarded-For', None)\n self.headers.pop('X-Forwarded-API-Key', None)",
"metadata": "root.Client.disable_rate_limit_forward",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 154
},
{
"content": " @deprecated\n def set_extra_header(self, key, value):\n \"\"\"\n Allow to set custom header.\n\n This API is deprecated, please use `set_extra_headers(**kwargs)`.\n \"\"\"\n self.set_extra_headers(**{key: value})",
"metadata": "root.Client.set_extra_header",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 159
},
{
"content": " def set_extra_headers(self, **kwargs):\n \"\"\"\n Allow to set custom headers.\n\n >>> client.set_extra_header(Private=True)\n >>> myHeaders = {\n ... 'X-User': 223254,\n ... 'X-Privacy-Settings': 'NSA-Free'\n ... }\n >>> client.set_extra_header(**myHeaders)\n \"\"\"\n self.headers.update(kwargs)",
"metadata": "root.Client.set_extra_headers",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 168
},
{
"content": " @property\n def headers(self):\n return self._session.headers",
"metadata": "root.Client.headers",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 181
},
{
"content": " @deprecated\n def set_timeout(self, connect_timeout, read_timeout, search_timeout=5):\n \"\"\"\n Allow to set the connection timeout in second.\n\n This API is deprecated. The new API allows you to set directly the\n timeout. For example, if `connect_timeout=1`, `read_timeout=30` and\n `search_timeout=5`:\n\n >>> client.timeout = (1, 30)\n >>> client.search_timeout = (1, 5)\n\n `connect_timeout` is not mandatory:\n\n >>> client.timeout = 30\n >>> client.search_timeout = 5\n \"\"\"\n self.timeout = (connect_timeout, read_timeout)\n self.search_timeout = (connect_timeout, search_timeout)",
"metadata": "root.Client.set_timeout",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 185
},
{
"content": " @deprecated\n def multipleQueries(self, queries, index_name_key='indexName'):\n return self.multiple_queries(queries, index_name_key)",
"metadata": "root.Client.multipleQueries",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 205
},
{
"content": " def multiple_queries(self, queries,\n index_name_key='indexName',\n strategy='none'):\n \"\"\"This method allows to query multiple indexes with one API call.\"\"\"\n path = '/1/indexes/*/queries'\n params = {'strategy': strategy}\n\n requests = []\n for query in queries:\n index_name = query.pop(index_name_key)\n\n requests.append({\n 'indexName': index_name,\n 'params': urlencode(urlify(query))\n })\n\n return self._perform_request(\n self.read_hosts, path, 'POST', params=params,\n body={'requests': requests}, is_search=True)",
"metadata": "root.Client.multiple_queries",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 209
},
{
"content": " def batch(self, requests):\n \"\"\"Send a batch request targetting multiple indices.\"\"\"\n if isinstance(requests, (list, tuple)):\n requests = {'requests': requests}\n\n return self._perform_request(self.write_hosts, '/1/indexes/*/batch',\n 'POST', body=requests)",
"metadata": "root.Client.batch",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 229
},
{
"content": " @deprecated\n def listIndexes(self):\n return self.list_indexes()",
"metadata": "root.Client.listIndexes",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 237
},
{
"content": " def list_indexes(self):\n \"\"\"\n List all existing indexes.\n Return an object of the form:\n {'items': [{ 'name': 'contacts', 'created_at': '2013-01-18T15:33:13.556Z'},\n {'name': 'notes', 'created_at': '2013-01-18T15:33:13.556Z'}]}\n \"\"\"\n return self._perform_request(self.read_hosts, '/1/indexes', 'GET')",
"metadata": "root.Client.list_indexes",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 241
},
{
"content": " @deprecated\n def deleteIndex(self, index_name):\n return self.delete_index(index_name)",
"metadata": "root.Client.deleteIndex",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 250
},
{
"content": " def delete_index(self, index_name):\n \"\"\"\n Delete an index.\n Return an object of the form: {'deleted_at': '2013-01-18T15:33:13.556Z'}\n\n @param index_name the name of index to delete\n \"\"\"\n path = '/1/indexes/%s' % safe(index_name)\n return self._perform_request(self.write_hosts, path, 'DELETE')",
"metadata": "root.Client.delete_index",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 254
},
{
"content": " @deprecated\n def moveIndex(self, src_index_name, dst_index_name):\n return self.move_index(src_index_name, dst_index_name)",
"metadata": "root.Client.moveIndex",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 264
},
{
"content": " def move_index(self, src_index_name, dst_index_name):\n \"\"\"\n Move an existing index.\n\n @param src_index_name the name of index to copy.\n @param dst_index_name the new index name that will contains a copy\n of src_index_name (destination will be overriten if it already exist).\n \"\"\"\n path = '/1/indexes/%s/operation' % safe(src_index_name)\n request = {'operation': 'move', 'destination': dst_index_name}\n return self._perform_request(self.write_hosts, path, 'POST',\n body=request)",
"metadata": "root.Client.move_index",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 268
},
{
"content": " @deprecated\n def copyIndex(self, src_index_name, dst_index_name):\n return self.copy_index(src_index_name, dst_index_name)",
"metadata": "root.Client.copyIndex",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 281
},
{
"content": " def copy_index(self, src_index_name, dst_index_name):\n \"\"\"\n Copy an existing index.\n\n @param src_index_name the name of index to copy.\n @param dst_index_name the new index name that will contains a copy of\n src_index_name (destination will be overriten if it already exist).\n \"\"\"\n path = '/1/indexes/%s/operation' % safe(src_index_name)\n request = {'operation': 'copy', 'destination': dst_index_name}\n return self._perform_request(self.write_hosts, path, 'POST',\n body=request)",
"metadata": "root.Client.copy_index",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 285
},
{
"content": " @deprecated\n def getLogs(self, offset=0, length=10, type='all'):\n return self.get_logs(offset, length, type)",
"metadata": "root.Client.getLogs",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 298
},
{
"content": " def get_logs(self, offset=0, length=10, type='all'):\n \"\"\"\n Return last logs entries.\n\n @param offset Specify the first entry to retrieve (0-based,\n 0 is the most recent log entry).\n @param length Specify the maximum number of entries to retrieve\n starting at offset. Maximum allowed value: 1000.\n \"\"\"\n params = {\n 'offset': offset,\n 'length': length,\n 'type': type\n }\n return self._perform_request(self.write_hosts, '/1/logs', 'GET',\n params=params)",
"metadata": "root.Client.get_logs",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 302
},
{
"content": " @deprecated\n def initIndex(self, index_name):\n return self.init_index(index_name)",
"metadata": "root.Client.initIndex",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 319
},
{
"content": " def init_index(self, index_name):\n \"\"\"\n Get the index object initialized (no server call needed for\n initialization).\n\n @param index_name the name of index\n \"\"\"\n return Index(self, index_name)",
"metadata": "root.Client.init_index",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 323
},
{
"content": " @deprecated\n def listUserKeys(self):\n return self.list_user_keys()",
"metadata": "root.Client.listUserKeys",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 332
},
{
"content": " def list_user_keys(self):\n \"\"\"List all existing user keys with their associated ACLs.\"\"\"\n return self._perform_request(self.read_hosts, '/1/keys', 'GET')",
"metadata": "root.Client.list_user_keys",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 336
},
{
"content": " @deprecated\n def getUserKeyACL(self, key):\n return self.get_user_key_acl(key)",
"metadata": "root.Client.getUserKeyACL",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 340
},
{
"content": " def get_user_key_acl(self, key):\n \"\"\"'Get ACL of a user key.\"\"\"\n path = '/1/keys/%s' % key\n return self._perform_request(self.read_hosts, path, 'GET')",
"metadata": "root.Client.get_user_key_acl",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 344
},
{
"content": " @deprecated\n def deleteUserKey(self, key):\n return self.delete_user_key(key)",
"metadata": "root.Client.deleteUserKey",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 349
},
{
"content": " def delete_user_key(self, key):\n \"\"\"Delete an existing user key.\"\"\"\n path = '/1/keys/%s' % key\n return self._perform_request(self.write_hosts, path, 'DELETE')",
"metadata": "root.Client.delete_user_key",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 353
},
{
"content": " @deprecated\n def addUserKey(self, obj,\n validity=0,\n max_queries_per_ip_per_hour=0,\n max_hits_per_query=0,\n indexes=None):\n return self.add_user_key(obj, validity, max_queries_per_ip_per_hour,\n max_hits_per_query, indexes)",
"metadata": "root.Client.addUserKey",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 358
},
{
"content": " def add_user_key(self, obj,\n validity=0,\n max_queries_per_ip_per_hour=0,\n max_hits_per_query=0,\n indexes=None):\n \"\"\"\n Create a new user key.\n\n @param obj can be two different parameters:\n The list of parameters for this key. Defined by a NSDictionary that\n can contains the following values:\n - acl: array of string\n - indices: array of string\n - validity: int\n - referers: array of string\n - description: string\n - maxHitsPerQuery: integer\n - queryParameters: string\n - maxQueriesPerIPPerHour: integer\n Or the list of ACL for this key. Defined by an array of NSString that\n can contains the following values:\n - search: allow to search (https and http)\n - addObject: allows to add/update an object in the index (https only)\n - deleteObject : allows to delete an existing object (https only)\n - deleteIndex : allows to delete index content (https only)\n - settings : allows to get index settings (https only)\n - editSettings : allows to change index settings (https only)\n @param validity the number of seconds after which the key will be\n automatically removed (0 means no time limit for this key)\n @param max_queries_per_ip_per_hour Specify the maximum number of API\n calls allowed from an IP address per hour. Defaults to 0 (no rate limit).\n @param max_hits_per_query Specify the maximum number of hits this API\n key can retrieve in one call. Defaults to 0 (unlimited)\n @param indexes the optional list of targeted indexes\n \"\"\"\n if not isinstance(obj, dict):\n obj = {'acl': obj}\n\n obj.update({\n 'validity': validity,\n 'maxQueriesPerIPPerHour': max_queries_per_ip_per_hour,\n 'maxHitsPerQuery': max_hits_per_query\n })\n\n if indexes:\n obj['indexes'] = indexes\n\n return self._perform_request(self.write_hosts, '/1/keys', 'POST',\n body=obj)",
"metadata": "root.Client.add_user_key",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 367
},
{
"content": " def update_user_key(self, key, obj,\n validity=None,\n max_queries_per_ip_per_hour=None,\n max_hits_per_query=None,\n indexes=None):\n \"\"\"\n Update a user key.\n\n @param obj can be two different parameters:\n The list of parameters for this key. Defined by a NSDictionary that\n can contains the following values:\n - acl: array of string\n - indices: array of string\n - validity: int\n - referers: array of string\n - description: string\n - maxHitsPerQuery: integer\n - queryParameters: string\n - maxQueriesPerIPPerHour: integer\n Or the list of ACL for this key. Defined by an array of NSString that\n can contains the following values:\n - search: allow to search (https and http)\n - addObject: allows to add/update an object in the index (https only)\n - deleteObject : allows to delete an existing object (https only)\n - deleteIndex : allows to delete index content (https only)\n - settings : allows to get index settings (https only)\n - editSettings : allows to change index settings (https only)\n @param validity the number of seconds after which the key will be\n automatically removed (0 means no time limit for this key)\n @param max_queries_per_ip_per_hour Specify the maximum number of API\n calls allowed from an IP address per hour. Defaults to 0 (no rate limit).\n @param max_hits_per_query Specify the maximum number of hits this API\n key can retrieve in one call. Defaults to 0 (unlimited)\n @param indexes the optional list of targeted indexes\n \"\"\"\n if not isinstance(obj, dict):\n obj = {'acl': obj}\n\n # Check with `is not None`, because 0 is evaluated to False\n if validity is not None:\n obj['validity'] = validity\n if max_queries_per_ip_per_hour is not None:\n obj['maxQueriesPerIPPerHour'] = max_queries_per_ip_per_hour\n if max_hits_per_query is not None:\n obj['maxHitsPerQuery'] = max_hits_per_query\n\n if indexes:\n obj['indexes'] = indexes\n\n path = '/1/keys/%s' % key\n return self._perform_request(self.write_hosts, path, 'PUT',\n body=obj)",
"metadata": "root.Client.update_user_key",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 417
},
{
"content": " @deprecated\n def generateSecuredApiKey(self, private_api_key, tag_filters,\n user_token=''):\n return self.generate_secured_api_key(private_api_key, tag_filters,\n user_token)",
"metadata": "root.Client.generateSecuredApiKey",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 470
},
{
"content": " def generate_secured_api_key(self, private_api_key, queryParameters,\n user_token=''):\n \"\"\"\n Generate a secured and public API Key from a dict of query parameters and an\n optional user token identifying the current user.\n\n @param private_api_key your private API Key\n @param queryParameters the dict of query parameters applied to the query (used as security)\n @param user_token an optional token identifying the current user\n \"\"\"\n if isinstance(queryParameters, (list, tuple)): #List of tags\n queryParameters = ','.join(\n map(lambda t: ''.join(['(', ','.join(t), ')']) if\n isinstance(t, (list, tuple)) else t, queryParameters))\n queryParameters = {'tagFilters': queryParameters}\n elif not isinstance(queryParameters, dict) and not '=' in queryParameters: #TagFilter\n queryParameters = {'tagFilters': queryParameters}\n\n if isinstance(queryParameters, dict): #New API Key generator\n if user_token != None and user_token != '':\n queryParameters['userToken'] = user_token\n queryParameters = urlencode(urlify(queryParameters))\n\n securedKey = hmac.new(private_api_key.encode('utf-8'), queryParameters.encode('utf-8'), hashlib.sha256).hexdigest()\n return str(base64.b64encode((\"%s%s\" % (securedKey, queryParameters)).encode('utf-8')).decode('utf-8'))",
"metadata": "root.Client.generate_secured_api_key",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 476
},
{
"content": " def _perform_appengine_request(self, host, path, method, timeout, params=None, data=None):\n \"\"\"\n Perform an HTTPS request with AppEngine's urlfetch. SSL certificate will not validate when \n the request is on a domain which is not a aloglia.net subdomain, a SNI is not available by\n default on GAE. Hence, we do set validate_certificate to False when calling those domains.\n \"\"\"\n method = APPENGINE_METHODS.get(method)\n if isinstance(timeout, tuple):\n timeout = timeout[1]\n url = 'https://%s%s' % (host, path)\n url = params and '%s?%s' %(url, urlencode(urlify(params))) or url\n res = urlfetch.fetch(url=url, method=method, payload=data,\n headers=self.headers, deadline=timeout,\n validate_certificate=host.endswith(SSL_CERTIFICATE_DOMAIN))\n content = res.content != None and json.loads(res.content) or None\n if (int(res.status_code / 100) == 2 and content):\n return content\n elif (int(res.status_code / 100) == 4):\n message = \"HttpCode: %d\" % res.status_code\n if content and content.get('message'):\n message = content['message']\n raise AlgoliaException(message)\n else:\n mesage = '%s Server Error: %s' % (res.status_code, res.content)\n raise Exception(http_error_msg, response=res)",
"metadata": "root.Client._perform_appengine_request",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 502
},
{
"content": " def _perform_session_request(self, host, path, method, timeout, params=None, data=None):\n \"\"\"Perform an HTTPS request with request's Session.\"\"\"\n res = self._session.request(\n method, 'https://%s%s' % (host, path),\n params=params, data=data, timeout=timeout)\n if (int(res.status_code / 100) == 2 and res.json != None):\n return res.json()\n elif (int(res.status_code / 100) == 4):\n message = \"HttpCode: %d\" % res.status_code\n if res.json != None and 'message' in res.json():\n message = res.json()['message']\n raise AlgoliaException(message)\n res.raise_for_status()",
"metadata": "root.Client._perform_session_request",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 528
},
{
"content": " def _perform_request(self, hosts, path, method, params=None, body=None,\n is_search=False):\n \"\"\"Perform an HTTPS request with retry logic.\"\"\"\n if params:\n params = urlify(params)\n if body:\n body = json.dumps(body, cls=CustomJSONEncoder)\n timeout = self.search_timeout if is_search else self.timeout\n exceptions_hosts = {}\n for i, host in enumerate(hosts):\n if i > 1:\n if isinstance(timeout, tuple):\n timeout = (timeout[0] + 2, timeout[1] + 10)\n else:\n timeout += 10\n try:\n _request = APPENGINE and self._perform_appengine_request or self._perform_session_request\n return _request(host, path, method, timeout, params=params, data=body)\n except AlgoliaException as e:\n raise e\n except Exception as e:\n exceptions_hosts[host] = \"%s: %s\" % (e.__class__.__name__, str(e))\n pass\n\n # Impossible to connect\n raise AlgoliaException('%s %s' % ('Unreachable hosts:',\n exceptions_hosts))",
"metadata": "root.Client._perform_request",
"header": "['class', 'Client', '(', 'object', ')', ':', '___EOS___']",
"index": 542
}
]
| [
{
"span": "from requests import exceptions",
"start_line": 49,
"start_column": 0,
"end_line": 49,
"end_column": 31
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"2013",
" ",
"Algo",
"lia",
"\\",
"10",
";",
"http",
"://",
"www",
".",
"algo",
"lia",
".",
"com",
"/",
"\\",
"10",
";",
"\\",
"10",
";",
"Permi",
"ssion",
" ",
"is",
" ",
"here",
"by",
" ",
"grant",
"ed",
",",
" ",
"free",
" ",
"of",
" ",
"charge",
",",
" ",
"to",
" ",
"any",
" ",
"person",
" ",
"obtain",
"ing",
" ",
"a",
" ",
"copy",
"\\",
"10",
";",
"of",
" ",
"this",
" ",
"software",
" ",
"and",
" ",
"associate",
"d",
" ",
"documentation",
" ",
"files",
" ",
"(",
"the",
" ",
"\"",
"Sof",
"twa",
"re",
"\")",
",",
" ",
"to",
" ",
"deal",
"\\",
"10",
";",
"in",
" ",
"the",
" ",
"Sof",
"twa",
"re",
" ",
"with",
"out",
" ",
"restriction",
",",
" ",
"inclu",
"ding",
" ",
"with",
"out",
" ",
"limit",
"ation",
" ",
"the",
" ",
"rights",
"\\",
"10",
";",
"to",
" ",
"use",
",",
" ",
"copy",
",",
" ",
"modif",
"y",
",",
" ",
"merge",
",",
" ",
"publi",
"sh",
",",
" ",
"distribute",
",",
" ",
"subli",
"cens",
"e",
",",
" ",
"and",
"/",
"or",
" ",
"sell",
"\\",
"10",
";",
"copie",
"s",
" ",
"of",
" ",
"the",
" ",
"Sof",
"twa",
"re",
",",
" ",
"and",
" ",
"to",
" ",
"permit",
" ",
"person",
"s",
" ",
"to",
" ",
"who",
"m",
" ",
"the",
" ",
"Sof",
"twa",
"re",
" ",
"is",
"\\",
"10",
";",
"fur",
"nish",
"ed",
" ",
"to",
" ",
"do",
" ",
"so",
",",
" ",
"subject",
" ",
"to",
" ",
"the",
" ",
"follow",
"ing",
" ",
"condition",
"s",
":",
"\\",
"10",
";",
"\\",
"10",
";",
"The",
" ",
"above",
" ",
"copyr",
"ight",
" ",
"notice",
" ",
"and",
" ",
"this",
" ",
"permissi",
"on",
" ",
"notice",
" ",
"sha",
"ll",
" ",
"be",
" ",
"include",
"d",
" ",
"in",
"\\",
"10",
";",
"all",
" ",
"copie",
"s",
" ",
"or",
" ",
"substa",
"nti",
"al",
" ",
"porti",
"ons",
" ",
"of",
" ",
"the",
" ",
"Sof",
"twa",
"re",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"THE",
" ",
"SOFT",
"WARE",
" ",
"IS",
" ",
"PROVI",
"DED",
" ",
"\"",
"AS",
" ",
"IS",
"\",",
" ",
"WITH",
"OUT",
" ",
"WAR",
"RAN",
"TY",
" ",
"OF",
" ",
"ANY",
" ",
"KIND",
",",
" ",
"EXPR",
"ESS",
" ",
"OR",
"\\",
"10",
";",
"IMPL",
"IED",
",",
" ",
"INC",
"LU",
"DING",
" ",
"BUT",
" ",
"NOT",
" ",
"LIMIT",
"ED",
" ",
"TO",
" ",
"THE",
" ",
"WAR",
"RAN",
"TIES",
" ",
"OF",
" ",
"MER",
"CHAN",
"TAB",
"ILI",
"TY",
",",
"\\",
"10",
";",
"FIT",
"NESS",
" ",
"FOR",
" ",
"A",
" ",
"PARTI",
"CUL",
"AR",
" ",
"PUR",
"POS",
"E",
" ",
"AND",
" ",
"NON",
"INF",
"RING",
"EME",
"NT",
".",
" ",
"IN",
" ",
"NO",
" ",
"EVENT",
" ",
"SHA",
"LL",
" ",
"THE",
"\\",
"10",
";",
"AUTHOR",
"S",
" ",
"OR",
" ",
"COPY",
"RIG",
"HT",
" ",
"HOLD",
"ERS",
" ",
"BE",
" ",
"LI",
"AB",
"LE",
" ",
"FOR",
" ",
"ANY",
" ",
"CLA",
"IM",
",",
" ",
"DA",
"MAGE",
"S",
" ",
"OR",
" ",
"OTHER",
"\\",
"10",
";",
"LI",
"ABI",
"LIT",
"Y",
",",
" ",
"WHE",
"THER",
" ",
"IN",
" ",
"AN",
" ",
"ACTI",
"ON",
" ",
"OF",
" ",
"CONTR",
"ACT",
",",
" ",
"TOR",
"T",
" ",
"OR",
" ",
"OTHER",
"WI",
"SE",
",",
" ",
"ARI",
"SIN",
"G",
" ",
"FROM",
",",
"\\",
"10",
";",
"OUT",
" ",
"OF",
" ",
"OR",
" ",
"IN",
" ",
"CONNECTION",
" ",
"WITH",
" ",
"THE",
" ",
"SOFT",
"WARE",
" ",
"OR",
" ",
"THE",
" ",
"USE",
" ",
"OR",
" ",
"OTHER",
" ",
"DEA",
"LING",
"S",
" ",
"IN",
"\\",
"10",
";",
"THE",
" ",
"SOFT",
"WARE",
".",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"json_",
"\\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_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"APPEN",
"GIN",
"E_",
"=_",
"'",
"APPEN",
"GIN",
"E",
"\\u",
"RUNT",
"IME",
"'_",
"in_",
"os_",
"._",
"environ_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"SS",
"L",
"\\u",
"CERT",
"IFIC",
"ATE",
"\\u",
"DOMAIN_",
"=_",
"'",
"algo",
"lia",
".",
"net",
"'_",
"\\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_",
"urllib_",
"import_",
"urlencode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Import",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"urllib_",
"._",
"parse_",
"import_",
"urlencode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"APPEN",
"GIN",
"E_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"google_",
"._",
"appengine_",
"._",
"api_",
"import_",
"urlf",
"etch",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"APPEN",
"GIN",
"E",
"\\u",
"METHODS_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"GET",
"'_",
":_",
"urlf",
"etch",
"_",
"._",
"GET_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"POST",
"'_",
":_",
"urlf",
"etch",
"_",
"._",
"POST_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"PU",
"T",
"'_",
":_",
"urlf",
"etch",
"_",
"._",
"PUT_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"DELET",
"E",
"'_",
":_",
"urlf",
"etch",
"_",
"._",
"DELETE_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"from_",
"requests_",
"import_",
"Session_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"requests_",
"import_",
"exceptions_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"._",
"version_",
"import_",
"VERSION_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"._",
"index_",
"import_",
"Index_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"._",
"helpers_",
"import_",
"Algo",
"lia",
"Exception_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"._",
"helpers_",
"import_",
"Custom",
"JSO",
"NE",
"ncode",
"r_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"._",
"helpers_",
"import_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"._",
"helpers_",
"import_",
"safe_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"._",
"helpers_",
"import_",
"url",
"ify_",
"\\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_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Entr",
"y",
" ",
"point",
" ",
"in",
" ",
"the",
" ",
"Pyth",
"on",
" ",
"Client",
" ",
"API",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"You",
" ",
"shou",
"ld",
" ",
"instan",
"ciat",
"e",
" ",
"a",
" ",
"Client",
" ",
"object",
" ",
"with",
" ",
"your",
" ",
"Applica",
"tion",
"ID",
",",
" ",
"Ap",
"i",
"Key",
" ",
"to",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"start",
" ",
"usi",
"ng",
" ",
"Algo",
"lia",
" ",
"Sear",
"ch",
" ",
"API",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\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\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"app",
"\\u",
"id_",
",_",
"api",
"\\u",
"key_",
",_",
"host",
"s",
"\\u",
"array_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Algo",
"lia",
" ",
"Sear",
"ch",
" ",
"Client",
" ",
"initialization",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"app",
"\\u",
"id",
" ",
"the",
" ",
"applica",
"tion",
" ",
"ID",
" ",
"you",
" ",
"have",
" ",
"in",
" ",
"your",
" ",
"admin",
" ",
"interface",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"api",
"\\u",
"key",
" ",
"a",
" ",
"valid",
" ",
"API",
" ",
"key",
" ",
"for",
" ",
"the",
" ",
"service",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"host",
"s",
"\\u",
"array",
" ",
"the",
" ",
"list",
" ",
"of",
" ",
"host",
"s",
" ",
"tha",
"t",
" ",
"you",
" ",
"have",
" ",
"receive",
"d",
" ",
"for",
" ",
"the",
" ",
"service",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"host",
"s",
"\\u",
"array_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"read",
"\\u",
"hosts_",
"=_",
"[_",
"'%",
"s",
"-",
"dsn",
".",
"algo",
"lia",
".",
"net",
"'_",
"%_",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'%",
"s",
"-1",
".",
"algo",
"lian",
"et",
".",
"com",
"'_",
"%_",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'%",
"s",
"-",
"2",
".",
"algo",
"lian",
"et",
".",
"com",
"'_",
"%_",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'%",
"s",
"-",
"3",
".",
"algo",
"lian",
"et",
".",
"com",
"'_",
"%_",
"app",
"\\u",
"id_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"write",
"\\u",
"hosts_",
"=_",
"[_",
"'%",
"s",
".",
"algo",
"lia",
".",
"net",
"'_",
"%_",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'%",
"s",
"-1",
".",
"algo",
"lian",
"et",
".",
"com",
"'_",
"%_",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'%",
"s",
"-",
"2",
".",
"algo",
"lian",
"et",
".",
"com",
"'_",
"%_",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'%",
"s",
"-",
"3",
".",
"algo",
"lian",
"et",
".",
"com",
"'_",
"%_",
"app",
"\\u",
"id_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"read",
"\\u",
"hosts_",
"=_",
"host",
"s",
"\\u",
"array_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"write",
"\\u",
"hosts_",
"=_",
"host",
"s",
"\\u",
"array_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"\\u",
"app",
"\\u",
"id_",
"=_",
"app",
"\\u",
"id_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"api",
"\\u",
"key_",
"=_",
"api",
"\\u",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"timeout_",
"=_",
"(_",
"1_",
",_",
"30_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"search",
"\\u",
"timeout_",
"=_",
"(_",
"1_",
",_",
"5_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"\\u",
"session_",
"=_",
"Session_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"session_",
"._",
"verify_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"resource",
"s",
"/",
"ca",
"-",
"bundle",
".",
"crt",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"session_",
"._",
"headers_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"X",
"-",
"Algo",
"lia",
"-",
"API",
"-",
"Key",
"'_",
":_",
"self_",
"._",
"api",
"\\u",
"key_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"X",
"-",
"Algo",
"lia",
"-",
"Applica",
"tion",
"-",
"Id",
"'_",
":_",
"self_",
"._",
"app",
"\\u",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Conten",
"t",
"-",
"Type",
"'_",
":_",
"'",
"gzip",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Accept",
"-",
"Enco",
"ding",
"'_",
":_",
"'",
"gzip",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"User",
"-",
"Agent",
"'_",
":_",
"'",
"Algo",
"lia",
" ",
"Sear",
"ch",
" ",
"for",
" ",
"Pyth",
"on",
" ",
"%",
"s",
"'_",
"%_",
"VERSION_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Fix",
" ",
"for",
" ",
"App",
"Engine",
" ",
"bug",
" ",
"whe",
"n",
" ",
"usi",
"ng",
" ",
"urlf",
"etch",
"\\u",
"stub_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"'",
"google",
".",
"appengine",
".",
"api",
".",
"api",
"proxy",
"\\u",
"stub",
"\\u",
"map",
"'_",
"in_",
"sys_",
"._",
"modules_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"\\u",
"session_",
"._",
"headers_",
"._",
"pop_",
"(_",
"'",
"Accept",
"-",
"Enco",
"ding",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"property_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"app",
"\\u",
"id_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"app",
"\\u",
"id_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"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_",
"api",
"\\u",
"key_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"api",
"\\u",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"api",
"\\u",
"key_",
"._",
"setter_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"api",
"\\u",
"key_",
"(_",
"self_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"\\u",
"api",
"\\u",
"key_",
"=_",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"set\\u",
"extra",
"\\u",
"headers_",
"(_",
"**_",
"{_",
"'",
"X",
"-",
"Algo",
"lia",
"-",
"API",
"-",
"Key",
"'_",
":_",
"value_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"enable",
"Rat",
"e",
"Limit",
"Forward_",
"(_",
"self_",
",_",
"admin",
"\\u",
"api",
"\\u",
"key_",
",_",
"end",
"\\u",
"user",
"\\u",
"ip_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"rate",
"\\u",
"limit",
"\\u",
"api",
"\\u",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"enable",
"\\u",
"rate",
"\\u",
"limit",
"\\u",
"forward_",
"(_",
"end",
"\\u",
"user",
"\\u",
"ip_",
",_",
"rate",
"\\u",
"limit",
"\\u",
"api",
"\\u",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"enable",
"\\u",
"rate",
"\\u",
"limit",
"\\u",
"forward_",
"(_",
"self_",
",_",
"end",
"\\u",
"user",
"\\u",
"ip_",
",_",
"rate",
"\\u",
"limit",
"\\u",
"api",
"\\u",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"All",
"ow",
" ",
"to",
" ",
"use",
" ",
"IP",
" ",
"rate",
" ",
"limit",
" ",
"whe",
"n",
" ",
"you",
" ",
"have",
" ",
"a",
" ",
"proxy",
" ",
"bet",
"ween",
" ",
"end",
"-",
"user",
" ",
"and",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Algo",
"lia",
".",
" ",
"Thi",
"s",
" ",
"option",
" ",
"will",
" ",
"set",
" ",
"the",
" ",
"X",
"-",
"Forward",
"ed",
"-",
"For",
" ",
"HTTP",
" ",
"header",
" ",
"with",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"client",
" ",
"IP",
" ",
"and",
" ",
"the",
" ",
"X",
"-",
"Forward",
"ed",
"-",
"API",
"-",
"Key",
" ",
"with",
" ",
"the",
" ",
"API",
" ",
"Key",
" ",
"hav",
"ing",
" ",
"rate",
" ",
"limit",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"end",
"\\u",
"user",
"\\u",
"ip",
" ",
"the",
" ",
"end",
" ",
"user",
" ",
"IP",
" ",
"(",
"you",
" ",
"can",
" ",
"use",
" ",
"bot",
"h",
" ",
"IP",
"V4",
" ",
"or",
" ",
"IP",
"V6",
" ",
"synta",
"x",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"rate",
"\\u",
"limit",
"\\u",
"api",
"\\u",
"key",
" ",
"the",
" ",
"API",
" ",
"key",
" ",
"on",
" ",
"whi",
"ch",
" ",
"you",
" ",
"have",
" ",
"a",
" ",
"rate",
" ",
"limit",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"headers_",
"._",
"update_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"X",
"-",
"Forward",
"ed",
"-",
"For",
"'_",
":_",
"end",
"\\u",
"user",
"\\u",
"ip_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"X",
"-",
"Forward",
"ed",
"-",
"API",
"-",
"Key",
"'_",
":_",
"rate",
"\\u",
"limit",
"\\u",
"api",
"\\u",
"key_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"end",
"\\u",
"user",
"\\u",
"ip_",
"(_",
"self_",
",_",
"end",
"\\u",
"user",
"\\u",
"ip_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"All",
"ow",
" ",
"to",
" ",
"forward",
" ",
"an",
" ",
"end",
" ",
"user",
" ",
"IP",
" ",
"to",
" ",
"the",
" ",
"back",
"end",
" ",
"for",
" ",
"geoi",
"p",
" ",
"geo",
"loc",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"option",
" ",
"will",
" ",
"set",
" ",
"the",
" ",
"X",
"-",
"Forward",
"ed",
"-",
"For",
" ",
"HTTP",
" ",
"header",
" ",
"with",
" ",
"the",
" ",
"client",
" ",
"IP",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"end",
"\\u",
"user",
"\\u",
"ip",
" ",
"the",
" ",
"end",
" ",
"user",
" ",
"IP",
" ",
"(",
"you",
" ",
"can",
" ",
"use",
" ",
"bot",
"h",
" ",
"IP",
"V4",
" ",
"or",
" ",
"IP",
"V6",
" ",
"synta",
"x",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"headers_",
"[_",
"'",
"X",
"-",
"Forward",
"ed",
"-",
"For",
"'_",
"]_",
"=_",
"end",
"\\u",
"user",
"\\u",
"ip_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"disable",
"Rat",
"e",
"Limit",
"Forward_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"disable",
"\\u",
"rate",
"\\u",
"limit",
"\\u",
"forward_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"disable",
"\\u",
"rate",
"\\u",
"limit",
"\\u",
"forward_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Disa",
"ble",
" ",
"IP",
" ",
"rate",
" ",
"limit",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"headers_",
"._",
"pop_",
"(_",
"'",
"X",
"-",
"Forward",
"ed",
"-",
"For",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"headers_",
"._",
"pop_",
"(_",
"'",
"X",
"-",
"Forward",
"ed",
"-",
"API",
"-",
"Key",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"set\\u",
"extra",
"\\u",
"header_",
"(_",
"self_",
",_",
"key_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"All",
"ow",
" ",
"to",
" ",
"set",
" ",
"custom",
" ",
"header",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"API",
" ",
"is",
" ",
"depre",
"cated",
",",
" ",
"plea",
"se",
" ",
"use",
" ",
"`",
"set\\u",
"extra",
"\\u",
"header",
"s",
"(*",
"*",
"kwarg",
"s",
")`",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"set\\u",
"extra",
"\\u",
"headers_",
"(_",
"**_",
"{_",
"key_",
":_",
"value_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"extra",
"\\u",
"headers_",
"(_",
"self_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"All",
"ow",
" ",
"to",
" ",
"set",
" ",
"custom",
" ",
"header",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"client",
".",
"set\\u",
"extra",
"\\u",
"header",
"(",
"Priva",
"te",
"=",
"Tru",
"e",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"my",
"Head",
"ers",
" ",
"=",
" ",
"{",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"...",
" ",
"'",
"X",
"-",
"User",
"':",
" ",
"223",
"254",
",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"...",
" ",
"'",
"X",
"-",
"Priva",
"cy",
"-",
"Sett",
"ings",
"':",
" ",
"'",
"NS",
"A",
"-",
"Free",
"'",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"...",
" ",
"}",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"client",
".",
"set\\u",
"extra",
"\\u",
"header",
"(*",
"*",
"my",
"Head",
"ers",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"headers_",
"._",
"update_",
"(_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"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_",
"headers_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"\\u",
"session_",
"._",
"headers_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"set\\u",
"timeout_",
"(_",
"self_",
",_",
"connect",
"\\u",
"timeout_",
",_",
"read",
"\\u",
"timeout_",
",_",
"search",
"\\u",
"timeout_",
"=_",
"5_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"All",
"ow",
" ",
"to",
" ",
"set",
" ",
"the",
" ",
"connecti",
"on",
" ",
"timeo",
"ut",
" ",
"in",
" ",
"second",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"API",
" ",
"is",
" ",
"depre",
"cated",
".",
" ",
"The",
" ",
"new",
" ",
"API",
" ",
"allow",
"s",
" ",
"you",
" ",
"to",
" ",
"set",
" ",
"direct",
"ly",
" ",
"the",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"timeo",
"ut",
".",
" ",
"For",
" ",
"example",
",",
" ",
"if",
" ",
"`",
"connect",
"\\u",
"timeo",
"ut",
"=",
"1",
"`",
",",
" ",
"`",
"read",
"\\u",
"timeo",
"ut",
"=",
"30",
"`",
" ",
"and",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"`",
"search",
"\\u",
"timeo",
"ut",
"=",
"5",
"`",
":",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"client",
".",
"timeo",
"ut",
" ",
"=",
" ",
"(",
"1",
",",
" ",
"30",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"client",
".",
"search",
"\\u",
"timeo",
"ut",
" ",
"=",
" ",
"(",
"1",
",",
" ",
"5",
")",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"`",
"connect",
"\\u",
"timeo",
"ut",
"`",
" ",
"is",
" ",
"not",
" ",
"mandat",
"ory",
":",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"client",
".",
"timeo",
"ut",
" ",
"=",
" ",
"30",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
">>>",
" ",
"client",
".",
"search",
"\\u",
"timeo",
"ut",
" ",
"=",
" ",
"5",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"timeout_",
"=_",
"(_",
"connect",
"\\u",
"timeout_",
",_",
"read",
"\\u",
"timeout_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"search",
"\\u",
"timeout_",
"=_",
"(_",
"connect",
"\\u",
"timeout_",
",_",
"search",
"\\u",
"timeout_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"multiple",
"Querie",
"s_",
"(_",
"self_",
",_",
"queries_",
",_",
"index",
"\\u",
"name",
"\\u",
"key_",
"=_",
"'",
"index",
"Name",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"multiple",
"\\u",
"queries_",
"(_",
"queries_",
",_",
"index",
"\\u",
"name",
"\\u",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"multiple",
"\\u",
"queries_",
"(_",
"self_",
",_",
"queries_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"index",
"\\u",
"name",
"\\u",
"key_",
"=_",
"'",
"index",
"Name",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"strategy_",
"=_",
"'",
"none",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Thi",
"s",
" ",
"method",
" ",
"allow",
"s",
" ",
"to",
" ",
"query",
" ",
"multiple",
" ",
"indexe",
"s",
" ",
"with",
" ",
"one",
" ",
"API",
" ",
"call",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"indexe",
"s",
"/*",
"/",
"querie",
"s",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"params_",
"=_",
"{_",
"'",
"strat",
"eg",
"y",
"'_",
":_",
"strategy_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"requests_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"query_",
"in_",
"queries_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"index",
"\\u",
"name_",
"=_",
"query_",
"._",
"pop_",
"(_",
"index",
"\\u",
"name",
"\\u",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"requests_",
"._",
"append_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"index",
"Name",
"'_",
":_",
"index",
"\\u",
"name_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"params",
"'_",
":_",
"urlencode_",
"(_",
"url",
"ify_",
"(_",
"query_",
")_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"read",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"POST",
"'_",
",_",
"params_",
"=_",
"params_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"body_",
"=_",
"{_",
"'",
"request",
"s",
"'_",
":_",
"requests_",
"}_",
",_",
"is",
"\\u",
"search_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"batch_",
"(_",
"self_",
",_",
"requests_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Sen",
"d",
" ",
"a",
" ",
"batch",
" ",
"request",
" ",
"target",
"ting",
" ",
"multiple",
" ",
"indice",
"s",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"requests_",
",_",
"(_",
"list_",
",_",
"tuple_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"requests_",
"=_",
"{_",
"'",
"request",
"s",
"'_",
":_",
"requests_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"'/",
"1",
"/",
"indexe",
"s",
"/*",
"/",
"batch",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"POST",
"'_",
",_",
"body_",
"=_",
"requests_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"list",
"Indexes_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"list",
"\\u",
"indexes_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"list",
"\\u",
"indexes_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"List",
" ",
"all",
" ",
"exist",
"ing",
" ",
"indexe",
"s",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"an",
" ",
"object",
" ",
"of",
" ",
"the",
" ",
"form",
":",
"\\",
"10",
";",
" ",
" ",
" ",
"{",
"'",
"items",
"':",
" ",
"[{",
" ",
"'",
"name",
"':",
" ",
"'",
"contact",
"s",
"',",
" ",
"'",
"created",
"\\u",
"at",
"':",
" ",
"'",
"2013",
"-0",
"1",
"-1",
"8",
"T1",
"5",
":",
"3",
"3",
":",
"13.",
"556",
"Z",
"'}",
",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"{",
"'",
"name",
"':",
" ",
"'",
"note",
"s",
"',",
" ",
"'",
"created",
"\\u",
"at",
"':",
" ",
"'",
"2013",
"-0",
"1",
"-1",
"8",
"T1",
"5",
":",
"3",
"3",
":",
"13.",
"556",
"Z",
"'}",
"]}",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"read",
"\\u",
"hosts_",
",_",
"'/",
"1",
"/",
"indexe",
"s",
"'_",
",_",
"'",
"GET",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"delete",
"Index_",
"(_",
"self_",
",_",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"delete",
"\\u",
"index_",
"(_",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"delete",
"\\u",
"index_",
"(_",
"self_",
",_",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Delete",
" ",
"an",
" ",
"index",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"an",
" ",
"object",
" ",
"of",
" ",
"the",
" ",
"form",
":",
" ",
"{",
"'",
"delete",
"d\\u",
"at",
"':",
" ",
"'",
"2013",
"-0",
"1",
"-1",
"8",
"T1",
"5",
":",
"3",
"3",
":",
"13.",
"556",
"Z",
"'}",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"index",
"\\u",
"name",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"index",
" ",
"to",
" ",
"delete",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"indexe",
"s",
"/",
"%",
"s",
"'_",
"%_",
"safe_",
"(_",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"DELET",
"E",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"move",
"Index_",
"(_",
"self_",
",_",
"src",
"\\u",
"index",
"\\u",
"name_",
",_",
"dst",
"\\u",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"move",
"\\u",
"index_",
"(_",
"src",
"\\u",
"index",
"\\u",
"name_",
",_",
"dst",
"\\u",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"move",
"\\u",
"index_",
"(_",
"self_",
",_",
"src",
"\\u",
"index",
"\\u",
"name_",
",_",
"dst",
"\\u",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Move",
" ",
"an",
" ",
"exist",
"ing",
" ",
"index",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"src",
"\\u",
"index",
"\\u",
"name",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"index",
" ",
"to",
" ",
"copy",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"dst",
"\\u",
"index",
"\\u",
"name",
" ",
"the",
" ",
"new",
" ",
"index",
" ",
"name",
" ",
"tha",
"t",
" ",
"will",
" ",
"contain",
"s",
" ",
"a",
" ",
"copy",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"of",
" ",
"src",
"\\u",
"index",
"\\u",
"name",
" ",
"(",
"destinat",
"ion",
" ",
"will",
" ",
"be",
" ",
"over",
"rite",
"n",
" ",
"if",
" ",
"it",
" ",
"alr",
"ead",
"y",
" ",
"exist",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"indexe",
"s",
"/",
"%",
"s",
"/",
"operati",
"on",
"'_",
"%_",
"safe_",
"(_",
"src",
"\\u",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"request_",
"=_",
"{_",
"'",
"operati",
"on",
"'_",
":_",
"'",
"move",
"'_",
",_",
"'",
"destinat",
"ion",
"'_",
":_",
"dst",
"\\u",
"index",
"\\u",
"name_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"POST",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"body_",
"=_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"copy",
"Index_",
"(_",
"self_",
",_",
"src",
"\\u",
"index",
"\\u",
"name_",
",_",
"dst",
"\\u",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"copy",
"\\u",
"index_",
"(_",
"src",
"\\u",
"index",
"\\u",
"name_",
",_",
"dst",
"\\u",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"copy",
"\\u",
"index_",
"(_",
"self_",
",_",
"src",
"\\u",
"index",
"\\u",
"name_",
",_",
"dst",
"\\u",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Copy",
" ",
"an",
" ",
"exist",
"ing",
" ",
"index",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"src",
"\\u",
"index",
"\\u",
"name",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"index",
" ",
"to",
" ",
"copy",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"dst",
"\\u",
"index",
"\\u",
"name",
" ",
"the",
" ",
"new",
" ",
"index",
" ",
"name",
" ",
"tha",
"t",
" ",
"will",
" ",
"contain",
"s",
" ",
"a",
" ",
"copy",
" ",
"of",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"src",
"\\u",
"index",
"\\u",
"name",
" ",
"(",
"destinat",
"ion",
" ",
"will",
" ",
"be",
" ",
"over",
"rite",
"n",
" ",
"if",
" ",
"it",
" ",
"alr",
"ead",
"y",
" ",
"exist",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"indexe",
"s",
"/",
"%",
"s",
"/",
"operati",
"on",
"'_",
"%_",
"safe_",
"(_",
"src",
"\\u",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"request_",
"=_",
"{_",
"'",
"operati",
"on",
"'_",
":_",
"'",
"copy",
"'_",
",_",
"'",
"destinat",
"ion",
"'_",
":_",
"dst",
"\\u",
"index",
"\\u",
"name_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"POST",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"body_",
"=_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"get",
"Logs_",
"(_",
"self_",
",_",
"offset_",
"=_",
"0_",
",_",
"length_",
"=_",
"10_",
",_",
"type_",
"=_",
"'",
"all",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"get",
"\\u",
"logs_",
"(_",
"offset_",
",_",
"length_",
",_",
"type_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"logs_",
"(_",
"self_",
",_",
"offset_",
"=_",
"0_",
",_",
"length_",
"=_",
"10_",
",_",
"type_",
"=_",
"'",
"all",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"last",
" ",
"logs",
" ",
"entri",
"es",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"offset",
" ",
"Speci",
"fy",
" ",
"the",
" ",
"first",
" ",
"entry",
" ",
"to",
" ",
"retrieve",
" ",
"(",
"0",
"-",
"based",
",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"0",
" ",
"is",
" ",
"the",
" ",
"most",
" ",
"recent",
" ",
"log",
" ",
"entry",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"length",
" ",
"Speci",
"fy",
" ",
"the",
" ",
"maxim",
"um",
" ",
"number",
" ",
"of",
" ",
"entri",
"es",
" ",
"to",
" ",
"retrieve",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"startin",
"g",
" ",
"at",
" ",
"offset",
".",
" ",
"Maxim",
"um",
" ",
"allow",
"ed",
" ",
"value",
":",
" ",
"1000",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"params_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"offset",
"'_",
":_",
"offset_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"length",
"'_",
":_",
"length_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"type_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"'/",
"1",
"/",
"logs",
"'_",
",_",
"'",
"GET",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"params_",
"=_",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"init",
"Index_",
"(_",
"self_",
",_",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"init",
"\\u",
"index_",
"(_",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"init",
"\\u",
"index_",
"(_",
"self_",
",_",
"index",
"\\u",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Get",
" ",
"the",
" ",
"index",
" ",
"object",
" ",
"initialize",
"d",
" ",
"(",
"no",
" ",
"server",
" ",
"call",
" ",
"need",
"ed",
" ",
"for",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"initialization",
").",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"index",
"\\u",
"name",
" ",
"the",
" ",
"name",
" ",
"of",
" ",
"index",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Index_",
"(_",
"self_",
",_",
"index",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"list",
"User",
"Keys_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"list",
"\\u",
"user",
"\\u",
"keys_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"list",
"\\u",
"user",
"\\u",
"keys_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"List",
" ",
"all",
" ",
"exist",
"ing",
" ",
"user",
" ",
"keys",
" ",
"with",
" ",
"thei",
"r",
" ",
"associate",
"d",
" ",
"ACL",
"s",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"read",
"\\u",
"hosts_",
",_",
"'/",
"1",
"/",
"keys",
"'_",
",_",
"'",
"GET",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"get",
"User",
"Key",
"ACL",
"_",
"(_",
"self_",
",_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"get",
"\\u",
"user",
"\\u",
"key",
"\\u",
"acl_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"user",
"\\u",
"key",
"\\u",
"acl_",
"(_",
"self_",
",_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"'",
"Get",
" ",
"ACL",
" ",
"of",
" ",
"a",
" ",
"user",
" ",
"key",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"keys",
"/",
"%",
"s",
"'_",
"%_",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"read",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"GET",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"delete",
"User",
"Key_",
"(_",
"self_",
",_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"delete",
"\\u",
"user",
"\\u",
"key_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"delete",
"\\u",
"user",
"\\u",
"key_",
"(_",
"self_",
",_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Delete",
" ",
"an",
" ",
"exist",
"ing",
" ",
"user",
" ",
"key",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"keys",
"/",
"%",
"s",
"'_",
"%_",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"DELET",
"E",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"add",
"User",
"Key_",
"(_",
"self_",
",_",
"obj_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"validity_",
"=_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
"=_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
"=_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"indexes_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"add",
"\\u",
"user",
"\\u",
"key_",
"(_",
"obj_",
",_",
"validity_",
",_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
",_",
"indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"add",
"\\u",
"user",
"\\u",
"key_",
"(_",
"self_",
",_",
"obj_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"validity_",
"=_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
"=_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
"=_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"indexes_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Creat",
"e",
" ",
"a",
" ",
"new",
" ",
"user",
" ",
"key",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"obj",
" ",
"can",
" ",
"be",
" ",
"two",
" ",
"different",
" ",
"parameter",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"The",
" ",
"list",
" ",
"of",
" ",
"parameter",
"s",
" ",
"for",
" ",
"this",
" ",
"key",
".",
" ",
"Define",
"d",
" ",
"by",
" ",
"a",
" ",
"NS",
"Dict",
"ionar",
"y",
" ",
"tha",
"t",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"can",
" ",
"contain",
"s",
" ",
"the",
" ",
"follow",
"ing",
" ",
"values",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"acl",
":",
" ",
"array",
" ",
"of",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"indice",
"s",
":",
" ",
"array",
" ",
"of",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"valid",
"it",
"y",
":",
" ",
"int",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"refere",
"rs",
":",
" ",
"array",
" ",
"of",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"description",
":",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"max",
"Hits",
"Per",
"Query",
":",
" ",
"integ",
"er",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"query",
"Parameter",
"s",
":",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"max",
"Querie",
"s",
"Per",
"IPP",
"er",
"Hour",
":",
" ",
"integ",
"er",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Or",
" ",
"the",
" ",
"list",
" ",
"of",
" ",
"ACL",
" ",
"for",
" ",
"this",
" ",
"key",
".",
" ",
"Define",
"d",
" ",
"by",
" ",
"an",
" ",
"array",
" ",
"of",
" ",
"NS",
"String",
" ",
"tha",
"t",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"can",
" ",
"contain",
"s",
" ",
"the",
" ",
"follow",
"ing",
" ",
"values",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"search",
":",
" ",
"allow",
" ",
"to",
" ",
"search",
" ",
"(",
"https",
" ",
"and",
" ",
"http",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"add",
"Object",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"add",
"/",
"update",
" ",
"an",
" ",
"object",
" ",
"in",
" ",
"the",
" ",
"index",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"delete",
"Object",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"delete",
" ",
"an",
" ",
"exist",
"ing",
" ",
"object",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"delete",
"Index",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"delete",
" ",
"index",
" ",
"content",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"settings",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"get",
" ",
"index",
" ",
"settings",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"edit",
"Sett",
"ings",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"change",
" ",
"index",
" ",
"settings",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"valid",
"it",
"y",
" ",
"the",
" ",
"number",
" ",
"of",
" ",
"second",
"s",
" ",
"after",
" ",
"whi",
"ch",
" ",
"the",
" ",
"key",
" ",
"will",
" ",
"be",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"automati",
"call",
"y",
" ",
"remove",
"d",
" ",
"(",
"0",
" ",
"means",
" ",
"no",
" ",
"time",
" ",
"limit",
" ",
"for",
" ",
"this",
" ",
"key",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour",
" ",
"Speci",
"fy",
" ",
"the",
" ",
"maxim",
"um",
" ",
"number",
" ",
"of",
" ",
"API",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"calls",
" ",
"allow",
"ed",
" ",
"from",
" ",
"an",
" ",
"IP",
" ",
"address",
" ",
"per",
" ",
"hour",
".",
" ",
" ",
"Default",
"s",
" ",
"to",
" ",
"0",
" ",
"(",
"no",
" ",
"rate",
" ",
"limit",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query",
" ",
"Speci",
"fy",
" ",
"the",
" ",
"maxim",
"um",
" ",
"number",
" ",
"of",
" ",
"hits",
" ",
"this",
" ",
"API",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"key",
" ",
"can",
" ",
"retrieve",
" ",
"in",
" ",
"one",
" ",
"call",
".",
" ",
"Default",
"s",
" ",
"to",
" ",
"0",
" ",
"(",
"unlimited",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"indexe",
"s",
" ",
"the",
" ",
"option",
"al",
" ",
"list",
" ",
"of",
" ",
"targeted",
" ",
"indexe",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"isinstance_",
"(_",
"obj_",
",_",
"dict_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"=_",
"{_",
"'",
"acl",
"'_",
":_",
"obj_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"obj_",
"._",
"update_",
"(_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"valid",
"it",
"y",
"'_",
":_",
"validity_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"max",
"Querie",
"s",
"Per",
"IPP",
"er",
"Hour",
"'_",
":_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"max",
"Hits",
"Per",
"Query",
"'_",
":_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"indexes_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"[_",
"'",
"indexe",
"s",
"'_",
"]_",
"=_",
"indexes_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"'/",
"1",
"/",
"keys",
"'_",
",_",
"'",
"POST",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"body_",
"=_",
"obj_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"update",
"\\u",
"user",
"\\u",
"key_",
"(_",
"self_",
",_",
"key_",
",_",
"obj_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"validity_",
"=_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
"=_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
"=_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"indexes_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Update",
" ",
"a",
" ",
"user",
" ",
"key",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"obj",
" ",
"can",
" ",
"be",
" ",
"two",
" ",
"different",
" ",
"parameter",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"The",
" ",
"list",
" ",
"of",
" ",
"parameter",
"s",
" ",
"for",
" ",
"this",
" ",
"key",
".",
" ",
"Define",
"d",
" ",
"by",
" ",
"a",
" ",
"NS",
"Dict",
"ionar",
"y",
" ",
"tha",
"t",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"can",
" ",
"contain",
"s",
" ",
"the",
" ",
"follow",
"ing",
" ",
"values",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"acl",
":",
" ",
"array",
" ",
"of",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"indice",
"s",
":",
" ",
"array",
" ",
"of",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"valid",
"it",
"y",
":",
" ",
"int",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"refere",
"rs",
":",
" ",
"array",
" ",
"of",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"description",
":",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"max",
"Hits",
"Per",
"Query",
":",
" ",
"integ",
"er",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"query",
"Parameter",
"s",
":",
" ",
"string",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"max",
"Querie",
"s",
"Per",
"IPP",
"er",
"Hour",
":",
" ",
"integ",
"er",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Or",
" ",
"the",
" ",
"list",
" ",
"of",
" ",
"ACL",
" ",
"for",
" ",
"this",
" ",
"key",
".",
" ",
"Define",
"d",
" ",
"by",
" ",
"an",
" ",
"array",
" ",
"of",
" ",
"NS",
"String",
" ",
"tha",
"t",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"can",
" ",
"contain",
"s",
" ",
"the",
" ",
"follow",
"ing",
" ",
"values",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"search",
":",
" ",
"allow",
" ",
"to",
" ",
"search",
" ",
"(",
"https",
" ",
"and",
" ",
"http",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"add",
"Object",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"add",
"/",
"update",
" ",
"an",
" ",
"object",
" ",
"in",
" ",
"the",
" ",
"index",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"delete",
"Object",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"delete",
" ",
"an",
" ",
"exist",
"ing",
" ",
"object",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"delete",
"Index",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"delete",
" ",
"index",
" ",
"content",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"settings",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"get",
" ",
"index",
" ",
"settings",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"-",
" ",
"edit",
"Sett",
"ings",
" ",
":",
" ",
"allow",
"s",
" ",
"to",
" ",
"change",
" ",
"index",
" ",
"settings",
" ",
"(",
"https",
" ",
"only",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"valid",
"it",
"y",
" ",
"the",
" ",
"number",
" ",
"of",
" ",
"second",
"s",
" ",
"after",
" ",
"whi",
"ch",
" ",
"the",
" ",
"key",
" ",
"will",
" ",
"be",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"automati",
"call",
"y",
" ",
"remove",
"d",
" ",
"(",
"0",
" ",
"means",
" ",
"no",
" ",
"time",
" ",
"limit",
" ",
"for",
" ",
"this",
" ",
"key",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour",
" ",
"Speci",
"fy",
" ",
"the",
" ",
"maxim",
"um",
" ",
"number",
" ",
"of",
" ",
"API",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"calls",
" ",
"allow",
"ed",
" ",
"from",
" ",
"an",
" ",
"IP",
" ",
"address",
" ",
"per",
" ",
"hour",
".",
" ",
" ",
"Default",
"s",
" ",
"to",
" ",
"0",
" ",
"(",
"no",
" ",
"rate",
" ",
"limit",
").",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query",
" ",
"Speci",
"fy",
" ",
"the",
" ",
"maxim",
"um",
" ",
"number",
" ",
"of",
" ",
"hits",
" ",
"this",
" ",
"API",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"key",
" ",
"can",
" ",
"retrieve",
" ",
"in",
" ",
"one",
" ",
"call",
".",
" ",
"Default",
"s",
" ",
"to",
" ",
"0",
" ",
"(",
"unlimited",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"indexe",
"s",
" ",
"the",
" ",
"option",
"al",
" ",
"list",
" ",
"of",
" ",
"targeted",
" ",
"indexe",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"isinstance_",
"(_",
"obj_",
",_",
"dict_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"=_",
"{_",
"'",
"acl",
"'_",
":_",
"obj_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Check",
" ",
"with",
" ",
"`",
"is",
" ",
"not",
" ",
"Non",
"e",
"`",
",",
" ",
"bec",
"aus",
"e",
" ",
"0",
" ",
"is",
" ",
"evaluate",
"d",
" ",
"to",
" ",
"False_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"validity_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"[_",
"'",
"valid",
"it",
"y",
"'_",
"]_",
"=_",
"validity_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"[_",
"'",
"max",
"Querie",
"s",
"Per",
"IPP",
"er",
"Hour",
"'_",
"]_",
"=_",
"max",
"\\u",
"querie",
"s",
"\\u",
"per",
"\\u",
"ip",
"\\u",
"per",
"\\u",
"hour_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"[_",
"'",
"max",
"Hits",
"Per",
"Query",
"'_",
"]_",
"=_",
"max",
"\\u",
"hits",
"\\u",
"per",
"\\u",
"query_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"indexes_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"obj_",
"[_",
"'",
"indexe",
"s",
"'_",
"]_",
"=_",
"indexes_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"path_",
"=_",
"'/",
"1",
"/",
"keys",
"/",
"%",
"s",
"'_",
"%_",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
"._",
"write",
"\\u",
"hosts_",
",_",
"path_",
",_",
"'",
"PU",
"T",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"body_",
"=_",
"obj_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"deprecated_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"generat",
"e",
"Secur",
"ed",
"Ap",
"i",
"Key_",
"(_",
"self_",
",_",
"private",
"\\u",
"api",
"\\u",
"key_",
",_",
"tag",
"\\u",
"filters_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"user",
"\\u",
"token_",
"=_",
"''_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"generat",
"e\\u",
"secure",
"d\\u",
"api",
"\\u",
"key_",
"(_",
"private",
"\\u",
"api",
"\\u",
"key_",
",_",
"tag",
"\\u",
"filters_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"user",
"\\u",
"token_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"generat",
"e\\u",
"secure",
"d\\u",
"api",
"\\u",
"key_",
"(_",
"self_",
",_",
"private",
"\\u",
"api",
"\\u",
"key_",
",_",
"query",
"Parameters_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"user",
"\\u",
"token_",
"=_",
"''_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Generate",
" ",
"a",
" ",
"secure",
"d",
" ",
"and",
" ",
"public",
" ",
"API",
" ",
"Key",
" ",
"from",
" ",
"a",
" ",
"dict",
" ",
"of",
" ",
"query",
" ",
"parameter",
"s",
" ",
"and",
" ",
"an",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"option",
"al",
" ",
"user",
" ",
"token",
" ",
"identify",
"ing",
" ",
"the",
" ",
"current",
" ",
"user",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"private",
"\\u",
"api",
"\\u",
"key",
" ",
"your",
" ",
"private",
" ",
"API",
" ",
"Key",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"query",
"Parameter",
"s",
" ",
"the",
" ",
"dict",
" ",
"of",
" ",
"query",
" ",
"parameter",
"s",
" ",
"applied",
" ",
"to",
" ",
"the",
" ",
"query",
" ",
"(",
"used",
" ",
"as",
" ",
"security",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"@",
"param",
" ",
"user",
"\\u",
"token",
" ",
"an",
" ",
"option",
"al",
" ",
"token",
" ",
"identify",
"ing",
" ",
"the",
" ",
"current",
" ",
"user",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"query",
"Parameters_",
",_",
"(_",
"list_",
",_",
"tuple_",
")_",
")_",
":_",
"#",
"List",
" ",
"of",
" ",
"tags_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"query",
"Parameters_",
"=_",
"','_",
"._",
"join_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"map_",
"(_",
"lambda_",
"t_",
":_",
"''_",
"._",
"join_",
"(_",
"[_",
"'('_",
",_",
"','_",
"._",
"join_",
"(_",
"t_",
")_",
",_",
"')'_",
"]_",
")_",
"if_",
"\\u\\u\\uNL\\u\\u\\u_",
"isinstance_",
"(_",
"t_",
",_",
"(_",
"list_",
",_",
"tuple_",
")_",
")_",
"else_",
"t_",
",_",
"query",
"Parameters_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"query",
"Parameters_",
"=_",
"{_",
"'",
"tag",
"Filter",
"s",
"'_",
":_",
"query",
"Parameters_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"not_",
"isinstance_",
"(_",
"query",
"Parameters_",
",_",
"dict_",
")_",
"and_",
"not_",
"'='_",
"in_",
"query",
"Parameters_",
":_",
"#",
"Ta",
"g",
"Filter_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"query",
"Parameters_",
"=_",
"{_",
"'",
"tag",
"Filter",
"s",
"'_",
":_",
"query",
"Parameters_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"query",
"Parameters_",
",_",
"dict_",
")_",
":_",
"#",
"New",
" ",
"API",
" ",
"Key",
" ",
"generator_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"user",
"\\u",
"token_",
"!=_",
"None_",
"and_",
"user",
"\\u",
"token_",
"!=_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"query",
"Parameters_",
"[_",
"'",
"user",
"Token",
"'_",
"]_",
"=_",
"user",
"\\u",
"token_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"query",
"Parameters_",
"=_",
"urlencode_",
"(_",
"url",
"ify_",
"(_",
"query",
"Parameters_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"secure",
"d",
"Key_",
"=_",
"hmac_",
"._",
"new_",
"(_",
"private",
"\\u",
"api",
"\\u",
"key_",
"._",
"encode_",
"(_",
"'",
"utf",
"-",
"8",
"'_",
")_",
",_",
"query",
"Parameters_",
"._",
"encode_",
"(_",
"'",
"utf",
"-",
"8",
"'_",
")_",
",_",
"hashlib_",
"._",
"sha256_",
")_",
"._",
"hexdigest_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"str_",
"(_",
"base64_",
"._",
"b64encode_",
"(_",
"(_",
"\"%",
"s",
"%",
"s",
"\"_",
"%_",
"(_",
"secure",
"d",
"Key_",
",_",
"query",
"Parameters_",
")_",
")_",
"._",
"encode_",
"(_",
"'",
"utf",
"-",
"8",
"'_",
")_",
")_",
"._",
"decode_",
"(_",
"'",
"utf",
"-",
"8",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"perform",
"\\u",
"appengine",
"\\u",
"request_",
"(_",
"self_",
",_",
"host_",
",_",
"path_",
",_",
"method_",
",_",
"timeout_",
",_",
"params_",
"=_",
"None_",
",_",
"data_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Perform",
" ",
"an",
" ",
"HTTP",
"S",
" ",
"request",
" ",
"with",
" ",
"App",
"Engine",
"'",
"s",
" ",
"urlf",
"etch",
".",
" ",
"SS",
"L",
" ",
"certifica",
"te",
" ",
"will",
" ",
"not",
" ",
"validat",
"e",
" ",
"whe",
"n",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"the",
" ",
"request",
" ",
"is",
" ",
"on",
" ",
"a",
" ",
"domain",
" ",
"whi",
"ch",
" ",
"is",
" ",
"not",
" ",
"a",
" ",
"alog",
"lia",
".",
"net",
" ",
"subdomain",
",",
" ",
"a",
" ",
"SNI",
" ",
"is",
" ",
"not",
" ",
"avail",
"able",
" ",
"by",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"default",
" ",
"on",
" ",
"GA",
"E",
".",
" ",
"Hen",
"ce",
",",
" ",
"we",
" ",
"do",
" ",
"set",
" ",
"validat",
"e\\u",
"certifica",
"te",
" ",
"to",
" ",
"Fal",
"se",
" ",
"whe",
"n",
" ",
"calling",
" ",
"tho",
"se",
" ",
"domains",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"method_",
"=_",
"APPEN",
"GIN",
"E",
"\\u",
"METHODS_",
"._",
"get_",
"(_",
"method_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"timeout_",
",_",
"tuple_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"timeout_",
"=_",
"timeout_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"url_",
"=_",
"'",
"https",
"://",
"%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"host_",
",_",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"url_",
"=_",
"params_",
"and_",
"'%",
"s",
"?",
"%",
"s",
"'_",
"%_",
"(_",
"url_",
",_",
"urlencode_",
"(_",
"url",
"ify_",
"(_",
"params_",
")_",
")_",
")_",
"or_",
"url_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"res_",
"=_",
"urlf",
"etch",
"_",
"._",
"fetch_",
"(_",
"url_",
"=_",
"url_",
",_",
"method_",
"=_",
"method_",
",_",
"payload_",
"=_",
"data_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"headers_",
"=_",
"self_",
"._",
"headers_",
",_",
"deadline_",
"=_",
"timeout_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"validat",
"e\\u",
"certificate_",
"=_",
"host_",
"._",
"endswith_",
"(_",
"SS",
"L",
"\\u",
"CERT",
"IFIC",
"ATE",
"\\u",
"DOMAIN_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"content_",
"=_",
"res_",
"._",
"content_",
"!=_",
"None_",
"and_",
"json_",
"._",
"loads_",
"(_",
"res_",
"._",
"content_",
")_",
"or_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"(_",
"int_",
"(_",
"res_",
"._",
"status",
"\\u",
"code_",
"/_",
"100_",
")_",
"==_",
"2_",
"and_",
"content_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"content_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"(_",
"int_",
"(_",
"res_",
"._",
"status",
"\\u",
"code_",
"/_",
"100_",
")_",
"==_",
"4_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"\"",
"Http",
"Code",
":",
" ",
"%",
"d",
"\"_",
"%_",
"res_",
"._",
"status",
"\\u",
"code_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"content_",
"and_",
"content_",
"._",
"get_",
"(_",
"'",
"message",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"content_",
"[_",
"'",
"message",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"raise_",
"Algo",
"lia",
"Exception_",
"(_",
"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 ",
" _",
"mesa",
"ge_",
"=_",
"'%",
"s",
" ",
"Server",
" ",
"Error",
":",
" ",
"%",
"s",
"'_",
"%_",
"(_",
"res_",
"._",
"status",
"\\u",
"code_",
",_",
"res_",
"._",
"content_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Exception_",
"(_",
"http",
"\\u",
"error",
"\\u",
"msg_",
",_",
"response_",
"=_",
"res_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"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",
"perform",
"\\u",
"session",
"\\u",
"request_",
"(_",
"self_",
",_",
"host_",
",_",
"path_",
",_",
"method_",
",_",
"timeout_",
",_",
"params_",
"=_",
"None_",
",_",
"data_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Perform",
" ",
"an",
" ",
"HTTP",
"S",
" ",
"request",
" ",
"with",
" ",
"request",
"'",
"s",
" ",
"Sess",
"ion",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"res_",
"=_",
"self_",
"._",
"\\u",
"session_",
"._",
"request_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"method_",
",_",
"'",
"https",
"://",
"%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"host_",
",_",
"path_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"params_",
"=_",
"params_",
",_",
"data_",
"=_",
"data_",
",_",
"timeout_",
"=_",
"timeout_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"(_",
"int_",
"(_",
"res_",
"._",
"status",
"\\u",
"code_",
"/_",
"100_",
")_",
"==_",
"2_",
"and_",
"res_",
"._",
"json_",
"!=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"res_",
"._",
"json_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"(_",
"int_",
"(_",
"res_",
"._",
"status",
"\\u",
"code_",
"/_",
"100_",
")_",
"==_",
"4_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"\"",
"Http",
"Code",
":",
" ",
"%",
"d",
"\"_",
"%_",
"res_",
"._",
"status",
"\\u",
"code_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"res_",
"._",
"json_",
"!=_",
"None_",
"and_",
"'",
"message",
"'_",
"in_",
"res_",
"._",
"json_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"message_",
"=_",
"res_",
"._",
"json_",
"(_",
")_",
"[_",
"'",
"message",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"raise_",
"Algo",
"lia",
"Exception_",
"(_",
"message_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"res_",
"._",
"raise",
"\\u",
"for",
"\\u",
"status_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Client_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"perform",
"\\u",
"request_",
"(_",
"self_",
",_",
"hosts_",
",_",
"path_",
",_",
"method_",
",_",
"params_",
"=_",
"None_",
",_",
"body_",
"=_",
"None_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"is",
"\\u",
"search_",
"=_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Perform",
" ",
"an",
" ",
"HTTP",
"S",
" ",
"request",
" ",
"with",
" ",
"retr",
"y",
" ",
"logic",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"params_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"params_",
"=_",
"url",
"ify_",
"(_",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"body_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"body_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"body_",
",_",
"cls_",
"=_",
"Custom",
"JSO",
"NE",
"ncode",
"r_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"timeout_",
"=_",
"self_",
"._",
"search",
"\\u",
"timeout_",
"if_",
"is",
"\\u",
"search_",
"else_",
"self_",
"._",
"timeout_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"exception",
"s",
"\\u",
"hosts_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
",_",
"host_",
"in_",
"enumerate_",
"(_",
"hosts_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"i_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"isinstance_",
"(_",
"timeout_",
",_",
"tuple_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"timeout_",
"=_",
"(_",
"timeout_",
"[_",
"0_",
"]_",
"+_",
"2_",
",_",
"timeout_",
"[_",
"1_",
"]_",
"+_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"timeout_",
"+=_",
"10_",
"\\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 ",
" _",
"\\u",
"request_",
"=_",
"APPEN",
"GIN",
"E_",
"and_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"appengine",
"\\u",
"request_",
"or_",
"self_",
"._",
"\\u",
"perform",
"\\u",
"session",
"\\u",
"request_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u",
"request_",
"(_",
"host_",
",_",
"path_",
",_",
"method_",
",_",
"timeout_",
",_",
"params_",
"=_",
"params_",
",_",
"data_",
"=_",
"body_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Algo",
"lia",
"Exception_",
"as_",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"e_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Exception_",
"as_",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"exception",
"s",
"\\u",
"hosts_",
"[_",
"host_",
"]_",
"=_",
"\"%",
"s",
":",
" ",
"%",
"s",
"\"_",
"%_",
"(_",
"e_",
"._",
"\\u\\u",
"class\\u\\u_",
"._",
"\\u\\u",
"name\\u\\u_",
",_",
"str_",
"(_",
"e_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Imp",
"oss",
"ibl",
"e",
" ",
"to",
" ",
"connect_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"raise_",
"Algo",
"lia",
"Exception_",
"(_",
"'%",
"s",
" ",
"%",
"s",
"'_",
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
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | adamb70/CSGO-Market-Float-Finder/pysteamkit/vdf.py | [
{
"content": "def _parse_binary(stream, ptr=0):\n\ti = ptr\n\tdeserialized = {}\n\t\n\twhile i < len(stream):\n\t\tc = stream[i]\n\t\t\n\t\tif c == BIN_END:\n\t\t\treturn deserialized, i\n\t\t\n\t\tnodename, i = _readtonull(stream, i + 1)\n\t\t\n\t\tif c == BIN_NONE:\n\t\t\tdeserialized[nodename], i = _parse_binary(stream, i + 1)\n\t\telif c == BIN_STRING:\n\t\t\tdeserialized[nodename], i = _readtonull(stream, i + 1)\n\t\telif c == BIN_WIDESTRING:\n\t\t\traise Exception('NYI')\n\t\telif c == BIN_INT32 or c == BIN_COLOR or c == BIN_POINTER:\n\t\t\tif len(stream) - i < 4:\n\t\t\t\traise Exception('Invalid KV')\n\t\t\tvalue, = struct.unpack_from('i', stream, i + 1)\n\t\t\tdeserialized[nodename], i = value, i + 4\n\t\telif c == BIN_UINT64:\n\t\t\tif len(stream) - i < 8:\n\t\t\t\traise Exception('Invalid KV')\n\t\t\tvalue, = struct.unpack_from('q', stream, i + 1)\n\t\t\tdeserialized[nodename], i = value, i + 8\n\t\telif c == BIN_FLOAT32:\n\t\t\tif len(stream) - i < 4:\n\t\t\t\traise Exception('Invalid KV')\n\t\t\tvalue, = struct.unpack_from('f', stream, i + 1)\n\t\t\tdeserialized[nodename], i = 0, i + 4\n\t\telse:\n\t\t\traise Exception('Unknown KV type')\n\t\t\t\n\t\ti += 1\n\n\treturn deserialized, i",
"metadata": "root._parse_binary",
"header": "['module', '___EOS___']",
"index": 90
}
]
| [
{
"span": "value,",
"start_line": 121,
"start_column": 3,
"end_line": 121,
"end_column": 8
}
]
| [
{
"span": "value,",
"start_line": 111,
"start_column": 3,
"end_line": 111,
"end_column": 8
},
{
"span": "value,",
"start_line": 116,
"start_column": 3,
"end_line": 116,
"end_column": 8
}
]
| 1 | true | [
"[CLS]_",
"Variable_",
"defined_",
"multiple_",
"times_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"parse",
"\\u",
"binary_",
"(_",
"stream_",
",_",
"ptr_",
"=_",
"0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"_",
"i_",
"=_",
"ptr_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deserialized_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"while_",
"i_",
"<_",
"len_",
"(_",
"stream_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"c_",
"=_",
"stream_",
"[_",
"i_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"c_",
"==_",
"BIN",
"\\u",
"END_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"return_",
"deserialized_",
",_",
"i_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"nodename_",
",_",
"i_",
"=_",
"\\u",
"read",
"ton",
"ull",
"_",
"(_",
"stream_",
",_",
"i_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"c_",
"==_",
"BIN",
"\\u",
"NONE_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"deserialized_",
"[_",
"nodename_",
"]_",
",_",
"i_",
"=_",
"\\u",
"parse",
"\\u",
"binary_",
"(_",
"stream_",
",_",
"i_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"c_",
"==_",
"BIN",
"\\u",
"STRING_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"deserialized_",
"[_",
"nodename_",
"]_",
",_",
"i_",
"=_",
"\\u",
"read",
"ton",
"ull",
"_",
"(_",
"stream_",
",_",
"i_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"c_",
"==_",
"BIN",
"\\u",
"WID",
"EST",
"RING",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"raise_",
"Exception_",
"(_",
"'",
"NY",
"I",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"c_",
"==_",
"BIN",
"\\u",
"INT",
"32_",
"or_",
"c_",
"==_",
"BIN",
"\\u",
"COLOR_",
"or_",
"c_",
"==_",
"BIN",
"\\u",
"POINTER_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"if_",
"len_",
"(_",
"stream_",
")_",
"-_",
"i_",
"<_",
"4_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t\t_",
"raise_",
"Exception_",
"(_",
"'",
"Inva",
"lid",
" ",
"KV",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"value_",
",_",
"=_",
"struct_",
"._",
"unpack",
"\\u",
"from_",
"(_",
"'",
"i",
"'_",
",_",
"stream_",
",_",
"i_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deserialized_",
"[_",
"nodename_",
"]_",
",_",
"i_",
"=_",
"value_",
",_",
"i_",
"+_",
"4_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"c_",
"==_",
"BIN",
"\\u",
"UINT",
"64_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"if_",
"len_",
"(_",
"stream_",
")_",
"-_",
"i_",
"<_",
"8_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t\t_",
"raise_",
"Exception_",
"(_",
"'",
"Inva",
"lid",
" ",
"KV",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"value_",
",_",
"=_",
"struct_",
"._",
"unpack",
"\\u",
"from_",
"(_",
"'",
"q",
"'_",
",_",
"stream_",
",_",
"i_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deserialized_",
"[_",
"nodename_",
"]_",
",_",
"i_",
"=_",
"value_",
",_",
"i_",
"+_",
"8_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"c_",
"==_",
"BIN",
"\\u",
"FLOAT",
"32_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"if_",
"len_",
"(_",
"stream_",
")_",
"-_",
"i_",
"<_",
"4_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t\t_",
"raise_",
"Exception_",
"(_",
"'",
"Inva",
"lid",
" ",
"KV",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"value_",
",_",
"=_",
"struct_",
"._",
"unpack",
"\\u",
"from_",
"(_",
"'",
"f",
"'_",
",_",
"stream_",
",_",
"i_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"deserialized_",
"[_",
"nodename_",
"]_",
",_",
"i_",
"=_",
"0_",
",_",
"i_",
"+_",
"4_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t\t_",
"raise_",
"Exception_",
"(_",
"'",
"Un",
"know",
"n",
" ",
"KV",
" ",
"type",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"i_",
"+=_",
"1_",
"\\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,
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
]
|
Unused import | pydanny/django-uni-form/uni_form/tests/runtests.py | [
{
"content": "#!/usr/bin/env python\n\nimport os, sys\n\nos.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings'\nparent = os.path.dirname(os.path.dirname(os.path.dirname(\n os.path.abspath(__file__))))\n\nsys.path.insert(0, parent)\n\nfrom django.test.simple import DjangoTestSuiteRunner\nfrom django.conf import settings\n\n\nif __name__ == '__main__':\n runtests()\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def runtests():\n DjangoTestSuiteRunner(failfast=False).run_tests([\n 'uni_form.TestBasicFunctionalityTags',\n 'uni_form.TestFormHelpers',\n 'uni_form.TestFormLayout',\n ], verbosity=1, interactive=True)",
"metadata": "root.runtests",
"header": "['module', '___EOS___']",
"index": 13
}
]
| [
{
"span": "from django.conf import settings",
"start_line": 11,
"start_column": 0,
"end_line": 11,
"end_column": 32
}
]
| []
| 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_",
"os_",
",_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"os_",
"._",
"environ_",
"[_",
"'",
"DJANGO",
"\\u",
"SETTING",
"S",
"\\u",
"MODUL",
"E",
"'_",
"]_",
"=_",
"'",
"test\\u",
"settings",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parent_",
"=_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"os_",
"._",
"path_",
"._",
"abspath_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"sys_",
"._",
"path_",
"._",
"insert_",
"(_",
"0_",
",_",
"parent_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"django_",
"._",
"test_",
"._",
"simple_",
"import_",
"Dj",
"ang",
"o",
"Test",
"Suit",
"e",
"Runner_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"conf_",
"import_",
"settings_",
"\\u\\u\\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 ",
" _",
"runtest",
"s_",
"(_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"runtest",
"s_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"Dj",
"ang",
"o",
"Test",
"Suit",
"e",
"Runner_",
"(_",
"fail",
"fast_",
"=_",
"False_",
")_",
"._",
"run",
"\\u",
"tests_",
"(_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uni",
"\\u",
"form",
".",
"Test",
"Basic",
"Function",
"ality",
"Ta",
"gs",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uni",
"\\u",
"form",
".",
"Test",
"Form",
"Help",
"ers",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uni",
"\\u",
"form",
".",
"Test",
"Form",
"Lay",
"out",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
",_",
"verbosity_",
"=_",
"1_",
",_",
"interactive_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | Shopify/shopify_python_api/test/asset_test.py | [
{
"content": " def test_get_assets(self):\n self.fake(\"assets\", method='GET', body=self.load_fixture('assets'))\n v = shopify.Asset.find()",
"metadata": "root.AssetTest.test_get_assets",
"header": "['class', 'AssetTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 5
},
{
"content": " def test_get_asset(self):\n self.fake(\"assets.json?asset%5Bkey%5D=templates%2Findex.liquid\", extension=False, method='GET', body=self.load_fixture('asset'))\n v = shopify.Asset.find('templates/index.liquid')",
"metadata": "root.AssetTest.test_get_asset",
"header": "['class', 'AssetTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 9
},
{
"content": " def test_get_assets_namespaced(self):\n self.fake(\"themes/1/assets\", method='GET', body=self.load_fixture('assets'))\n v = shopify.Asset.find(theme_id = 1)",
"metadata": "root.AssetTest.test_get_assets_namespaced",
"header": "['class', 'AssetTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 20
},
{
"content": " def test_get_asset_namespaced(self):\n self.fake(\"themes/1/assets.json?asset%5Bkey%5D=templates%2Findex.liquid&theme_id=1\", extension=False, method='GET', body=self.load_fixture('asset'))\n v = shopify.Asset.find('templates/index.liquid', theme_id=1)",
"metadata": "root.AssetTest.test_get_asset_namespaced",
"header": "['class', 'AssetTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 24
}
]
| [
{
"span": "v ",
"start_line": 7,
"start_column": 8,
"end_line": 7,
"end_column": 9
},
{
"span": "v ",
"start_line": 11,
"start_column": 8,
"end_line": 11,
"end_column": 9
},
{
"span": "v ",
"start_line": 22,
"start_column": 8,
"end_line": 22,
"end_column": 9
},
{
"span": "v ",
"start_line": 26,
"start_column": 8,
"end_line": 26,
"end_column": 9
}
]
| []
| 1 | true | [
"[CLS]_",
"Un",
"used_",
"local_",
"variable_",
"[SEP]_",
"class_",
"Asset",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"test\\u",
"get",
"\\u",
"assets_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fake_",
"(_",
"\"",
"asset",
"s",
"\"_",
",_",
"method_",
"=_",
"'",
"GET",
"'_",
",_",
"body_",
"=_",
"self_",
"._",
"load",
"\\u",
"fixture_",
"(_",
"'",
"asset",
"s",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"v_",
"=_",
"shop",
"ify_",
"._",
"Asset_",
"._",
"find_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Asset",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"get",
"\\u",
"asset_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fake_",
"(_",
"\"",
"asset",
"s",
".",
"json",
"?",
"asset",
"%",
"5",
"Bk",
"ey",
"%",
"5",
"D",
"=",
"template",
"s",
"%",
"2",
"Fin",
"dex",
".",
"liquid",
"\"_",
",_",
"extension_",
"=_",
"False_",
",_",
"method_",
"=_",
"'",
"GET",
"'_",
",_",
"body_",
"=_",
"self_",
"._",
"load",
"\\u",
"fixture_",
"(_",
"'",
"asset",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"v_",
"=_",
"shop",
"ify_",
"._",
"Asset_",
"._",
"find_",
"(_",
"'",
"template",
"s",
"/",
"index",
".",
"liquid",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Asset",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"get",
"\\u",
"asset",
"s",
"\\u",
"namespace",
"d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fake_",
"(_",
"\"",
"themes",
"/",
"1",
"/",
"asset",
"s",
"\"_",
",_",
"method_",
"=_",
"'",
"GET",
"'_",
",_",
"body_",
"=_",
"self_",
"._",
"load",
"\\u",
"fixture_",
"(_",
"'",
"asset",
"s",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"v_",
"=_",
"shop",
"ify_",
"._",
"Asset_",
"._",
"find_",
"(_",
"them",
"e\\u",
"id_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Asset",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"get",
"\\u",
"asset",
"\\u",
"namespace",
"d_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"fake_",
"(_",
"\"",
"themes",
"/",
"1",
"/",
"asset",
"s",
".",
"json",
"?",
"asset",
"%",
"5",
"Bk",
"ey",
"%",
"5",
"D",
"=",
"template",
"s",
"%",
"2",
"Fin",
"dex",
".",
"liquid",
"&",
"them",
"e\\u",
"id",
"=",
"1",
"\"_",
",_",
"extension_",
"=_",
"False_",
",_",
"method_",
"=_",
"'",
"GET",
"'_",
",_",
"body_",
"=_",
"self_",
"._",
"load",
"\\u",
"fixture_",
"(_",
"'",
"asset",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"v_",
"=_",
"shop",
"ify_",
"._",
"Asset_",
"._",
"find_",
"(_",
"'",
"template",
"s",
"/",
"index",
".",
"liquid",
"'_",
",_",
"them",
"e\\u",
"id_",
"=_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
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,
0,
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,
0,
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,
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
]
|
Unused import | charanpald/APGL/apgl/graph/Benchmark.py | [
{
"content": "\"\"\"\nA set of benchmark tests in order to compare the speed of algorithms under different \ngraph types. \n\"\"\"\nimport numpy \nimport logging \nimport time \nimport networkx \nfrom apgl.graph import DenseGraph, SparseGraph, PySparseGraph, DictGraph \nfrom exp.sandbox.graph.CsArrayGraph import CsArrayGraph\n\nnumpy.set_printoptions(suppress=True, precision=4)\n\n\n \n \n \nedgeList = generateEdges() \n#timeArray = benchmarkAddEdges(edgeList)\ntimeArray = benchmark(edgeList)\n\nfor i in range(timeArray.shape[2]): \n print(timeArray[:, :, i])\n\n\n#subgraph, degree sequence, ",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class GraphIterator:\n\n \n ",
"metadata": "root.GraphIterator",
"header": "['module', '___EOS___']",
"index": 13
},
{
"content": " def __init__(self, numVertices, sparseOnly=False, numEdges=0): \n self.numVertices = numVertices \n self.sparseOnly = sparseOnly \n \n self.graphList = [] \n \n if not self.sparseOnly: \n self.graphList.append(DenseGraph(numVertices))\n\n #self.graphList.append(SparseGraph(numVertices, frmt=\"lil\"))\n #self.graphList.append(SparseGraph(numVertices, frmt=\"csc\"))\n #self.graphList.append(SparseGraph(numVertices, frmt=\"csr\"))\n self.graphList.append(PySparseGraph(numVertices))\n #self.graphList.append(CsArrayGraph(numVertices))\n self.graphList.append(DictGraph())\n\n self.i = 0 ",
"metadata": "root.GraphIterator.__init__",
"header": "['class', 'GraphIterator', ':', '___EOS___']",
"index": 14
},
{
"content": " def __iter__(self): \n return self ",
"metadata": "root.GraphIterator.__iter__",
"header": "['class', 'GraphIterator', ':', '___EOS___']",
"index": 32
},
{
"content": " def next(self): \n if self.i==len(self.graphList): \n raise StopIteration \n else: \n graph = self.graphList[self.i]\n self.i += 1 \n return graph ",
"metadata": "root.GraphIterator.next",
"header": "['class', 'GraphIterator', ':', '___EOS___']",
"index": 35
},
{
"content": " def getNumGraphs(self): \n return len(self.graphList)",
"metadata": "root.GraphIterator.getNumGraphs",
"header": "['class', 'GraphIterator', ':', '___EOS___']",
"index": 43
},
{
"content": "def generateEdges(): \n edgeList = [] \n \n density = 0.01 \n numVertices = numpy.array([100, 200, 500, 1000]) \n \n for i in numVertices: \n numEdges = (i**2) * density\n \n \n edges = numpy.zeros((numEdges, 2))\n edges[:, 0] = numpy.random.randint(0, i, numEdges)\n edges[:, 1] = numpy.random.randint(0, i, numEdges)\n \n edgeList.append((i, edges))\n \n return edgeList ",
"metadata": "root.generateEdges",
"header": "['module', '___EOS___']",
"index": 46
},
{
"content": "def benchmark(edgeList): \n iterator = GraphIterator(100)\n numGraphTypes = iterator.getNumGraphs() \n numMeasures = 6 \n timeArray = numpy.zeros((len(edgeList), numGraphTypes, numMeasures)) \n i = 0 \n \n nxGraph = networkx.Graph()\n \n for numVertices, edges in edgeList: \n print(\"Timing graphs of size \" + str(numVertices) + \" with \" + str(edges.shape[0]) + \" edges\")\n \n iterator = GraphIterator(numVertices)\n j = 0 \n \n for graph in iterator:\n measureInd = 0 \n \n print(\"Add edges benchmark on \" + str(graph)) \n startTime = time.clock()\n for m in range(10): \n graph.addEdges(edges) \n timeArray[i, j, measureInd] = time.clock() - startTime\n measureInd += 1 \n \n vertexIds = graph.getAllVertexIds() \n \n print(\"Neighbours benchmark on \" + str(graph)) \n startTime = time.clock()\n for m in range(100): \n for k in range(50): \n graph.neighbours(vertexIds[k]) \n timeArray[i, j, measureInd] = time.clock() - startTime\n measureInd += 1\n \n print(\"Depth first search benchmark on \" + str(graph)) \n startTime = time.clock()\n for k in range(5): \n graph.depthFirstSearch(vertexIds[k]) \n timeArray[i, j, measureInd] = time.clock() - startTime\n measureInd += 1\n \n print(\"Breadth first search benchmark on \" + str(graph)) \n startTime = time.clock()\n for k in range(5): \n graph.breadthFirstSearch(vertexIds[k]) \n timeArray[i, j, measureInd] = time.clock() - startTime \n measureInd += 1\n \n print(\"Find components benchmark on \" + str(graph)) \n startTime = time.clock()\n graph.findConnectedComponents() \n timeArray[i, j, measureInd] = time.clock() - startTime \n measureInd += 1 \n \n print(\"Degree sequence benchmark on \" + str(graph)) \n startTime = time.clock()\n for k in range(100): \n graph.degreeSequence() \n timeArray[i, j, measureInd] = time.clock() - startTime \n measureInd += 1 \n \n j += 1\n \n i +=1 \n \n return timeArray ",
"metadata": "root.benchmark",
"header": "['module', '___EOS___']",
"index": 65
}
]
| [
{
"span": "import logging ",
"start_line": 5,
"start_column": 0,
"end_line": 5,
"end_column": 14
},
{
"span": "from apgl.graph import DenseGraph, SparseGraph, PySparseGraph, DictGraph ",
"start_line": 8,
"start_column": 0,
"end_line": 8,
"end_column": 72
},
{
"span": "from exp.sandbox.graph.CsArrayGraph import CsArrayGraph",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 55
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
"A",
" ",
"set",
" ",
"of",
" ",
"bench",
"mark",
" ",
"tests",
" ",
"in",
" ",
"order",
" ",
"to",
" ",
"compare",
" ",
"the",
" ",
"speed",
" ",
"of",
" ",
"algo",
"rit",
"hms",
" ",
"under",
" ",
"different",
" ",
"\\",
"10",
";",
"graph",
" ",
"types",
".",
" ",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"numpy_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"logging_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"networkx_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"ap",
"gl_",
"._",
"graph_",
"import_",
"Den",
"se",
"Graph_",
",_",
"Spar",
"se",
"Graph_",
",_",
"Py",
"Spar",
"se",
"Graph_",
",_",
"Dict",
"Graph_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"exp_",
"._",
"sandbox_",
"._",
"graph_",
"._",
"Cs",
"Array",
"Graph_",
"import_",
"Cs",
"Array",
"Graph_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"numpy_",
"._",
"set\\u",
"printo",
"ptions_",
"(_",
"suppress_",
"=_",
"True_",
",_",
"precision_",
"=_",
"4_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"edge",
"List_",
"=_",
"generat",
"e",
"Edges_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"time",
"Array",
" ",
"=",
" ",
"bench",
"mark",
"Add",
"Ed",
"ges",
"(",
"edge",
"List",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"time",
"Array_",
"=_",
"benchmark_",
"(_",
"edge",
"List_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"time",
"Array_",
"._",
"shape_",
"[_",
"2_",
"]_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"time",
"Array_",
"[_",
":_",
",_",
":_",
",_",
"i_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"subgraph",
",",
" ",
"degr",
"ee",
" ",
"sequence",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Graph",
"Iterator_",
":_",
"\\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_",
"Graph",
"Iterator_",
":_",
"\\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_",
",_",
"num",
"Vertices_",
",_",
"spars",
"e",
"Only_",
"=_",
"False_",
",_",
"num",
"Edges_",
"=_",
"0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"num",
"Vertices_",
"=_",
"num",
"Vertices_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"spars",
"e",
"Only_",
"=_",
"spars",
"e",
"Only_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"graph",
"List_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"self_",
"._",
"spars",
"e",
"Only_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"graph",
"List_",
"._",
"append_",
"(_",
"Den",
"se",
"Graph_",
"(_",
"num",
"Vertices_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"self",
".",
"graph",
"List",
".",
"append",
"(",
"Spar",
"se",
"Graph",
"(",
"num",
"Vert",
"ices",
",",
" ",
"frm",
"t",
"=\"",
"lil",
"\"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"self",
".",
"graph",
"List",
".",
"append",
"(",
"Spar",
"se",
"Graph",
"(",
"num",
"Vert",
"ices",
",",
" ",
"frm",
"t",
"=\"",
"csc",
"\"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"self",
".",
"graph",
"List",
".",
"append",
"(",
"Spar",
"se",
"Graph",
"(",
"num",
"Vert",
"ices",
",",
" ",
"frm",
"t",
"=\"",
"csr",
"\"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"graph",
"List_",
"._",
"append_",
"(_",
"Py",
"Spar",
"se",
"Graph_",
"(_",
"num",
"Vertices_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"self",
".",
"graph",
"List",
".",
"append",
"(",
"Cs",
"Array",
"Graph",
"(",
"num",
"Vert",
"ices",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"graph",
"List_",
"._",
"append_",
"(_",
"Dict",
"Graph_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"i_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Graph",
"Iterator_",
":_",
"\\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_",
"self_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Graph",
"Iterator_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"next_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"self_",
"._",
"i_",
"==_",
"len_",
"(_",
"self_",
"._",
"graph",
"List_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Sto",
"p",
"Iteration_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"graph_",
"=_",
"self_",
"._",
"graph",
"List_",
"[_",
"self_",
"._",
"i_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"i_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"graph_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Graph",
"Iterator_",
":_",
"\\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",
"Num",
"Graph",
"s_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"len_",
"(_",
"self_",
"._",
"graph",
"List_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"generat",
"e",
"Edges_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"edge",
"List_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"density_",
"=_",
"0.01_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"num",
"Vertices_",
"=_",
"numpy_",
"._",
"array_",
"(_",
"[_",
"100_",
",_",
"200_",
",_",
"500_",
",_",
"1000_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"i_",
"in_",
"num",
"Vertices_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"num",
"Edges_",
"=_",
"(_",
"i_",
"**_",
"2_",
")_",
"*_",
"density_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"edges_",
"=_",
"numpy_",
"._",
"zeros_",
"(_",
"(_",
"num",
"Edges_",
",_",
"2_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"edges_",
"[_",
":_",
",_",
"0_",
"]_",
"=_",
"numpy_",
"._",
"random_",
"._",
"randint_",
"(_",
"0_",
",_",
"i_",
",_",
"num",
"Edges_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"edges_",
"[_",
":_",
",_",
"1_",
"]_",
"=_",
"numpy_",
"._",
"random_",
"._",
"randint_",
"(_",
"0_",
",_",
"i_",
",_",
"num",
"Edges_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"edge",
"List_",
"._",
"append_",
"(_",
"(_",
"i_",
",_",
"edges_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"edge",
"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_",
"benchmark_",
"(_",
"edge",
"List_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"iterator_",
"=_",
"Graph",
"Iterator_",
"(_",
"100_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"num",
"Graph",
"Types_",
"=_",
"iterator_",
"._",
"get",
"Num",
"Graph",
"s_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"num",
"Measure",
"s_",
"=_",
"6_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"time",
"Array_",
"=_",
"numpy_",
"._",
"zeros_",
"(_",
"(_",
"len_",
"(_",
"edge",
"List_",
")_",
",_",
"num",
"Graph",
"Types_",
",_",
"num",
"Measure",
"s_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"i_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"nx",
"Graph_",
"=_",
"networkx_",
"._",
"Graph_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"num",
"Vertices_",
",_",
"edges_",
"in_",
"edge",
"List_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"Tim",
"ing",
" ",
"graph",
"s",
" ",
"of",
" ",
"size",
" ",
"\"_",
"+_",
"str_",
"(_",
"num",
"Vertices_",
")_",
"+_",
"\"",
" ",
"with",
" ",
"\"_",
"+_",
"str_",
"(_",
"edges_",
"._",
"shape_",
"[_",
"0_",
"]_",
")_",
"+_",
"\"",
" ",
"edge",
"s",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"iterator_",
"=_",
"Graph",
"Iterator_",
"(_",
"num",
"Vertices_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"j_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"graph_",
"in_",
"iterator_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"measure",
"Ind_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Add",
" ",
"edge",
"s",
" ",
"bench",
"mark",
" ",
"on",
" ",
"\"_",
"+_",
"str_",
"(_",
"graph_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"m_",
"in_",
"range_",
"(_",
"10_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"graph_",
"._",
"add",
"Edges_",
"(_",
"edges_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"time",
"Array_",
"[_",
"i_",
",_",
"j_",
",_",
"measure",
"Ind_",
"]_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"Time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"measure",
"Ind_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"vertex",
"Ids_",
"=_",
"graph_",
"._",
"get",
"All",
"Vertex",
"Ids_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Neigh",
"bour",
"s",
" ",
"bench",
"mark",
" ",
"on",
" ",
"\"_",
"+_",
"str_",
"(_",
"graph_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"m_",
"in_",
"range_",
"(_",
"100_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"k_",
"in_",
"range_",
"(_",
"50_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"graph_",
"._",
"neighbours_",
"(_",
"vertex",
"Ids_",
"[_",
"k_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"time",
"Array_",
"[_",
"i_",
",_",
"j_",
",_",
"measure",
"Ind_",
"]_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"Time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"measure",
"Ind_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Dep",
"th",
" ",
"first",
" ",
"search",
" ",
"bench",
"mark",
" ",
"on",
" ",
"\"_",
"+_",
"str_",
"(_",
"graph_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
"in_",
"range_",
"(_",
"5_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"graph_",
"._",
"depth",
"Fi",
"rst",
"Search_",
"(_",
"vertex",
"Ids_",
"[_",
"k_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"time",
"Array_",
"[_",
"i_",
",_",
"j_",
",_",
"measure",
"Ind_",
"]_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"Time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"measure",
"Ind_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Bre",
"adt",
"h",
" ",
"first",
" ",
"search",
" ",
"bench",
"mark",
" ",
"on",
" ",
"\"_",
"+_",
"str_",
"(_",
"graph_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
"in_",
"range_",
"(_",
"5_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"graph_",
"._",
"bread",
"th",
"Fi",
"rst",
"Search_",
"(_",
"vertex",
"Ids_",
"[_",
"k_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"time",
"Array_",
"[_",
"i_",
",_",
"j_",
",_",
"measure",
"Ind_",
"]_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"Time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"measure",
"Ind_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Fin",
"d",
" ",
"component",
"s",
" ",
"bench",
"mark",
" ",
"on",
" ",
"\"_",
"+_",
"str_",
"(_",
"graph_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"graph_",
"._",
"find",
"Connect",
"ed",
"Components_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"time",
"Array_",
"[_",
"i_",
",_",
"j_",
",_",
"measure",
"Ind_",
"]_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"Time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"measure",
"Ind_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"(_",
"\"",
"Deg",
"ree",
" ",
"sequence",
" ",
"bench",
"mark",
" ",
"on",
" ",
"\"_",
"+_",
"str_",
"(_",
"graph_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
"in_",
"range_",
"(_",
"100_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"graph_",
"._",
"degr",
"ee",
"Sequence_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"time",
"Array_",
"[_",
"i_",
",_",
"j_",
",_",
"measure",
"Ind_",
"]_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"Time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"measure",
"Ind_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"j_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"i_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"time",
"Array_",
"\\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,
0,
1,
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,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
]
|
Unused import | iskandr/parakeet/benchmarks/diffuse.py | [
{
"content": "#\n# Code taken from Numba's documentation at http://numba.pydata.org/numba-doc/0.11/arrays.html\n#\n\nimport numpy as np \n\nmu = 0.1\nLx, Ly = 101, 101\nN = 1000\nimport parakeet\nimport parakeet.c_backend\n#parakeet.c_backend.config.print_module_source = True\n\n\n\n\n\nfrom compare_perf import compare_perf \n\ncompare_perf(diffuse_loops, [N], numba=True)\ncompare_perf( diffuse_array_expressions, [N], numba =True)\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def diffuse_loops(iter_num):\n u = np.zeros((Lx, Ly), dtype=np.float64)\n temp_u = np.zeros_like(u)\n temp_u[Lx / 2, Ly / 2] = 1000.0\n\n for n in range(iter_num):\n for i in range(1, Lx - 1):\n for j in range(1, Ly - 1):\n u[i, j] = mu * (temp_u[i + 1, j] + temp_u[i - 1, j] +\n temp_u[i, j + 1] + temp_u[i, j - 1] -\n 4 * temp_u[i, j])\n\n temp = u\n u = temp_u\n temp_u = temp\n\n return u",
"metadata": "root.diffuse_loops",
"header": "['module', '___EOS___']",
"index": 14
},
{
"content": "def diffuse_array_expressions(iter_num):\n u = np.zeros((Lx, Ly), dtype=np.float64)\n temp_u = np.zeros_like(u)\n temp_u[Lx / 2, Ly / 2] = 1000.0\n\n for i in range(iter_num):\n u[1:-1, 1:-1] = mu * (temp_u[2:, 1:-1] + temp_u[:-2, 1:-1] +\n temp_u[1:-1, 2:] + temp_u[1:-1, :-2] -\n 4 * temp_u[1:-1, 1:-1])\n\n temp = u\n u = temp_u\n temp_u = temp\n return u",
"metadata": "root.diffuse_array_expressions",
"header": "['module', '___EOS___']",
"index": 32
}
]
| [
{
"span": "import parakeet",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 15
},
{
"span": "import parakeet.c_backend",
"start_line": 10,
"start_column": 0,
"end_line": 10,
"end_column": 25
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Code",
" ",
"take",
"n",
" ",
"from",
" ",
"Num",
"ba",
"'",
"s",
" ",
"documentation",
" ",
"at",
" ",
"http",
"://",
"numb",
"a",
".",
"pyda",
"ta",
".",
"org",
"/",
"numb",
"a",
"-",
"doc",
"/",
"0.11",
"/",
"arrays",
".",
"html_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"numpy_",
"as_",
"np_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"mu_",
"=_",
"0.1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Lx",
"_",
",_",
"Ly",
"_",
"=_",
"101_",
",_",
"101_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"N_",
"=_",
"1000_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"para",
"ke",
"et_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"para",
"ke",
"et_",
"._",
"c\\u",
"backend_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"para",
"ke",
"et",
".",
"c\\u",
"back",
"end",
".",
"config",
".",
"print",
"\\u",
"module",
"\\u",
"source",
" ",
"=",
" ",
"True_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"from_",
"compare",
"\\u",
"perf_",
"import_",
"compare",
"\\u",
"perf_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"compare",
"\\u",
"perf_",
"(_",
"diffuse",
"\\u",
"loops_",
",_",
"[_",
"N_",
"]_",
",_",
"numba_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"compare",
"\\u",
"perf_",
"(_",
"diffuse",
"\\u",
"array",
"\\u",
"expressions_",
",_",
"[_",
"N_",
"]_",
",_",
"numba_",
"=_",
"True_",
")_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"diffuse",
"\\u",
"loops_",
"(_",
"iter",
"\\u",
"num_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"u_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"(_",
"Lx",
"_",
",_",
"Ly",
"_",
")_",
",_",
"dtype_",
"=_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"temp",
"\\u",
"u_",
"=_",
"np_",
"._",
"zero",
"s",
"\\u",
"like_",
"(_",
"u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"temp",
"\\u",
"u_",
"[_",
"Lx",
"_",
"/_",
"2_",
",_",
"Ly",
"_",
"/_",
"2_",
"]_",
"=_",
"1000.0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"n_",
"in_",
"range_",
"(_",
"iter",
"\\u",
"num_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"i_",
"in_",
"range_",
"(_",
"1_",
",_",
"Lx",
"_",
"-_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"j_",
"in_",
"range_",
"(_",
"1_",
",_",
"Ly",
"_",
"-_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"u_",
"[_",
"i_",
",_",
"j_",
"]_",
"=_",
"mu_",
"*_",
"(_",
"temp",
"\\u",
"u_",
"[_",
"i_",
"+_",
"1_",
",_",
"j_",
"]_",
"+_",
"temp",
"\\u",
"u_",
"[_",
"i_",
"-_",
"1_",
",_",
"j_",
"]_",
"+_",
"\\u\\u\\uNL\\u\\u\\u_",
"temp",
"\\u",
"u_",
"[_",
"i_",
",_",
"j_",
"+_",
"1_",
"]_",
"+_",
"temp",
"\\u",
"u_",
"[_",
"i_",
",_",
"j_",
"-_",
"1_",
"]_",
"-_",
"\\u\\u\\uNL\\u\\u\\u_",
"4_",
"*_",
"temp",
"\\u",
"u_",
"[_",
"i_",
",_",
"j_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"temp_",
"=_",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"u_",
"=_",
"temp",
"\\u",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"temp",
"\\u",
"u_",
"=_",
"temp_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"diffuse",
"\\u",
"array",
"\\u",
"expressions_",
"(_",
"iter",
"\\u",
"num_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"u_",
"=_",
"np_",
"._",
"zeros_",
"(_",
"(_",
"Lx",
"_",
",_",
"Ly",
"_",
")_",
",_",
"dtype_",
"=_",
"np_",
"._",
"float64_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"temp",
"\\u",
"u_",
"=_",
"np_",
"._",
"zero",
"s",
"\\u",
"like_",
"(_",
"u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"temp",
"\\u",
"u_",
"[_",
"Lx",
"_",
"/_",
"2_",
",_",
"Ly",
"_",
"/_",
"2_",
"]_",
"=_",
"1000.0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"iter",
"\\u",
"num_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"u_",
"[_",
"1_",
":_",
"-_",
"1_",
",_",
"1_",
":_",
"-_",
"1_",
"]_",
"=_",
"mu_",
"*_",
"(_",
"temp",
"\\u",
"u_",
"[_",
"2_",
":_",
",_",
"1_",
":_",
"-_",
"1_",
"]_",
"+_",
"temp",
"\\u",
"u_",
"[_",
":_",
"-_",
"2_",
",_",
"1_",
":_",
"-_",
"1_",
"]_",
"+_",
"\\u\\u\\uNL\\u\\u\\u_",
"temp",
"\\u",
"u_",
"[_",
"1_",
":_",
"-_",
"1_",
",_",
"2_",
":_",
"]_",
"+_",
"temp",
"\\u",
"u_",
"[_",
"1_",
":_",
"-_",
"1_",
",_",
":_",
"-_",
"2_",
"]_",
"-_",
"\\u\\u\\uNL\\u\\u\\u_",
"4_",
"*_",
"temp",
"\\u",
"u_",
"[_",
"1_",
":_",
"-_",
"1_",
",_",
"1_",
":_",
"-_",
"1_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"temp_",
"=_",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"u_",
"=_",
"temp",
"\\u",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"temp",
"\\u",
"u_",
"=_",
"temp_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | zmap/ztag/ztag/annotations/FtpGenericUpdate.py | [
{
"content": "import re\nfrom ztag.annotation import Annotation\nfrom ztag.annotation import OperatingSystem\nfrom ztag.annotation import Type\nfrom ztag.annotation import Manufacturer\nfrom ztag import protocols\nimport ztag.test\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class FtpGenericUpdate(Annotation):\n protocol = protocols.FTP\n subprotocol = protocols.FTP.BANNER\n port = None\n\n tests = {\n \"FtpGenericUpdate_1\": {\n \"tags\": [\"Update utility\"]\n }\n }\n\n\n \"\"\" Tests\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"220 Ftp firmware update utility\\r\\n\"\n \"\"\"",
"metadata": "root.FtpGenericUpdate",
"header": "['module', '___EOS___']",
"index": 9
},
{
"content": " def process(self, obj, meta):\n banner = obj[\"banner\"]\n\n if banner.startswith(\"220 Ftp firmware update utility\"):\n meta.tags.add(\"Update utility\")\n\n return meta",
"metadata": "root.FtpGenericUpdate.process",
"header": "['class', 'FtpGenericUpdate', '(', 'Annotation', ')', ':', '___EOS___']",
"index": 20
}
]
| [
{
"span": "import re",
"start_line": 0,
"start_column": 0,
"end_line": 0,
"end_column": 9
},
{
"span": "from ztag.annotation import OperatingSystem",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 43
},
{
"span": "from ztag.annotation import Type",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 32
},
{
"span": "from ztag.annotation import Manufacturer",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 40
},
{
"span": "import ztag.test",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 16
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"zt",
"ag_",
"._",
"annotation_",
"import_",
"Annotation_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"zt",
"ag_",
"._",
"annotation_",
"import_",
"Opera",
"ting",
"System_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"zt",
"ag_",
"._",
"annotation_",
"import_",
"Type_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"zt",
"ag_",
"._",
"annotation_",
"import_",
"Manufacturer",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"zt",
"ag_",
"import_",
"protocols_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"zt",
"ag_",
"._",
"test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Ft",
"p",
"Gene",
"ric",
"Update_",
"(_",
"Annotation_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"protocol_",
"=_",
"protocols_",
"._",
"FTP",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"subpro",
"toco",
"l_",
"=_",
"protocols_",
"._",
"FTP",
"_",
"._",
"BAN",
"NER",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"port_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"tests_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"Ft",
"p",
"Gene",
"ric",
"Update",
"\\u",
"1",
"\"_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"tags",
"\"_",
":_",
"[_",
"\"",
"Update",
" ",
"utility",
"\"_",
"]_",
"\\u\\u\\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_",
"\"\"\"",
" ",
"Test",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\\\\",
"r",
"\\\\",
"n",
"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"[SEP]_",
"class_",
"Ft",
"p",
"Gene",
"ric",
"Update_",
"(_",
"Annotation_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"process_",
"(_",
"self_",
",_",
"obj_",
",_",
"meta_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"banner_",
"=_",
"obj_",
"[_",
"\"",
"banner",
"\"_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"banner_",
"._",
"startswith_",
"(_",
"\"",
"220",
" ",
"Ft",
"p",
" ",
"firmware",
" ",
"update",
" ",
"utility",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"meta_",
"._",
"tags_",
"._",
"add_",
"(_",
"\"",
"Update",
" ",
"utility",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"meta_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
0,
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,
2,
0,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | networkdynamics/zenlib/src/zen/tests/gml_tokenizer.py | [
{
"content": "from zen import *\nimport unittest\nimport os\nimport os.path as path\nimport tempfile\n\n\n\t\n\n#\tdef test_read_undirected_test1(self):\n#\t\tfname = path.join(path.dirname(__file__),'test2.gml')\n#\t\tG = gml.read(fname)\n#\t\t\n#\t\tself.assertEqual(len(G),3)\n#\t\tself.assertEqual(G.size(),2)\n#\t\t\n#\t\tself.assertEqual(type(G),Graph)\n#\t\tself.assertTrue(G.has_edge('N1','N2'))\n#\t\tself.assertTrue(G.has_edge('N2','N3'))\n#\t\tself.assertFalse(G.has_edge('N1','N3'))\n#\t\tself.assertTrue(G.has_edge('N3','N2'))\n#\t\t\n#\t\tself.assertEqual(G.node_idx('N1'),1)\n#\t\tself.assertEqual(G.node_idx('N2'),2)\n#\t\tself.assertEqual(G.node_idx('N3'),3)\n#\t\t\n#\t\tself.assertEqual(G.node_data('N1')['sample1'],42)\n#\t\tself.assertEqual(G.node_data('N2')['sample2'],42.1)\n#\t\tself.assertEqual(G.node_data('N3')['sample3'],'HELLO WORLD')\n#\t\t\n#\t\tself.assertEqual(G.edge_data('N1','N2')['label'],'Edge from node 1 to node 2')\n#\t\t\n#\tdef test_list_variables(self):\n#\t\tfname = path.join(path.dirname(__file__),'test3.gml')\n#\t\tG = gml.read(fname)\n#\t\t\n#\t\tself.assertEqual(len(G),3)\n#\t\tself.assertEqual(G.size(),2)\n#\t\t\n#\t\tself.assertEqual(G.node_data('N1')['listVar'],[1,'a',3.2])\n#\t\t\n#\tdef test_weight_fxn(self):\n#\t\tfname = path.join(path.dirname(__file__),'test3.gml')\n#\t\tG = gml.read(fname,weight_fxn=lambda data:data['value'])\n#\t\t\n#\t\tself.assertEqual(len(G),3)\n#\t\tself.assertEqual(G.size(),2)\n#\t\t\n#\t\tself.assertEqual(G.weight('N1','N2'),2)\n#\t\tself.assertEqual(G.weight('N2','N3'),3)\n\t\t\nif __name__ == '__main__':\n\tunittest.main()\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class GMLTokenizerCase(unittest.TestCase):\n\t\t\n\ttok = gml_tokenizer.GMLTokenizer()\n\n\t\t\n\n\n\n\n\n\t\t\n\n\n\n",
"metadata": "root.GMLTokenizerCase",
"header": "['module', '___EOS___']",
"index": 6
},
{
"content": "\tdef test_basic_correct(self):\n\t\tgml_string = 'keyOne \"one\" keyTwo 2'\n\n\t\tgot_tokens = self.tok.tokenize(gml_string)\n\t\texpected_tokens = [('keyOne', 0, 0), ('\"one\"', 1, 0), ('keyTwo', 0, 0), ('2', 1, 0)]\n\n\t\tself.assertEqual(got_tokens, expected_tokens)",
"metadata": "root.GMLTokenizerCase.test_basic_correct",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 10
},
{
"content": "\tdef test_nested_list_correct(self):\n\t\tgml_string = '''\n\t\t\tkeyOne [\n\t\t\t\tsubKeyOne \"one\"\n\t\t\t\tsubKeyTwo [\n\t\t\t\t\tsubSubKey \"one\"\n\t\t\t\t\tsubSubKey 2\n\t\t\t\t]\n\t\t\t]\n\t\t\tkeyTwo \"two\"\n\t\t'''\n\n\t\tgot_tokens = self.tok.tokenize(gml_string)\n\t\texpected_tokens = [\n\t\t\t('keyOne', 0, 1), ('[', 2, 1), \n\t\t\t\t('subKeyOne', 0, 2), ('\"one\"', 1, 2), \n\t\t\t\t('subKeyTwo', 0, 3), ('[', 2, 3), \n\t\t\t\t\t('subSubKey', 0, 4), ('\"one\"', 1, 4), \n\t\t\t\t\t('subSubKey', 0, 5), ('2', 1, 5), \n\t\t\t\t(']', 3, 6), \n\t\t\t(']', 3, 7), \n\t\t\t('keyTwo', 0, 8), ('\"two\"', 1, 8)\n\t\t]\n\n\t\tself.assertEqual(got_tokens, expected_tokens)",
"metadata": "root.GMLTokenizerCase.test_nested_list_correct",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 19
},
{
"content": "\tdef test_correct_with_comments(self):\n\t\tgml_string = '''\n\t\t\t# comment\n\t\t\tkeyOne# comment\n\t\t\t\"#one\"# comment\n\t\t\tkeyTwo # comment\n\t\t\t2 # comment\n\t\t\t#comment\n\t\t'''\n\n\t\tgot_tokens = self.tok.tokenize(gml_string)\n\t\texpected_tokens = [\n\t\t\t('keyOne', 0, 2), ('\"#one\"', 1, 3), \n\t\t\t('keyTwo', 0, 4), ('2', 1, 5)\n\t\t]\n\n\t\tself.assertEqual(got_tokens, expected_tokens)",
"metadata": "root.GMLTokenizerCase.test_correct_with_comments",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 45
},
{
"content": "\tdef test_correct_empty_list(self):\n\t\tgml_string = '''\n\t\t\tkeyOne [\n\t\t\t]\n\t\t\tkeyTwo \"two\"\n\t\t'''\n\n\t\tgot_tokens = self.tok.tokenize(gml_string)\n\t\texpected_tokens = [\n\t\t\t('keyOne', 0, 1), ('[', 2, 1), \n\t\t\t(']', 3, 2), ('keyTwo', 0, 3), ('\"two\"', 1, 3)\n\t\t]\n\n\t\tself.assertEqual(got_tokens, expected_tokens)",
"metadata": "root.GMLTokenizerCase.test_correct_empty_list",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 63
},
{
"content": "\tdef test_incorrect_eof_in_string(self):\n\t\tgml_string = 'keyOne \"one'\n\t\tself.assertRaises(ZenException, self.tok.tokenize, gml_string)",
"metadata": "root.GMLTokenizerCase.test_incorrect_eof_in_string",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 79
},
{
"content": "\tdef test_incorrect_string_as_key(self):\n\t\tgml_string = 'keyOne \"one\" \"keyTwo\" 2'\n\t\tself.assertRaises(ZenException, self.tok.tokenize, gml_string)",
"metadata": "root.GMLTokenizerCase.test_incorrect_string_as_key",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 84
},
{
"content": "\tdef test_incorrect_eof_when_expecting_value(self):\n\t\tgml_string = 'keyOne \"one\" keyTwo'\n\t\tself.assertRaises(ZenException, self.tok.tokenize, gml_string)",
"metadata": "root.GMLTokenizerCase.test_incorrect_eof_when_expecting_value",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 88
},
{
"content": "\tdef test_incorrect_eolist_when_expecting_value(self):\n\t\tgml_string = '''\n\t\t\tkeyOne [\n\t\t\t\tsubKeyOne \"one\"\n\t\t\t\tsubKeyTwo \n\t\t\t]\n\t\t\tkeyTwo \"two\"\n\t\t'''\n\t\tself.assertRaises(ZenException, self.tok.tokenize, gml_string)",
"metadata": "root.GMLTokenizerCase.test_incorrect_eolist_when_expecting_value",
"header": "['class', 'GMLTokenizerCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 93
}
]
| [
{
"span": "import os",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 9
},
{
"span": "import os.path as path",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 22
},
{
"span": "import tempfile",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 15
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"from_",
"zen",
"_",
"import_",
"*_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"._",
"path_",
"as_",
"path_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"tempfile_",
"\\u\\u\\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_",
"#",
"\t",
"def",
" ",
"test\\u",
"read",
"\\u",
"undi",
"rect",
"ed",
"\\u",
"test",
"1",
"(",
"self",
"):",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"fname",
" ",
"=",
" ",
"path",
".",
"join",
"(",
"path",
".",
"dir",
"name",
"(\\u",
"\\u",
"file",
"\\u\\u)",
",'",
"test",
"2",
".",
"gm",
"l",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"G",
" ",
"=",
" ",
"gm",
"l",
".",
"read",
"(",
"fname",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"len",
"(",
"G",
"),",
"3",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"size",
"()",
",",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"type",
"(",
"G",
"),",
"Graph",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Tru",
"e",
"(",
"G",
".",
"has",
"\\u",
"edge",
"('",
"N1",
"','",
"N",
"2",
"'))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Tru",
"e",
"(",
"G",
".",
"has",
"\\u",
"edge",
"('",
"N",
"2",
"','",
"N3",
"'))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Fal",
"se",
"(",
"G",
".",
"has",
"\\u",
"edge",
"('",
"N1",
"','",
"N3",
"'))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Tru",
"e",
"(",
"G",
".",
"has",
"\\u",
"edge",
"('",
"N3",
"','",
"N",
"2",
"'))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"idx",
"('",
"N1",
"')",
",",
"1",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"idx",
"('",
"N",
"2",
"')",
",",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"idx",
"('",
"N3",
"')",
",",
"3",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"data",
"('",
"N1",
"')",
"['",
"sample",
"1",
"']",
",",
"4",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"data",
"('",
"N",
"2",
"')",
"['",
"sample",
"2",
"']",
",",
"42.",
"1",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"data",
"('",
"N3",
"')",
"['",
"sample",
"3",
"']",
",'",
"HELL",
"O",
" ",
"WORLD",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"edge",
"\\u",
"data",
"('",
"N1",
"','",
"N",
"2",
"')",
"['",
"label",
"']",
",'",
"Ed",
"ge",
" ",
"from",
" ",
"node",
" ",
"1",
" ",
"to",
" ",
"node",
" ",
"2",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"def",
" ",
"test\\u",
"list",
"\\u",
"variab",
"les",
"(",
"self",
"):",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"fname",
" ",
"=",
" ",
"path",
".",
"join",
"(",
"path",
".",
"dir",
"name",
"(\\u",
"\\u",
"file",
"\\u\\u)",
",'",
"test",
"3",
".",
"gm",
"l",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"G",
" ",
"=",
" ",
"gm",
"l",
".",
"read",
"(",
"fname",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"len",
"(",
"G",
"),",
"3",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"size",
"()",
",",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"node",
"\\u",
"data",
"('",
"N1",
"')",
"['",
"list",
"Var",
"']",
",",
"[",
"1",
",'",
"a",
"',",
"3.2",
"])",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"def",
" ",
"test\\u",
"weight",
"\\u",
"fx",
"n",
"(",
"self",
"):",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"fname",
" ",
"=",
" ",
"path",
".",
"join",
"(",
"path",
".",
"dir",
"name",
"(\\u",
"\\u",
"file",
"\\u\\u)",
",'",
"test",
"3",
".",
"gm",
"l",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"G",
" ",
"=",
" ",
"gm",
"l",
".",
"read",
"(",
"fname",
",",
"weight",
"\\u",
"fx",
"n",
"=",
"lambda",
" ",
"data",
":",
"data",
"['",
"value",
"'])",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"len",
"(",
"G",
"),",
"3",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"size",
"()",
",",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t\t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"weight",
"('",
"N1",
"','",
"N",
"2",
"')",
",",
"2",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"\t",
"\t",
"self",
".",
"assert",
"Equal",
"(",
"G",
".",
"weight",
"('",
"N",
"2",
"','",
"N3",
"')",
",",
"3",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\\u\\u",
"name\\u\\u_",
"==_",
"'\\u",
"\\u",
"main",
"\\u\\u'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"_",
"unittest_",
"._",
"main_",
"(_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"_",
"tok_",
"=_",
"gm",
"l\\u",
"tokenizer_",
"._",
"GM",
"LT",
"oken",
"izer_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"GM",
"LT",
"oken",
"ize",
"r",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"basic",
"\\u",
"correct_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'",
"key",
"One",
" ",
"\"",
"one",
"\"",
" ",
"key",
"Tw",
"o",
" ",
"2",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"got",
"\\u",
"tokens_",
"=_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
"(_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"tokens_",
"=_",
"[_",
"(_",
"'",
"key",
"One",
"'_",
",_",
"0_",
",_",
"0_",
")_",
",_",
"(_",
"'\"",
"one",
"\"'_",
",_",
"1_",
",_",
"0_",
")_",
",_",
"(_",
"'",
"key",
"Tw",
"o",
"'_",
",_",
"0_",
",_",
"0_",
")_",
",_",
"(_",
"'",
"2",
"'_",
",_",
"1_",
",_",
"0_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"got",
"\\u",
"tokens_",
",_",
"expected",
"\\u",
"tokens_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"nest",
"ed",
"\\u",
"list",
"\\u",
"correct_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'''",
"\\",
"10",
";",
"\t\t\t",
"key",
"One",
" ",
"[",
"\\",
"10",
";",
"\t\t\t",
"\t",
"sub",
"Key",
"One",
" ",
"\"",
"one",
"\"",
"\\",
"10",
";",
"\t\t\t",
"\t",
"sub",
"Key",
"Tw",
"o",
" ",
"[",
"\\",
"10",
";",
"\t\t\t",
"\t",
"\t",
"sub",
"Sub",
"Key",
" ",
"\"",
"one",
"\"",
"\\",
"10",
";",
"\t\t\t",
"\t",
"\t",
"sub",
"Sub",
"Key",
" ",
"2",
"\\",
"10",
";",
"\t\t\t",
"\t",
"]",
"\\",
"10",
";",
"\t\t\t",
"]",
"\\",
"10",
";",
"\t\t\t",
"key",
"Tw",
"o",
" ",
"\"",
"two",
"\"",
"\\",
"10",
";",
"\t",
"\t",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"got",
"\\u",
"tokens_",
"=_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
"(_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"tokens_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"key",
"One",
"'_",
",_",
"0_",
",_",
"1_",
")_",
",_",
"(_",
"'['_",
",_",
"2_",
",_",
"1_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"sub",
"Key",
"One",
"'_",
",_",
"0_",
",_",
"2_",
")_",
",_",
"(_",
"'\"",
"one",
"\"'_",
",_",
"1_",
",_",
"2_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"sub",
"Key",
"Tw",
"o",
"'_",
",_",
"0_",
",_",
"3_",
")_",
",_",
"(_",
"'['_",
",_",
"2_",
",_",
"3_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"sub",
"Sub",
"Key",
"'_",
",_",
"0_",
",_",
"4_",
")_",
",_",
"(_",
"'\"",
"one",
"\"'_",
",_",
"1_",
",_",
"4_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"sub",
"Sub",
"Key",
"'_",
",_",
"0_",
",_",
"5_",
")_",
",_",
"(_",
"'",
"2",
"'_",
",_",
"1_",
",_",
"5_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"']'_",
",_",
"3_",
",_",
"6_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"']'_",
",_",
"3_",
",_",
"7_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"key",
"Tw",
"o",
"'_",
",_",
"0_",
",_",
"8_",
")_",
",_",
"(_",
"'\"",
"two",
"\"'_",
",_",
"1_",
",_",
"8_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"got",
"\\u",
"tokens_",
",_",
"expected",
"\\u",
"tokens_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"correct",
"\\u",
"with",
"\\u",
"comments_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'''",
"\\",
"10",
";",
"\t\t\t",
"#",
" ",
"comment",
"\\",
"10",
";",
"\t\t\t",
"key",
"One",
"#",
" ",
"comment",
"\\",
"10",
";",
"\t\t\t",
"\"#",
"one",
"\"#",
" ",
"comment",
"\\",
"10",
";",
"\t\t\t",
"key",
"Tw",
"o",
" ",
"#",
" ",
"comment",
"\\",
"10",
";",
"\t\t\t",
"2",
" ",
"#",
" ",
"comment",
"\\",
"10",
";",
"\t\t\t",
"#",
"comment",
"\\",
"10",
";",
"\t",
"\t",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"got",
"\\u",
"tokens_",
"=_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
"(_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"tokens_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"key",
"One",
"'_",
",_",
"0_",
",_",
"2_",
")_",
",_",
"(_",
"'\"",
"#",
"one",
"\"'_",
",_",
"1_",
",_",
"3_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"key",
"Tw",
"o",
"'_",
",_",
"0_",
",_",
"4_",
")_",
",_",
"(_",
"'",
"2",
"'_",
",_",
"1_",
",_",
"5_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"got",
"\\u",
"tokens_",
",_",
"expected",
"\\u",
"tokens_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"correct",
"\\u",
"empty",
"\\u",
"list_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'''",
"\\",
"10",
";",
"\t\t\t",
"key",
"One",
" ",
"[",
"\\",
"10",
";",
"\t\t\t",
"]",
"\\",
"10",
";",
"\t\t\t",
"key",
"Tw",
"o",
" ",
"\"",
"two",
"\"",
"\\",
"10",
";",
"\t",
"\t",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"got",
"\\u",
"tokens_",
"=_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
"(_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"tokens_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"'",
"key",
"One",
"'_",
",_",
"0_",
",_",
"1_",
")_",
",_",
"(_",
"'['_",
",_",
"2_",
",_",
"1_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"']'_",
",_",
"3_",
",_",
"2_",
")_",
",_",
"(_",
"'",
"key",
"Tw",
"o",
"'_",
",_",
"0_",
",_",
"3_",
")_",
",_",
"(_",
"'\"",
"two",
"\"'_",
",_",
"1_",
",_",
"3_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"got",
"\\u",
"tokens_",
",_",
"expected",
"\\u",
"tokens_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"incorrect",
"\\u",
"eof",
"\\u",
"in",
"\\u",
"string_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'",
"key",
"One",
" ",
"\"",
"one",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Raises_",
"(_",
"Ze",
"n",
"Exception_",
",_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
",_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"incorrect",
"\\u",
"string",
"\\u",
"as",
"\\u",
"key_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'",
"key",
"One",
" ",
"\"",
"one",
"\"",
" ",
"\"",
"key",
"Tw",
"o",
"\"",
" ",
"2",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Raises_",
"(_",
"Ze",
"n",
"Exception_",
",_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
",_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"incorrect",
"\\u",
"eof",
"\\u",
"whe",
"n",
"\\u",
"expect",
"ing",
"\\u",
"value_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'",
"key",
"One",
" ",
"\"",
"one",
"\"",
" ",
"key",
"Tw",
"o",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Raises_",
"(_",
"Ze",
"n",
"Exception_",
",_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
",_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"GM",
"LT",
"oken",
"ize",
"r",
"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",
"incorrect",
"\\u",
"eol",
"ist",
"\\u",
"whe",
"n",
"\\u",
"expect",
"ing",
"\\u",
"value_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u\t",
"\t_",
"gm",
"l\\u",
"string_",
"=_",
"'''",
"\\",
"10",
";",
"\t\t\t",
"key",
"One",
" ",
"[",
"\\",
"10",
";",
"\t\t\t",
"\t",
"sub",
"Key",
"One",
" ",
"\"",
"one",
"\"",
"\\",
"10",
";",
"\t\t\t",
"\t",
"sub",
"Key",
"Tw",
"o",
" ",
"\\",
"10",
";",
"\t\t\t",
"]",
"\\",
"10",
";",
"\t\t\t",
"key",
"Tw",
"o",
" ",
"\"",
"two",
"\"",
"\\",
"10",
";",
"\t",
"\t",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Raises_",
"(_",
"Ze",
"n",
"Exception_",
",_",
"self_",
"._",
"tok_",
"._",
"tokenize_",
",_",
"gm",
"l\\u",
"string_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
0,
1,
1,
1,
1,
1,
2,
0,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Testing equality to None | benadida/helios-server/helios/views.py | [
{
"content": "@election_view()\ndef one_election_cast_confirm(request, election):\n user = get_user(request) \n\n # if no encrypted vote, the user is reloading this page or otherwise getting here in a bad way\n if not request.session.has_key('encrypted_vote'):\n return HttpResponseRedirect(settings.URL_HOST)\n\n # election not frozen or started\n if not election.voting_has_started():\n return render_template(request, 'election_not_started', {'election': election})\n\n voter = get_voter(request, user, election)\n\n # auto-register this person if the election is openreg\n if user and not voter and election.openreg:\n voter = _register_voter(election, user)\n \n # tallied election, no vote casting\n if election.encrypted_tally or election.result:\n return render_template(request, 'election_tallied', {'election': election})\n \n encrypted_vote = request.session['encrypted_vote']\n vote_fingerprint = cryptoutils.hash_b64(encrypted_vote)\n\n # if this user is a voter, prepare some stuff\n if voter:\n vote = datatypes.LDObject.fromDict(utils.from_json(encrypted_vote), type_hint='legacy/EncryptedVote').wrapped_obj\n\n # prepare the vote to cast\n cast_vote_params = {\n 'vote' : vote,\n 'voter' : voter,\n 'vote_hash': vote_fingerprint,\n 'cast_at': datetime.datetime.utcnow()\n }\n\n cast_vote = CastVote(**cast_vote_params)\n else:\n cast_vote = None\n \n if request.method == \"GET\":\n if voter:\n past_votes = CastVote.get_by_voter(voter)\n if len(past_votes) == 0:\n past_votes = None\n else:\n past_votes = None\n\n if cast_vote:\n # check for issues\n issues = cast_vote.issues(election)\n else:\n issues = None\n\n bad_voter_login = (request.GET.get('bad_voter_login', \"0\") == \"1\")\n\n # status update this vote\n if voter and voter.user.can_update_status():\n status_update_label = voter.user.update_status_template() % \"your smart ballot tracker\"\n status_update_message = \"I voted in %s - my smart tracker is %s.. #heliosvoting\" % (get_election_url(election),cast_vote.vote_hash[:10])\n else:\n status_update_label = None\n status_update_message = None\n\n # do we need to constrain the auth_systems?\n if election.eligibility:\n auth_systems = [e['auth_system'] for e in election.eligibility]\n else:\n auth_systems = None\n\n password_only = False\n\n if auth_systems == None or 'password' in auth_systems:\n show_password = True\n password_login_form = forms.VoterPasswordForm()\n\n if auth_systems == ['password']:\n password_only = True\n else:\n show_password = False\n password_login_form = None\n\n return_url = reverse(one_election_cast_confirm, args=[election.uuid])\n login_box = auth_views.login_box_raw(request, return_url=return_url, auth_systems = auth_systems)\n\n return render_template(request, 'election_cast_confirm', {\n 'login_box': login_box, 'election' : election, 'vote_fingerprint': vote_fingerprint,\n 'past_votes': past_votes, 'issues': issues, 'voter' : voter,\n 'return_url': return_url,\n 'status_update_label': status_update_label, 'status_update_message': status_update_message,\n 'show_password': show_password, 'password_only': password_only, 'password_login_form': password_login_form,\n 'bad_voter_login': bad_voter_login})\n \n if request.method == \"POST\":\n check_csrf(request)\n \n # voting has not started or has ended\n if (not election.voting_has_started()) or election.voting_has_stopped():\n return HttpResponseRedirect(settings.URL_HOST)\n \n # if user is not logged in\n # bring back to the confirmation page to let him know\n if not voter:\n return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_cast_confirm, args=[election.uuid]))\n \n # don't store the vote in the voter's data structure until verification\n cast_vote.save()\n\n # status update?\n if request.POST.get('status_update', False):\n status_update_message = request.POST.get('status_update_message')\n else:\n status_update_message = None\n\n # launch the verification task\n tasks.cast_vote_verify_and_store.delay(\n cast_vote_id = cast_vote.id,\n status_update_message = status_update_message)\n \n # remove the vote from the store\n del request.session['encrypted_vote']\n \n return HttpResponseRedirect(\"%s%s\" % (settings.URL_HOST, reverse(one_election_cast_done, args=[election.uuid])))",
"metadata": "root.one_election_cast_confirm",
"header": "['module', '___EOS___']",
"index": 589
},
{
"content": "@trustee_check\ndef trustee_decrypt_and_prove(request, election, trustee):\n if not _check_election_tally_type(election) or election.encrypted_tally == None:\n return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_view,args=[election.uuid]))\n \n return render_template(request, 'trustee_decrypt_and_prove', {'election': election, 'trustee': trustee})",
"metadata": "root.trustee_decrypt_and_prove",
"header": "['module', '___EOS___']",
"index": 995
},
{
"content": "@election_view(frozen=True)\ndef trustee_upload_decryption(request, election, trustee_uuid):\n if not _check_election_tally_type(election) or election.encrypted_tally == None:\n return FAILURE\n\n trustee = Trustee.get_by_election_and_uuid(election, trustee_uuid)\n\n factors_and_proofs = utils.from_json(request.POST['factors_and_proofs'])\n\n # verify the decryption factors\n trustee.decryption_factors = [[datatypes.LDObject.fromDict(factor, type_hint='core/BigInteger').wrapped_obj for factor in one_q_factors] for one_q_factors in factors_and_proofs['decryption_factors']]\n\n # each proof needs to be deserialized\n trustee.decryption_proofs = [[datatypes.LDObject.fromDict(proof, type_hint='legacy/EGZKProof').wrapped_obj for proof in one_q_proofs] for one_q_proofs in factors_and_proofs['decryption_proofs']]\n\n if trustee.verify_decryption_proofs():\n trustee.save()\n \n try:\n # send a note to admin\n election.admin.send_message(\"%s - trustee partial decryption\" % election.name, \"trustee %s (%s) did their partial decryption.\" % (trustee.name, trustee.email))\n except:\n # ah well\n pass\n \n return SUCCESS\n else:\n return FAILURE",
"metadata": "root.trustee_upload_decryption",
"header": "['module', '___EOS___']",
"index": 1002
},
{
"content": "@election_admin(frozen=True)\ndef one_election_set_result_and_proof(request, election):\n if election.tally_type != \"homomorphic\" or election.encrypted_tally == None:\n return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_view,args=[election.election_id]))\n\n # FIXME: check csrf\n \n election.result = utils.from_json(request.POST['result'])\n election.result_proof = utils.from_json(request.POST['result_proof'])\n election.save()\n\n if get_user(request):\n return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(one_election_view, args=[election.uuid]))\n else:\n return SUCCESS",
"metadata": "root.one_election_set_result_and_proof",
"header": "['module', '___EOS___']",
"index": 1068
}
]
| [
{
"span": "auth_systems == None ",
"start_line": 662,
"start_column": 7,
"end_line": 662,
"end_column": 27
},
{
"span": "election.encrypted_tally == None:",
"start_line": 997,
"start_column": 49,
"end_line": 997,
"end_column": 81
},
{
"span": "election.encrypted_tally == None:",
"start_line": 1004,
"start_column": 49,
"end_line": 1004,
"end_column": 81
},
{
"span": "election.encrypted_tally == None:",
"start_line": 1070,
"start_column": 45,
"end_line": 1070,
"end_column": 77
}
]
| []
| 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_",
"@_",
"election",
"\\u",
"view_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"one",
"\\u",
"election",
"\\u",
"cast",
"\\u",
"confirm_",
"(_",
"request_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"user_",
"=_",
"get",
"\\u",
"user_",
"(_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"if",
" ",
"no",
" ",
"encrypt",
"ed",
" ",
"vote",
",",
" ",
"the",
" ",
"user",
" ",
"is",
" ",
"relo",
"ading",
" ",
"this",
" ",
"page",
" ",
"or",
" ",
"other",
"wis",
"e",
" ",
"getti",
"ng",
" ",
"here",
" ",
"in",
" ",
"a",
" ",
"bad",
" ",
"way_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"request_",
"._",
"session_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"encrypt",
"ed",
"\\u",
"vote",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"settings_",
"._",
"URL",
"\\u",
"HOST_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"election",
" ",
"not",
" ",
"frozen",
" ",
"or",
" ",
"started_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"election_",
"._",
"voting",
"\\u",
"has",
"\\u",
"started_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"render",
"\\u",
"template_",
"(_",
"request_",
",_",
"'",
"election",
"\\u",
"not",
"\\u",
"start",
"ed",
"'_",
",_",
"{_",
"'",
"election",
"'_",
":_",
"election_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"voter",
"_",
"=_",
"get",
"\\u",
"voter",
"_",
"(_",
"request_",
",_",
"user_",
",_",
"election_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"auto",
"-",
"register",
" ",
"this",
" ",
"person",
" ",
"if",
" ",
"the",
" ",
"election",
" ",
"is",
" ",
"open",
"reg_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"user_",
"and_",
"not_",
"voter",
"_",
"and_",
"election_",
"._",
"open",
"reg_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"voter",
"_",
"=_",
"\\u",
"register",
"\\u",
"voter",
"_",
"(_",
"election_",
",_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"tall",
"ied",
" ",
"election",
",",
" ",
"no",
" ",
"vote",
" ",
"casting",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"election_",
"._",
"encrypt",
"ed",
"\\u",
"tally",
"_",
"or_",
"election_",
"._",
"result_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"render",
"\\u",
"template_",
"(_",
"request_",
",_",
"'",
"election",
"\\u",
"tall",
"ied",
"'_",
",_",
"{_",
"'",
"election",
"'_",
":_",
"election_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"encrypt",
"ed",
"\\u",
"vote_",
"=_",
"request_",
"._",
"session_",
"[_",
"'",
"encrypt",
"ed",
"\\u",
"vote",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"vote",
"\\u",
"fingerprint_",
"=_",
"crypto",
"utils_",
"._",
"hash",
"\\u",
"b64",
"_",
"(_",
"encrypt",
"ed",
"\\u",
"vote_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"if",
" ",
"this",
" ",
"user",
" ",
"is",
" ",
"a",
" ",
"voter",
",",
" ",
"prepar",
"e",
" ",
"some",
" ",
"stuff_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"voter",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"vote_",
"=_",
"datatypes_",
"._",
"LD",
"Object_",
"._",
"from",
"Dict_",
"(_",
"utils_",
"._",
"from",
"\\u",
"json_",
"(_",
"encrypt",
"ed",
"\\u",
"vote_",
")_",
",_",
"type",
"\\u",
"hint_",
"=_",
"'",
"lega",
"cy",
"/",
"Encrypt",
"ed",
"Vote",
"'_",
")_",
"._",
"wrapp",
"ed",
"\\u",
"obj_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"prepar",
"e",
" ",
"the",
" ",
"vote",
" ",
"to",
" ",
"cast_",
"\\u\\u\\uNL\\u\\u\\u_",
"cast",
"\\u",
"vote",
"\\u",
"params_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"'_",
":_",
"vote_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"'_",
":_",
"voter",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"\\u",
"hash",
"'_",
":_",
"vote",
"\\u",
"fingerprint_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"cast",
"\\u",
"at",
"'_",
":_",
"datetime_",
"._",
"datetime_",
"._",
"utcnow_",
"(_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"cast",
"\\u",
"vote_",
"=_",
"Cast",
"Vote",
"_",
"(_",
"**_",
"cast",
"\\u",
"vote",
"\\u",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cast",
"\\u",
"vote_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"request_",
"._",
"method_",
"==_",
"\"",
"GET",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"voter",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"past",
"\\u",
"votes_",
"=_",
"Cast",
"Vote",
"_",
"._",
"get",
"\\u",
"by",
"\\u",
"voter",
"_",
"(_",
"voter",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"len_",
"(_",
"past",
"\\u",
"votes_",
")_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"past",
"\\u",
"votes_",
"=_",
"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 ",
" _",
"past",
"\\u",
"votes_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"cast",
"\\u",
"vote_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"check",
" ",
"for",
" ",
"issues_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"issues_",
"=_",
"cast",
"\\u",
"vote_",
"._",
"issues_",
"(_",
"election_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"issues_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"bad",
"\\u",
"voter",
"\\u",
"login_",
"=_",
"(_",
"request_",
"._",
"GET_",
"._",
"get_",
"(_",
"'",
"bad",
"\\u",
"voter",
"\\u",
"login",
"'_",
",_",
"\"",
"0",
"\"_",
")_",
"==_",
"\"",
"1",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"status",
" ",
"update",
" ",
"this",
" ",
"vote_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"voter",
"_",
"and_",
"voter",
"_",
"._",
"user_",
"._",
"can",
"\\u",
"update",
"\\u",
"status_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"status",
"\\u",
"update",
"\\u",
"label_",
"=_",
"voter",
"_",
"._",
"user_",
"._",
"update",
"\\u",
"status",
"\\u",
"template_",
"(_",
")_",
"%_",
"\"",
"your",
" ",
"smart",
" ",
"ballot",
" ",
"track",
"er",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"status",
"\\u",
"update",
"\\u",
"message_",
"=_",
"\"",
"I",
" ",
"vote",
"d",
" ",
"in",
" ",
"%",
"s",
" ",
"-",
" ",
"my",
" ",
"smart",
" ",
"track",
"er",
" ",
"is",
" ",
"%",
"s",
"..",
" ",
"#",
"heli",
"os",
"voting",
"\"_",
"%_",
"(_",
"get",
"\\u",
"election",
"\\u",
"url_",
"(_",
"election_",
")_",
",_",
"cast",
"\\u",
"vote_",
"._",
"vote",
"\\u",
"hash_",
"[_",
":_",
"10_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"status",
"\\u",
"update",
"\\u",
"label_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"status",
"\\u",
"update",
"\\u",
"message_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"do",
" ",
"we",
" ",
"need",
" ",
"to",
" ",
"constrain",
" ",
"the",
" ",
"auth",
"\\u",
"system",
"s",
"?",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"election_",
"._",
"eli",
"gib",
"ility_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"auth",
"\\u",
"systems_",
"=_",
"[_",
"e_",
"[_",
"'",
"auth",
"\\u",
"system",
"'_",
"]_",
"for_",
"e_",
"in_",
"election_",
"._",
"eli",
"gib",
"ility_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"auth",
"\\u",
"systems_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"password",
"\\u",
"only_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"auth",
"\\u",
"systems_",
"==_",
"None_",
"or_",
"'",
"password",
"'_",
"in_",
"auth",
"\\u",
"systems_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"show",
"\\u",
"password_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"password",
"\\u",
"login",
"\\u",
"form_",
"=_",
"forms_",
"._",
"Vote",
"r",
"Passw",
"ord",
"Form_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"auth",
"\\u",
"systems_",
"==_",
"[_",
"'",
"password",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"password",
"\\u",
"only_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"show",
"\\u",
"password_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"password",
"\\u",
"login",
"\\u",
"form_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return",
"\\u",
"url_",
"=_",
"reverse_",
"(_",
"one",
"\\u",
"election",
"\\u",
"cast",
"\\u",
"confirm_",
",_",
"args_",
"=_",
"[_",
"election_",
"._",
"uuid_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"login",
"\\u",
"box_",
"=_",
"auth",
"\\u",
"views_",
"._",
"login",
"\\u",
"box",
"\\u",
"raw_",
"(_",
"request_",
",_",
"return",
"\\u",
"url_",
"=_",
"return",
"\\u",
"url_",
",_",
"auth",
"\\u",
"systems_",
"=_",
"auth",
"\\u",
"systems_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"render",
"\\u",
"template_",
"(_",
"request_",
",_",
"'",
"election",
"\\u",
"cast",
"\\u",
"confirm",
"'_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"login",
"\\u",
"box",
"'_",
":_",
"login",
"\\u",
"box_",
",_",
"'",
"election",
"'_",
":_",
"election_",
",_",
"'",
"vote",
"\\u",
"fingerprint",
"'_",
":_",
"vote",
"\\u",
"fingerprint_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"past",
"\\u",
"vote",
"s",
"'_",
":_",
"past",
"\\u",
"votes_",
",_",
"'",
"issue",
"s",
"'_",
":_",
"issues_",
",_",
"'",
"voter",
"'_",
":_",
"voter",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"return",
"\\u",
"url",
"'_",
":_",
"return",
"\\u",
"url_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"status",
"\\u",
"update",
"\\u",
"label",
"'_",
":_",
"status",
"\\u",
"update",
"\\u",
"label_",
",_",
"'",
"status",
"\\u",
"update",
"\\u",
"message",
"'_",
":_",
"status",
"\\u",
"update",
"\\u",
"message_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"show",
"\\u",
"password",
"'_",
":_",
"show",
"\\u",
"password_",
",_",
"'",
"password",
"\\u",
"only",
"'_",
":_",
"password",
"\\u",
"only_",
",_",
"'",
"password",
"\\u",
"login",
"\\u",
"form",
"'_",
":_",
"password",
"\\u",
"login",
"\\u",
"form_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"bad",
"\\u",
"voter",
"\\u",
"login",
"'_",
":_",
"bad",
"\\u",
"voter",
"\\u",
"login_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"request_",
"._",
"method_",
"==_",
"\"",
"POST",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"check",
"\\u",
"csrf_",
"(_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"voting",
" ",
"has",
" ",
"not",
" ",
"start",
"ed",
" ",
"or",
" ",
"has",
" ",
"ended_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"(_",
"not_",
"election_",
"._",
"voting",
"\\u",
"has",
"\\u",
"started_",
"(_",
")_",
")_",
"or_",
"election_",
"._",
"voting",
"\\u",
"has",
"\\u",
"stopped_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"settings_",
"._",
"URL",
"\\u",
"HOST_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"if",
" ",
"user",
" ",
"is",
" ",
"not",
" ",
"logged",
" ",
"in_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"bring",
" ",
"back",
" ",
"to",
" ",
"the",
" ",
"confirmation",
" ",
"page",
" ",
"to",
" ",
"let",
" ",
"him",
" ",
"know",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"voter",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"settings_",
"._",
"SECU",
"RE",
"\\u",
"URL",
"\\u",
"HOST_",
"+_",
"reverse_",
"(_",
"one",
"\\u",
"election",
"\\u",
"cast",
"\\u",
"confirm_",
",_",
"args_",
"=_",
"[_",
"election_",
"._",
"uuid_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"don",
"'",
"t",
" ",
"store",
" ",
"the",
" ",
"vote",
" ",
"in",
" ",
"the",
" ",
"voter",
"'",
"s",
" ",
"data",
" ",
"structure",
" ",
"unti",
"l",
" ",
"verification",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"cast",
"\\u",
"vote_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"status",
" ",
"update",
"?",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"request_",
"._",
"POST_",
"._",
"get_",
"(_",
"'",
"status",
"\\u",
"update",
"'_",
",_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"status",
"\\u",
"update",
"\\u",
"message_",
"=_",
"request_",
"._",
"POST_",
"._",
"get_",
"(_",
"'",
"status",
"\\u",
"update",
"\\u",
"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 ",
" _",
"status",
"\\u",
"update",
"\\u",
"message_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"launch",
" ",
"the",
" ",
"verification",
" ",
"task_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"tasks_",
"._",
"cast",
"\\u",
"vote",
"\\u",
"verify",
"\\u",
"and",
"\\u",
"store_",
"._",
"delay_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"cast",
"\\u",
"vote",
"\\u",
"id_",
"=_",
"cast",
"\\u",
"vote_",
"._",
"id_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"status",
"\\u",
"update",
"\\u",
"message_",
"=_",
"status",
"\\u",
"update",
"\\u",
"message_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"remove",
" ",
"the",
" ",
"vote",
" ",
"from",
" ",
"the",
" ",
"store_",
"\\u\\u\\uNL\\u\\u\\u_",
"del_",
"request_",
"._",
"session_",
"[_",
"'",
"encrypt",
"ed",
"\\u",
"vote",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"\"%",
"s",
"%",
"s",
"\"_",
"%_",
"(_",
"settings_",
"._",
"URL",
"\\u",
"HOST_",
",_",
"reverse_",
"(_",
"one",
"\\u",
"election",
"\\u",
"cast",
"\\u",
"done_",
",_",
"args_",
"=_",
"[_",
"election_",
"._",
"uuid_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"trust",
"ee",
"\\u",
"check_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"trust",
"ee",
"\\u",
"decrypt",
"\\u",
"and",
"\\u",
"prove",
"_",
"(_",
"request_",
",_",
"election_",
",_",
"trust",
"ee_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"\\u",
"check",
"\\u",
"election",
"\\u",
"tally",
"\\u",
"type_",
"(_",
"election_",
")_",
"or_",
"election_",
"._",
"encrypt",
"ed",
"\\u",
"tally",
"_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"settings_",
"._",
"SECU",
"RE",
"\\u",
"URL",
"\\u",
"HOST_",
"+_",
"reverse_",
"(_",
"one",
"\\u",
"election",
"\\u",
"view_",
",_",
"args_",
"=_",
"[_",
"election_",
"._",
"uuid_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"render",
"\\u",
"template_",
"(_",
"request_",
",_",
"'",
"trust",
"ee",
"\\u",
"decrypt",
"\\u",
"and",
"\\u",
"prove",
"'_",
",_",
"{_",
"'",
"election",
"'_",
":_",
"election_",
",_",
"'",
"trust",
"ee",
"'_",
":_",
"trust",
"ee_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"election",
"\\u",
"view_",
"(_",
"frozen_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"trust",
"ee",
"\\u",
"upload",
"\\u",
"decrypt",
"ion_",
"(_",
"request_",
",_",
"election_",
",_",
"trust",
"ee",
"\\u",
"uuid_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"\\u",
"check",
"\\u",
"election",
"\\u",
"tally",
"\\u",
"type_",
"(_",
"election_",
")_",
"or_",
"election_",
"._",
"encrypt",
"ed",
"\\u",
"tally",
"_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"FAILURE_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"trust",
"ee_",
"=_",
"Trust",
"ee_",
"._",
"get",
"\\u",
"by",
"\\u",
"election",
"\\u",
"and",
"\\u",
"uuid_",
"(_",
"election_",
",_",
"trust",
"ee",
"\\u",
"uuid_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"factor",
"s",
"\\u",
"and",
"\\u",
"proof",
"s_",
"=_",
"utils_",
"._",
"from",
"\\u",
"json_",
"(_",
"request_",
"._",
"POST_",
"[_",
"'",
"factor",
"s",
"\\u",
"and",
"\\u",
"proof",
"s",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"verify",
" ",
"the",
" ",
"decrypt",
"ion",
" ",
"factors_",
"\\u\\u\\uNL\\u\\u\\u_",
"trust",
"ee_",
"._",
"decrypt",
"ion",
"\\u",
"factors_",
"=_",
"[_",
"[_",
"datatypes_",
"._",
"LD",
"Object_",
"._",
"from",
"Dict_",
"(_",
"factor_",
",_",
"type",
"\\u",
"hint_",
"=_",
"'",
"core",
"/",
"Big",
"Integer",
"'_",
")_",
"._",
"wrapp",
"ed",
"\\u",
"obj_",
"for_",
"factor_",
"in_",
"one",
"\\u",
"q",
"\\u",
"factors_",
"]_",
"for_",
"one",
"\\u",
"q",
"\\u",
"factors_",
"in_",
"factor",
"s",
"\\u",
"and",
"\\u",
"proof",
"s_",
"[_",
"'",
"decrypt",
"ion",
"\\u",
"factor",
"s",
"'_",
"]_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"each",
" ",
"proof",
" ",
"need",
"s",
" ",
"to",
" ",
"be",
" ",
"deserialized_",
"\\u\\u\\uNL\\u\\u\\u_",
"trust",
"ee_",
"._",
"decrypt",
"ion",
"\\u",
"proof",
"s_",
"=_",
"[_",
"[_",
"datatypes_",
"._",
"LD",
"Object_",
"._",
"from",
"Dict_",
"(_",
"proof",
"_",
",_",
"type",
"\\u",
"hint_",
"=_",
"'",
"lega",
"cy",
"/",
"EG",
"ZK",
"Pro",
"of",
"'_",
")_",
"._",
"wrapp",
"ed",
"\\u",
"obj_",
"for_",
"proof",
"_",
"in_",
"one",
"\\u",
"q",
"\\u",
"proof",
"s_",
"]_",
"for_",
"one",
"\\u",
"q",
"\\u",
"proof",
"s_",
"in_",
"factor",
"s",
"\\u",
"and",
"\\u",
"proof",
"s_",
"[_",
"'",
"decrypt",
"ion",
"\\u",
"proof",
"s",
"'_",
"]_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"trust",
"ee_",
"._",
"verify",
"\\u",
"decrypt",
"ion",
"\\u",
"proof",
"s_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"trust",
"ee_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"send",
" ",
"a",
" ",
"note",
" ",
"to",
" ",
"admin_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"election_",
"._",
"admin_",
"._",
"send",
"\\u",
"message_",
"(_",
"\"%",
"s",
" ",
"-",
" ",
"trust",
"ee",
" ",
"partial",
" ",
"decrypt",
"ion",
"\"_",
"%_",
"election_",
"._",
"name_",
",_",
"\"",
"trust",
"ee",
" ",
"%",
"s",
" ",
"(%",
"s",
")",
" ",
"did",
" ",
"thei",
"r",
" ",
"partial",
" ",
"decrypt",
"ion",
".\"_",
"%_",
"(_",
"trust",
"ee_",
"._",
"name_",
",_",
"trust",
"ee_",
"._",
"email_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"ah",
" ",
"well_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"SUCCESS_",
"\\u\\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_",
"FAILURE_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"election",
"\\u",
"admin_",
"(_",
"frozen_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"one",
"\\u",
"election",
"\\u",
"set\\u",
"result",
"\\u",
"and",
"\\u",
"proof",
"_",
"(_",
"request_",
",_",
"election_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"election_",
"._",
"tally",
"\\u",
"type_",
"!=_",
"\"",
"homo",
"morphi",
"c",
"\"_",
"or_",
"election_",
"._",
"encrypt",
"ed",
"\\u",
"tally",
"_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"settings_",
"._",
"SECU",
"RE",
"\\u",
"URL",
"\\u",
"HOST_",
"+_",
"reverse_",
"(_",
"one",
"\\u",
"election",
"\\u",
"view_",
",_",
"args_",
"=_",
"[_",
"election_",
"._",
"election",
"\\u",
"id_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"FIX",
"ME",
":",
" ",
"check",
" ",
"csrf_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"election_",
"._",
"result_",
"=_",
"utils_",
"._",
"from",
"\\u",
"json_",
"(_",
"request_",
"._",
"POST_",
"[_",
"'",
"result",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"election_",
"._",
"result",
"\\u",
"proof",
"_",
"=_",
"utils_",
"._",
"from",
"\\u",
"json_",
"(_",
"request_",
"._",
"POST_",
"[_",
"'",
"result",
"\\u",
"proof",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"election_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"get",
"\\u",
"user_",
"(_",
"request_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Http",
"Respons",
"e",
"Redirect_",
"(_",
"settings_",
"._",
"SECU",
"RE",
"\\u",
"URL",
"\\u",
"HOST_",
"+_",
"reverse_",
"(_",
"one",
"\\u",
"election",
"\\u",
"view_",
",_",
"args_",
"=_",
"[_",
"election_",
"._",
"uuid_",
"]_",
")_",
")_",
"\\u\\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_",
"SUCCESS_",
"\\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,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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
]
|
Except block handles 'BaseException' | dcramer/sentry-old/tests/test_events.py | [
{
"content": " def test_exception_event_without_exc_info(self):\n try:\n raise ValueError('foo bar')\n except:\n pass\n\n # Exception pulls in sys.exc_info()\n # by default\n event_id = capture('Exception')\n\n event = Event.objects.get(event_id)\n\n self.assertEquals(event.type, 'sentry.events.Exception')\n self.assertEquals(event.time_spent, 0)\n\n data = event.data\n\n self.assertTrue('sentry.interfaces.Exception' in data)\n event_data = data['sentry.interfaces.Exception']\n self.assertTrue('value' in event_data)\n self.assertEquals(event_data['value'], 'foo bar')\n self.assertTrue('type' in event_data)\n self.assertEquals(event_data['type'], 'ValueError')\n \n self.assertTrue('sentry.interfaces.Stacktrace' in data)\n event_data = data['sentry.interfaces.Stacktrace']\n self.assertTrue('frames' in event_data)\n self.assertEquals(len(event_data['frames']), 1)\n frame = event_data['frames'][0]\n self.assertTrue('function' in frame)\n self.assertEquals(frame['function'], 'test_exception_event_without_exc_info')\n self.assertTrue('lineno' in frame)\n self.assertTrue(frame['lineno'] > 0)\n self.assertTrue('module' in frame)\n self.assertEquals(frame['module'], 'tests.test_events')\n self.assertTrue('id' in frame)\n self.assertTrue('filename' in frame)",
"metadata": "root.SentryTest.test_exception_event_without_exc_info",
"header": "['class', 'SentryTest', '(', 'BaseTest', ')', ':', '___NEWLINE___', '# Some quick ugly high level tests to get shit working fast', '___NL___', '___EOS___']",
"index": 221
},
{
"content": " def test_exception_event_with_exc_info(self):\n try:\n raise ValueError('foo bar')\n except:\n exc_info = sys.exc_info()\n\n # We raise a second event to ensure we actually reference\n # the first event\n try:\n raise SyntaxError('baz')\n except:\n pass\n\n # Exception pulls in sys.exc_info()\n # by default\n event_id = capture('Exception', exc_info=exc_info)\n\n event = Event.objects.get(event_id)\n\n self.assertEquals(event.type, 'sentry.events.Exception')\n self.assertEquals(event.time_spent, 0)\n\n data = event.data\n\n self.assertTrue('sentry.interfaces.Exception' in data)\n event_data = data['sentry.interfaces.Exception']\n self.assertTrue('value' in event_data)\n self.assertEquals(event_data['value'], 'foo bar')\n self.assertTrue('type' in event_data)\n self.assertEquals(event_data['type'], 'ValueError')\n\n self.assertTrue('sentry.interfaces.Stacktrace' in data)\n event_data = data['sentry.interfaces.Stacktrace']\n self.assertTrue('frames' in event_data)\n self.assertEquals(len(event_data['frames']), 1)\n frame = event_data['frames'][0]\n self.assertTrue('function' in frame)\n self.assertEquals(frame['function'], 'test_exception_event_with_exc_info')\n self.assertTrue('lineno' in frame)\n self.assertTrue(frame['lineno'] > 0)\n self.assertTrue('module' in frame)\n self.assertEquals(frame['module'], 'tests.test_events')\n self.assertTrue('id' in frame)\n self.assertTrue('filename' in frame)",
"metadata": "root.SentryTest.test_exception_event_with_exc_info",
"header": "['class', 'SentryTest', '(', 'BaseTest', ')', ':', '___NEWLINE___', '# Some quick ugly high level tests to get shit working fast', '___NL___', '___EOS___']",
"index": 259
},
{
"content": " def test_context_processors(self):\n try:\n username = 'random_user'\n password = 'secret42'\n raise ValueError('foo bar')\n except:\n exc_info = sys.exc_info()\n\n # We raise a second event to ensure we actually reference\n # the first event\n try:\n raise SyntaxError('baz')\n except:\n pass\n\n # Exception pulls in sys.exc_info()\n # by default\n event_id = capture('Exception')\n\n event = Event.objects.get(event_id)\n self.assertTrue('sentry.interfaces.Stacktrace' in event.data)\n event_data = event.data['sentry.interfaces.Stacktrace']\n frame = event_data['frames'][0]\n self.assertEquals(frame['vars']['password'], '****************')",
"metadata": "root.SentryTest.test_context_processors",
"header": "['class', 'SentryTest', '(', 'BaseTest', ')', ':', '___NEWLINE___', '# Some quick ugly high level tests to get shit working fast', '___NL___', '___EOS___']",
"index": 304
}
]
| [
{
"span": "except:",
"start_line": 224,
"start_column": 8,
"end_line": 224,
"end_column": 15
},
{
"span": "except:",
"start_line": 262,
"start_column": 8,
"end_line": 262,
"end_column": 15
},
{
"span": "except:",
"start_line": 269,
"start_column": 8,
"end_line": 269,
"end_column": 15
},
{
"span": "except:",
"start_line": 309,
"start_column": 8,
"end_line": 309,
"end_column": 15
},
{
"span": "except:",
"start_line": 316,
"start_column": 8,
"end_line": 316,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Sent",
"ry",
"Test_",
"(_",
"Base",
"Test_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Some",
" ",
"quick",
" ",
"ug",
"ly",
" ",
"high",
" ",
"level",
" ",
"tests",
" ",
"to",
" ",
"get",
" ",
"shi",
"t",
" ",
"working",
" ",
"fast_",
"\\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",
"exception",
"\\u",
"event",
"\\u",
"with",
"out",
"\\u",
"exc",
"\\u",
"info_",
"(_",
"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 ",
" _",
"raise_",
"Value",
"Error_",
"(_",
"'",
"foo",
" ",
"bar",
"'_",
")_",
"\\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_",
"#",
" ",
"Except",
"ion",
" ",
"pull",
"s",
" ",
"in",
" ",
"sys",
".",
"exc",
"\\u",
"info",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"by",
" ",
"default_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"event",
"\\u",
"id_",
"=_",
"capture_",
"(_",
"'",
"Except",
"ion",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"event_",
"=_",
"Event_",
"._",
"objects_",
"._",
"get_",
"(_",
"event",
"\\u",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event_",
"._",
"type_",
",_",
"'",
"sentry",
".",
"events",
".",
"Except",
"ion",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event_",
"._",
"time",
"\\u",
"spe",
"nt_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"=_",
"event_",
"._",
"data_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Except",
"ion",
"'_",
"in_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"event",
"\\u",
"data_",
"=_",
"data_",
"[_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Except",
"ion",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"value",
"'_",
"in_",
"event",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event",
"\\u",
"data_",
"[_",
"'",
"value",
"'_",
"]_",
",_",
"'",
"foo",
" ",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"type",
"'_",
"in_",
"event",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event",
"\\u",
"data_",
"[_",
"'",
"type",
"'_",
"]_",
",_",
"'",
"Value",
"Error",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Stack",
"trace",
"'_",
"in_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"event",
"\\u",
"data_",
"=_",
"data_",
"[_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Stack",
"trace",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"frames",
"'_",
"in_",
"event",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"len_",
"(_",
"event",
"\\u",
"data_",
"[_",
"'",
"frames",
"'_",
"]_",
")_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"frame_",
"=_",
"event",
"\\u",
"data_",
"[_",
"'",
"frames",
"'_",
"]_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"function",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"frame_",
"[_",
"'",
"function",
"'_",
"]_",
",_",
"'",
"test\\u",
"exception",
"\\u",
"event",
"\\u",
"with",
"out",
"\\u",
"exc",
"\\u",
"info",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"linen",
"o",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"frame_",
"[_",
"'",
"linen",
"o",
"'_",
"]_",
">_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"module",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"frame_",
"[_",
"'",
"module",
"'_",
"]_",
",_",
"'",
"tests",
".",
"test\\u",
"events",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"id",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"filename",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sent",
"ry",
"Test_",
"(_",
"Base",
"Test_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Some",
" ",
"quick",
" ",
"ug",
"ly",
" ",
"high",
" ",
"level",
" ",
"tests",
" ",
"to",
" ",
"get",
" ",
"shi",
"t",
" ",
"working",
" ",
"fast_",
"\\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",
"exception",
"\\u",
"event",
"\\u",
"with",
"\\u",
"exc",
"\\u",
"info_",
"(_",
"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 ",
" _",
"raise_",
"Value",
"Error_",
"(_",
"'",
"foo",
" ",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"exc",
"\\u",
"info_",
"=_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"We",
" ",
"raise",
" ",
"a",
" ",
"second",
" ",
"event",
" ",
"to",
" ",
"ensure",
" ",
"we",
" ",
"actual",
"ly",
" ",
"reference_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"first",
" ",
"event_",
"\\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 ",
" _",
"raise_",
"Syntax",
"Error_",
"(_",
"'",
"ba",
"z",
"'_",
")_",
"\\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_",
"#",
" ",
"Except",
"ion",
" ",
"pull",
"s",
" ",
"in",
" ",
"sys",
".",
"exc",
"\\u",
"info",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"by",
" ",
"default_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"event",
"\\u",
"id_",
"=_",
"capture_",
"(_",
"'",
"Except",
"ion",
"'_",
",_",
"exc",
"\\u",
"info_",
"=_",
"exc",
"\\u",
"info_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"event_",
"=_",
"Event_",
"._",
"objects_",
"._",
"get_",
"(_",
"event",
"\\u",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event_",
"._",
"type_",
",_",
"'",
"sentry",
".",
"events",
".",
"Except",
"ion",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event_",
"._",
"time",
"\\u",
"spe",
"nt_",
",_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"=_",
"event_",
"._",
"data_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Except",
"ion",
"'_",
"in_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"event",
"\\u",
"data_",
"=_",
"data_",
"[_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Except",
"ion",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"value",
"'_",
"in_",
"event",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event",
"\\u",
"data_",
"[_",
"'",
"value",
"'_",
"]_",
",_",
"'",
"foo",
" ",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"type",
"'_",
"in_",
"event",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"event",
"\\u",
"data_",
"[_",
"'",
"type",
"'_",
"]_",
",_",
"'",
"Value",
"Error",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Stack",
"trace",
"'_",
"in_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"event",
"\\u",
"data_",
"=_",
"data_",
"[_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Stack",
"trace",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"frames",
"'_",
"in_",
"event",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"len_",
"(_",
"event",
"\\u",
"data_",
"[_",
"'",
"frames",
"'_",
"]_",
")_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"frame_",
"=_",
"event",
"\\u",
"data_",
"[_",
"'",
"frames",
"'_",
"]_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"function",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"frame_",
"[_",
"'",
"function",
"'_",
"]_",
",_",
"'",
"test\\u",
"exception",
"\\u",
"event",
"\\u",
"with",
"\\u",
"exc",
"\\u",
"info",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"linen",
"o",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"frame_",
"[_",
"'",
"linen",
"o",
"'_",
"]_",
">_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"module",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"frame_",
"[_",
"'",
"module",
"'_",
"]_",
",_",
"'",
"tests",
".",
"test\\u",
"events",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"id",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"filename",
"'_",
"in_",
"frame_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Sent",
"ry",
"Test_",
"(_",
"Base",
"Test_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Some",
" ",
"quick",
" ",
"ug",
"ly",
" ",
"high",
" ",
"level",
" ",
"tests",
" ",
"to",
" ",
"get",
" ",
"shi",
"t",
" ",
"working",
" ",
"fast_",
"\\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",
"context",
"\\u",
"processors_",
"(_",
"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 ",
" _",
"username_",
"=_",
"'",
"random",
"\\u",
"user",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"password_",
"=_",
"'",
"secret",
"4",
"2",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Value",
"Error_",
"(_",
"'",
"foo",
" ",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"exc",
"\\u",
"info_",
"=_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"We",
" ",
"raise",
" ",
"a",
" ",
"second",
" ",
"event",
" ",
"to",
" ",
"ensure",
" ",
"we",
" ",
"actual",
"ly",
" ",
"reference_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"first",
" ",
"event_",
"\\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 ",
" _",
"raise_",
"Syntax",
"Error_",
"(_",
"'",
"ba",
"z",
"'_",
")_",
"\\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_",
"#",
" ",
"Except",
"ion",
" ",
"pull",
"s",
" ",
"in",
" ",
"sys",
".",
"exc",
"\\u",
"info",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"by",
" ",
"default_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"event",
"\\u",
"id_",
"=_",
"capture_",
"(_",
"'",
"Except",
"ion",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"event_",
"=_",
"Event_",
"._",
"objects_",
"._",
"get_",
"(_",
"event",
"\\u",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Stack",
"trace",
"'_",
"in_",
"event_",
"._",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"event",
"\\u",
"data_",
"=_",
"event_",
"._",
"data_",
"[_",
"'",
"sentry",
".",
"interface",
"s",
".",
"Stack",
"trace",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"frame_",
"=_",
"event",
"\\u",
"data_",
"[_",
"'",
"frames",
"'_",
"]_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"frame_",
"[_",
"'",
"vars",
"'_",
"]_",
"[_",
"'",
"password",
"'_",
"]_",
",_",
"'*******",
"********",
"*'_",
")_"
]
| [
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,
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,
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
]
|
Unused import | nii-cloud/dodai-compute/nova/test.py | [
{
"content": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\n# Copyright 2010 United States Government as represented by the\n# Administrator of the National Aeronautics and Space Administration.\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\n\"\"\"Base classes for our unit tests.\n\nAllows overriding of flags for use of fakes, and some black magic for\ninline callbacks.\n\n\"\"\"\n\nimport functools\nimport os\nimport shutil\nimport uuid\nimport unittest\n\nimport mox\nimport nose.plugins.skip\nimport nova.image.fake\nimport shutil\nimport stubout\nfrom eventlet import greenthread\n\nfrom nova import fakerabbit\nfrom nova import flags\nfrom nova import log\nfrom nova import rpc\nfrom nova import utils\nfrom nova import service\nfrom nova.virt import fake\n\n\nFLAGS = flags.FLAGS\nflags.DEFINE_string('sqlite_clean_db', 'clean.sqlite',\n 'File name of clean sqlite db')\nflags.DEFINE_bool('fake_tests', True,\n 'should we use everything for testing')\n\nLOG = log.getLogger('nova.tests')\n\n\n\n\n\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class skip_test(object):\n \"\"\"Decorator that skips a test.\"\"\"\n",
"metadata": "root.skip_test",
"header": "['module', '___EOS___']",
"index": 56
},
{
"content": " def __init__(self, msg):\n self.message = msg",
"metadata": "root.skip_test.__init__",
"header": "['class', 'skip_test', '(', 'object', ')', ':', '___EOS___']",
"index": 58
},
{
"content": " def __call__(self, func):\n @functools.wraps(func)\n def _skipper(*args, **kw):\n \"\"\"Wrapped skipper function.\"\"\"\n raise nose.SkipTest(self.message)\n return _skipper",
"metadata": "root.skip_test.__call__",
"header": "['class', 'skip_test', '(', 'object', ')', ':', '___EOS___']",
"index": 61
},
{
"content": "class skip_if(object):\n \"\"\"Decorator that skips a test if contition is true.\"\"\"\n",
"metadata": "root.skip_if",
"header": "['module', '___EOS___']",
"index": 69
},
{
"content": " def __init__(self, condition, msg):\n self.condition = condition\n self.message = msg",
"metadata": "root.skip_if.__init__",
"header": "['class', 'skip_if', '(', 'object', ')', ':', '___EOS___']",
"index": 71
},
{
"content": " def __call__(self, func):\n @functools.wraps(func)\n def _skipper(*args, **kw):\n \"\"\"Wrapped skipper function.\"\"\"\n if self.condition:\n raise nose.SkipTest(self.message)\n func(*args, **kw)\n return _skipper",
"metadata": "root.skip_if.__call__",
"header": "['class', 'skip_if', '(', 'object', ')', ':', '___EOS___']",
"index": 75
},
{
"content": "class skip_unless(object):\n \"\"\"Decorator that skips a test if condition is not true.\"\"\"\n",
"metadata": "root.skip_unless",
"header": "['module', '___EOS___']",
"index": 85
},
{
"content": " def __init__(self, condition, msg):\n self.condition = condition\n self.message = msg",
"metadata": "root.skip_unless.__init__",
"header": "['class', 'skip_unless', '(', 'object', ')', ':', '___EOS___']",
"index": 87
},
{
"content": " def __call__(self, func):\n @functools.wraps(func)\n def _skipper(*args, **kw):\n \"\"\"Wrapped skipper function.\"\"\"\n if not self.condition:\n raise nose.SkipTest(self.message)\n func(*args, **kw)\n return _skipper",
"metadata": "root.skip_unless.__call__",
"header": "['class', 'skip_unless', '(', 'object', ')', ':', '___EOS___']",
"index": 91
},
{
"content": "def skip_if_fake(func):\n \"\"\"Decorator that skips a test if running in fake mode.\"\"\"\n def _skipper(*args, **kw):\n \"\"\"Wrapped skipper function.\"\"\"\n if FLAGS.fake_tests:\n raise unittest.SkipTest('Test cannot be run in fake mode')\n else:\n return func(*args, **kw)\n return _skipper",
"metadata": "root.skip_if_fake",
"header": "['module', '___EOS___']",
"index": 101
},
{
"content": "class TestCase(unittest.TestCase):\n \"\"\"Test case base class for all unit tests.\"\"\"\n\n\n\n\n\n\n # Useful assertions\n\n\n\n",
"metadata": "root.TestCase",
"header": "['module', '___EOS___']",
"index": 112
},
{
"content": " def setUp(self):\n \"\"\"Run before each test method to initialize test environment.\"\"\"\n super(TestCase, self).setUp()\n # NOTE(vish): We need a better method for creating fixtures for tests\n # now that we have some required db setup for the system\n # to work properly.\n self.start = utils.utcnow()\n shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db),\n os.path.join(FLAGS.state_path, FLAGS.sqlite_db))\n\n # emulate some of the mox stuff, we can't use the metaclass\n # because it screws with our generators\n self.mox = mox.Mox()\n self.stubs = stubout.StubOutForTesting()\n self.flag_overrides = {}\n self.injected = []\n self._services = []\n self._original_flags = FLAGS.FlagValuesDict()",
"metadata": "root.TestCase.setUp",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 115
},
{
"content": " def tearDown(self):\n \"\"\"Runs after each test method to tear down test environment.\"\"\"\n try:\n self.mox.UnsetStubs()\n self.stubs.UnsetAll()\n self.stubs.SmartUnsetAll()\n self.mox.VerifyAll()\n super(TestCase, self).tearDown()\n finally:\n # Clean out fake_rabbit's queue if we used it\n if FLAGS.fake_rabbit:\n fakerabbit.reset_all()\n\n if FLAGS.connection_type == 'fake':\n if hasattr(fake.FakeConnection, '_instance'):\n del fake.FakeConnection._instance\n\n if FLAGS.image_service == 'nova.image.fake.FakeImageService':\n nova.image.fake.FakeImageService_reset()\n\n # Reset any overriden flags\n self.reset_flags()\n\n # Stop any timers\n for x in self.injected:\n try:\n x.stop()\n except AssertionError:\n pass\n\n # Kill any services\n for x in self._services:\n try:\n x.kill()\n except Exception:\n pass",
"metadata": "root.TestCase.tearDown",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 134
},
{
"content": " def flags(self, **kw):\n \"\"\"Override flag variables for a test.\"\"\"\n for k, v in kw.iteritems():\n # Store original flag value if it's not been overriden yet\n if k not in self.flag_overrides:\n self.flag_overrides[k] = getattr(FLAGS, k)\n setattr(FLAGS, k, v)",
"metadata": "root.TestCase.flags",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 171
},
{
"content": " def reset_flags(self):\n \"\"\"Resets all flag variables for the test.\n\n Runs after each test.\n\n \"\"\"\n FLAGS.Reset()\n for k, v in self._original_flags.iteritems():\n setattr(FLAGS, k, v)",
"metadata": "root.TestCase.reset_flags",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 179
},
{
"content": " def start_service(self, name, host=None, **kwargs):\n host = host and host or uuid.uuid4().hex\n kwargs.setdefault('host', host)\n kwargs.setdefault('binary', 'nova-%s' % name)\n svc = service.Service.create(**kwargs)\n svc.start()\n self._services.append(svc)\n return svc",
"metadata": "root.TestCase.start_service",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 189
},
{
"content": " def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):\n \"\"\"Assert two dicts are equivalent.\n\n This is a 'deep' match in the sense that it handles nested\n dictionaries appropriately.\n\n NOTE:\n\n If you don't care (or don't know) a given value, you can specify\n the string DONTCARE as the value. This will cause that dict-item\n to be skipped.\n\n \"\"\"\n def raise_assertion(msg):\n d1str = str(d1)\n d2str = str(d2)\n base_msg = ('Dictionaries do not match. %(msg)s d1: %(d1str)s '\n 'd2: %(d2str)s' % locals())\n raise AssertionError(base_msg)\n\n d1keys = set(d1.keys())\n d2keys = set(d2.keys())\n if d1keys != d2keys:\n d1only = d1keys - d2keys\n d2only = d2keys - d1keys\n raise_assertion('Keys in d1 and not d2: %(d1only)s. '\n 'Keys in d2 and not d1: %(d2only)s' % locals())\n\n for key in d1keys:\n d1value = d1[key]\n d2value = d2[key]\n try:\n error = abs(float(d1value) - float(d2value))\n within_tolerance = error <= tolerance\n except (ValueError, TypeError):\n # If both values aren't convertable to float, just ignore\n # ValueError if arg is a str, TypeError if it's something else\n # (like None)\n within_tolerance = False\n\n if hasattr(d1value, 'keys') and hasattr(d2value, 'keys'):\n self.assertDictMatch(d1value, d2value)\n elif 'DONTCARE' in (d1value, d2value):\n continue\n elif approx_equal and within_tolerance:\n continue\n elif d1value != d2value:\n raise_assertion(\"d1['%(key)s']=%(d1value)s != \"\n \"d2['%(key)s']=%(d2value)s\" % locals())",
"metadata": "root.TestCase.assertDictMatch",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 199
},
{
"content": " def assertDictListMatch(self, L1, L2, approx_equal=False, tolerance=0.001):\n \"\"\"Assert a list of dicts are equivalent.\"\"\"\n def raise_assertion(msg):\n L1str = str(L1)\n L2str = str(L2)\n base_msg = ('List of dictionaries do not match: %(msg)s '\n 'L1: %(L1str)s L2: %(L2str)s' % locals())\n raise AssertionError(base_msg)\n\n L1count = len(L1)\n L2count = len(L2)\n if L1count != L2count:\n raise_assertion('Length mismatch: len(L1)=%(L1count)d != '\n 'len(L2)=%(L2count)d' % locals())\n\n for d1, d2 in zip(L1, L2):\n self.assertDictMatch(d1, d2, approx_equal=approx_equal,\n tolerance=tolerance)",
"metadata": "root.TestCase.assertDictListMatch",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 249
},
{
"content": " def assertSubDictMatch(self, sub_dict, super_dict):\n \"\"\"Assert a sub_dict is subset of super_dict.\"\"\"\n self.assertTrue(set(sub_dict.keys()).issubset(set(super_dict.keys())))\n for k, sub_value in sub_dict.items():\n super_value = super_dict[k]\n if isinstance(sub_value, dict):\n self.assertSubDictMatch(sub_value, super_value)\n elif 'DONTCARE' in (sub_value, super_value):\n continue\n else:\n self.assertEqual(sub_value, super_value)",
"metadata": "root.TestCase.assertSubDictMatch",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 268
},
{
"content": " def assertIn(self, a, b, *args, **kwargs):\n \"\"\"Python < v2.7 compatibility. Assert 'a' in 'b'\"\"\"\n try:\n f = super(TestCase, self).assertIn\n except AttributeError:\n self.assertTrue(a in b, *args, **kwargs)\n else:\n f(a, b, *args, **kwargs)",
"metadata": "root.TestCase.assertIn",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 280
},
{
"content": " def assertNotIn(self, a, b, *args, **kwargs):\n \"\"\"Python < v2.7 compatibility. Assert 'a' NOT in 'b'\"\"\"\n try:\n f = super(TestCase, self).assertNotIn\n except AttributeError:\n self.assertFalse(a in b, *args, **kwargs)\n else:\n f(a, b, *args, **kwargs)",
"metadata": "root.TestCase.assertNotIn",
"header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 289
}
]
| [
{
"span": "from eventlet import greenthread",
"start_line": 36,
"start_column": 0,
"end_line": 36,
"end_column": 32
},
{
"span": "from nova import rpc",
"start_line": 41,
"start_column": 0,
"end_line": 41,
"end_column": 20
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"vim",
":",
" ",
"tabs",
"top",
"=",
"4",
" ",
"shift",
"widt",
"h",
"=",
"4",
" ",
"soft",
"tabs",
"top",
"=",
"4_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"2010",
" ",
"Unit",
"ed",
" ",
"State",
"s",
" ",
"Gov",
"ern",
"ment",
" ",
"as",
" ",
"represent",
"ed",
" ",
"by",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Administra",
"tor",
" ",
"of",
" ",
"the",
" ",
"Nat",
"ional",
" ",
"Aer",
"ona",
"uti",
"cs",
" ",
"and",
" ",
"Spac",
"e",
" ",
"Administrati",
"on",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"All",
" ",
"Rig",
"hts",
" ",
"Reserve",
"d",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"License",
"d",
" ",
"under",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"License",
",",
" ",
"Version",
" ",
"2.0",
" ",
"(",
"the",
" ",
"\"",
"License",
"\");",
" ",
"you",
" ",
"may",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"not",
" ",
"use",
" ",
"this",
" ",
"file",
" ",
"except",
" ",
"in",
" ",
"compli",
"anc",
"e",
" ",
"with",
" ",
"the",
" ",
"License",
".",
" ",
"You",
" ",
"may",
" ",
"obtain",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"a",
" ",
"copy",
" ",
"of",
" ",
"the",
" ",
"License",
" ",
"at_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
" ",
"http",
"://",
"www",
".",
"apa",
"che",
".",
"org",
"/",
"license",
"s",
"/",
"LICENSE",
"-",
"2.0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"Un",
"less",
" ",
"require",
"d",
" ",
"by",
" ",
"applica",
"ble",
" ",
"law",
" ",
"or",
" ",
"agree",
"d",
" ",
"to",
" ",
"in",
" ",
"writ",
"ing",
",",
" ",
"software",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"distributed",
" ",
"under",
" ",
"the",
" ",
"License",
" ",
"is",
" ",
"distributed",
" ",
"on",
" ",
"an",
" ",
"\"",
"AS",
" ",
"IS",
"\"",
" ",
"BAS",
"IS",
",",
" ",
"WITH",
"OUT_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"WAR",
"RAN",
"TIES",
" ",
"OR",
" ",
"CONDITION",
"S",
" ",
"OF",
" ",
"ANY",
" ",
"KIND",
",",
" ",
"eit",
"her",
" ",
"express",
" ",
"or",
" ",
"impli",
"ed",
".",
" ",
"See",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"License",
" ",
"for",
" ",
"the",
" ",
"specific",
" ",
"language",
" ",
"govern",
"ing",
" ",
"permissi",
"ons",
" ",
"and",
" ",
"limit",
"ations_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"under",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"Base",
" ",
"classe",
"s",
" ",
"for",
" ",
"our",
" ",
"unit",
" ",
"tests",
".",
"\\",
"10",
";",
"\\",
"10",
";",
"All",
"ow",
"s",
" ",
"overrid",
"ing",
" ",
"of",
" ",
"flags",
" ",
"for",
" ",
"use",
" ",
"of",
" ",
"fake",
"s",
",",
" ",
"and",
" ",
"some",
" ",
"black",
" ",
"magic",
" ",
"for",
"\\",
"10",
";",
"inline",
" ",
"callback",
"s",
".",
"\\",
"10",
";",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"functools_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"shutil_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"uuid_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"mox_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"nose_",
"._",
"plugins_",
"._",
"skip_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"nova_",
"._",
"image_",
"._",
"fake_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"shutil_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"stub",
"out_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"eventlet_",
"import_",
"green",
"thread_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"nova_",
"import_",
"faker",
"abb",
"it_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"nova_",
"import_",
"flags_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"nova_",
"import_",
"log_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"nova_",
"import_",
"rpc_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"nova_",
"import_",
"utils_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"nova_",
"import_",
"service_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"nova_",
"._",
"virt_",
"import_",
"fake_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"FLAGS_",
"=_",
"flags_",
"._",
"FLAGS_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"flags_",
"._",
"DEFINE",
"\\u",
"string_",
"(_",
"'",
"sql",
"ite",
"\\u",
"clean",
"\\u",
"db",
"'_",
",_",
"'",
"clean",
".",
"sql",
"ite",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"File",
" ",
"name",
" ",
"of",
" ",
"clean",
" ",
"sql",
"ite",
" ",
"db",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"flags_",
"._",
"DEFINE",
"\\u",
"bool_",
"(_",
"'",
"fake",
"\\u",
"tests",
"'_",
",_",
"True_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"shou",
"ld",
" ",
"we",
" ",
"use",
" ",
"every",
"thing",
" ",
"for",
" ",
"testi",
"ng",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"LOG_",
"=_",
"log_",
"._",
"get",
"Logger_",
"(_",
"'",
"nova",
".",
"tests",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"skip",
"\\u",
"test_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Decorat",
"or",
" ",
"tha",
"t",
" ",
"skips",
" ",
"a",
" ",
"test",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"skip",
"\\u",
"test_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"msg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"message_",
"=_",
"msg_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"skip",
"\\u",
"test_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"call\\u\\u_",
"(_",
"self_",
",_",
"func_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"@_",
"functools_",
"._",
"wraps_",
"(_",
"func_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u",
"skip",
"per_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Wrapp",
"ed",
" ",
"skip",
"per",
" ",
"function",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"nose_",
"._",
"Ski",
"p",
"Test_",
"(_",
"self_",
"._",
"message_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"\\u",
"skip",
"per_",
"\\u\\u\\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_",
"skip",
"\\u",
"if_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Decorat",
"or",
" ",
"tha",
"t",
" ",
"skips",
" ",
"a",
" ",
"test",
" ",
"if",
" ",
"conti",
"tion",
" ",
"is",
" ",
"true",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"skip",
"\\u",
"if_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"condition_",
",_",
"msg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"condition_",
"=_",
"condition_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"message_",
"=_",
"msg_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"skip",
"\\u",
"if_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"call\\u\\u_",
"(_",
"self_",
",_",
"func_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"@_",
"functools_",
"._",
"wraps_",
"(_",
"func_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u",
"skip",
"per_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Wrapp",
"ed",
" ",
"skip",
"per",
" ",
"function",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"condition_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"nose_",
"._",
"Ski",
"p",
"Test_",
"(_",
"self_",
"._",
"message_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"func_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"\\u",
"skip",
"per_",
"\\u\\u\\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_",
"skip",
"\\u",
"unl",
"ess_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Decorat",
"or",
" ",
"tha",
"t",
" ",
"skips",
" ",
"a",
" ",
"test",
" ",
"if",
" ",
"condition",
" ",
"is",
" ",
"not",
" ",
"true",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"skip",
"\\u",
"unl",
"ess_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"condition_",
",_",
"msg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"condition_",
"=_",
"condition_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"message_",
"=_",
"msg_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"skip",
"\\u",
"unl",
"ess_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"call\\u\\u_",
"(_",
"self_",
",_",
"func_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"@_",
"functools_",
"._",
"wraps_",
"(_",
"func_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u",
"skip",
"per_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Wrapp",
"ed",
" ",
"skip",
"per",
" ",
"function",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"self_",
"._",
"condition_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"nose_",
"._",
"Ski",
"p",
"Test_",
"(_",
"self_",
"._",
"message_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"func_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"\\u",
"skip",
"per_",
"\\u\\u\\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_",
"skip",
"\\u",
"if",
"\\u",
"fake_",
"(_",
"func_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Decorat",
"or",
" ",
"tha",
"t",
" ",
"skips",
" ",
"a",
" ",
"test",
" ",
"if",
" ",
"runn",
"ing",
" ",
"in",
" ",
"fake",
" ",
"mode",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u",
"skip",
"per_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Wrapp",
"ed",
" ",
"skip",
"per",
" ",
"function",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"FLAGS_",
"._",
"fake",
"\\u",
"tests_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"unittest_",
"._",
"Ski",
"p",
"Test_",
"(_",
"'",
"Test",
" ",
"cann",
"ot",
" ",
"be",
" ",
"run",
" ",
"in",
" ",
"fake",
" ",
"mode",
"'_",
")_",
"\\u\\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_",
"func_",
"(_",
"*_",
"args_",
",_",
"**_",
"kw_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"\\u",
"skip",
"per_",
"\\u\\u\\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",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Test",
" ",
"case",
" ",
"base",
" ",
"class",
" ",
"for",
" ",
"all",
" ",
"unit",
" ",
"tests",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Us",
"efu",
"l",
" ",
"assertions_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\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",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Run",
" ",
"bef",
"ore",
" ",
"each",
" ",
"test",
" ",
"method",
" ",
"to",
" ",
"initialize",
" ",
"test",
" ",
"environ",
"ment",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"super_",
"(_",
"Test",
"Case_",
",_",
"self_",
")_",
"._",
"set",
"Up_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"NOTE",
"(",
"vis",
"h",
"):",
" ",
"We",
" ",
"need",
" ",
"a",
" ",
"bett",
"er",
" ",
"method",
" ",
"for",
" ",
"creati",
"ng",
" ",
"fixture",
"s",
" ",
"for",
" ",
"tests_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
" ",
"now",
" ",
"tha",
"t",
" ",
"we",
" ",
"have",
" ",
"some",
" ",
"require",
"d",
" ",
"db",
" ",
"setup",
" ",
"for",
" ",
"the",
" ",
"system_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
" ",
"to",
" ",
"work",
" ",
"proper",
"ly",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"start_",
"=_",
"utils_",
"._",
"utcnow_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"shutil_",
"._",
"copyfile_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"FLAGS_",
"._",
"state",
"\\u",
"path_",
",_",
"FLAGS_",
"._",
"sql",
"ite",
"\\u",
"clean",
"\\u",
"db_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"FLAGS_",
"._",
"state",
"\\u",
"path_",
",_",
"FLAGS_",
"._",
"sql",
"ite",
"\\u",
"db_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"emulate",
" ",
"some",
" ",
"of",
" ",
"the",
" ",
"mo",
"x",
" ",
"stu",
"ff",
",",
" ",
"we",
" ",
"can",
"'",
"t",
" ",
"use",
" ",
"the",
" ",
"metaclass_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"bec",
"aus",
"e",
" ",
"it",
" ",
"scre",
"ws",
" ",
"with",
" ",
"our",
" ",
"generators_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"mox_",
"=_",
"mox_",
"._",
"Mo",
"x_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"stubs_",
"=_",
"stub",
"out_",
"._",
"Stu",
"b",
"Out",
"For",
"Test",
"ing_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"flag",
"\\u",
"overrides_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"injected",
"_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"services_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"original",
"\\u",
"flags_",
"=_",
"FLAGS_",
"._",
"Fla",
"g",
"Value",
"s",
"Dict_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"tear",
"Down_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Run",
"s",
" ",
"after",
" ",
"each",
" ",
"test",
" ",
"method",
" ",
"to",
" ",
"tear",
" ",
"down",
" ",
"test",
" ",
"environ",
"ment",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"mox_",
"._",
"Unse",
"t",
"Stu",
"bs_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"stubs_",
"._",
"Unse",
"t",
"All_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"stubs_",
"._",
"Sma",
"rt",
"Unse",
"t",
"All_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"mox_",
"._",
"Verify",
"All_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"super_",
"(_",
"Test",
"Case_",
",_",
"self_",
")_",
"._",
"tear",
"Down_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"finally_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Clean",
" ",
"out",
" ",
"fake",
"\\u",
"rabbit",
"'",
"s",
" ",
"queue",
" ",
"if",
" ",
"we",
" ",
"used",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"FLAGS_",
"._",
"fake",
"\\u",
"rabbit",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"faker",
"abb",
"it_",
"._",
"reset",
"\\u",
"all_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"FLAGS_",
"._",
"connecti",
"on",
"\\u",
"type_",
"==_",
"'",
"fake",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"fake_",
"._",
"Fake",
"Connection_",
",_",
"'\\u",
"instance",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"del_",
"fake_",
"._",
"Fake",
"Connection_",
"._",
"\\u",
"instance_",
"\\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_",
"FLAGS_",
"._",
"image",
"\\u",
"service_",
"==_",
"'",
"nova",
".",
"image",
".",
"fake",
".",
"Fake",
"Image",
"Service",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"nova_",
"._",
"image_",
"._",
"fake_",
"._",
"Fake",
"Image",
"Service",
"\\u",
"reset_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Reset",
" ",
"any",
" ",
"override",
"n",
" ",
"flags_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"reset",
"\\u",
"flags_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sto",
"p",
" ",
"any",
" ",
"timers_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"x_",
"in_",
"self_",
"._",
"injected",
"_",
":_",
"\\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 ",
" ",
"_",
"x_",
"._",
"stop_",
"(_",
")_",
"\\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 ",
" ",
"_",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Kill",
" ",
"any",
" ",
"services_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"x_",
"in_",
"self_",
"._",
"\\u",
"services_",
":_",
"\\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 ",
" ",
"_",
"x_",
"._",
"kill_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Exception_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"flags_",
"(_",
"self_",
",_",
"**_",
"kw_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Override",
" ",
"flag",
" ",
"variab",
"les",
" ",
"for",
" ",
"a",
" ",
"test",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
",_",
"v_",
"in_",
"kw_",
"._",
"iteritems_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Stor",
"e",
" ",
"original",
" ",
"flag",
" ",
"value",
" ",
"if",
" ",
"it",
"'",
"s",
" ",
"not",
" ",
"bee",
"n",
" ",
"override",
"n",
" ",
"ye",
"t_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"k_",
"not_",
"in_",
"self_",
"._",
"flag",
"\\u",
"overrides_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"flag",
"\\u",
"overrides_",
"[_",
"k_",
"]_",
"=_",
"getattr_",
"(_",
"FLAGS_",
",_",
"k_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"setattr_",
"(_",
"FLAGS_",
",_",
"k_",
",_",
"v_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"reset",
"\\u",
"flags_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Reset",
"s",
" ",
"all",
" ",
"flag",
" ",
"variab",
"les",
" ",
"for",
" ",
"the",
" ",
"test",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Run",
"s",
" ",
"after",
" ",
"each",
" ",
"test",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"FLAGS_",
"._",
"Reset_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
",_",
"v_",
"in_",
"self_",
"._",
"\\u",
"original",
"\\u",
"flags_",
"._",
"iteritems_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"setattr_",
"(_",
"FLAGS_",
",_",
"k_",
",_",
"v_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"start",
"\\u",
"service_",
"(_",
"self_",
",_",
"name_",
",_",
"host_",
"=_",
"None_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"host_",
"=_",
"host_",
"and_",
"host_",
"or_",
"uuid_",
"._",
"uuid4_",
"(_",
")_",
"._",
"hex_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kwargs_",
"._",
"setdefault_",
"(_",
"'",
"host",
"'_",
",_",
"host_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kwargs_",
"._",
"setdefault_",
"(_",
"'",
"binar",
"y",
"'_",
",_",
"'",
"nova",
"-%",
"s",
"'_",
"%_",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"svc_",
"=_",
"service_",
"._",
"Service_",
"._",
"create_",
"(_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"svc_",
"._",
"start_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"services_",
"._",
"append_",
"(_",
"svc_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"svc_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"assert",
"Dict",
"Match_",
"(_",
"self_",
",_",
"d1_",
",_",
"d2_",
",_",
"approx",
"\\u",
"equal_",
"=_",
"False_",
",_",
"tolerance_",
"=_",
"0.001_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Assert",
" ",
"two",
" ",
"dict",
"s",
" ",
"are",
" ",
"equivalent",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"is",
" ",
"a",
" ",
"'",
"deep",
"'",
" ",
"match",
" ",
"in",
" ",
"the",
" ",
"sense",
" ",
"tha",
"t",
" ",
"it",
" ",
"handle",
"s",
" ",
"nest",
"ed",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"dictionar",
"ies",
" ",
"appropr",
"iate",
"ly",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"NOTE",
":",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"If",
" ",
"you",
" ",
"don",
"'",
"t",
" ",
"care",
" ",
"(",
"or",
" ",
"don",
"'",
"t",
" ",
"know",
")",
" ",
"a",
" ",
"give",
"n",
" ",
"value",
",",
" ",
"you",
" ",
"can",
" ",
"speci",
"fy",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"the",
" ",
"string",
" ",
"DON",
"TCA",
"RE",
" ",
"as",
" ",
"the",
" ",
"value",
".",
" ",
"Thi",
"s",
" ",
"will",
" ",
"caus",
"e",
" ",
"tha",
"t",
" ",
"dict",
"-",
"item",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"to",
" ",
"be",
" ",
"skip",
"ped",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"raise",
"\\u",
"assertion_",
"(_",
"msg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"d1",
"str_",
"=_",
"str_",
"(_",
"d1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"d2",
"str_",
"=_",
"str_",
"(_",
"d2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"base",
"\\u",
"msg_",
"=_",
"(_",
"'",
"Dict",
"ionar",
"ies",
" ",
"do",
" ",
"not",
" ",
"match",
".",
" ",
"%",
"(",
"msg",
")",
"s",
" ",
"d1",
":",
" ",
"%",
"(",
"d1",
"str",
")",
"s",
" ",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"d2",
":",
" ",
"%",
"(",
"d2",
"str",
")",
"s",
"'_",
"%_",
"locals_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Assert",
"ion",
"Error_",
"(_",
"base",
"\\u",
"msg_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"d1",
"keys_",
"=_",
"set_",
"(_",
"d1_",
"._",
"keys_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"d2",
"keys_",
"=_",
"set_",
"(_",
"d2_",
"._",
"keys_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"d1",
"keys_",
"!=_",
"d2",
"keys_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"d1",
"only_",
"=_",
"d1",
"keys_",
"-_",
"d2",
"keys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"d2",
"only_",
"=_",
"d2",
"keys_",
"-_",
"d1",
"keys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise",
"\\u",
"assertion_",
"(_",
"'",
"Keys",
" ",
"in",
" ",
"d1",
" ",
"and",
" ",
"not",
" ",
"d2",
":",
" ",
"%",
"(",
"d1",
"only",
")",
"s",
".",
" ",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Keys",
" ",
"in",
" ",
"d2",
" ",
"and",
" ",
"not",
" ",
"d1",
":",
" ",
"%",
"(",
"d2",
"only",
")",
"s",
"'_",
"%_",
"locals_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"key_",
"in_",
"d1",
"keys_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"d1",
"value_",
"=_",
"d1_",
"[_",
"key_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"d2",
"value_",
"=_",
"d2_",
"[_",
"key_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"error_",
"=_",
"abs_",
"(_",
"float_",
"(_",
"d1",
"value_",
")_",
"-_",
"float_",
"(_",
"d2",
"value_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"within",
"\\u",
"tolerance_",
"=_",
"error_",
"<=_",
"tolerance_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"(_",
"Value",
"Error_",
",_",
"Type",
"Error_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"If",
" ",
"bot",
"h",
" ",
"values",
" ",
"are",
"n",
"'",
"t",
" ",
"convert",
"able",
" ",
"to",
" ",
"float",
",",
" ",
"just",
" ",
"ignore_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Value",
"Error",
" ",
"if",
" ",
"arg",
" ",
"is",
" ",
"a",
" ",
"str",
",",
" ",
"Type",
"Error",
" ",
"if",
" ",
"it",
"'",
"s",
" ",
"somet",
"hing",
" ",
"else_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"(",
"like",
" ",
"Non",
"e",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"within",
"\\u",
"tolerance_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"hasattr_",
"(_",
"d1",
"value_",
",_",
"'",
"keys",
"'_",
")_",
"and_",
"hasattr_",
"(_",
"d2",
"value_",
",_",
"'",
"keys",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Dict",
"Match_",
"(_",
"d1",
"value_",
",_",
"d2",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"'",
"DON",
"TCA",
"RE",
"'_",
"in_",
"(_",
"d1",
"value_",
",_",
"d2",
"value_",
")_",
":_",
"\\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_",
"elif_",
"approx",
"\\u",
"equal_",
"and_",
"within",
"\\u",
"tolerance_",
":_",
"\\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_",
"elif_",
"d1",
"value_",
"!=_",
"d2",
"value_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise",
"\\u",
"assertion_",
"(_",
"\"",
"d1",
"['",
"%",
"(",
"key",
")",
"s",
"']",
"=",
"%",
"(",
"d1",
"value",
")",
"s",
" ",
"!=",
" ",
"\"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"d2",
"['",
"%",
"(",
"key",
")",
"s",
"']",
"=",
"%",
"(",
"d2",
"value",
")",
"s",
"\"_",
"%_",
"locals_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"assert",
"Dict",
"List",
"Match_",
"(_",
"self_",
",_",
"L1_",
",_",
"L2_",
",_",
"approx",
"\\u",
"equal_",
"=_",
"False_",
",_",
"tolerance_",
"=_",
"0.001_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Assert",
" ",
"a",
" ",
"list",
" ",
"of",
" ",
"dict",
"s",
" ",
"are",
" ",
"equivalent",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"raise",
"\\u",
"assertion_",
"(_",
"msg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"L1",
"str_",
"=_",
"str_",
"(_",
"L1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"L",
"2str_",
"=_",
"str_",
"(_",
"L2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"base",
"\\u",
"msg_",
"=_",
"(_",
"'",
"List",
" ",
"of",
" ",
"dictionar",
"ies",
" ",
"do",
" ",
"not",
" ",
"match",
":",
" ",
"%",
"(",
"msg",
")",
"s",
" ",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"L1",
":",
" ",
"%",
"(",
"L1",
"str",
")",
"s",
" ",
"L",
"2",
":",
" ",
"%",
"(",
"L",
"2s",
"tr",
")",
"s",
"'_",
"%_",
"locals_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Assert",
"ion",
"Error_",
"(_",
"base",
"\\u",
"msg_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"L1",
"count_",
"=_",
"len_",
"(_",
"L1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"L",
"2co",
"unt_",
"=_",
"len_",
"(_",
"L2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"L1",
"count_",
"!=_",
"L",
"2co",
"unt_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise",
"\\u",
"assertion_",
"(_",
"'",
"Length",
" ",
"mism",
"atch",
":",
" ",
"len",
"(",
"L1",
")=",
"%",
"(",
"L1",
"count",
")",
"d",
" ",
"!=",
" ",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"len",
"(",
"L",
"2",
")=",
"%",
"(",
"L",
"2co",
"unt",
")",
"d",
"'_",
"%_",
"locals_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"d1_",
",_",
"d2_",
"in_",
"zip_",
"(_",
"L1_",
",_",
"L2_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Dict",
"Match_",
"(_",
"d1_",
",_",
"d2_",
",_",
"approx",
"\\u",
"equal_",
"=_",
"approx",
"\\u",
"equal_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"tolerance_",
"=_",
"tolerance_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"assert",
"Sub",
"Dict",
"Match_",
"(_",
"self_",
",_",
"sub\\u",
"dict_",
",_",
"super",
"\\u",
"dict_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Assert",
" ",
"a",
" ",
"sub\\u",
"dict",
" ",
"is",
" ",
"subse",
"t",
" ",
"of",
" ",
"super",
"\\u",
"dict",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"set_",
"(_",
"sub\\u",
"dict_",
"._",
"keys_",
"(_",
")_",
")_",
"._",
"issubset_",
"(_",
"set_",
"(_",
"super",
"\\u",
"dict_",
"._",
"keys_",
"(_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"k_",
",_",
"sub\\u",
"value_",
"in_",
"sub\\u",
"dict_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"super",
"\\u",
"value_",
"=_",
"super",
"\\u",
"dict_",
"[_",
"k_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"sub\\u",
"value_",
",_",
"dict_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Sub",
"Dict",
"Match_",
"(_",
"sub\\u",
"value_",
",_",
"super",
"\\u",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"'",
"DON",
"TCA",
"RE",
"'_",
"in_",
"(_",
"sub\\u",
"value_",
",_",
"super",
"\\u",
"value_",
")_",
":_",
"\\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_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Equal_",
"(_",
"sub\\u",
"value_",
",_",
"super",
"\\u",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"assert",
"In_",
"(_",
"self_",
",_",
"a_",
",_",
"b_",
",_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Pyth",
"on",
" ",
"<",
" ",
"v2",
".7",
" ",
"compatibility",
".",
" ",
" ",
"Assert",
" ",
"'",
"a",
"'",
" ",
"in",
" ",
"'",
"b",
"'\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"f_",
"=_",
"super_",
"(_",
"Test",
"Case_",
",_",
"self_",
")_",
"._",
"assert",
"In_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Attribute",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"True_",
"(_",
"a_",
"in_",
"b_",
",_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"f_",
"(_",
"a_",
",_",
"b_",
",_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Case_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"assert",
"Not",
"In_",
"(_",
"self_",
",_",
"a_",
",_",
"b_",
",_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Pyth",
"on",
" ",
"<",
" ",
"v2",
".7",
" ",
"compatibility",
".",
" ",
" ",
"Assert",
" ",
"'",
"a",
"'",
" ",
"NOT",
" ",
"in",
" ",
"'",
"b",
"'\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"f_",
"=_",
"super_",
"(_",
"Test",
"Case_",
",_",
"self_",
")_",
"._",
"assert",
"Not",
"In_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Attribute",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"False_",
"(_",
"a_",
"in_",
"b_",
",_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"f_",
"(_",
"a_",
",_",
"b_",
",_",
"*_",
"args_",
",_",
"**_",
"kwargs_",
")_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | benadida/helios-server/helios/south_migrations/0003_v3_1_election_specific_voters_with_passwords.py | [
{
"content": "# encoding: utf-8\nimport datetime\nfrom south.db import db\nfrom south.v2 import DataMigration\nfrom django.db import models\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class Migration(DataMigration):\n\n\n\n\n\n models = {\n 'helios_auth.user': {\n 'Meta': {'unique_together': \"(('user_type', 'user_id'),)\", 'object_name': 'User'},\n 'admin_p': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'info': ('helios_auth.jsonfield.JSONField', [], {}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True'}),\n 'token': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'user_id': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'user_type': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n },\n 'helios.auditedballot': {\n 'Meta': {'object_name': 'AuditedBallot'},\n 'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios.Election']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'raw_vote': ('django.db.models.fields.TextField', [], {}),\n 'vote_hash': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n },\n 'helios.castvote': {\n 'Meta': {'object_name': 'CastVote'},\n 'cast_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'invalidated_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),\n 'verified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),\n 'vote': ('helios_auth.jsonfield.JSONField', [], {}),\n 'vote_hash': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'vote_tinyhash': ('django.db.models.fields.CharField', [], {'max_length': '50', 'unique': 'True', 'null': 'True'}),\n 'voter': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios.Voter']\"})\n },\n 'helios.election': {\n 'Meta': {'object_name': 'Election'},\n 'admin': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios_auth.User']\"}),\n 'archived_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'cast_url': ('django.db.models.fields.CharField', [], {'max_length': '500'}),\n 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'datatype': ('django.db.models.fields.CharField', [], {'default': \"'legacy/Election'\", 'max_length': '250'}),\n 'description': ('django.db.models.fields.TextField', [], {}),\n 'election_type': ('django.db.models.fields.CharField', [], {'default': \"'election'\", 'max_length': '250'}),\n 'eligibility': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'encrypted_tally': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'featured_p': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'frozen_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '250'}),\n 'openreg': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'private_key': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'private_p': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'public_key': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'questions': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'registration_starts_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'result': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'result_proof': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'tallies_combined_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'tallying_finished_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'tallying_started_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'tallying_starts_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'use_advanced_audit_features': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n 'use_voter_aliases': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}),\n 'voters_hash': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),\n 'voting_ended_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'voting_ends_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'voting_extended_until': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'voting_started_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),\n 'voting_starts_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'})\n },\n 'helios.electionlog': {\n 'Meta': {'object_name': 'ElectionLog'},\n 'at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios.Election']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'log': ('django.db.models.fields.CharField', [], {'max_length': '500'})\n },\n 'helios.trustee': {\n 'Meta': {'object_name': 'Trustee'},\n 'decryption_factors': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'decryption_proofs': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios.Election']\"}),\n 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),\n 'pok': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'public_key': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'public_key_hash': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'secret': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'secret_key': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n },\n 'helios.voter': {\n 'Meta': {'object_name': 'Voter'},\n 'alias': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),\n 'cast_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),\n 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios.Election']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True'}),\n 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios_auth.User']\", 'null': 'True'}),\n 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50'}),\n 'vote': ('helios_auth.jsonfield.JSONField', [], {'null': 'True'}),\n 'vote_hash': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),\n 'voter_email': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True'}),\n 'voter_id': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'voter_login_id': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),\n 'voter_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True'}),\n 'voter_password': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),\n 'voter_type': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n },\n 'helios.voterfile': {\n 'Meta': {'object_name': 'VoterFile'},\n 'election': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['helios.Election']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'num_voters': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),\n 'processing_finished_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),\n 'processing_started_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),\n 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'voter_file': ('django.db.models.fields.files.FileField', [], {'max_length': '250'})\n }\n }\n\n complete_apps = ['helios']",
"metadata": "root.Migration",
"header": "['module', '___EOS___']",
"index": 6
},
{
"content": " def forwards(self, orm):\n \"\"\"\n update the voters data objects to point to users when it makes sense,\n and otherwise to copy the data needed from the users table.\n make all elections legacy, because before now they are.\n \"\"\"\n for e in orm.Election.objects.all():\n e.datatype = 'legacy/Election'\n e.save()\n\n # use the .iterator() call to reduce caching and make this more efficient\n # so as not to trigger a memory error\n for v in orm.Voter.objects.all().iterator():\n user = orm['helios_auth.User'].objects.get(user_type = v.voter_type, user_id = v.voter_id)\n\n if v.voter_type == 'password':\n v.voter_login_id = v.voter_id\n v.voter_name = v.name\n\n v.voter_email = user.info['email']\n v.voter_password = user.info['password']\n else:\n v.user = user\n\n v.save()\n\n # also, update tinyhash for all votes\n for cv in orm.CastVote.objects.all().iterator():\n safe_hash = cv.vote_hash\n for c in ['/', '+']:\n safe_hash = safe_hash.replace(c,'')\n \n length = 8\n while True:\n vote_tinyhash = safe_hash[:length]\n if orm.CastVote.objects.filter(vote_tinyhash = vote_tinyhash).count() == 0:\n break\n length += 1\n \n cv.vote_tinyhash = vote_tinyhash\n cv.save()",
"metadata": "root.Migration.forwards",
"header": "['class', 'Migration', '(', 'DataMigration', ')', ':', '___EOS___']",
"index": 8
},
{
"content": " def backwards(self, orm):\n \"Write your backwards methods here.\"\n raise Exception(\"can't revert to system-wide user passwords, rather than election specific\")",
"metadata": "root.Migration.backwards",
"header": "['class', 'Migration', '(', 'DataMigration', ')', ':', '___EOS___']",
"index": 51
}
]
| [
{
"span": "import datetime",
"start_line": 1,
"start_column": 0,
"end_line": 1,
"end_column": 15
},
{
"span": "from south.db import db",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 23
},
{
"span": "from django.db import models",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 28
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"encoding",
":",
" ",
"utf",
"-",
"8_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"south_",
"._",
"db_",
"import_",
"db_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"south_",
"._",
"v2_",
"import_",
"Data",
"Migration_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"db_",
"import_",
"models_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Migration_",
"(_",
"Data",
"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_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"user",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"unique",
"\\u",
"tog",
"ether",
"'_",
":_",
"\"(",
"('",
"user",
"\\u",
"type",
"',",
" ",
"'",
"user",
"\\u",
"id",
"'),)\"_",
",_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"User",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"admin",
"\\u",
"p",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Boo",
"lean",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Fal",
"se",
"'_",
"}_",
")_",
",_",
"\\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_",
"'",
"info",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"200",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"\\u",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"\\u",
"type",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"50",
"'_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"audit",
"edb",
"allo",
"t",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Audi",
"ted",
"Ball",
"ot",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"adde",
"d\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"auto",
"\\u",
"now",
"\\u",
"add",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"blank",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
".",
"Elect",
"ion",
"']\"_",
"}_",
")_",
",_",
"\\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_",
"'",
"raw",
"\\u",
"vote",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Text",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"\\u",
"hash",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"cast",
"vote",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Cast",
"Vote",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"cast",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"auto",
"\\u",
"now",
"\\u",
"add",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"blank",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Auto",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"primary",
"\\u",
"key",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"invalidate",
"d\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"verifie",
"d\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"\\u",
"hash",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"\\u",
"tiny",
"hash",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"50",
"'_",
",_",
"'",
"unique",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
".",
"Vote",
"r",
"']\"_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"election",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Elect",
"ion",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"admin",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
"\\u",
"auth",
".",
"User",
"']\"_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"archived",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"cast",
"\\u",
"url",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"500",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"created",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"auto",
"\\u",
"now",
"\\u",
"add",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"blank",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"datatype",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"\"'",
"lega",
"cy",
"/",
"Elect",
"ion",
"'\"_",
",_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"250",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"description",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Text",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"\\u",
"type",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"\"'",
"election",
"'\"_",
",_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"250",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"eli",
"gib",
"ilit",
"y",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"encrypt",
"ed",
"\\u",
"tally",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"feature",
"d\\u",
"p",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Boo",
"lean",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Fal",
"se",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"frozen",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Auto",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"primary",
"\\u",
"key",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"modifi",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"auto",
"\\u",
"now",
"\\u",
"add",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"blank",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"250",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"open",
"reg",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Boo",
"lean",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Fal",
"se",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"private",
"\\u",
"key",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"private",
"\\u",
"p",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Boo",
"lean",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Fal",
"se",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"public",
"\\u",
"key",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"question",
"s",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"registration",
"\\u",
"starts",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"result",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"result",
"\\u",
"proof",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"short",
"\\u",
"name",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tall",
"ies",
"\\u",
"combin",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tally",
"ing",
"\\u",
"finish",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tally",
"ing",
"\\u",
"start",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tally",
"ing",
"\\u",
"starts",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"use",
"\\u",
"advanced",
"\\u",
"audit",
"\\u",
"features",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Boo",
"lean",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"use",
"\\u",
"voter",
"\\u",
"alias",
"es",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Boo",
"lean",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Fal",
"se",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uuid",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"50",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"s",
"\\u",
"hash",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voting",
"\\u",
"ende",
"d\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voting",
"\\u",
"ends",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voting",
"\\u",
"extend",
"ed",
"\\u",
"unti",
"l",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voting",
"\\u",
"start",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voting",
"\\u",
"starts",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"default",
"'_",
":_",
"'",
"Non",
"e",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"election",
"log",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Elect",
"ion",
"Log",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"auto",
"\\u",
"now",
"\\u",
"add",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"blank",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
".",
"Elect",
"ion",
"']\"_",
"}_",
")_",
",_",
"\\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_",
"'",
"log",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"500",
"'_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"trust",
"ee",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Trust",
"ee",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"decrypt",
"ion",
"\\u",
"factor",
"s",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"decrypt",
"ion",
"\\u",
"proof",
"s",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
".",
"Elect",
"ion",
"']\"_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"email",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Ema",
"il",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"7",
"5",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Auto",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"primary",
"\\u",
"key",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"200",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"po",
"k",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"public",
"\\u",
"key",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"public",
"\\u",
"key",
"\\u",
"hash",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"secret",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"secret",
"\\u",
"key",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uuid",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"50",
"'_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"voter",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Vote",
"r",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"alias",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"cast",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
".",
"Elect",
"ion",
"']\"_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Auto",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"primary",
"\\u",
"key",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"200",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
"\\u",
"auth",
".",
"User",
"']\"_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uuid",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"50",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"'_",
":_",
"(_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"jsonfi",
"eld",
".",
"JSO",
"NF",
"iel",
"d",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"vote",
"\\u",
"hash",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"email",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"250",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"login",
"\\u",
"id",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"name",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"200",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"password",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
",_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"type",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Char",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"100",
"'_",
"}_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"heli",
"os",
".",
"voter",
"file",
"'_",
":_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Meta",
"'_",
":_",
"{_",
"'",
"object\\u",
"name",
"'_",
":_",
"'",
"Vote",
"r",
"File",
"'_",
"}_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"election",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"relate",
"d",
".",
"Fore",
"ign",
"Key",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"to",
"'_",
":_",
"\"",
"orm",
"['",
"heli",
"os",
".",
"Elect",
"ion",
"']\"_",
"}_",
")_",
",_",
"\\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_",
"'",
"num",
"\\u",
"voter",
"s",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Integer",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"process",
"ing",
"\\u",
"finish",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"process",
"ing",
"\\u",
"start",
"ed",
"\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"null",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"uploade",
"d\\u",
"at",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"Date",
"Time",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"auto",
"\\u",
"now",
"\\u",
"add",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
",_",
"'",
"blank",
"'_",
":_",
"'",
"Tru",
"e",
"'_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"voter",
"\\u",
"file",
"'_",
":_",
"(_",
"'",
"django",
".",
"db",
".",
"model",
"s",
".",
"fields",
".",
"files",
".",
"File",
"Field",
"'_",
",_",
"[_",
"]_",
",_",
"{_",
"'",
"max",
"\\u",
"length",
"'_",
":_",
"'",
"250",
"'_",
"}_",
")_",
"\\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_",
"=_",
"[_",
"'",
"heli",
"os",
"'_",
"]_",
"[SEP]_",
"class_",
"Migration_",
"(_",
"Data",
"Migration_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"forwards_",
"(_",
"self_",
",_",
"orm_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"update",
" ",
"the",
" ",
"voter",
"s",
" ",
"data",
" ",
"object",
"s",
" ",
"to",
" ",
"point",
" ",
"to",
" ",
"users",
" ",
"whe",
"n",
" ",
"it",
" ",
"make",
"s",
" ",
"sense",
",",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"and",
" ",
"other",
"wis",
"e",
" ",
"to",
" ",
"copy",
" ",
"the",
" ",
"data",
" ",
"need",
"ed",
" ",
"from",
" ",
"the",
" ",
"users",
" ",
"table",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"make",
" ",
"all",
" ",
"election",
"s",
" ",
"lega",
"cy",
",",
" ",
"bec",
"aus",
"e",
" ",
"bef",
"ore",
" ",
"now",
" ",
"the",
"y",
" ",
"are",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"e_",
"in_",
"orm_",
"._",
"Elect",
"ion_",
"._",
"objects_",
"._",
"all_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"e_",
"._",
"datatype_",
"=_",
"'",
"lega",
"cy",
"/",
"Elect",
"ion",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"e_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"use",
" ",
"the",
" ",
".",
"iter",
"ator",
"()",
" ",
"call",
" ",
"to",
" ",
"reduce",
" ",
"caching",
" ",
"and",
" ",
"make",
" ",
"this",
" ",
"more",
" ",
"efficien",
"t_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"so",
" ",
"as",
" ",
"not",
" ",
"to",
" ",
"trigger",
" ",
"a",
" ",
"memory",
" ",
"error_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"v_",
"in_",
"orm_",
"._",
"Vote",
"r_",
"._",
"objects_",
"._",
"all_",
"(_",
")_",
"._",
"iterator_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"user_",
"=_",
"orm_",
"[_",
"'",
"heli",
"os",
"\\u",
"auth",
".",
"User",
"'_",
"]_",
"._",
"objects_",
"._",
"get_",
"(_",
"user",
"\\u",
"type_",
"=_",
"v_",
"._",
"voter",
"\\u",
"type_",
",_",
"user",
"\\u",
"id_",
"=_",
"v_",
"._",
"voter",
"\\u",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"v_",
"._",
"voter",
"\\u",
"type_",
"==_",
"'",
"password",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"v_",
"._",
"voter",
"\\u",
"login",
"\\u",
"id_",
"=_",
"v_",
"._",
"voter",
"\\u",
"id_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"v_",
"._",
"voter",
"\\u",
"name_",
"=_",
"v_",
"._",
"name_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"v_",
"._",
"voter",
"\\u",
"email_",
"=_",
"user_",
"._",
"info_",
"[_",
"'",
"email",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"v_",
"._",
"voter",
"\\u",
"password_",
"=_",
"user_",
"._",
"info_",
"[_",
"'",
"password",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"v_",
"._",
"user_",
"=_",
"user_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"v_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"als",
"o",
",",
" ",
"update",
" ",
"tiny",
"hash",
" ",
"for",
" ",
"all",
" ",
"votes_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"cv_",
"in_",
"orm_",
"._",
"Cast",
"Vote",
"_",
"._",
"objects_",
"._",
"all_",
"(_",
")_",
"._",
"iterator_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"safe",
"\\u",
"hash_",
"=_",
"cv_",
"._",
"vote",
"\\u",
"hash_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"c_",
"in_",
"[_",
"'/'_",
",_",
"'+'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"safe",
"\\u",
"hash_",
"=_",
"safe",
"\\u",
"hash_",
"._",
"replace_",
"(_",
"c_",
",_",
"''_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"length_",
"=_",
"8_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"True_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"vote",
"\\u",
"tiny",
"hash_",
"=_",
"safe",
"\\u",
"hash_",
"[_",
":_",
"length_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"orm_",
"._",
"Cast",
"Vote",
"_",
"._",
"objects_",
"._",
"filter_",
"(_",
"vote",
"\\u",
"tiny",
"hash_",
"=_",
"vote",
"\\u",
"tiny",
"hash_",
")_",
"._",
"count_",
"(_",
")_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"break_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"length_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"cv_",
"._",
"vote",
"\\u",
"tiny",
"hash_",
"=_",
"vote",
"\\u",
"tiny",
"hash_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cv_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Migration_",
"(_",
"Data",
"Migration_",
")_",
":_",
"\\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_",
"backwards_",
"(_",
"self_",
",_",
"orm_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"",
"Write",
" ",
"your",
" ",
"back",
"ward",
"s",
" ",
"method",
"s",
" ",
"here",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Exception_",
"(_",
"\"",
"can",
"'",
"t",
" ",
"revert",
" ",
"to",
" ",
"system",
"-",
"wide",
" ",
"user",
" ",
"passwords",
",",
" ",
"rat",
"her",
" ",
"than",
" ",
"election",
" ",
"specific",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
0,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused import | khamidou/kite/src/back/kite/utils.py | [
{
"content": "# utils.py : various utilities\nimport os\nimport json\nimport datetime\nimport time\nimport dateutil.parser\nimport dateutil.tz\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class DatetimeEncoder(json.JSONEncoder):",
"metadata": "root.DatetimeEncoder",
"header": "['module', '___EOS___']",
"index": 9
},
{
"content": " def default(self, obj):\n if isinstance(obj, datetime.datetime):\n return obj.isoformat()\n\n return json.JSONEncoder.default(self, obj)",
"metadata": "root.DatetimeEncoder.default",
"header": "['class', 'DatetimeEncoder', '(', 'json', '.', 'JSONEncoder', ')', ':', '___EOS___']",
"index": 10
},
{
"content": "def serialize_json(obj, protection=True):\n # we prepend this strange string to prevent jsonp vulnerabilities.\n # see: https://docs.angularjs.org/api/ng/service/$http for more info.\n str = json.dumps(obj, cls=DatetimeEncoder)\n if protection:\n return \")]}',\\n\" + str\n else:\n return str",
"metadata": "root.serialize_json",
"header": "['module', '___EOS___']",
"index": 16
},
{
"content": "def deserialize_json(string):\n return json.loads(string, object_hook=deserialize_datetime)",
"metadata": "root.deserialize_json",
"header": "['module', '___EOS___']",
"index": 25
},
{
"content": "def deserialize_datetime(obj):\n try:\n obj['date'] = dateutil.parser.parse(obj['date'])\n except KeyError:\n pass\n return obj",
"metadata": "root.deserialize_datetime",
"header": "['module', '___EOS___']",
"index": 28
}
]
| [
{
"span": "import os",
"start_line": 1,
"start_column": 0,
"end_line": 1,
"end_column": 9
},
{
"span": "import time",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 11
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"util",
"s",
".",
"py",
" ",
":",
" ",
"vari",
"ous",
" ",
"utilities_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"json_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"dateutil_",
"._",
"parser_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"dateutil_",
"._",
"tz_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Date",
"time",
"Encoder_",
"(_",
"json_",
"._",
"JSO",
"NE",
"ncode",
"r_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Date",
"time",
"Encoder_",
"(_",
"json_",
"._",
"JSO",
"NE",
"ncode",
"r_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"default_",
"(_",
"self_",
",_",
"obj_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"isinstance_",
"(_",
"obj_",
",_",
"datetime_",
"._",
"datetime_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"obj_",
"._",
"isoformat_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"json_",
"._",
"JSO",
"NE",
"ncode",
"r_",
"._",
"default_",
"(_",
"self_",
",_",
"obj_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"serialize",
"\\u",
"json_",
"(_",
"obj_",
",_",
"protection",
"_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"we",
" ",
"prepend",
" ",
"this",
" ",
"stran",
"ge",
" ",
"string",
" ",
"to",
" ",
"prevent",
" ",
"jsonp",
" ",
"vulnerab",
"ilities",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"see",
":",
" ",
"https",
"://",
"docs",
".",
"angular",
"js",
".",
"org",
"/",
"api",
"/",
"ng",
"/",
"service",
"/$",
"http",
" ",
"for",
" ",
"more",
" ",
"info",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"str_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"obj_",
",_",
"cls_",
"=_",
"Date",
"time",
"Encoder_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"protection",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\")]",
"}'",
",\\\\",
"n",
"\"_",
"+_",
"str_",
"\\u\\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_",
"str_",
"\\u\\u\\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_",
"deserialize",
"\\u",
"json_",
"(_",
"string_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"json_",
"._",
"loads_",
"(_",
"string_",
",_",
"object\\u",
"hook_",
"=_",
"deserialize",
"\\u",
"datetime_",
")_",
"\\u\\u\\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_",
"deserialize",
"\\u",
"datetime_",
"(_",
"obj_",
")_",
":_",
"\\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 ",
" _",
"obj_",
"[_",
"'",
"date",
"'_",
"]_",
"=_",
"dateutil_",
"._",
"parser_",
"._",
"parse_",
"(_",
"obj_",
"[_",
"'",
"date",
"'_",
"]_",
")_",
"\\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_",
"return_",
"obj_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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' | enthought/traitsui/traitsui/null/font_trait.py | [
{
"content": " def validate(self, object, name, value):\n \"\"\" Validates that the value is a valid font descriptor string.\n \"\"\"\n try:\n point_size = family = style = weight = underline = ''\n facename = ['']\n for word in value.split():\n lword = word.lower()\n if lword in font_families:\n family = ' ' + lword\n elif lword in font_styles:\n style = ' ' + lword\n elif lword in font_weights:\n weight = ' ' + lword\n elif lword == 'underline':\n underline = ' ' + lword\n elif lword not in font_noise:\n try:\n int(lword)\n point_size = lword + ' pt'\n except:\n facename.append(word)\n fontstr = ('%s%s%s%s%s%s' % (point_size, family, style, weight,\n underline, ' '.join(facename))).strip()\n return fontstr\n except Exception:\n pass\n raise TraitError(object, name, 'a font descriptor string',\n repr(value))",
"metadata": "root.TraitFont.validate",
"header": "['class', 'TraitFont', '(', 'TraitHandler', ')', ':', '___EOS___']",
"index": 71
}
]
| [
{
"span": "except:",
"start_line": 91,
"start_column": 20,
"end_line": 91,
"end_column": 27
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Trait",
"Font_",
"(_",
"Trait",
"Handler_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"validate_",
"(_",
"self_",
",_",
"object_",
",_",
"name_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"Validate",
"s",
" ",
"tha",
"t",
" ",
"the",
" ",
"value",
" ",
"is",
" ",
"a",
" ",
"valid",
" ",
"font",
" ",
"descrip",
"tor",
" ",
"string",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"point",
"\\u",
"size_",
"=_",
"family_",
"=_",
"style_",
"=_",
"weight_",
"=_",
"underline_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"face",
"name_",
"=_",
"[_",
"''_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"word_",
"in_",
"value_",
"._",
"split_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"lw",
"ord_",
"=_",
"word_",
"._",
"lower_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"lw",
"ord_",
"in_",
"font",
"\\u",
"families_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"family_",
"=_",
"'",
" ",
"'_",
"+_",
"lw",
"ord_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"lw",
"ord_",
"in_",
"font",
"\\u",
"styles_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"style_",
"=_",
"'",
" ",
"'_",
"+_",
"lw",
"ord_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"lw",
"ord_",
"in_",
"font",
"\\u",
"weights_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"weight_",
"=_",
"'",
" ",
"'_",
"+_",
"lw",
"ord_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"lw",
"ord_",
"==_",
"'",
"underl",
"ine",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"underline_",
"=_",
"'",
" ",
"'_",
"+_",
"lw",
"ord_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"lw",
"ord_",
"not_",
"in_",
"font",
"\\u",
"noise_",
":_",
"\\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 ",
" ",
" _",
"int_",
"(_",
"lw",
"ord_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"point",
"\\u",
"size_",
"=_",
"lw",
"ord_",
"+_",
"'",
" ",
"pt",
"'_",
"\\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 ",
" ",
" _",
"face",
"name_",
"._",
"append_",
"(_",
"word_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"font",
"str_",
"=_",
"(_",
"'%",
"s",
"%",
"s",
"%",
"s",
"%",
"s",
"%",
"s",
"%",
"s",
"'_",
"%_",
"(_",
"point",
"\\u",
"size_",
",_",
"family_",
",_",
"style_",
",_",
"weight_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"underline_",
",_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"face",
"name_",
")_",
")_",
")_",
"._",
"strip_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"font",
"str_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Exception_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDED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2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Variable defined multiple times | AppScale/appscale/AppServer/lib/django-1.2/django/utils/datastructures.py | [
{
"content": " def __init__(self, key_to_list_mapping):\n for k, v in key_to_list_mapping.items():\n current = self\n bits = k.split('.')\n for bit in bits[:-1]:\n current = current.setdefault(bit, {})\n # Now assign value to current position\n try:\n current[bits[-1]] = v\n except TypeError: # Special-case if current isn't a dict.\n current = {bits[-1]: v}",
"metadata": "root.DotExpandedDict.__init__",
"header": "['class', 'DotExpandedDict', '(', 'dict', ')', ':', '___EOS___']",
"index": 387
}
]
| [
{
"span": "current ",
"start_line": 397,
"start_column": 16,
"end_line": 397,
"end_column": 23
}
]
| [
{
"span": "current ",
"start_line": 389,
"start_column": 12,
"end_line": 389,
"end_column": 19
}
]
| 1 | true | [
"[CLS]_",
"Variable_",
"defined_",
"multiple_",
"times_",
"[SEP]_",
"class_",
"Dot",
"Expand",
"ed",
"Dict_",
"(_",
"dict_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"key",
"\\u",
"to",
"\\u",
"list",
"\\u",
"mapping_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"k_",
",_",
"v_",
"in_",
"key",
"\\u",
"to",
"\\u",
"list",
"\\u",
"mapping_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"current_",
"=_",
"self_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"bits_",
"=_",
"k_",
"._",
"split_",
"(_",
"'.'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"bit_",
"in_",
"bits_",
"[_",
":_",
"-_",
"1_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"current_",
"=_",
"current_",
"._",
"setdefault_",
"(_",
"bit_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"No",
"w",
" ",
"assign",
" ",
"value",
" ",
"to",
" ",
"current",
" ",
"position_",
"\\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 ",
" _",
"current_",
"[_",
"bits_",
"[_",
"-_",
"1_",
"]_",
"]_",
"=_",
"v_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Type",
"Error_",
":_",
"#",
" ",
"Special",
"-",
"case",
" ",
"if",
" ",
"current",
" ",
"isn",
"'",
"t",
" ",
"a",
" ",
"dict",
"._",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"current_",
"=_",
"{_",
"bits_",
"[_",
"-_",
"1_",
"]_",
":_",
"v_",
"}_",
"\\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,
3,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
`__eq__` not overridden when adding attributes | tarbell-project/tarbell/tarbell/s3.py | [
{
"content": "class S3Url(str):\n \"\"\"\n Encapsulates an S3 URL\n \"\"\"",
"metadata": "root.S3Url",
"header": "['module', '___EOS___']",
"index": 18
},
{
"content": " def __new__(self, content):\n # Parse\n if not content.endswith(\"/\"):\n content = \"{0}/\".format(content)\n if content.startswith(\"s3://\"):\n content = content[5:]\n self.root, self.path = content.split(\"/\", 1)\n return str.__new__(self, content.rstrip(\"/\"))",
"metadata": "root.S3Url.__new__",
"header": "['class', 'S3Url', '(', 'str', ')', ':', '___EOS___']",
"index": 22
}
]
| [
{
"span": "class S3Url(str):",
"start_line": 18,
"start_column": 0,
"end_line": 18,
"end_column": 17
}
]
| [
{
"span": "self.root,",
"start_line": 28,
"start_column": 8,
"end_line": 28,
"end_column": 17
},
{
"span": "self.path ",
"start_line": 28,
"start_column": 19,
"end_line": 28,
"end_column": 28
}
]
| 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_",
"class_",
"S",
"3",
"Url_",
"(_",
"str_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Enca",
"psu",
"late",
"s",
" ",
"an",
" ",
"S",
"3",
" ",
"URL",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"S",
"3",
"Url_",
"(_",
"str_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"new\\u\\u_",
"(_",
"self_",
",_",
"content_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Parse_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"content_",
"._",
"endswith_",
"(_",
"\"/\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"content_",
"=_",
"\"{",
"0",
"}/",
"\"_",
"._",
"format_",
"(_",
"content_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"content_",
"._",
"startswith_",
"(_",
"\"",
"s3",
"://\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"content_",
"=_",
"content_",
"[_",
"5_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"root_",
",_",
"self_",
"._",
"path_",
"=_",
"content_",
"._",
"split_",
"(_",
"\"/\"_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"str_",
"._",
"\\u\\u",
"new\\u\\u_",
"(_",
"self_",
",_",
"content_",
"._",
"rstrip_",
"(_",
"\"/\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
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,
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,
3,
1,
1,
1,
2,
3,
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 | Sheeprider/BitBucket-api/bitbucket/tests/private/__main__.py | [
{
"content": "# -*- coding: utf-8 -*-\n# run with `site-packages$> python -m bitbucket.tests.private`\nimport unittest\n\nfrom bitbucket.tests.private.private import BitbucketAuthenticatedMethodsTest\nfrom bitbucket.tests.private.repository import RepositoryAuthenticatedMethodsTest, ArchiveRepositoryAuthenticatedMethodsTest\nfrom bitbucket.tests.private.issue import IssueAuthenticatedMethodsTest\nfrom bitbucket.tests.private.issue_comment import IssueCommentAuthenticatedMethodsTest\nfrom bitbucket.tests.private.service import ServiceAuthenticatedMethodsTest\nfrom bitbucket.tests.private.ssh import SSHAuthenticatedMethodsTest\n\nif __name__ == '__main__':\n unittest.main()\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "from bitbucket.tests.private.private import BitbucketAuthenticatedMethodsTest",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 77
},
{
"span": "from bitbucket.tests.private.repository import RepositoryAuthenticatedMethodsTest, ArchiveRepositoryAuthenticatedMethodsTest",
"start_line": 5,
"start_column": 0,
"end_line": 5,
"end_column": 124
},
{
"span": "from bitbucket.tests.private.issue import IssueAuthenticatedMethodsTest",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 71
},
{
"span": "from bitbucket.tests.private.issue_comment import IssueCommentAuthenticatedMethodsTest",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 86
},
{
"span": "from bitbucket.tests.private.service import ServiceAuthenticatedMethodsTest",
"start_line": 8,
"start_column": 0,
"end_line": 8,
"end_column": 75
},
{
"span": "from bitbucket.tests.private.ssh import SSHAuthenticatedMethodsTest",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 67
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"run",
" ",
"with",
" ",
"`",
"site",
"-",
"package",
"s",
"$",
">",
" ",
"python",
" ",
"-",
"m",
" ",
"bitb",
"ucket",
".",
"tests",
".",
"private",
"`_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"bitb",
"ucket",
"_",
"._",
"tests_",
"._",
"private_",
"._",
"private_",
"import_",
"Bit",
"bucket",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bitb",
"ucket",
"_",
"._",
"tests_",
"._",
"private_",
"._",
"repository_",
"import_",
"Repos",
"itor",
"y",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
",_",
"Archive",
"Repos",
"itor",
"y",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bitb",
"ucket",
"_",
"._",
"tests_",
"._",
"private_",
"._",
"issue_",
"import_",
"Issue",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bitb",
"ucket",
"_",
"._",
"tests_",
"._",
"private_",
"._",
"issue",
"\\u",
"comment_",
"import_",
"Issue",
"Comme",
"nt",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bitb",
"ucket",
"_",
"._",
"tests_",
"._",
"private_",
"._",
"service_",
"import_",
"Service",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bitb",
"ucket",
"_",
"._",
"tests_",
"._",
"private_",
"._",
"ssh_",
"import_",
"SSH",
"Auth",
"entica",
"ted",
"Meth",
"ods",
"Test_",
"\\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 ",
" _",
"unittest_",
"._",
"main_",
"(_",
")_",
"\\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,
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,
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,
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Signature mismatch in overriding method | ilastik/ilastik-0.5/ilastik/core/baseModuleMgr.py | [
{
"content": "class PropertyMgr(object):\n \"\"\"\n Holds a bag of Properties that can be serialized and deserialized\n new properties are also added to the parents regular attributes\n for easier access\n \"\"\"\n \n \n\n \n\n ",
"metadata": "root.PropertyMgr",
"header": "['module', '___EOS___']",
"index": 8
},
{
"content": " def __init__(self, parent):\n self._dict = {}\n self._parent = parent",
"metadata": "root.PropertyMgr.__init__",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 14
},
{
"content": " def serialize(self, h5g, name):\n for v in self.values():\n if hasattr(v, \"serialize\"):\n v.serialize(h5g)",
"metadata": "root.PropertyMgr.serialize",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 18
},
{
"content": " def deserialize(self, h5g, name):\n pass",
"metadata": "root.PropertyMgr.deserialize",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 23
},
{
"content": " def keys(self):\n return self._dict.keys()",
"metadata": "root.PropertyMgr.keys",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 26
},
{
"content": " def values(self):\n return self._dict.values()",
"metadata": "root.PropertyMgr.values",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 29
},
{
"content": " def __setitem__(self, key, value):\n self._dict[key] = value\n setattr(self._parent, key, value)",
"metadata": "root.PropertyMgr.__setitem__",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 32
},
{
"content": " def __getitem__(self, key):\n try:\n answer = self._dict[key]\n except:\n answer = None\n return answer",
"metadata": "root.PropertyMgr.__getitem__",
"header": "['class', 'PropertyMgr', '(', 'object', ')', ':', '___EOS___']",
"index": 36
},
{
"content": "class BaseModuleDataItemMgr(PropertyMgr, QObject):\n \"\"\"\n abstract base class for modules controlling a DataItem\n \"\"\"\n name = \"BaseModuleDataItemMgr\"\n \n \n \n \n \n\n \n ",
"metadata": "root.BaseModuleDataItemMgr",
"header": "['module', '___EOS___']",
"index": 47
},
{
"content": " def __init__(self, dataItemImage):\n self.dataItem = dataItemImage \n PropertyMgr.__init__(self, dataItemImage)\n QObject.__init__(self)\n self.overlayReferences = OverlayReferenceMgr()\n self.globalMgr = None",
"metadata": "root.BaseModuleDataItemMgr.__init__",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 53
},
{
"content": " def onModuleStart(self):\n pass",
"metadata": "root.BaseModuleDataItemMgr.onModuleStart",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 60
},
{
"content": " def onModuleStop(self):\n pass",
"metadata": "root.BaseModuleDataItemMgr.onModuleStop",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 63
},
{
"content": " def getOverlayRefs(self):\n return self.overlayReferences",
"metadata": "root.BaseModuleDataItemMgr.getOverlayRefs",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 66
},
{
"content": " def insertOverlayRef(self, position, ov):\n self.overlayReferences.insert(position, ov)",
"metadata": "root.BaseModuleDataItemMgr.insertOverlayRef",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 69
},
{
"content": " def addOverlayRef(self, ov):\n if len(self.overlayReferences) >= 1:\n self.overlayReferences.insert(1, ov)\n else:\n self.overlayReferences.insert(0, ov)",
"metadata": "root.BaseModuleDataItemMgr.addOverlayRef",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 72
},
{
"content": " def serialize(self, h5g, destbegin = (0,0,0), destend = (0,0,0), srcbegin = (0,0,0), srcend = (0,0,0), destshape = (0,0,0) ):\n pass",
"metadata": "root.BaseModuleDataItemMgr.serialize",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 78
},
{
"content": " def deserialize(self, h5g, offsets, shape):\n pass",
"metadata": "root.BaseModuleDataItemMgr.deserialize",
"header": "['class', 'BaseModuleDataItemMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 81
},
{
"content": "class BaseModuleMgr(PropertyMgr, QObject):\n \"\"\"\n abstract base class for modules\n \"\"\"\n name = \"BaseModuleMgr\"\n \n \n \n \n \n \n \n \n ",
"metadata": "root.BaseModuleMgr",
"header": "['module', '___EOS___']",
"index": 90
},
{
"content": " def __init__(self, dataMgr):\n PropertyMgr.__init__(self, dataMgr)\n QObject.__init__(self)",
"metadata": "root.BaseModuleMgr.__init__",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 96
},
{
"content": " def onModuleStart(self):\n pass",
"metadata": "root.BaseModuleMgr.onModuleStart",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 100
},
{
"content": " def onModuleStop(self):\n pass",
"metadata": "root.BaseModuleMgr.onModuleStop",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 103
},
{
"content": " def onNewImage(self, dataItemImage):\n pass",
"metadata": "root.BaseModuleMgr.onNewImage",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 106
},
{
"content": " def onDeleteImage(self, dataItemImage):\n pass",
"metadata": "root.BaseModuleMgr.onDeleteImage",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 109
},
{
"content": " def computeResults(self, input):\n pass",
"metadata": "root.BaseModuleMgr.computeResults",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 112
},
{
"content": " def finalizeResults(self):\n pass",
"metadata": "root.BaseModuleMgr.finalizeResults",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 115
},
{
"content": " def serialize(self, h5g):\n pass",
"metadata": "root.BaseModuleMgr.serialize",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 118
},
{
"content": " def deserialize(self, h5g):\n pass ",
"metadata": "root.BaseModuleMgr.deserialize",
"header": "['class', 'BaseModuleMgr', '(', 'PropertyMgr', ',', 'QObject', ')', ':', '___EOS___']",
"index": 121
}
]
| [
{
"span": "def deserialize(self, h5g, offsets, shape):",
"start_line": 81,
"start_column": 4,
"end_line": 81,
"end_column": 47
},
{
"span": "def serialize(self, h5g):",
"start_line": 118,
"start_column": 4,
"end_line": 118,
"end_column": 29
},
{
"span": "def deserialize(self, h5g):",
"start_line": 121,
"start_column": 4,
"end_line": 121,
"end_column": 31
}
]
| [
{
"span": "def serialize(self, h5g, name):",
"start_line": 18,
"start_column": 4,
"end_line": 18,
"end_column": 35
},
{
"span": "def deserialize(self, h5g, name):",
"start_line": 23,
"start_column": 4,
"end_line": 23,
"end_column": 37
}
]
| 1 | false | [
"[CLS]_",
"Signature_",
"mismatch_",
"in_",
"overrid",
"ing_",
"method_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Hold",
"s",
" ",
"a",
" ",
"bag",
" ",
"of",
" ",
"Proper",
"ties",
" ",
"tha",
"t",
" ",
"can",
" ",
"be",
" ",
"serialize",
"d",
" ",
"and",
" ",
"deserialized",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"new",
" ",
"proper",
"ties",
" ",
"are",
" ",
"als",
"o",
" ",
"adde",
"d",
" ",
"to",
" ",
"the",
" ",
"parents",
" ",
"regular",
" ",
"attribute",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"for",
" ",
"easi",
"er",
" ",
"access",
"\\",
"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_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"parent_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"\\u",
"dict_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"parent_",
"=_",
"parent_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"serialize_",
"(_",
"self_",
",_",
"h5",
"g_",
",_",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"v_",
"in_",
"self_",
"._",
"values_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"v_",
",_",
"\"",
"serialize",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"v_",
"._",
"serialize_",
"(_",
"h5",
"g_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"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_",
"deserialize_",
"(_",
"self_",
",_",
"h5",
"g_",
",_",
"name_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"object_",
")_",
":_",
"\\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_",
"._",
"\\u",
"dict_",
"._",
"keys_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"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 ",
" _",
"return_",
"self_",
"._",
"\\u",
"dict_",
"._",
"values_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"object_",
")_",
":_",
"\\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 ",
" _",
"self_",
"._",
"\\u",
"dict_",
"[_",
"key_",
"]_",
"=_",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"setattr_",
"(_",
"self_",
"._",
"\\u",
"parent_",
",_",
"key_",
",_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Proper",
"ty",
"Mgr_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"getitem\\u\\u_",
"(_",
"self_",
",_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"answer_",
"=_",
"self_",
"._",
"\\u",
"dict_",
"[_",
"key_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"answer_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"answer_",
"\\u\\u\\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",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"abstract",
" ",
"base",
" ",
"class",
" ",
"for",
" ",
"module",
"s",
" ",
"controll",
"ing",
" ",
"a",
" ",
"Data",
"Item",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\"",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\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",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"data",
"Item",
"Image_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"data",
"Item_",
"=_",
"data",
"Item",
"Image_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Proper",
"ty",
"Mgr_",
"._",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"data",
"Item",
"Image_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"QO",
"bject_",
"._",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"overlay",
"Reference",
"s_",
"=_",
"Overla",
"y",
"Reference",
"Mgr_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"global",
"Mgr_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"on",
"Modul",
"e",
"Start_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"on",
"Modul",
"e",
"Stop_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Overla",
"y",
"Refs",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"overlay",
"Reference",
"s_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"insert",
"Overla",
"y",
"Ref_",
"(_",
"self_",
",_",
"position_",
",_",
"ov_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"overlay",
"Reference",
"s_",
"._",
"insert_",
"(_",
"position_",
",_",
"ov_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"add",
"Overla",
"y",
"Ref_",
"(_",
"self_",
",_",
"ov_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"len_",
"(_",
"self_",
"._",
"overlay",
"Reference",
"s_",
")_",
">=_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"overlay",
"Reference",
"s_",
"._",
"insert_",
"(_",
"1_",
",_",
"ov_",
")_",
"\\u\\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_",
"._",
"overlay",
"Reference",
"s_",
"._",
"insert_",
"(_",
"0_",
",_",
"ov_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\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_",
"serialize_",
"(_",
"self_",
",_",
"h5",
"g_",
",_",
"dest",
"begin_",
"=_",
"(_",
"0_",
",_",
"0_",
",_",
"0_",
")_",
",_",
"dest",
"end_",
"=_",
"(_",
"0_",
",_",
"0_",
",_",
"0_",
")_",
",_",
"src",
"begin_",
"=_",
"(_",
"0_",
",_",
"0_",
",_",
"0_",
")_",
",_",
"src",
"end_",
"=_",
"(_",
"0_",
",_",
"0_",
",_",
"0_",
")_",
",_",
"dest",
"shape_",
"=_",
"(_",
"0_",
",_",
"0_",
",_",
"0_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Data",
"Item",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"deserialize_",
"(_",
"self_",
",_",
"h5",
"g_",
",_",
"offsets_",
",_",
"shape_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"abstract",
" ",
"base",
" ",
"class",
" ",
"for",
" ",
"module",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"\"",
"Base",
"Modul",
"e",
"Mgr",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\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",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"data",
"Mgr_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"Proper",
"ty",
"Mgr_",
"._",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"data",
"Mgr_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"QO",
"bject_",
"._",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"on",
"Modul",
"e",
"Start_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"on",
"Modul",
"e",
"Stop_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"on",
"New",
"Image_",
"(_",
"self_",
",_",
"data",
"Item",
"Image_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"on",
"Delete",
"Image_",
"(_",
"self_",
",_",
"data",
"Item",
"Image_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"compute",
"Results_",
"(_",
"self_",
",_",
"input_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"finalize",
"Results_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"serialize_",
"(_",
"self_",
",_",
"h5",
"g_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Base",
"Modul",
"e",
"Mgr_",
"(_",
"Proper",
"ty",
"Mgr_",
",_",
"QO",
"bject_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"deserialize_",
"(_",
"self_",
",_",
"h5",
"g_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_"
]
| [
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2
]
|
Imprecise assert | crossbario/autobahn-python/autobahn/twisted/test/test_protocol.py | [
{
"content": " def test_connection_done(self):\n # pretend we connected\n self.proto._connectionMade()\n\n self.proto.connectionLost(Failure(ConnectionDone()))\n\n messages = ' '.join([str(x[1]) for x in self.proto.log.mock_calls])\n self.assertTrue('closed cleanly' in messages)",
"metadata": "root.ExceptionHandlingTests.test_connection_done",
"header": "['class', 'ExceptionHandlingTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 61
},
{
"content": " def test_connection_aborted(self):\n # pretend we connected\n self.proto._connectionMade()\n\n self.proto.connectionLost(Failure(ConnectionAborted()))\n\n messages = ' '.join([str(x[1]) for x in self.proto.log.mock_calls])\n self.assertTrue(' aborted ' in messages)",
"metadata": "root.ExceptionHandlingTests.test_connection_aborted",
"header": "['class', 'ExceptionHandlingTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 70
},
{
"content": " def test_connection_lost(self):\n # pretend we connected\n self.proto._connectionMade()\n\n self.proto.connectionLost(Failure(ConnectionLost()))\n\n messages = ' '.join([str(x[1]) for x in self.proto.log.mock_calls])\n self.assertTrue(' was lost ' in messages)",
"metadata": "root.ExceptionHandlingTests.test_connection_lost",
"header": "['class', 'ExceptionHandlingTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 79
},
{
"content": " def test_connection_lost_arg(self):\n # pretend we connected\n self.proto._connectionMade()\n\n self.proto.connectionLost(Failure(ConnectionLost(\"greetings\")))\n\n messages = ' '.join([str(x[1]) + str(x[2]) for x in self.proto.log.mock_calls])\n self.assertTrue(' was lost ' in messages)\n self.assertTrue('greetings' in messages)",
"metadata": "root.ExceptionHandlingTests.test_connection_lost_arg",
"header": "['class', 'ExceptionHandlingTests', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 88
}
]
| [
{
"span": "self.assertTrue('closed cleanly' in messages)",
"start_line": 68,
"start_column": 8,
"end_line": 68,
"end_column": 53
},
{
"span": "self.assertTrue(' aborted ' in messages)",
"start_line": 77,
"start_column": 8,
"end_line": 77,
"end_column": 48
},
{
"span": "self.assertTrue(' was lost ' in messages)",
"start_line": 86,
"start_column": 8,
"end_line": 86,
"end_column": 49
},
{
"span": "self.assertTrue(' was lost ' in messages)",
"start_line": 95,
"start_column": 8,
"end_line": 95,
"end_column": 49
},
{
"span": "self.assertTrue('greetings' in messages)",
"start_line": 96,
"start_column": 8,
"end_line": 96,
"end_column": 48
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Except",
"ion",
"Hand",
"ling",
"Tests_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"connecti",
"on",
"\\u",
"done_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"prete",
"nd",
" ",
"we",
" ",
"connected_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"proto_",
"._",
"\\u",
"connecti",
"on",
"Made",
"_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"proto_",
"._",
"connecti",
"on",
"Lost",
"_",
"(_",
"Failure_",
"(_",
"Connect",
"ion",
"Done_",
"(_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"messages_",
"=_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"[_",
"str_",
"(_",
"x_",
"[_",
"1_",
"]_",
")_",
"for_",
"x_",
"in_",
"self_",
"._",
"proto_",
"._",
"log_",
"._",
"mock",
"\\u",
"calls_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"close",
"d",
" ",
"clean",
"ly",
"'_",
"in_",
"messages_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Except",
"ion",
"Hand",
"ling",
"Tests_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"connecti",
"on",
"\\u",
"abort",
"ed_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"prete",
"nd",
" ",
"we",
" ",
"connected_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"proto_",
"._",
"\\u",
"connecti",
"on",
"Made",
"_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"proto_",
"._",
"connecti",
"on",
"Lost",
"_",
"(_",
"Failure_",
"(_",
"Connect",
"ion",
"Abo",
"rted",
"_",
"(_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"messages_",
"=_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"[_",
"str_",
"(_",
"x_",
"[_",
"1_",
"]_",
")_",
"for_",
"x_",
"in_",
"self_",
"._",
"proto_",
"._",
"log_",
"._",
"mock",
"\\u",
"calls_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
" ",
"abort",
"ed",
" ",
"'_",
"in_",
"messages_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Except",
"ion",
"Hand",
"ling",
"Tests_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"connecti",
"on",
"\\u",
"lost_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"prete",
"nd",
" ",
"we",
" ",
"connected_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"proto_",
"._",
"\\u",
"connecti",
"on",
"Made",
"_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"proto_",
"._",
"connecti",
"on",
"Lost",
"_",
"(_",
"Failure_",
"(_",
"Connect",
"ion",
"Lost",
"_",
"(_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"messages_",
"=_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"[_",
"str_",
"(_",
"x_",
"[_",
"1_",
"]_",
")_",
"for_",
"x_",
"in_",
"self_",
"._",
"proto_",
"._",
"log_",
"._",
"mock",
"\\u",
"calls_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
" ",
"was",
" ",
"lost",
" ",
"'_",
"in_",
"messages_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Except",
"ion",
"Hand",
"ling",
"Tests_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"connecti",
"on",
"\\u",
"lost",
"\\u",
"arg_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"prete",
"nd",
" ",
"we",
" ",
"connected_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"proto_",
"._",
"\\u",
"connecti",
"on",
"Made",
"_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"proto_",
"._",
"connecti",
"on",
"Lost",
"_",
"(_",
"Failure_",
"(_",
"Connect",
"ion",
"Lost",
"_",
"(_",
"\"",
"greeting",
"s",
"\"_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"messages_",
"=_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"[_",
"str_",
"(_",
"x_",
"[_",
"1_",
"]_",
")_",
"+_",
"str_",
"(_",
"x_",
"[_",
"2_",
"]_",
")_",
"for_",
"x_",
"in_",
"self_",
"._",
"proto_",
"._",
"log_",
"._",
"mock",
"\\u",
"calls_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
" ",
"was",
" ",
"lost",
" ",
"'_",
"in_",
"messages_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"greeting",
"s",
"'_",
"in_",
"messages_",
")_",
"\\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,
0,
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
2
]
|
Except block handles 'BaseException' | treeio/treeio/treeio/core/middleware/chat.py | [
{
"content": "def create_lock(key):\n try:\n while True:\n if cache.add(key + '_lock', '1', 10): # lifetime lock 10 seconds\n break\n return True\n except:\n print \"Error: \", sys.exc_info()\n return False",
"metadata": "root.create_lock",
"header": "['module', '___EOS___']",
"index": 32
},
{
"content": "def get_notifications(user):\n \"\"\"\n Return list notifications\n :param user: object user\n \"\"\"\n notifications = []\n try:\n user.id\n except:\n return []\n try:\n if not getattr(settings, 'HARDTREE_ALLOW_GRITTER_NOTIFICATIONS', False):\n return notifications\n request = HttpRequest()\n request.user = user\n storage = default_storage(request)\n for msg in storage._get()[0]:\n notifications.append({'message': msg.message,\n 'tags': msg._get_tags()})\n storage._store(None)\n except:\n pass\n return notifications",
"metadata": "root.get_notifications",
"header": "['module', '___EOS___']",
"index": 71
},
{
"content": "def get_user_profile(user):\n \"\"\"\n return user profile\n \"\"\"\n try:\n listeners = get_memcached(get_key(\"listeners\"))\n return listeners[user][\"profile\"]\n except:\n return user",
"metadata": "root.get_user_profile",
"header": "['module', '___EOS___']",
"index": 96
},
{
"content": "def update_user(user, location):\n \"\"\"\n update location and the last time request Users\n :param user: object user\n :param location: location user on site\n :type location: basestring\n \"\"\"\n try:\n listeners = get_memcached(get_key(\"listeners\"))\n _user_profile = str(user.profile)\n _user = str(user)\n listeners[_user] = {\n \"datetime\": datetime.now(), \"locations\": location, \"profile\": _user_profile}\n set_memcached(get_key(\"listeners\"), listeners)\n except:\n print \"Error: \", sys.exc_info()",
"metadata": "root.update_user",
"header": "['module', '___EOS___']",
"index": 107
},
{
"content": "def get_new_message_for_user(user, **kwargs):\n \"\"\"\n get_new_message_for_user(user, **kwargs) -> HTTPResponse(json(new_data))\n Return HTTP response to new data\n :type user: basestring\n \"\"\"\n def __update_data(_data):\n conferences = get_memcached(get_key(\"conferences\"))\n for key in conferences.keys():\n if user in conferences[key][\"users\"].keys():\n try:\n msg = conferences[key][\"users\"][user][\"messages\"]\n except:\n msg = []\n if msg:\n _data[\"new_data\"].append({key: {\"messages\": msg}})\n conferences[key][\"users\"][user][\"messages\"] = []\n set_memcached(get_key(\"conferences\"), conferences)\n notifications = get_notifications(kwargs[\"user_obj\"])\n if notifications:\n _data[\"notifications\"] = _data[\"notifications\"] + notifications\n return _data\n\n def __get_new_data():\n listeners = get_memcached(get_key(\"listeners\"))\n _new_data = {\n \"users\": [dict(name=key,\n location=listeners[key][\"locations\"],\n profile=listeners[key][\"profile\"]) for key in listeners.keys() if not key == str(user)],\n \"new_data\": [],\n \"conferences\": get_active_conferences(user),\n \"notifications\": get_notifications(kwargs[\"user_obj\"])\n }\n return _new_data.copy()\n\n if \"flag\" not in kwargs.keys():\n kwargs[\"flag\"] = None\n if \"long_polling\" not in kwargs.keys():\n kwargs[\"long_polling\"] = False\n if \"user_obj\" in kwargs.keys() and \"location\" in kwargs.keys():\n _location = kwargs['location']\n else:\n kwargs[\"user_obj\"] = None\n\n data = __get_new_data()\n\n if settings.CHAT_LONG_POLLING and kwargs[\"long_polling\"]:\n\n out_time = 0\n while not data[\"new_data\"] and out_time < settings.CHAT_TIMEOUT:\n\n if kwargs[\"user_obj\"]:\n if _location:\n update_user(kwargs[\"user_obj\"], _location)\n\n out_time += 1\n\n _temp_data = __get_new_data()\n _temp_data = __update_data(_temp_data)\n\n if not _temp_data == data:\n data = _temp_data.copy()\n break\n\n if kwargs[\"flag\"] == \"connect\":\n break\n\n if not _temp_data[\"new_data\"]:\n sleep(settings.CHAT_TIME_SLEEP_NEWDATA)\n else:\n data = _temp_data.copy()\n\n data = json.dumps(data)\n return HttpResponse(data, content_type='application/json', status=200)",
"metadata": "root.get_new_message_for_user",
"header": "['module', '___EOS___']",
"index": 292
},
{
"content": "def add_new_message(id, user, user_profile, text):\n \"\"\"\n Add new message\n :param id: ID conference\n :type id: basestring\n :type user: basestring\n :type user_profile: basestring\n :type text: basestring\n \"\"\"\n try:\n if not verification_user(id, user):\n return get_new_message_for_user(user)\n if checking_conference(id):\n conferences = get_memcached(get_key(\"conferences\"))\n for key in conferences[id][\"users\"].keys():\n conferences[id][\"users\"][key][\"messages\"].append(\n dict(user=user,\n text=text,\n time=strftime(\"%H:%M:%S\"),\n date=strftime(\"%Y-%m-%d\"),\n profile=user_profile)\n )\n set_memcached(get_key(\"conferences\"), conferences)\n except:\n data = json.dumps(\n {\"cmd\": \"Error\", \"data\": {\"msg\": str(sys.exc_info())}})\n return HttpResponse(data, content_type='application/json', status=200)\n\n return get_new_message_for_user(user)",
"metadata": "root.add_new_message",
"header": "['module', '___EOS___']",
"index": 368
},
{
"content": "def cmd(message, user):\n \"\"\"\n Handler AJAX query\n :param user: object user\n :param message: content POST\n :type message: basedict\n \"\"\"\n try:\n user_obj = user\n user_profile = str(user.profile)\n user = str(user).lower()\n data = json.loads(message[\"json\"])\n except:\n print \"error: \", sys.exc_info()\n data = json.dumps(\n {\"cmd\": \"Error\", \"data\": {\"msg\": str(sys.exc_info())}})\n return HttpResponse(data, content_type='application/json', status=200)\n\n try:\n\n update_user(user_obj, data['location'])\n\n if data['cmd'] == 'Connect':\n return connect(user_obj, data['location'])\n\n if data['cmd'] == 'Disconnect':\n return disconnect(user)\n\n if data['cmd'] == 'Get':\n return get_new_message_for_user(user, user_obj=user_obj, location=data['location'], long_polling=True)\n\n if data['cmd'] == 'Message':\n return add_new_message(data[\"data\"][\"id\"], user, user_profile, data[\"data\"][\"text\"])\n\n if data['cmd'] == 'Exit':\n return exit_from_conference(data[\"data\"][\"id\"], user)\n\n if data['cmd'] == 'Delete':\n return delete_conference(data['data']['id'], user)\n\n if data['cmd'] == 'Remove':\n return remove_users_in_conference(data['data']['id'], user, data['data']['users'])\n\n if data['cmd'] == 'Add':\n return add_users_in_conference(data['data']['id'], user, data['data']['users'])\n\n if data['cmd'] == 'Create':\n return create_conference(user, data['data']['users'], data['data']['title'])\n\n except:\n print \"Error: \", sys.exc_info()\n data = json.dumps(\n {\"cmd\": \"Error\", \"data\": {\"msg\": str(sys.exc_info())}})\n return HttpResponse(data, content_type='application/json', status=200)\n\n return HttpResponse(json.dumps({\"cmd\": \"Error\", \"data\": {\"msg\": \"unknown command\"}}),\n content_type='application/json', status=200)",
"metadata": "root.cmd",
"header": "['module', '___EOS___']",
"index": 412
}
]
| [
{
"span": "except:",
"start_line": 38,
"start_column": 4,
"end_line": 38,
"end_column": 11
},
{
"span": "except:",
"start_line": 79,
"start_column": 4,
"end_line": 79,
"end_column": 11
},
{
"span": "except:",
"start_line": 91,
"start_column": 4,
"end_line": 91,
"end_column": 11
},
{
"span": "except:",
"start_line": 103,
"start_column": 4,
"end_line": 103,
"end_column": 11
},
{
"span": "except:",
"start_line": 121,
"start_column": 4,
"end_line": 121,
"end_column": 11
},
{
"span": "except:",
"start_line": 304,
"start_column": 16,
"end_line": 304,
"end_column": 23
},
{
"span": "except:",
"start_line": 391,
"start_column": 4,
"end_line": 391,
"end_column": 11
},
{
"span": "except:",
"start_line": 424,
"start_column": 4,
"end_line": 424,
"end_column": 11
},
{
"span": "except:",
"start_line": 461,
"start_column": 4,
"end_line": 461,
"end_column": 11
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"create",
"\\u",
"lock_",
"(_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"while_",
"True_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"cache_",
"._",
"add_",
"(_",
"key_",
"+_",
"'\\u",
"lock",
"'_",
",_",
"'",
"1",
"'_",
",_",
"10_",
")_",
":_",
"#",
" ",
"life",
"time",
" ",
"lock",
" ",
"10",
" ",
"seconds_",
"\\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_",
"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 ",
" _",
"print_",
"\"",
"Error",
":",
" ",
"\"_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"notifications_",
"(_",
"user_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"list",
" ",
"notification",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"param",
" ",
"user",
":",
" ",
"object",
" ",
"user",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"notifications_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"user_",
"._",
"id_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"getattr_",
"(_",
"settings_",
",_",
"'",
"HARD",
"TREE",
"\\u",
"ALLOW",
"\\u",
"GRI",
"TT",
"ER",
"\\u",
"NOTIFICATION",
"S",
"'_",
",_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"notifications_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"request_",
"=_",
"Http",
"Request_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"request_",
"._",
"user_",
"=_",
"user_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"storage_",
"=_",
"default",
"\\u",
"storage_",
"(_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"msg_",
"in_",
"storage_",
"._",
"\\u",
"get_",
"(_",
")_",
"[_",
"0_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"notifications_",
"._",
"append_",
"(_",
"{_",
"'",
"message",
"'_",
":_",
"msg_",
"._",
"message_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"tags",
"'_",
":_",
"msg_",
"._",
"\\u",
"get",
"\\u",
"tags_",
"(_",
")_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"storage_",
"._",
"\\u",
"store_",
"(_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"notifications_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"user",
"\\u",
"profile_",
"(_",
"user_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"return",
" ",
"user",
" ",
"profile",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"listeners_",
"=_",
"get",
"\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"listeners",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"listeners_",
"[_",
"user_",
"]_",
"[_",
"\"",
"profile",
"\"_",
"]_",
"\\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_",
"user_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"update",
"\\u",
"user_",
"(_",
"user_",
",_",
"location_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"update",
" ",
"location",
" ",
"and",
" ",
"the",
" ",
"last",
" ",
"time",
" ",
"request",
" ",
"User",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"param",
" ",
"user",
":",
" ",
"object",
" ",
"user",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"param",
" ",
"location",
":",
" ",
"location",
" ",
"user",
" ",
"on",
" ",
"site",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"location",
":",
" ",
"basest",
"ring",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"listeners_",
"=_",
"get",
"\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"listeners",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"user",
"\\u",
"profile_",
"=_",
"str_",
"(_",
"user_",
"._",
"profile_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"user_",
"=_",
"str_",
"(_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"listeners_",
"[_",
"\\u",
"user_",
"]_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"datetime",
"\"_",
":_",
"datetime_",
"._",
"now_",
"(_",
")_",
",_",
"\"",
"location",
"s",
"\"_",
":_",
"location_",
",_",
"\"",
"profile",
"\"_",
":_",
"\\u",
"user",
"\\u",
"profile_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"listeners",
"\"_",
")_",
",_",
"listeners_",
")_",
"\\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",
":",
" ",
"\"_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"new",
"\\u",
"message",
"\\u",
"for",
"\\u",
"user_",
"(_",
"user_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"get",
"\\u",
"new",
"\\u",
"message",
"\\u",
"for",
"\\u",
"user",
"(",
"user",
",",
" ",
"**",
"kwarg",
"s",
")",
" ",
"->",
" ",
"HTTP",
"Respons",
"e",
"(",
"json",
"(",
"new",
"\\u",
"data",
"))\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
" ",
"HTTP",
" ",
"response",
" ",
"to",
" ",
"new",
" ",
"data",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"user",
":",
" ",
"basest",
"ring",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"update",
"\\u",
"data_",
"(_",
"\\u",
"data_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"conference",
"s_",
"=_",
"get",
"\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"conference",
"s",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"key_",
"in_",
"conference",
"s_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"user_",
"in_",
"conference",
"s_",
"[_",
"key_",
"]_",
"[_",
"\"",
"users",
"\"_",
"]_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"msg_",
"=_",
"conference",
"s_",
"[_",
"key_",
"]_",
"[_",
"\"",
"users",
"\"_",
"]_",
"[_",
"user_",
"]_",
"[_",
"\"",
"message",
"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 ",
" ",
"_",
"msg_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"msg_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"\\u",
"data_",
"[_",
"\"",
"new",
"\\u",
"data",
"\"_",
"]_",
"._",
"append_",
"(_",
"{_",
"key_",
":_",
"{_",
"\"",
"message",
"s",
"\"_",
":_",
"msg_",
"}_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"conference",
"s_",
"[_",
"key_",
"]_",
"[_",
"\"",
"users",
"\"_",
"]_",
"[_",
"user_",
"]_",
"[_",
"\"",
"message",
"s",
"\"_",
"]_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"set\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"conference",
"s",
"\"_",
")_",
",_",
"conference",
"s_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"notifications_",
"=_",
"get",
"\\u",
"notifications_",
"(_",
"kwargs_",
"[_",
"\"",
"user",
"\\u",
"obj",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"notifications_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"data_",
"[_",
"\"",
"notification",
"s",
"\"_",
"]_",
"=_",
"\\u",
"data_",
"[_",
"\"",
"notification",
"s",
"\"_",
"]_",
"+_",
"notifications_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"\\u",
"data_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"get",
"\\u",
"new",
"\\u",
"data_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"listeners_",
"=_",
"get",
"\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"listeners",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"new",
"\\u",
"data_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"users",
"\"_",
":_",
"[_",
"dict_",
"(_",
"name_",
"=_",
"key_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"location_",
"=_",
"listeners_",
"[_",
"key_",
"]_",
"[_",
"\"",
"location",
"s",
"\"_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"profile_",
"=_",
"listeners_",
"[_",
"key_",
"]_",
"[_",
"\"",
"profile",
"\"_",
"]_",
")_",
"for_",
"key_",
"in_",
"listeners_",
"._",
"keys_",
"(_",
")_",
"if_",
"not_",
"key_",
"==_",
"str_",
"(_",
"user_",
")_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"new",
"\\u",
"data",
"\"_",
":_",
"[_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"conference",
"s",
"\"_",
":_",
"get",
"\\u",
"active",
"\\u",
"conference",
"s_",
"(_",
"user_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"notification",
"s",
"\"_",
":_",
"get",
"\\u",
"notifications_",
"(_",
"kwargs_",
"[_",
"\"",
"user",
"\\u",
"obj",
"\"_",
"]_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u",
"new",
"\\u",
"data_",
"._",
"copy_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\"",
"flag",
"\"_",
"not_",
"in_",
"kwargs_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"kwargs_",
"[_",
"\"",
"flag",
"\"_",
"]_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\"",
"long",
"\\u",
"polling",
"\"_",
"not_",
"in_",
"kwargs_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"kwargs_",
"[_",
"\"",
"long",
"\\u",
"polling",
"\"_",
"]_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\"",
"user",
"\\u",
"obj",
"\"_",
"in_",
"kwargs_",
"._",
"keys_",
"(_",
")_",
"and_",
"\"",
"location",
"\"_",
"in_",
"kwargs_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"location_",
"=_",
"kwargs_",
"[_",
"'",
"location",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"kwargs_",
"[_",
"\"",
"user",
"\\u",
"obj",
"\"_",
"]_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"data_",
"=_",
"\\u\\u",
"get",
"\\u",
"new",
"\\u",
"data_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"settings_",
"._",
"CHAT",
"\\u",
"LONG",
"\\u",
"POLL",
"ING_",
"and_",
"kwargs_",
"[_",
"\"",
"long",
"\\u",
"polling",
"\"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"out",
"\\u",
"time_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"not_",
"data_",
"[_",
"\"",
"new",
"\\u",
"data",
"\"_",
"]_",
"and_",
"out",
"\\u",
"time_",
"<_",
"settings_",
"._",
"CHAT",
"\\u",
"TIMEOUT_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"kwargs_",
"[_",
"\"",
"user",
"\\u",
"obj",
"\"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"\\u",
"location_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"update",
"\\u",
"user_",
"(_",
"kwargs_",
"[_",
"\"",
"user",
"\\u",
"obj",
"\"_",
"]_",
",_",
"\\u",
"location_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"out",
"\\u",
"time_",
"+=_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u",
"temp",
"\\u",
"data_",
"=_",
"\\u\\u",
"get",
"\\u",
"new",
"\\u",
"data_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"temp",
"\\u",
"data_",
"=_",
"\\u\\u",
"update",
"\\u",
"data_",
"(_",
"\\u",
"temp",
"\\u",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"not_",
"\\u",
"temp",
"\\u",
"data_",
"==_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"\\u",
"temp",
"\\u",
"data_",
"._",
"copy_",
"(_",
")_",
"\\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_",
"if_",
"kwargs_",
"[_",
"\"",
"flag",
"\"_",
"]_",
"==_",
"\"",
"connect",
"\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"break_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"\\u",
"temp",
"\\u",
"data_",
"[_",
"\"",
"new",
"\\u",
"data",
"\"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"sleep_",
"(_",
"settings_",
"._",
"CHAT",
"\\u",
"TIME",
"\\u",
"SLEEP",
"\\u",
"NEW",
"DATA_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"\\u",
"temp",
"\\u",
"data_",
"._",
"copy_",
"(_",
")_",
"\\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_",
"data_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Http",
"Response_",
"(_",
"data_",
",_",
"content",
"\\u",
"type_",
"=_",
"'",
"applica",
"tion",
"/",
"json",
"'_",
",_",
"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_",
"def_",
"add",
"\\u",
"new",
"\\u",
"message_",
"(_",
"id_",
",_",
"user_",
",_",
"user",
"\\u",
"profile_",
",_",
"text_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Add",
" ",
"new",
" ",
"message",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"param",
" ",
"id",
":",
" ",
"ID",
" ",
"conference",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"id",
":",
" ",
"basest",
"ring",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"user",
":",
" ",
"basest",
"ring",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"user",
"\\u",
"profile",
":",
" ",
"basest",
"ring",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"text",
":",
" ",
"basest",
"ring",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"verification",
"\\u",
"user_",
"(_",
"id_",
",_",
"user_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"get",
"\\u",
"new",
"\\u",
"message",
"\\u",
"for",
"\\u",
"user_",
"(_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"checking",
"\\u",
"conference_",
"(_",
"id_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"conference",
"s_",
"=_",
"get",
"\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"conference",
"s",
"\"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"key_",
"in_",
"conference",
"s_",
"[_",
"id_",
"]_",
"[_",
"\"",
"users",
"\"_",
"]_",
"._",
"keys_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"conference",
"s_",
"[_",
"id_",
"]_",
"[_",
"\"",
"users",
"\"_",
"]_",
"[_",
"key_",
"]_",
"[_",
"\"",
"message",
"s",
"\"_",
"]_",
"._",
"append_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"dict_",
"(_",
"user_",
"=_",
"user_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"text_",
"=_",
"text_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"time_",
"=_",
"strftime_",
"(_",
"\"%",
"H",
":",
"%",
"M",
":",
"%",
"S",
"\"_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"date_",
"=_",
"strftime_",
"(_",
"\"%",
"Y",
"-%",
"m",
"-%",
"d",
"\"_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"profile_",
"=_",
"user",
"\\u",
"profile_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"set\\u",
"memcached",
"_",
"(_",
"get",
"\\u",
"key_",
"(_",
"\"",
"conference",
"s",
"\"_",
")_",
",_",
"conference",
"s_",
")_",
"\\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 ",
" _",
"data_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"{_",
"\"",
"cmd",
"\"_",
":_",
"\"",
"Error",
"\"_",
",_",
"\"",
"data",
"\"_",
":_",
"{_",
"\"",
"msg",
"\"_",
":_",
"str_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"}_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Http",
"Response_",
"(_",
"data_",
",_",
"content",
"\\u",
"type_",
"=_",
"'",
"applica",
"tion",
"/",
"json",
"'_",
",_",
"status_",
"=_",
"200_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"get",
"\\u",
"new",
"\\u",
"message",
"\\u",
"for",
"\\u",
"user_",
"(_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"cmd_",
"(_",
"message_",
",_",
"user_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Handle",
"r",
" ",
"AJ",
"AX",
" ",
"query",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"param",
" ",
"user",
":",
" ",
"object",
" ",
"user",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"param",
" ",
"message",
":",
" ",
"content",
" ",
"POST",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
":",
"type",
" ",
"message",
":",
" ",
"based",
"ict",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"user",
"\\u",
"obj_",
"=_",
"user_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"user",
"\\u",
"profile_",
"=_",
"str_",
"(_",
"user_",
"._",
"profile_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"user_",
"=_",
"str_",
"(_",
"user_",
")_",
"._",
"lower_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"=_",
"json_",
"._",
"loads_",
"(_",
"message_",
"[_",
"\"",
"json",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"\"",
"error",
":",
" ",
"\"_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"{_",
"\"",
"cmd",
"\"_",
":_",
"\"",
"Error",
"\"_",
",_",
"\"",
"data",
"\"_",
":_",
"{_",
"\"",
"msg",
"\"_",
":_",
"str_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"}_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Http",
"Response_",
"(_",
"data_",
",_",
"content",
"\\u",
"type_",
"=_",
"'",
"applica",
"tion",
"/",
"json",
"'_",
",_",
"status_",
"=_",
"200_",
")_",
"\\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\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"update",
"\\u",
"user_",
"(_",
"user",
"\\u",
"obj_",
",_",
"data_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Connect",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"connect_",
"(_",
"user",
"\\u",
"obj_",
",_",
"data_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Disconnect",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"disconnect_",
"(_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Get",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"get",
"\\u",
"new",
"\\u",
"message",
"\\u",
"for",
"\\u",
"user_",
"(_",
"user_",
",_",
"user",
"\\u",
"obj_",
"=_",
"user",
"\\u",
"obj_",
",_",
"location_",
"=_",
"data_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"long",
"\\u",
"polling",
"_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Messag",
"e",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"add",
"\\u",
"new",
"\\u",
"message_",
"(_",
"data_",
"[_",
"\"",
"data",
"\"_",
"]_",
"[_",
"\"",
"id",
"\"_",
"]_",
",_",
"user_",
",_",
"user",
"\\u",
"profile_",
",_",
"data_",
"[_",
"\"",
"data",
"\"_",
"]_",
"[_",
"\"",
"text",
"\"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Exi",
"t",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"exit",
"\\u",
"from",
"\\u",
"conference_",
"(_",
"data_",
"[_",
"\"",
"data",
"\"_",
"]_",
"[_",
"\"",
"id",
"\"_",
"]_",
",_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Delete",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"delete",
"\\u",
"conference_",
"(_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"id",
"'_",
"]_",
",_",
"user_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Remove",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"remove",
"\\u",
"users",
"\\u",
"in",
"\\u",
"conference_",
"(_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"id",
"'_",
"]_",
",_",
"user_",
",_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"users",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Add",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"add",
"\\u",
"users",
"\\u",
"in",
"\\u",
"conference_",
"(_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"id",
"'_",
"]_",
",_",
"user_",
",_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"users",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"data_",
"[_",
"'",
"cmd",
"'_",
"]_",
"==_",
"'",
"Creat",
"e",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"create",
"\\u",
"conference_",
"(_",
"user_",
",_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"users",
"'_",
"]_",
",_",
"data_",
"[_",
"'",
"data",
"'_",
"]_",
"[_",
"'",
"title",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"\"",
"Error",
":",
" ",
"\"_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"{_",
"\"",
"cmd",
"\"_",
":_",
"\"",
"Error",
"\"_",
",_",
"\"",
"data",
"\"_",
":_",
"{_",
"\"",
"msg",
"\"_",
":_",
"str_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"}_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"Http",
"Response_",
"(_",
"data_",
",_",
"content",
"\\u",
"type_",
"=_",
"'",
"applica",
"tion",
"/",
"json",
"'_",
",_",
"status_",
"=_",
"200_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"Http",
"Response_",
"(_",
"json_",
"._",
"dumps_",
"(_",
"{_",
"\"",
"cmd",
"\"_",
":_",
"\"",
"Error",
"\"_",
",_",
"\"",
"data",
"\"_",
":_",
"{_",
"\"",
"msg",
"\"_",
":_",
"\"",
"unknown",
" ",
"command",
"\"_",
"}_",
"}_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"content",
"\\u",
"type_",
"=_",
"'",
"applica",
"tion",
"/",
"json",
"'_",
",_",
"status_",
"=_",
"200_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,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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
]
|
Except block handles 'BaseException' | DTVD/rainbowstream/rainbowstream/config.py | [
{
"content": "def get_all_config():\n \"\"\"\n Get all config\n \"\"\"\n try:\n path = os.path.expanduser(\"~\") + os.sep + '.rainbow_config.json'\n data = load_config(path)\n # Hard to set from prompt\n data.pop('ONLY_LIST', None)\n data.pop('IGNORE_LIST', None)\n data.pop('FORMAT', None)\n data.pop('QUOTE_FORMAT', None)\n data.pop('NOTIFY_FORMAT', None)\n return data\n except:\n return []",
"metadata": "root.get_all_config",
"header": "['module', '___EOS___']",
"index": 40
},
{
"content": "def set_config(key, value):\n \"\"\"\n Set a config key with specific value\n \"\"\"\n # Modify value\n if value.isdigit():\n value = int(value)\n elif value.lower() == 'true':\n value = True\n elif value.lower() == 'false':\n value = False\n # Update global config\n c[key] = value\n # Load current user config\n path = os.path.expanduser(\"~\") + os.sep + '.rainbow_config.json'\n data = {}\n try:\n data = load_config(path)\n except:\n return\n # Update config file\n if key in data:\n fixup(data, key, value)\n else:\n data[key] = value\n # Save\n with open(path, 'w') as out:\n json.dump(data, out, indent=4)\n os.system('chmod 777 ' + path)",
"metadata": "root.set_config",
"header": "['module', '___EOS___']",
"index": 77
},
{
"content": "def delete_config(key):\n \"\"\"\n Delete a config key\n \"\"\"\n path = os.path.expanduser(\"~\") + os.sep + '.rainbow_config.json'\n try:\n data = load_config(path)\n except:\n raise Exception('Config file is messed up.')\n # Drop key\n if key in data and key in c:\n data.pop(key)\n c.pop(key)\n try:\n data[key] = c[key] = get_default_config(key)\n except:\n pass\n else:\n raise Exception('No such config key.')\n # Save\n with open(path, 'w') as out:\n json.dump(data, out, indent=4)\n os.system('chmod 777 ' + path)",
"metadata": "root.delete_config",
"header": "['module', '___EOS___']",
"index": 108
},
{
"content": "def init_config():\n \"\"\"\n Init configuration\n \"\"\"\n # Load the initial config\n config = os.path.dirname(__file__) + \\\n '/colorset/config'\n try:\n data = load_config(config)\n for d in data:\n c[d] = data[d]\n except:\n pass\n # Load user's config\n rainbow_config = os.path.expanduser(\"~\") + os.sep + '.rainbow_config.json'\n try:\n data = load_config(rainbow_config)\n for d in data:\n c[d] = data[d]\n except (IOError, ValueError) as e:\n c['USER_JSON_ERROR'] = str(e)\n # Load default theme\n theme_file = os.path.dirname(__file__) + \\\n '/colorset/' + c['THEME'] + '.json'\n try:\n data = load_config(theme_file)\n for d in data:\n c[d] = data[d]\n except:\n pass",
"metadata": "root.init_config",
"header": "['module', '___EOS___']",
"index": 147
}
]
| [
{
"span": "except:",
"start_line": 54,
"start_column": 4,
"end_line": 54,
"end_column": 11
},
{
"span": "except:",
"start_line": 95,
"start_column": 4,
"end_line": 95,
"end_column": 11
},
{
"span": "except:",
"start_line": 123,
"start_column": 8,
"end_line": 123,
"end_column": 15
},
{
"span": "except:",
"start_line": 158,
"start_column": 4,
"end_line": 158,
"end_column": 11
},
{
"span": "except:",
"start_line": 175,
"start_column": 4,
"end_line": 175,
"end_column": 11
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"all",
"\\u",
"config_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Get",
" ",
"all",
" ",
"config",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"path_",
"=_",
"os_",
"._",
"path_",
"._",
"expanduser_",
"(_",
"\"~\"_",
")_",
"+_",
"os_",
"._",
"sep_",
"+_",
"'.",
"rain",
"bow",
"\\u",
"config",
".",
"json",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"=_",
"load",
"\\u",
"config_",
"(_",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Hard",
" ",
"to",
" ",
"set",
" ",
"from",
" ",
"prompt_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"._",
"pop_",
"(_",
"'",
"ONL",
"Y",
"\\u",
"LIST",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"._",
"pop_",
"(_",
"'",
"IGNORE",
"\\u",
"LIST",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"._",
"pop_",
"(_",
"'",
"FORMAT",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"._",
"pop_",
"(_",
"'",
"QUOTE",
"\\u",
"FORMAT",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"._",
"pop_",
"(_",
"'",
"NOTIF",
"Y",
"\\u",
"FORMAT",
"'_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"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 ",
" _",
"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_",
"set\\u",
"config_",
"(_",
"key_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Set",
" ",
"a",
" ",
"config",
" ",
"key",
" ",
"with",
" ",
"specific",
" ",
"value",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Modif",
"y",
" ",
"value_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"value_",
"._",
"isdigit_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"value_",
"=_",
"int_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"value_",
"._",
"lower_",
"(_",
")_",
"==_",
"'",
"true",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"value_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"value_",
"._",
"lower_",
"(_",
")_",
"==_",
"'",
"fal",
"se",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"value_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Update",
" ",
"global",
" ",
"config_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"c_",
"[_",
"key_",
"]_",
"=_",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Load",
" ",
"current",
" ",
"user",
" ",
"config_",
"\\u\\u\\uNL\\u\\u\\u_",
"path_",
"=_",
"os_",
"._",
"path_",
"._",
"expanduser_",
"(_",
"\"~\"_",
")_",
"+_",
"os_",
"._",
"sep_",
"+_",
"'.",
"rain",
"bow",
"\\u",
"config",
".",
"json",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load",
"\\u",
"config_",
"(_",
"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 ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Update",
" ",
"config",
" ",
"file_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"key_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fixup",
"_",
"(_",
"data_",
",_",
"key_",
",_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"[_",
"key_",
"]_",
"=_",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Save_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"path_",
",_",
"'",
"w",
"'_",
")_",
"as_",
"out_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"json_",
"._",
"dump_",
"(_",
"data_",
",_",
"out_",
",_",
"indent_",
"=_",
"4_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"os_",
"._",
"system_",
"(_",
"'",
"chm",
"od",
" ",
"777",
" ",
"'_",
"+_",
"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_",
"delete",
"\\u",
"config_",
"(_",
"key_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Delete",
" ",
"a",
" ",
"config",
" ",
"key",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"path_",
"=_",
"os_",
"._",
"path_",
"._",
"expanduser_",
"(_",
"\"~\"_",
")_",
"+_",
"os_",
"._",
"sep_",
"+_",
"'.",
"rain",
"bow",
"\\u",
"config",
".",
"json",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load",
"\\u",
"config_",
"(_",
"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 ",
" _",
"raise_",
"Exception_",
"(_",
"'",
"Config",
" ",
"file",
" ",
"is",
" ",
"mess",
"ed",
" ",
"up",
".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Drop",
" ",
"key_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"key_",
"in_",
"data_",
"and_",
"key_",
"in_",
"c_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"._",
"pop_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"c_",
"._",
"pop_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"[_",
"key_",
"]_",
"=_",
"c_",
"[_",
"key_",
"]_",
"=_",
"get",
"\\u",
"default",
"\\u",
"config_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Exception_",
"(_",
"'",
"No",
" ",
"suc",
"h",
" ",
"config",
" ",
"key",
".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Save_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"with_",
"open_",
"(_",
"path_",
",_",
"'",
"w",
"'_",
")_",
"as_",
"out_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"json_",
"._",
"dump_",
"(_",
"data_",
",_",
"out_",
",_",
"indent_",
"=_",
"4_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"os_",
"._",
"system_",
"(_",
"'",
"chm",
"od",
" ",
"777",
" ",
"'_",
"+_",
"path_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"init",
"\\u",
"config_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Ini",
"t",
" ",
"configura",
"tion",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Load",
" ",
"the",
" ",
"initial",
" ",
"config_",
"\\u\\u\\uNL\\u\\u\\u_",
"config_",
"=_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
"+_",
"'/",
"colors",
"et",
"/",
"config",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load",
"\\u",
"config_",
"(_",
"config_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"d_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"c_",
"[_",
"d_",
"]_",
"=_",
"data_",
"[_",
"d_",
"]_",
"\\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_",
"#",
" ",
"Load",
" ",
"user",
"'",
"s",
" ",
"config_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"rain",
"bow",
"\\u",
"config_",
"=_",
"os_",
"._",
"path_",
"._",
"expanduser_",
"(_",
"\"~\"_",
")_",
"+_",
"os_",
"._",
"sep_",
"+_",
"'.",
"rain",
"bow",
"\\u",
"config",
".",
"json",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load",
"\\u",
"config_",
"(_",
"rain",
"bow",
"\\u",
"config_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"d_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"c_",
"[_",
"d_",
"]_",
"=_",
"data_",
"[_",
"d_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"(_",
"IO",
"Error_",
",_",
"Value",
"Error_",
")_",
"as_",
"e_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"c_",
"[_",
"'",
"USER",
"\\u",
"JSO",
"N",
"\\u",
"ERROR",
"'_",
"]_",
"=_",
"str_",
"(_",
"e_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Load",
" ",
"default",
" ",
"theme_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"them",
"e\\u",
"file_",
"=_",
"os_",
"._",
"path_",
"._",
"dirname_",
"(_",
"\\u\\u",
"file\\u\\u_",
")_",
"+_",
"'/",
"colors",
"et",
"/'_",
"+_",
"c_",
"[_",
"'",
"THEME",
"'_",
"]_",
"+_",
"'.",
"json",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"load",
"\\u",
"config_",
"(_",
"them",
"e\\u",
"file_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"d_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"c_",
"[_",
"d_",
"]_",
"=_",
"data_",
"[_",
"d_",
"]_",
"\\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_"
]
| [
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,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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,
0,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
2,
2,
2,
2,
2
]
|
Except block handles 'BaseException' | ufora/ufora/ufora/FORA/python/PurePython/InMemoryExecutorTestCases.py | [
{
"content": " def test_slicing_operations_1(self):\n a = \"testing\"\n l = len(a)\n with self.create_executor() as fora:\n results = []\n def f(idx1, idx2):\n try:\n return (\"OK\", a[idx1:idx2])\n except:\n return \"FAIL\"\n\n for idx1 in range(-l - 1, l + 1):\n for idx2 in range(-l - 1, l + 1):\n results = results + [f(idx1, idx2)]\n\n return results\n\n self.equivalentEvaluationTest(f)",
"metadata": "root.InMemoryExecutorTestCases.test_slicing_operations_1",
"header": "['class', 'InMemoryExecutorTestCases', '(', 'ExecutorTestCases', '.', 'ExecutorTestCases', ')', ':', '___EOS___']",
"index": 220
},
{
"content": " def test_slicing_operations_2(self):\n a = \"abcdefg\"\n\n def f():\n l = len(a) + 1\n\n def trySlice(low,high,step):\n try:\n return (\"OK\", a[low:high:step])\n except:\n return \"FAIL\"\n\n result = []\n for idx1 in xrange(-l,l):\n for idx2 in xrange(-l,l):\n for idx3 in xrange(-l,l):\n if idx3 != 0:\n result = result + [trySlice(idx1, idx2, idx3)]\n return result\n\n self.equivalentEvaluationTest(f)",
"metadata": "root.InMemoryExecutorTestCases.test_slicing_operations_2",
"header": "['class', 'InMemoryExecutorTestCases', '(', 'ExecutorTestCases', '.', 'ExecutorTestCases', ')', ':', '___EOS___']",
"index": 239
}
]
| [
{
"span": "except:",
"start_line": 228,
"start_column": 16,
"end_line": 228,
"end_column": 23
},
{
"span": "except:",
"start_line": 248,
"start_column": 16,
"end_line": 248,
"end_column": 23
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"In",
"Memo",
"ry",
"Execut",
"or",
"Test",
"Cases_",
"(_",
"Execut",
"or",
"Test",
"Cases_",
"._",
"Execut",
"or",
"Test",
"Cases_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"slicing",
"\\u",
"operati",
"ons",
"\\u",
"1_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"a_",
"=_",
"\"",
"testi",
"ng",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"l_",
"=_",
"len_",
"(_",
"a_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"with_",
"self_",
"._",
"create",
"\\u",
"executor_",
"(_",
")_",
"as_",
"fora",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"results_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"f_",
"(_",
"idx1_",
",_",
"idx2_",
")_",
":_",
"\\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_",
"(_",
"\"",
"OK",
"\"_",
",_",
"a_",
"[_",
"idx1_",
":_",
"idx2_",
"]_",
")_",
"\\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_",
"\"",
"FAIL",
"\"_",
"\\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_",
"idx1_",
"in_",
"range_",
"(_",
"-_",
"l_",
"-_",
"1_",
",_",
"l_",
"+_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"idx2_",
"in_",
"range_",
"(_",
"-_",
"l_",
"-_",
"1_",
",_",
"l_",
"+_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"results_",
"=_",
"results_",
"+_",
"[_",
"f_",
"(_",
"idx1_",
",_",
"idx2_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"results_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"equivalent",
"Evaluati",
"on",
"Test_",
"(_",
"f_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"In",
"Memo",
"ry",
"Execut",
"or",
"Test",
"Cases_",
"(_",
"Execut",
"or",
"Test",
"Cases_",
"._",
"Execut",
"or",
"Test",
"Cases_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"slicing",
"\\u",
"operati",
"ons",
"\\u",
"2_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"a_",
"=_",
"\"",
"abcdefg",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"f_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"l_",
"=_",
"len_",
"(_",
"a_",
")_",
"+_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"try",
"Slice_",
"(_",
"low_",
",_",
"high_",
",_",
"step_",
")_",
":_",
"\\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_",
"(_",
"\"",
"OK",
"\"_",
",_",
"a_",
"[_",
"low_",
":_",
"high_",
":_",
"step_",
"]_",
")_",
"\\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_",
"\"",
"FAIL",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"result_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"idx1_",
"in_",
"xrange_",
"(_",
"-_",
"l_",
",_",
"l_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"idx2_",
"in_",
"xrange_",
"(_",
"-_",
"l_",
",_",
"l_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"for_",
"idx",
"3_",
"in_",
"xrange_",
"(_",
"-_",
"l_",
",_",
"l_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"if_",
"idx",
"3_",
"!=_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"result_",
"=_",
"result_",
"+_",
"[_",
"try",
"Slice_",
"(_",
"idx1_",
",_",
"idx2_",
",_",
"idx",
"3_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"result_",
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2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused import | django-oscar/django-oscar-accounts/sandbox/apps/shipping/repository.py | [
{
"content": "from decimal import Decimal as D\n\nfrom oscar.apps.shipping.methods import FixedPrice, NoShippingRequired\nfrom oscar.apps.shipping.repository import Repository as CoreRepository\n\n# Dummy shipping methods\nmethod1 = FixedPrice(D('10.00'))\nmethod1.code = 'method1'\nmethod1.description = 'Ship by van'\n\nmethod2 = FixedPrice(D('20.00'))\nmethod2.code = 'method2'\nmethod2.description = 'Ship by boat'\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class Repository(CoreRepository):\n methods = (method1, method2,)",
"metadata": "root.Repository",
"header": "['module', '___EOS___']",
"index": 15
}
]
| [
{
"span": "from oscar.apps.shipping.methods import FixedPrice, NoShippingRequired",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 70
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"from_",
"decimal_",
"import_",
"Decimal_",
"as_",
"D_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"osc",
"ar_",
"._",
"apps_",
"._",
"shipping",
"_",
"._",
"methods_",
"import_",
"Fix",
"ed",
"Price_",
",_",
"No",
"Ship",
"ping",
"Required_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"osc",
"ar_",
"._",
"apps_",
"._",
"shipping",
"_",
"._",
"repository_",
"import_",
"Repository_",
"as_",
"Core",
"Repository_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Du",
"mm",
"y",
" ",
"shipping",
" ",
"methods_",
"\\u\\u\\uNL\\u\\u\\u_",
"method",
"1_",
"=_",
"Fix",
"ed",
"Price_",
"(_",
"D_",
"(_",
"'",
"10.",
"00",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"method",
"1_",
"._",
"code_",
"=_",
"'",
"method",
"1",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"method",
"1_",
"._",
"description_",
"=_",
"'",
"Ship",
" ",
"by",
" ",
"van",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"method",
"2_",
"=_",
"Fix",
"ed",
"Price_",
"(_",
"D_",
"(_",
"'",
"20.",
"00",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"method",
"2_",
"._",
"code_",
"=_",
"'",
"method",
"2",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"method",
"2_",
"._",
"description_",
"=_",
"'",
"Ship",
" ",
"by",
" ",
"boat",
"'_",
"\\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_",
"Repository_",
"(_",
"Core",
"Repository_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"methods_",
"=_",
"(_",
"method",
"1_",
",_",
"method",
"2_",
",_",
")_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
4,
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 | neuropoly/spinalcordtoolbox/dev/control_points/linear_fitting.py | [
{
"content": "\nfrom mpl_toolkits.mplot3d import Axes3D\nimport matplotlib.pyplot as plt\nimport mpl_toolkits.mplot3d as m3d\nimport os\nimport numpy as np\nfrom scipy import ndimage\nfrom numpy import linalg\nimport nibabel\nimport splines_approximation_v2 as splinap\nfrom sklearn.metrics import mean_squared_error\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n returnSquaredErrors()",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def returnSquaredErrors(fname=None, div=None, size=None):\n if fname == None:\n #fname = 'centerlines/t250_half_sup_straight_seg_centerline.nii.gz'\n fname = 't234_crop_200_500_straight_centerline.nii.gz'\n file = nibabel.load(fname)\n data = file.get_data()\n p1, p2, p3 = splinap.getPxDimensions(fname)\n nx, ny, nz = splinap.getDim(fname)\n #os.remove(fname)\n\n\n\n print 'sizes: ', nx, ny, nx\n #x, y, x_fit, y_fit = fit(data, nz)\n\n '''\n print x, y, z\n fig1 = plt.figure()\n ax = Axes3D(fig1)\n ax.plot(x,y,z,'b:',zdir='z')\n plt.show()\n '''\n\n X,Y,Z = (data>0).nonzero()\n\n zmin = min(Z) + 10\n zmax = max(Z) - 10\n\n print \"min value element : \", zmin\n print \"max value element : \", zmax\n\n nz = zmax - zmin\n\n x = [0 for iz in range(0, nz, 1)]\n y = [0 for iz in range(0, nz, 1)]\n z = [iz for iz in range(0, nz, 1)]\n\n\n for iz in range(0, nz, 1):\n x[iz], y[iz] = ndimage.measurements.center_of_mass(np.array(data[:,:,iz + zmin]))\n\n\n x_fit,y_fit = get_good_centerline(nx, ny, nz)\n\n\n msx = mean_squared_error(x, x_fit)\n msy = mean_squared_error(y, y_fit)\n mean_ms = (msx+msy)/2\n\n #print x, x_fit\n #print y, y_fit\n\n fig1 = plt.figure()\n ax = Axes3D(fig1)\n ax.plot(x,y,z,zdir='z')\n ax.plot(x_fit,y_fit,z,zdir='z')\n plt.show()\n\n\n print msx, msy, mean_ms\n size_crop = splinap.getSize(x, y, z, p1, p2, p3)\n\n\n txt = open('results.txt', 'a')\n txt.write(str(div)+' '+str(int(round(size))/div)+' '+str(size_crop)+' '+str(size)+' '+str(msx)+' '+str(msy)+' '+' '+str(mean_ms)+' '+fname+'\\n')\n #txt.write(' plynomial_fitting '+str(size_crop)+' '+str(size)+' '+str(msx)+' '+str(msy)+' '+' '+str(mean_ms)+' '+fname+'\\n')\n\n\n txt.close()\n\n #splinap.plot(x_fit,y_fit, z, x, y, z, fname, int(round(size))/div)",
"metadata": "root.returnSquaredErrors",
"header": "['module', '___EOS___']",
"index": 13
},
{
"content": "def get_good_centerline (nx, ny,nz):\n x = [nx/2 for iz in range(0, nz, 1)]\n y = [ny/2 for iz in range(0, nz, 1)]\n return x,y",
"metadata": "root.get_good_centerline",
"header": "['module', '___EOS___']",
"index": 91
},
{
"content": "def fit(data, nz):\n x = [0 for iz in range(0, nz, 1)]\n y = [0 for iz in range(0, nz, 1)]\n z = [iz for iz in range(0, nz, 1)]\n\n for iz in range(0, nz, 1):\n x[iz], y[iz] = ndimage.measurements.center_of_mass(np.array(data[:,:,iz]))\n\n #Fit centerline in the Z-X plane using polynomial function\n print '\\nFit centerline in the Z-X plane using polynomial function...'\n coeffsx = np.polyfit(z, x, 1)\n polyx = np.poly1d(coeffsx)\n x_fit = np.polyval(polyx, z)\n print 'x_fit'\n print x_fit\n\n #Fit centerline in the Z-Y plane using polynomial function\n print '\\nFit centerline in the Z-Y plane using polynomial function...'\n coeffsy = np.polyfit(z, y, 1)\n polyy = np.poly1d(coeffsy)\n y_fit = np.polyval(polyy, z)\n\n\n #### 3D plot\n fig1 = plt.figure()\n ax = Axes3D(fig1)\n ax.plot(x,y,z,zdir='z')\n ax.plot(x_fit,y_fit,z,zdir='z')\n plt.show()\n return x, y, x_fit, y_fit\n\n \t#return x_centerline_fit,y_centerline_fit,z_centerline_fit",
"metadata": "root.fit",
"header": "['module', '___EOS___']",
"index": 97
}
]
| [
{
"span": "import mpl_toolkits.mplot3d as m3d",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 34
},
{
"span": "import os",
"start_line": 4,
"start_column": 0,
"end_line": 4,
"end_column": 9
},
{
"span": "from numpy import linalg",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 24
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"mpl",
"\\u",
"toolkits_",
"._",
"mplo",
"t3",
"d_",
"import_",
"Axe",
"s3",
"D_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"matplotlib_",
"._",
"pyplot_",
"as_",
"plt_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"mpl",
"\\u",
"toolkits_",
"._",
"mplo",
"t3",
"d_",
"as_",
"m3",
"d_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"numpy_",
"as_",
"np_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"scipy_",
"import_",
"ndimage_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"numpy_",
"import_",
"linalg_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"nib",
"abel_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"spline",
"s",
"\\u",
"approx",
"imat",
"ion",
"\\u",
"v2_",
"as_",
"spl",
"ina",
"p_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"sklearn_",
"._",
"metrics_",
"import_",
"mean",
"\\u",
"square",
"d\\u",
"error_",
"\\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\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\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 ",
" _",
"return",
"Square",
"d",
"Errors_",
"(_",
")_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"return",
"Square",
"d",
"Errors_",
"(_",
"fname_",
"=_",
"None_",
",_",
"div_",
"=_",
"None_",
",_",
"size_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"fname_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"fname",
" ",
"=",
" ",
"'",
"center",
"lines",
"/",
"t2",
"50",
"\\u",
"half",
"\\u",
"sup",
"\\u",
"straight",
"\\u",
"seg",
"\\u",
"center",
"line",
".",
"ni",
"i",
".",
"gz",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fname_",
"=_",
"'",
"t2",
"3",
"4",
"\\u",
"crop",
"\\u",
"200",
"\\u",
"500",
"\\u",
"straight",
"\\u",
"center",
"line",
".",
"ni",
"i",
".",
"gz",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"file_",
"=_",
"nib",
"abel_",
"._",
"load_",
"(_",
"fname_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
"=_",
"file_",
"._",
"get",
"\\u",
"data_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"p1_",
",_",
"p2_",
",_",
"p3_",
"=_",
"spl",
"ina",
"p_",
"._",
"get",
"Px",
"Dimensions_",
"(_",
"fname_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nx_",
",_",
"ny_",
",_",
"nz_",
"=_",
"spl",
"ina",
"p_",
"._",
"get",
"Dim_",
"(_",
"fname_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"os",
".",
"remove",
"(",
"fname",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"'",
"size",
"s",
":",
" ",
"'_",
",_",
"nx_",
",_",
"ny_",
",_",
"nx_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"x",
",",
" ",
"y",
",",
" ",
"x",
"\\u",
"fit",
",",
" ",
"y",
"\\u",
"fit",
" ",
"=",
" ",
"fit",
"(",
"data",
",",
" ",
"nz",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"print",
" ",
"x",
",",
" ",
"y",
",",
" ",
"z",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"fig",
"1",
" ",
"=",
" ",
"plt",
".",
"figure",
"()",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"ax",
" ",
"=",
" ",
"Axe",
"s3",
"D",
"(",
"fig",
"1",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"ax",
".",
"plot",
"(",
"x",
",",
"y",
",",
"z",
",'",
"b",
":'",
",",
"zd",
"ir",
"='",
"z",
"')",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"plt",
".",
"show",
"()",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"X_",
",_",
"Y_",
",_",
"Z_",
"=_",
"(_",
"data_",
">_",
"0_",
")_",
"._",
"nonzero_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"zmin",
"_",
"=_",
"min_",
"(_",
"Z_",
")_",
"+_",
"10_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"zmax",
"_",
"=_",
"max_",
"(_",
"Z_",
")_",
"-_",
"10_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"\"",
"min",
" ",
"value",
" ",
"element",
" ",
":",
" ",
"\"_",
",_",
"zmin",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"max",
" ",
"value",
" ",
"element",
" ",
":",
" ",
"\"_",
",_",
"zmax",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"nz_",
"=_",
"zmax",
"_",
"-_",
"zmin",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"x_",
"=_",
"[_",
"0_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"y_",
"=_",
"[_",
"0_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"z_",
"=_",
"[_",
"iz_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"[_",
"iz_",
"]_",
",_",
"y_",
"[_",
"iz_",
"]_",
"=_",
"ndimage_",
"._",
"measurements_",
"._",
"center",
"\\u",
"of",
"\\u",
"mass_",
"(_",
"np_",
"._",
"array_",
"(_",
"data_",
"[_",
":_",
",_",
":_",
",_",
"iz_",
"+_",
"zmin",
"_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"x",
"\\u",
"fit_",
",_",
"y",
"\\u",
"fit_",
"=_",
"get",
"\\u",
"good",
"\\u",
"center",
"line_",
"(_",
"nx_",
",_",
"ny_",
",_",
"nz_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"ms",
"x_",
"=_",
"mean",
"\\u",
"square",
"d\\u",
"error_",
"(_",
"x_",
",_",
"x",
"\\u",
"fit_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ms",
"y_",
"=_",
"mean",
"\\u",
"square",
"d\\u",
"error_",
"(_",
"y_",
",_",
"y",
"\\u",
"fit_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"mean",
"\\u",
"ms_",
"=_",
"(_",
"ms",
"x_",
"+_",
"ms",
"y_",
")_",
"/_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
" ",
"x",
",",
" ",
"x",
"\\u",
"fit_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
" ",
"y",
",",
" ",
"y",
"\\u",
"fit_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"fig",
"1_",
"=_",
"plt_",
"._",
"figure_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ax_",
"=_",
"Axe",
"s3",
"D_",
"(_",
"fig",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ax_",
"._",
"plot_",
"(_",
"x_",
",_",
"y_",
",_",
"z_",
",_",
"zd",
"ir_",
"=_",
"'",
"z",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ax_",
"._",
"plot_",
"(_",
"x",
"\\u",
"fit_",
",_",
"y",
"\\u",
"fit_",
",_",
"z_",
",_",
"zd",
"ir_",
"=_",
"'",
"z",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plt_",
"._",
"show_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"ms",
"x_",
",_",
"ms",
"y_",
",_",
"mean",
"\\u",
"ms_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"size",
"\\u",
"crop_",
"=_",
"spl",
"ina",
"p_",
"._",
"get",
"Size_",
"(_",
"x_",
",_",
"y_",
",_",
"z_",
",_",
"p1_",
",_",
"p2_",
",_",
"p3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"txt_",
"=_",
"open_",
"(_",
"'",
"results",
".",
"txt",
"'_",
",_",
"'",
"a",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"txt_",
"._",
"write_",
"(_",
"str_",
"(_",
"div_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"str_",
"(_",
"int_",
"(_",
"round_",
"(_",
"size_",
")_",
")_",
"/_",
"div_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"str_",
"(_",
"size",
"\\u",
"crop_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"str_",
"(_",
"size_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"str_",
"(_",
"ms",
"x_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"str_",
"(_",
"ms",
"y_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"'",
" ",
"'_",
"+_",
"str_",
"(_",
"mean",
"\\u",
"ms_",
")_",
"+_",
"'",
" ",
"'_",
"+_",
"fname_",
"+_",
"'\\\\",
"n",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"txt",
".",
"write",
"('",
" ",
"ply",
"nomi",
"al",
"\\u",
"fitting",
" ",
"'+",
"str",
"(",
"size",
"\\u",
"crop",
")+",
"'",
" ",
"'+",
"str",
"(",
"size",
")+",
"'",
" ",
"'+",
"str",
"(",
"ms",
"x",
")+",
"'",
" ",
"'+",
"str",
"(",
"ms",
"y",
")+",
"'",
" ",
"'+",
"'",
" ",
"'+",
"str",
"(",
"mean",
"\\u",
"ms",
")+",
"'",
" ",
"'+",
"fname",
"+'",
"\\\\",
"n",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"txt_",
"._",
"close_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"spl",
"ina",
"p",
".",
"plot",
"(",
"x",
"\\u",
"fit",
",",
"y",
"\\u",
"fit",
",",
" ",
"z",
",",
" ",
"x",
",",
" ",
"y",
",",
" ",
"z",
",",
" ",
"fname",
",",
" ",
"int",
"(",
"round",
"(",
"size",
"))",
"/",
"div",
")_",
"\\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_",
"get",
"\\u",
"good",
"\\u",
"center",
"line_",
"(_",
"nx_",
",_",
"ny_",
",_",
"nz_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"[_",
"nx_",
"/_",
"2_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"y_",
"=_",
"[_",
"ny_",
"/_",
"2_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"x_",
",_",
"y_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"fit_",
"(_",
"data_",
",_",
"nz_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"=_",
"[_",
"0_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"y_",
"=_",
"[_",
"0_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"z_",
"=_",
"[_",
"iz_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"iz_",
"in_",
"range_",
"(_",
"0_",
",_",
"nz_",
",_",
"1_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
"[_",
"iz_",
"]_",
",_",
"y_",
"[_",
"iz_",
"]_",
"=_",
"ndimage_",
"._",
"measurements_",
"._",
"center",
"\\u",
"of",
"\\u",
"mass_",
"(_",
"np_",
"._",
"array_",
"(_",
"data_",
"[_",
":_",
",_",
":_",
",_",
"iz_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Fit",
" ",
"center",
"line",
" ",
"in",
" ",
"the",
" ",
"Z",
"-",
"X",
" ",
"plane",
" ",
"usi",
"ng",
" ",
"polynomial",
" ",
"function_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"'\\\\",
"n",
"Fit",
" ",
"center",
"line",
" ",
"in",
" ",
"the",
" ",
"Z",
"-",
"X",
" ",
"plane",
" ",
"usi",
"ng",
" ",
"polynomial",
" ",
"function",
"...'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"coeffs",
"x_",
"=_",
"np_",
"._",
"polyf",
"it_",
"(_",
"z_",
",_",
"x_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"poly",
"x_",
"=_",
"np_",
"._",
"poly",
"1d_",
"(_",
"coeffs",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"x",
"\\u",
"fit_",
"=_",
"np_",
"._",
"poly",
"val_",
"(_",
"poly",
"x_",
",_",
"z_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"x",
"\\u",
"fit",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"x",
"\\u",
"fit_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Fit",
" ",
"center",
"line",
" ",
"in",
" ",
"the",
" ",
"Z",
"-",
"Y",
" ",
"plane",
" ",
"usi",
"ng",
" ",
"polynomial",
" ",
"function_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"'\\\\",
"n",
"Fit",
" ",
"center",
"line",
" ",
"in",
" ",
"the",
" ",
"Z",
"-",
"Y",
" ",
"plane",
" ",
"usi",
"ng",
" ",
"polynomial",
" ",
"function",
"...'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"coeffs",
"y_",
"=_",
"np_",
"._",
"polyf",
"it_",
"(_",
"z_",
",_",
"y_",
",_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"poly",
"y_",
"=_",
"np_",
"._",
"poly",
"1d_",
"(_",
"coeffs",
"y_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"y",
"\\u",
"fit_",
"=_",
"np_",
"._",
"poly",
"val_",
"(_",
"poly",
"y_",
",_",
"z_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"###",
"#",
" ",
"3",
"D",
" ",
"plot_",
"\\u\\u\\uNL\\u\\u\\u_",
"fig",
"1_",
"=_",
"plt_",
"._",
"figure_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ax_",
"=_",
"Axe",
"s3",
"D_",
"(_",
"fig",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ax_",
"._",
"plot_",
"(_",
"x_",
",_",
"y_",
",_",
"z_",
",_",
"zd",
"ir_",
"=_",
"'",
"z",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"ax_",
"._",
"plot_",
"(_",
"x",
"\\u",
"fit_",
",_",
"y",
"\\u",
"fit_",
",_",
"z_",
",_",
"zd",
"ir_",
"=_",
"'",
"z",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"plt_",
"._",
"show_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"x_",
",_",
"y_",
",_",
"x",
"\\u",
"fit_",
",_",
"y",
"\\u",
"fit_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"return",
" ",
"x",
"\\u",
"center",
"line",
"\\u",
"fit",
",",
"y",
"\\u",
"center",
"line",
"\\u",
"fit",
",",
"z",
"\\u",
"center",
"line",
"\\u",
"fit_",
"\\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,
0,
1,
1,
1,
1,
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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' | cimatosa/jobmanager/jobmanager/persistentData.py | [
{
"content": " def close(self):\n \"\"\"\n close the sqligtedict ans therefore the SQL database\n \"\"\"\n try:\n self.db.close()\n self._open = False\n if self.verbose > 1:\n print(\"closed db {} in {}\".format(self._name, self._dirname))\n except:\n if self.verbose > 1:\n print(\"db seem already closed {} in {}\".format(self._name, self._dirname))",
"metadata": "root.PersistentDataStructure.close",
"header": "['class', 'PersistentDataStructure', '(', 'object', ')', ':', '___EOS___']",
"index": 151
},
{
"content": " def erase(self):\n \"\"\"\n removed the database file from the disk\n \n this is called recursively for all sub PersistentDataStructure\n \"\"\"\n if self.verbose > 1:\n print(\"erase db {} in {}\".format(self._name, self._dirname)) \n\n if self.is_closed():\n self.open()\n \n try:\n\n if self.verbose > 1:\n print(\"sub_data_keys:\", self.sub_data_keys)\n for key in self:\n t, v = self.get_value_and_value_type(key)\n if t == TYPE_SUB:\n with self.getData(key) as sub_data:\n sub_data.erase()\n elif t == TYPE_NPA:\n os.remove(os.path.join(self._dirname, v['fname']))\n\n except:\n traceback.print_exc()\n finally:\n self.close()\n\n if self.verbose > 1:\n print(\"remove\", self._filename)\n os.remove(path = self._filename)\n try:\n os.rmdir(path = self._dirname)\n except OSError as e:\n if self.verbose > 0:\n warnings.warn(\"directory structure can not be deleted\\n{}\".format(e))",
"metadata": "root.PersistentDataStructure.erase",
"header": "['class', 'PersistentDataStructure', '(', 'object', ')', ':', '___EOS___']",
"index": 164
},
{
"content": " def __is_sub_data(self, value):\n \"\"\"\n determine if the value gotten from the sqlitedict refers\n to a sub PersistentDataStructure\n \n this is considered the case if the value itself has an index 'magic'\n whose value matches a magic sign defined by MAGIC_SIGN \n \"\"\"\n try:\n assert value['magic'] == MAGIC_SIGN\n return True\n except:\n return False",
"metadata": "root.PersistentDataStructure.__is_sub_data",
"header": "['class', 'PersistentDataStructure', '(', 'object', ')', ':', '___EOS___']",
"index": 267
},
{
"content": " def __is_nparray(self, value):\n \"\"\"\n determine if the value gotten from the sqlitedict refers\n to a numpy array which is stored in a seperate file\n \n this is considered the case if the value itself has an index 'magic'\n whose value matches a magic sign defined by MAGIC_SIGN_NPARRAY \n \"\"\"\n try:\n assert value['magic'] == MAGIC_SIGN_NPARRAY\n return True\n except:\n return False ",
"metadata": "root.PersistentDataStructure.__is_nparray",
"header": "['class', 'PersistentDataStructure', '(', 'object', ')', ':', '___EOS___']",
"index": 281
}
]
| [
{
"span": "except:",
"start_line": 160,
"start_column": 8,
"end_line": 160,
"end_column": 15
},
{
"span": "except:",
"start_line": 188,
"start_column": 8,
"end_line": 188,
"end_column": 15
},
{
"span": "except:",
"start_line": 278,
"start_column": 8,
"end_line": 278,
"end_column": 15
},
{
"span": "except:",
"start_line": 292,
"start_column": 8,
"end_line": 292,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Persisten",
"t",
"Data",
"Structure_",
"(_",
"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_",
"close_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"close",
" ",
"the",
" ",
"sql",
"ig",
"ted",
"ict",
" ",
"ans",
" ",
"there",
"fore",
" ",
"the",
" ",
"SQL",
" ",
"databa",
"se",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"db_",
"._",
"close_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"\\u",
"open_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"verbose_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"close",
"d",
" ",
"db",
" ",
" ",
" ",
" ",
" ",
" ",
"{}",
" ",
"in",
" ",
"{}\"_",
"._",
"format_",
"(_",
"self_",
"._",
"\\u",
"name_",
",_",
"self_",
"._",
"\\u",
"dirname_",
")_",
")_",
"\\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 ",
" _",
"if_",
"self_",
"._",
"verbose_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"db",
" ",
"see",
"m",
" ",
"alr",
"ead",
"y",
" ",
"close",
"d",
" ",
"{}",
" ",
"in",
" ",
"{}\"_",
"._",
"format_",
"(_",
"self_",
"._",
"\\u",
"name_",
",_",
"self_",
"._",
"\\u",
"dirname_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Persisten",
"t",
"Data",
"Structure_",
"(_",
"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_",
"erase_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"remove",
"d",
" ",
"the",
" ",
"databa",
"se",
" ",
"file",
" ",
"from",
" ",
"the",
" ",
"disk",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"this",
" ",
"is",
" ",
"call",
"ed",
" ",
"recurs",
"ively",
" ",
"for",
" ",
"all",
" ",
"sub",
" ",
"Persisten",
"t",
"Data",
"Structur",
"e",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"verbose_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"erase",
" ",
"db",
" ",
" ",
" ",
"{}",
" ",
"in",
" ",
"{}\"_",
"._",
"format_",
"(_",
"self_",
"._",
"\\u",
"name_",
",_",
"self_",
"._",
"\\u",
"dirname_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"is",
"\\u",
"closed_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"open_",
"(_",
")_",
"\\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\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"self_",
"._",
"verbose_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"sub\\u",
"data\\u",
"keys",
":\"_",
",_",
"self_",
"._",
"sub\\u",
"data\\u",
"keys_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"key_",
"in_",
"self_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"t_",
",_",
"v_",
"=_",
"self_",
"._",
"get",
"\\u",
"value",
"\\u",
"and",
"\\u",
"value",
"\\u",
"type_",
"(_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"t_",
"==_",
"TYPE",
"\\u",
"SUB",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"with_",
"self_",
"._",
"get",
"Data_",
"(_",
"key_",
")_",
"as_",
"sub\\u",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"sub\\u",
"data_",
"._",
"erase_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"t_",
"==_",
"TYPE",
"\\u",
"NP",
"A_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"os_",
"._",
"remove_",
"(_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"\\u",
"dirname_",
",_",
"v_",
"[_",
"'",
"fname",
"'_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"traceback_",
"._",
"print",
"\\u",
"exc_",
"(_",
")_",
"\\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 ",
" _",
"self_",
"._",
"close_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"verbose_",
">_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"\"",
"remove",
"\"_",
",_",
"self_",
"._",
"\\u",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"os_",
"._",
"remove_",
"(_",
"path_",
"=_",
"self_",
"._",
"\\u",
"filename_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"rmdir_",
"(_",
"path_",
"=_",
"self_",
"._",
"\\u",
"dirname_",
")_",
"\\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_",
"self_",
"._",
"verbose_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"warnings_",
"._",
"warn_",
"(_",
"\"",
"director",
"y",
" ",
"structure",
" ",
"can",
" ",
"not",
" ",
"be",
" ",
"delete",
"d",
"\\\\",
"n",
"{}\"_",
"._",
"format_",
"(_",
"e_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Persisten",
"t",
"Data",
"Structure_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"is",
"\\u",
"sub\\u",
"data_",
"(_",
"self_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"dete",
"rmin",
"e",
" ",
"if",
" ",
"the",
" ",
"value",
" ",
"got",
"ten",
" ",
"from",
" ",
"the",
" ",
"sql",
"ited",
"ict",
" ",
"refer",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"to",
" ",
"a",
" ",
"sub",
" ",
"Persisten",
"t",
"Data",
"Structur",
"e",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"this",
" ",
"is",
" ",
"consider",
"ed",
" ",
"the",
" ",
"case",
" ",
"if",
" ",
"the",
" ",
"value",
" ",
"its",
"elf",
" ",
"has",
" ",
"an",
" ",
"index",
" ",
"'",
"magic",
"'",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"who",
"se",
" ",
"value",
" ",
"matche",
"s",
" ",
"a",
" ",
"magic",
" ",
"sign",
" ",
"defin",
"ed",
" ",
"by",
" ",
"MAGIC",
"\\u",
"SIGN",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"assert_",
"value_",
"[_",
"'",
"magic",
"'_",
"]_",
"==_",
"MAGIC",
"\\u",
"SIGN",
"_",
"\\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_",
"Persisten",
"t",
"Data",
"Structure_",
"(_",
"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",
"is",
"\\u",
"npar",
"ray_",
"(_",
"self_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"dete",
"rmin",
"e",
" ",
"if",
" ",
"the",
" ",
"value",
" ",
"got",
"ten",
" ",
"from",
" ",
"the",
" ",
"sql",
"ited",
"ict",
" ",
"refer",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"to",
" ",
"a",
" ",
"nump",
"y",
" ",
"array",
" ",
"whi",
"ch",
" ",
"is",
" ",
"store",
"d",
" ",
"in",
" ",
"a",
" ",
"seperat",
"e",
" ",
"file",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"this",
" ",
"is",
" ",
"consider",
"ed",
" ",
"the",
" ",
"case",
" ",
"if",
" ",
"the",
" ",
"value",
" ",
"its",
"elf",
" ",
"has",
" ",
"an",
" ",
"index",
" ",
"'",
"magic",
"'",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"who",
"se",
" ",
"value",
" ",
"matche",
"s",
" ",
"a",
" ",
"magic",
" ",
"sign",
" ",
"defin",
"ed",
" ",
"by",
" ",
"MAGIC",
"\\u",
"SIGN",
"\\u",
"NP",
"ARR",
"AY",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"assert_",
"value_",
"[_",
"'",
"magic",
"'_",
"]_",
"==_",
"MAGIC",
"\\u",
"SIGN",
"\\u",
"NP",
"ARRAY_",
"\\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_"
]
| [
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,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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,
0,
1,
1,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | datamade/dedupe/dedupe/blocking.py | [
{
"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nfrom future.utils import viewitems, viewvalues\n\nfrom collections import defaultdict\nimport collections\nimport itertools\nimport logging\nimport time\n\nlogger = logging.getLogger(__name__)\n\n \n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class Blocker:\n '''Takes in a record and returns all blocks that record belongs to'''\n\n\n\n\n",
"metadata": "root.Blocker",
"header": "['module', '___EOS___']",
"index": 15
},
{
"content": " def __init__(self, predicates) :\n\n self.predicates = predicates\n\n self.index_fields = defaultdict(lambda:defaultdict(list))\n\n for full_predicate in predicates :\n for predicate in full_predicate :\n if hasattr(predicate, 'index') :\n self.index_fields[predicate.field][predicate.type].append(predicate)",
"metadata": "root.Blocker.__init__",
"header": "['class', 'Blocker', ':', '___EOS___']",
"index": 17
},
{
"content": " def __call__(self, records):\n\n start_time = time.clock()\n predicates = [(':' + str(i), predicate)\n for i, predicate\n in enumerate(self.predicates)]\n\n \n\n for i, record in enumerate(records) :\n record_id, instance = record\n\n for pred_id, predicate in predicates :\n block_keys = predicate(instance)\n for block_key in block_keys :\n yield block_key + pred_id, record_id\n \n if i and i % 10000 == 0 :\n logger.info('%(iteration)d, %(elapsed)f2 seconds',\n {'iteration' :i,\n 'elapsed' :time.clock() - start_time})",
"metadata": "root.Blocker.__call__",
"header": "['class', 'Blocker', ':', '___EOS___']",
"index": 28
},
{
"content": " def resetIndices(self) :\n # clear canopies to reduce memory usage\n for index_type in self.index_fields.values() :\n for predicates in index_type.values() :\n for predicate in predicates :\n predicate.index = None\n if hasattr(predicate, 'canopy') :\n predicate.canopy = {}",
"metadata": "root.Blocker.resetIndices",
"header": "['class', 'Blocker', ':', '___EOS___']",
"index": 50
},
{
"content": " def index(self, data, field): \n '''Creates TF/IDF index of a given set of data'''\n indices = extractIndices(self.index_fields[field])\n\n for doc in data :\n if doc :\n for _, index, preprocess in indices :\n index.index(preprocess(doc))\n\n for index_type, index, _ in indices :\n\n index.initSearch()\n\n for predicate in self.index_fields[field][index_type] :\n logger.info(\"Canopy: %s\", str(predicate))\n predicate.index = index",
"metadata": "root.Blocker.index",
"header": "['class', 'Blocker', ':', '___EOS___']",
"index": 59
},
{
"content": " def unindex(self, data, field) :\n '''Remove index of a given set of data'''\n indices = extractIndices(self.index_fields[field])\n\n for doc in data :\n if doc :\n for _, index, preprocess in indices :\n index.unindex(preprocess(doc))\n\n for index_type, index, _ in indices :\n\n index._index.initSearch()\n\n for predicate in self.index_fields[field][index_type] :\n logger.info(\"Canopy: %s\", str(predicate))\n predicate.index = index",
"metadata": "root.Blocker.unindex",
"header": "['class', 'Blocker', ':', '___EOS___']",
"index": 76
},
{
"content": " def indexAll(self, data_d) :\n for field in self.index_fields :\n unique_fields = {record[field]\n for record \n in viewvalues(data_d)\n if record[field]}\n self.index(unique_fields, field)",
"metadata": "root.Blocker.indexAll",
"header": "['class', 'Blocker', ':', '___EOS___']",
"index": 93
},
{
"content": "def extractIndices(index_fields) :\n \n indices = []\n for index_type, predicates in index_fields.items() :\n predicate = predicates[0]\n index = predicate.index\n preprocess = predicate.preprocess\n if predicate.index is None :\n index = predicate.initIndex()\n indices.append((index_type, index, preprocess))\n\n return indices",
"metadata": "root.extractIndices",
"header": "['module', '___EOS___']",
"index": 102
}
]
| [
{
"span": "from future.utils import viewitems, viewvalues",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 46
},
{
"span": "import collections",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 18
},
{
"span": "import itertools",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 16
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#!",
"/",
"usr",
"/",
"bin",
"/",
"python_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"-*-",
" ",
"codi",
"ng",
":",
" ",
"utf",
"-",
"8",
" ",
"-*-",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"future_",
"._",
"utils_",
"import_",
"view",
"items_",
",_",
"view",
"values_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"collections_",
"import_",
"defaultdict_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"collections_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"itertools_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"logging_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"logger_",
"=_",
"logging_",
"._",
"get",
"Logger_",
"(_",
"\\u\\u",
"name\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"Block",
"er_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"Tak",
"es",
" ",
"in",
" ",
"a",
" ",
"record",
" ",
"and",
" ",
"return",
"s",
" ",
"all",
" ",
"blocks",
" ",
"tha",
"t",
" ",
"record",
" ",
"belo",
"ngs",
" ",
"to",
"'''_",
"\\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_",
"Block",
"er_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"predicates_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"predicates_",
"=_",
"predicates_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"index",
"\\u",
"fields_",
"=_",
"defaultdict_",
"(_",
"lambda_",
":_",
"defaultdict_",
"(_",
"list_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"full",
"\\u",
"predicate_",
"in_",
"predicates_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"predicate_",
"in_",
"full",
"\\u",
"predicate_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"predicate_",
",_",
"'",
"index",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"self_",
"._",
"index",
"\\u",
"fields_",
"[_",
"predicate_",
"._",
"field_",
"]_",
"[_",
"predicate_",
"._",
"type_",
"]_",
"._",
"append_",
"(_",
"predicate_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Block",
"er_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u\\u",
"call\\u\\u_",
"(_",
"self_",
",_",
"records_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"start",
"\\u",
"time_",
"=_",
"time_",
"._",
"clock_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"predicates_",
"=_",
"[_",
"(_",
"':'_",
"+_",
"str_",
"(_",
"i_",
")_",
",_",
"predicate_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"i_",
",_",
"predicate_",
"\\u\\u\\uNL\\u\\u\\u_",
"in_",
"enumerate_",
"(_",
"self_",
"._",
"predicates_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"i_",
",_",
"record_",
"in_",
"enumerate_",
"(_",
"records_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"record",
"\\u",
"id_",
",_",
"instance_",
"=_",
"record_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"pred",
"\\u",
"id_",
",_",
"predicate_",
"in_",
"predicates_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"block",
"\\u",
"keys_",
"=_",
"predicate_",
"(_",
"instance_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"block",
"\\u",
"key_",
"in_",
"block",
"\\u",
"keys_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"yield_",
"block",
"\\u",
"key_",
"+_",
"pred",
"\\u",
"id_",
",_",
"record",
"\\u",
"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_",
"if_",
"i_",
"and_",
"i_",
"%_",
"10000_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logger_",
"._",
"info_",
"(_",
"'%",
"(",
"iterati",
"on",
")",
"d",
",",
" ",
"%",
"(",
"ela",
"pse",
"d",
")",
"f2",
" ",
"second",
"s",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"{_",
"'",
"iterati",
"on",
"'_",
":_",
"i_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"ela",
"pse",
"d",
"'_",
":_",
"time_",
"._",
"clock_",
"(_",
")_",
"-_",
"start",
"\\u",
"time_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Block",
"er_",
":_",
"\\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_",
"reset",
"Indices_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"clear",
" ",
"can",
"opi",
"es",
" ",
"to",
" ",
"reduce",
" ",
"memory",
" ",
"usage_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"index",
"\\u",
"type_",
"in_",
"self_",
"._",
"index",
"\\u",
"fields_",
"._",
"values_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"predicates_",
"in_",
"index",
"\\u",
"type_",
"._",
"values_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"predicate_",
"in_",
"predicates_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"predicate_",
"._",
"index_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"hasattr_",
"(_",
"predicate_",
",_",
"'",
"can",
"opy",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"predicate_",
"._",
"can",
"opy_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Block",
"er_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"index_",
"(_",
"self_",
",_",
"data_",
",_",
"field_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"Creat",
"es",
" ",
"TF",
"/",
"IDF",
" ",
"index",
" ",
"of",
" ",
"a",
" ",
"give",
"n",
" ",
"set",
" ",
"of",
" ",
"data",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"indices_",
"=_",
"extract",
"Indices_",
"(_",
"self_",
"._",
"index",
"\\u",
"fields_",
"[_",
"field_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"doc_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"doc_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"\\u_",
",_",
"index_",
",_",
"preprocess_",
"in_",
"indices_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"index_",
"._",
"index_",
"(_",
"preprocess_",
"(_",
"doc_",
")_",
")_",
"\\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_",
"index",
"\\u",
"type_",
",_",
"index_",
",_",
"\\u_",
"in_",
"indices_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"index_",
"._",
"init",
"Search_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"predicate_",
"in_",
"self_",
"._",
"index",
"\\u",
"fields_",
"[_",
"field_",
"]_",
"[_",
"index",
"\\u",
"type_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logger_",
"._",
"info_",
"(_",
"\"",
"Can",
"opy",
":",
" ",
"%",
"s",
"\"_",
",_",
"str_",
"(_",
"predicate_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"predicate_",
"._",
"index_",
"=_",
"index_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Block",
"er_",
":_",
"\\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_",
"unin",
"dex_",
"(_",
"self_",
",_",
"data_",
",_",
"field_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"Remove",
" ",
"index",
" ",
"of",
" ",
"a",
" ",
"give",
"n",
" ",
"set",
" ",
"of",
" ",
"data",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"indices_",
"=_",
"extract",
"Indices_",
"(_",
"self_",
"._",
"index",
"\\u",
"fields_",
"[_",
"field_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"doc_",
"in_",
"data_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"doc_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"\\u_",
",_",
"index_",
",_",
"preprocess_",
"in_",
"indices_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"index_",
"._",
"unin",
"dex_",
"(_",
"preprocess_",
"(_",
"doc_",
")_",
")_",
"\\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_",
"index",
"\\u",
"type_",
",_",
"index_",
",_",
"\\u_",
"in_",
"indices_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"index_",
"._",
"\\u",
"index_",
"._",
"init",
"Search_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"predicate_",
"in_",
"self_",
"._",
"index",
"\\u",
"fields_",
"[_",
"field_",
"]_",
"[_",
"index",
"\\u",
"type_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logger_",
"._",
"info_",
"(_",
"\"",
"Can",
"opy",
":",
" ",
"%",
"s",
"\"_",
",_",
"str_",
"(_",
"predicate_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"predicate_",
"._",
"index_",
"=_",
"index_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Block",
"er_",
":_",
"\\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_",
"index",
"All_",
"(_",
"self_",
",_",
"data\\u",
"d_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"field_",
"in_",
"self_",
"._",
"index",
"\\u",
"fields_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"unique",
"\\u",
"fields_",
"=_",
"{_",
"record_",
"[_",
"field_",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"record_",
"\\u\\u\\uNL\\u\\u\\u_",
"in_",
"view",
"values_",
"(_",
"data\\u",
"d_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"record_",
"[_",
"field_",
"]_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"index_",
"(_",
"unique",
"\\u",
"fields_",
",_",
"field_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"extract",
"Indices_",
"(_",
"index",
"\\u",
"fields_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"indices_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"index",
"\\u",
"type_",
",_",
"predicates_",
"in_",
"index",
"\\u",
"fields_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"predicate_",
"=_",
"predicates_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"index_",
"=_",
"predicate_",
"._",
"index_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"preprocess_",
"=_",
"predicate_",
"._",
"preprocess_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"predicate_",
"._",
"index_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"index_",
"=_",
"predicate_",
"._",
"init",
"Index_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"indices_",
"._",
"append_",
"(_",
"(_",
"index",
"\\u",
"type_",
",_",
"index_",
",_",
"preprocess_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"indices_"
]
| [
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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
]
|
Except block handles 'BaseException' | lmco/laikaboss/laikad.py | [
{
"content": " def perform_scan(self, poll_timeout):\n '''\n Wait for work from broker then perform the scan. If timeout occurs, no\n scan is performed and no result is returned.\n\n Arguments:\n poll_timeout -- The amount of time to wait for work.\n\n Returns:\n The result of the scan or None if no scan was performed.\n '''\n from laikaboss.dispatch import Dispatch\n from laikaboss.objectmodel import ScanResult, ExternalObject, ExternalVars\n from laikaboss.util import log_result\n\n # If task is found, perform scan\n try:\n logging.debug(\"Worker (%s): checking for work\", self.identity)\n tasks = dict(self.broker_poller.poll(poll_timeout))\n if tasks.get(self.broker) == zmq.POLLIN:\n logging.debug(\"Worker (%s): performing scan\", self.identity)\n # task should be in the following format\n # ['', client_id, '', request_type, '', request]\n # where:\n # client_id -- ZMQ identifier of the client socket\n # request_type -- The type of request (json/pickle/zlib)\n # request -- Object to be scanned\n\n task = self.broker.recv_multipart()\n \n client_id = task[1]\n if len(task) == 6:\n request_type = task[3]\n request = task[5]\n if request_type in [REQ_TYPE_PICKLE, REQ_TYPE_PICKLE_ZLIB]:\n #logging.debug(\"Worker: received work %s\", str(task))\n if request_type == REQ_TYPE_PICKLE_ZLIB:\n externalObject = pickle.loads(zlib.decompress(request))\n else:\n externalObject = pickle.loads(request)\n elif request_type in [REQ_TYPE_JSON, REQ_TYPE_JSON_ZLIB]:\n if request_type == REQ_TYPE_JSON_ZLIB:\n jsonRequest = json.loads(zlib.decompress(request))\n else:\n jsonRequest = json.loads(request)\n \n # Set default values for our request just in case some were omitted\n if not 'buffer' in jsonRequest:\n jsonRequest['buffer'] = ''\n else:\n try:\n jsonRequest['buffer'] = base64.b64decode(jsonRequest['buffer'])\n except:\n # This should never happen unless invalid input is given\n jsonRequest['buffer'] = ''\n if not 'filename' in jsonRequest:\n jsonRequest['filename'] = ''\n if not 'ephID' in jsonRequest:\n jsonRequest['ephID'] = ''\n if not 'uniqID' in jsonRequest:\n jsonRequest['uniqID'] = ''\n if not 'contentType' in jsonRequest:\n jsonRequest['contentType'] = []\n if not 'timestamp' in jsonRequest:\n jsonRequest['timestamp'] = ''\n if not 'source' in jsonRequest:\n jsonRequest['source'] = ''\n if not 'origRootUID' in jsonRequest:\n jsonRequest['origRootUID'] = ''\n if not 'extMetaData' in jsonRequest:\n jsonRequest['extMetaData'] = {}\n if not 'level' in jsonRequest:\n jsonRequest['level'] = 2\n\n externalVars = ExternalVars(filename=jsonRequest['filename'],\n ephID=jsonRequest['ephID'],\n uniqID=jsonRequest['uniqID'],\n contentType=jsonRequest['contentType'],\n timestamp=jsonRequest['timestamp'],\n source=jsonRequest['source'],\n origRootUID=jsonRequest['origRootUID'],\n extMetaData=jsonRequest['extMetaData'])\n\n externalObject = ExternalObject(buffer=jsonRequest['buffer'],\n level=jsonRequest['level'],\n externalVars=externalVars)\n\n else:\n return [client_id, '', 'INVALID REQUEST']\n \n result = ScanResult(\n source=externalObject.externalVars.source,\n level=externalObject.level)\n result.startTime = time.time()\n try:\n Dispatch(externalObject.buffer, result, 0,\n externalVars=externalObject.externalVars)\n except QuitScanException:\n raise\n except:\n exc_type, exc_value, exc_traceback = sys.exc_info()\n log_debug(\n \"exception on file: %s, detailed exception: %s\" % (\n externalObject.externalVars.filename,\n repr(traceback.format_exception(\n exc_type, exc_value, exc_traceback))))\n if self.logresult:\n log_result(result)\n if request_type == REQ_TYPE_PICKLE_ZLIB: \n result = zlib.compress(\n pickle.dumps(result, pickle.HIGHEST_PROTOCOL))\n elif request_type == REQ_TYPE_PICKLE: \n result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL)\n elif request_type == REQ_TYPE_JSON_ZLIB: \n result = zlib.compress(\n json.dumps(result, cls=ResultEncoder))\n elif request_type == REQ_TYPE_JSON: \n result = json.dumps(result, cls=ResultEncoder)\n return [client_id, '', result]\n\n else:\n return [client_id, '', 'INVALID REQUEST']\n except zmq.ZMQError as zmqerror:\n if \"Interrupted system call\" not in str(zmqerror):\n logging.exception(\"Worker (%s): Received ZMQError\", self.identity)\n else:\n logging.debug(\"Worker (%s): ZMQ interrupted by shutdown signal\", self.identity)\n return None",
"metadata": "root.Worker.perform_scan",
"header": "['class', 'Worker', '(', 'Process', ')', ':', '___EOS___']",
"index": 461
}
]
| [
{
"span": "except:",
"start_line": 513,
"start_column": 28,
"end_line": 513,
"end_column": 35
},
{
"span": "except:",
"start_line": 560,
"start_column": 20,
"end_line": 560,
"end_column": 27
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Worker_",
"(_",
"Process_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"perform",
"\\u",
"scan_",
"(_",
"self_",
",_",
"poll",
"\\u",
"timeout_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Wait",
" ",
"for",
" ",
"work",
" ",
"from",
" ",
"broker",
" ",
"then",
" ",
"perform",
" ",
"the",
" ",
"scan",
".",
" ",
"If",
" ",
"timeo",
"ut",
" ",
"occur",
"s",
",",
" ",
"no",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"scan",
" ",
"is",
" ",
"perform",
"ed",
" ",
"and",
" ",
"no",
" ",
"result",
" ",
"is",
" ",
"return",
"ed",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Arg",
"ument",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"poll",
"\\u",
"timeo",
"ut",
" ",
" ",
" ",
" ",
"--",
" ",
" ",
"The",
" ",
"amo",
"unt",
" ",
"of",
" ",
"time",
" ",
"to",
" ",
"wait",
" ",
"for",
" ",
"work",
".",
"\\",
"10",
";",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Return",
"s",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"The",
" ",
"result",
" ",
"of",
" ",
"the",
" ",
"scan",
" ",
"or",
" ",
"Non",
"e",
" ",
"if",
" ",
"no",
" ",
"scan",
" ",
"was",
" ",
"perform",
"ed",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"lai",
"kab",
"oss",
"_",
"._",
"dispatch_",
"import_",
"Dispa",
"tch_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"lai",
"kab",
"oss",
"_",
"._",
"object",
"model_",
"import_",
"Sca",
"n",
"Result_",
",_",
"Exter",
"nal",
"Object_",
",_",
"Exter",
"nal",
"Vars_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"lai",
"kab",
"oss",
"_",
"._",
"util_",
"import_",
"log",
"\\u",
"result_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"If",
" ",
"task",
" ",
"is",
" ",
"found",
",",
" ",
"perform",
" ",
"scan_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logging_",
"._",
"debug_",
"(_",
"\"",
"Worke",
"r",
" ",
"(%",
"s",
"):",
" ",
"checking",
" ",
"for",
" ",
"work",
"\"_",
",_",
"self_",
"._",
"identity_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tasks_",
"=_",
"dict_",
"(_",
"self_",
"._",
"broker",
"\\u",
"poller_",
"._",
"poll_",
"(_",
"poll",
"\\u",
"timeout_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"tasks_",
"._",
"get_",
"(_",
"self_",
"._",
"broker_",
")_",
"==_",
"zmq_",
"._",
"POLL",
"IN_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logging_",
"._",
"debug_",
"(_",
"\"",
"Worke",
"r",
" ",
"(%",
"s",
"):",
" ",
"perform",
"ing",
" ",
"scan",
"\"_",
",_",
"self_",
"._",
"identity_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"task",
" ",
"shou",
"ld",
" ",
"be",
" ",
"in",
" ",
"the",
" ",
"follow",
"ing",
" ",
"format_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"['",
"',",
" ",
"client",
"\\u",
"id",
",",
" ",
"''",
",",
" ",
"request",
"\\u",
"type",
",",
" ",
"''",
",",
" ",
"request",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"where",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"client",
"\\u",
"id",
" ",
" ",
" ",
" ",
"--",
" ",
" ",
"ZM",
"Q",
" ",
"identifi",
"er",
" ",
"of",
" ",
"the",
" ",
"client",
" ",
"socket_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"request",
"\\u",
"type",
" ",
"--",
" ",
" ",
"The",
" ",
"type",
" ",
"of",
" ",
"request",
" ",
"(",
"json",
"/",
"pickle",
"/",
"zli",
"b",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"request",
" ",
" ",
"--",
" ",
" ",
"Object",
" ",
"to",
" ",
"be",
" ",
"scanned",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"task_",
"=_",
"self_",
"._",
"broker_",
"._",
"recv",
"\\u",
"multipart_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"client",
"\\u",
"id_",
"=_",
"task_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"len_",
"(_",
"task_",
")_",
"==_",
"6_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"request",
"\\u",
"type_",
"=_",
"task_",
"[_",
"3_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"request_",
"=_",
"task_",
"[_",
"5_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"request",
"\\u",
"type_",
"in_",
"[_",
"REQ",
"\\u",
"TYPE",
"\\u",
"PIC",
"KL",
"E_",
",_",
"REQ",
"\\u",
"TYPE",
"\\u",
"PIC",
"KL",
"E",
"\\u",
"ZL",
"IB",
"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"logg",
"ing",
".",
"debug",
"(\"",
"Worke",
"r",
":",
" ",
"receive",
"d",
" ",
"work",
" ",
"%",
"s",
"\",",
" ",
"str",
"(",
"task",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"if_",
"request",
"\\u",
"type_",
"==_",
"REQ",
"\\u",
"TYPE",
"\\u",
"PIC",
"KL",
"E",
"\\u",
"ZL",
"IB",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"external",
"Object_",
"=_",
"pickle_",
"._",
"loads_",
"(_",
"zlib_",
"._",
"decompress_",
"(_",
"request_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"external",
"Object_",
"=_",
"pickle_",
"._",
"loads_",
"(_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"request",
"\\u",
"type_",
"in_",
"[_",
"REQ",
"\\u",
"TYPE",
"\\u",
"JSON_",
",_",
"REQ",
"\\u",
"TYPE",
"\\u",
"JSO",
"N",
"\\u",
"ZL",
"IB",
"_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"if_",
"request",
"\\u",
"type_",
"==_",
"REQ",
"\\u",
"TYPE",
"\\u",
"JSO",
"N",
"\\u",
"ZL",
"IB",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"=_",
"json_",
"._",
"loads_",
"(_",
"zlib_",
"._",
"decompress_",
"(_",
"request_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"=_",
"json_",
"._",
"loads_",
"(_",
"request_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Set",
" ",
"default",
" ",
"values",
" ",
"for",
" ",
"our",
" ",
"request",
" ",
"just",
" ",
"in",
" ",
"case",
" ",
"some",
" ",
"wer",
"e",
" ",
"omit",
"ted_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"buffer",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"buffer",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"buffer",
"'_",
"]_",
"=_",
"base64_",
"._",
"b64decode_",
"(_",
"json",
"Request_",
"[_",
"'",
"buffer",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"shou",
"ld",
" ",
"neve",
"r",
" ",
"happ",
"en",
" ",
"unl",
"ess",
" ",
"invalid",
" ",
"input",
" ",
"is",
" ",
"given_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"buffer",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"filename",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"filename",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"eph",
"ID",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"eph",
"ID",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"uniq",
"ID",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"uniq",
"ID",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"content",
"Type",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"content",
"Type",
"'_",
"]_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"timestamp",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"timestamp",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"source",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"source",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"orig",
"Roo",
"t",
"UI",
"D",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"orig",
"Roo",
"t",
"UI",
"D",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"ext",
"Meta",
"Data",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"ext",
"Meta",
"Data",
"'_",
"]_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"'",
"level",
"'_",
"in_",
"json",
"Request_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"json",
"Request_",
"[_",
"'",
"level",
"'_",
"]_",
"=_",
"2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"external",
"Vars_",
"=_",
"Exter",
"nal",
"Vars_",
"(_",
"filename_",
"=_",
"json",
"Request_",
"[_",
"'",
"filename",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"eph",
"ID_",
"=_",
"json",
"Request_",
"[_",
"'",
"eph",
"ID",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"uniq",
"ID_",
"=_",
"json",
"Request_",
"[_",
"'",
"uniq",
"ID",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"content",
"Type_",
"=_",
"json",
"Request_",
"[_",
"'",
"content",
"Type",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"timestamp_",
"=_",
"json",
"Request_",
"[_",
"'",
"timestamp",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"source_",
"=_",
"json",
"Request_",
"[_",
"'",
"source",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"orig",
"Roo",
"t",
"UID_",
"=_",
"json",
"Request_",
"[_",
"'",
"orig",
"Roo",
"t",
"UI",
"D",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"ext",
"Meta",
"Data_",
"=_",
"json",
"Request_",
"[_",
"'",
"ext",
"Meta",
"Data",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"external",
"Object_",
"=_",
"Exter",
"nal",
"Object_",
"(_",
"buffer_",
"=_",
"json",
"Request_",
"[_",
"'",
"buffer",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"level_",
"=_",
"json",
"Request_",
"[_",
"'",
"level",
"'_",
"]_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"external",
"Vars_",
"=_",
"external",
"Vars_",
")_",
"\\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 ",
" ",
" _",
"return_",
"[_",
"client",
"\\u",
"id_",
",_",
"''_",
",_",
"'",
"INVALID",
" ",
"REQUEST",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"result_",
"=_",
"Sca",
"n",
"Result_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"source_",
"=_",
"external",
"Object_",
"._",
"external",
"Vars_",
"._",
"source_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"level_",
"=_",
"external",
"Object_",
"._",
"level_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"result_",
"._",
"start",
"Time_",
"=_",
"time_",
"._",
"time_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"Dispa",
"tch_",
"(_",
"external",
"Object_",
"._",
"buffer_",
",_",
"result_",
",_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"external",
"Vars_",
"=_",
"external",
"Object_",
"._",
"external",
"Vars_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Qui",
"t",
"Sca",
"n",
"Exception_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"raise_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"exc",
"\\u",
"type_",
",_",
"exc",
"\\u",
"value_",
",_",
"exc",
"\\u",
"traceback_",
"=_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"log",
"\\u",
"debug_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"exception",
" ",
"on",
" ",
"file",
":",
" ",
"%",
"s",
",",
" ",
"detailed",
" ",
"exception",
":",
" ",
"%",
"s",
"\"_",
"%_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"external",
"Object_",
"._",
"external",
"Vars_",
"._",
"filename_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"repr_",
"(_",
"traceback_",
"._",
"format\\u",
"exception_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"exc",
"\\u",
"type_",
",_",
"exc",
"\\u",
"value_",
",_",
"exc",
"\\u",
"traceback_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"logr",
"esult",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"log",
"\\u",
"result_",
"(_",
"result_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"request",
"\\u",
"type_",
"==_",
"REQ",
"\\u",
"TYPE",
"\\u",
"PIC",
"KL",
"E",
"\\u",
"ZL",
"IB",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"result_",
"=_",
"zlib_",
"._",
"compress_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"pickle_",
"._",
"dumps_",
"(_",
"result_",
",_",
"pickle_",
"._",
"HIGHE",
"ST",
"\\u",
"PROTOCOL_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"request",
"\\u",
"type_",
"==_",
"REQ",
"\\u",
"TYPE",
"\\u",
"PIC",
"KL",
"E_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"result_",
"=_",
"pickle_",
"._",
"dumps_",
"(_",
"result_",
",_",
"pickle_",
"._",
"HIGHE",
"ST",
"\\u",
"PROTOCOL_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"request",
"\\u",
"type_",
"==_",
"REQ",
"\\u",
"TYPE",
"\\u",
"JSO",
"N",
"\\u",
"ZL",
"IB",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"result_",
"=_",
"zlib_",
"._",
"compress_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"json_",
"._",
"dumps_",
"(_",
"result_",
",_",
"cls_",
"=_",
"Result",
"Encoder_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"request",
"\\u",
"type_",
"==_",
"REQ",
"\\u",
"TYPE",
"\\u",
"JSON_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"result_",
"=_",
"json_",
"._",
"dumps_",
"(_",
"result_",
",_",
"cls_",
"=_",
"Result",
"Encoder_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"[_",
"client",
"\\u",
"id_",
",_",
"''_",
",_",
"result_",
"]_",
"\\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 ",
" ",
"_",
"return_",
"[_",
"client",
"\\u",
"id_",
",_",
"''_",
",_",
"'",
"INVALID",
" ",
"REQUEST",
"'_",
"]_",
"\\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_",
"zmq_",
"._",
"ZM",
"QE",
"rror_",
"as_",
"zmq",
"error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"\"",
"Interr",
"upt",
"ed",
" ",
"system",
" ",
"call",
"\"_",
"not_",
"in_",
"str_",
"(_",
"zmq",
"error_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"logging_",
"._",
"exception_",
"(_",
"\"",
"Worke",
"r",
" ",
"(%",
"s",
"):",
" ",
"Receive",
"d",
" ",
"ZM",
"QE",
"rror",
"\"_",
",_",
"self_",
"._",
"identity_",
")_",
"\\u\\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_",
"(_",
"\"",
"Worke",
"r",
" ",
"(%",
"s",
"):",
" ",
"ZM",
"Q",
" ",
"interrupted",
" ",
"by",
" ",
"shut",
"down",
" ",
"signal",
"\"_",
",_",
"self_",
"._",
"identity_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
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,
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Unused import | pyjs/pyjs/pyjswidgets/pyjamas/ui/UIObject.py | [
{
"content": "# Copyright 2006 James Tauber and contributors\n# Copyright (C) 2009 Luke Kenneth Casson Leighton <[email protected]>\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.\nfrom pyjamas import DOM\nfrom pyjamas import Factory\nfrom pyjamas import Window\nfrom pyjamas.ui import Applier\n\n\n\n\nFactory.registerClass('pyjamas.ui.UIObject', 'UIObject', UIObject)\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def findStyleName(element, style):\n\n oldStyle = DOM.getAttribute(element, \"className\")\n if oldStyle is None:\n return -1\n idx = oldStyle.find(style)\n\n # Calculate matching index\n lastPos = len(oldStyle)\n while idx != -1:\n if idx == 0 or (oldStyle[idx - 1] == \" \"):\n last = idx + len(style)\n if (last == lastPos) or ((last < lastPos) and \\\n (oldStyle[last] == \" \")):\n break\n idx = oldStyle.find(style, idx + 1)\n\n return idx",
"metadata": "root.findStyleName",
"header": "['module', '___EOS___']",
"index": 19
},
{
"content": "def setStyleName(element, style, add):\n\n oldStyle = DOM.getAttribute(element, \"className\")\n if oldStyle is None:\n oldStyle = \"\"\n\n idx = findStyleName(element, style)\n\n if add:\n if idx == -1:\n DOM.setAttribute(element, \"className\", oldStyle + \" \" + style)\n return\n\n if idx == -1:\n return\n\n if idx == 0:\n begin = ''\n else:\n begin = oldStyle[:idx-1]\n\n end = oldStyle[idx + len(style):]\n DOM.setAttribute(element, \"className\", begin + end)",
"metadata": "root.setStyleName",
"header": "['module', '___EOS___']",
"index": 38
},
{
"content": "class UIObject(Applier):\n\n _props = [ (\"visible\", \"Visibility\", \"Visible\", None),\n (\"element\", \"Element\", \"Element\", None),\n (\"stylename\", \"Style name\", \"StyleName\", None),\n (\"width\", \"Width\", \"Width\", None),\n (\"height\", \"Height\", \"Height\", None),\n (\"size\", \"Size\", \"Size\", None),\n (\"title\", \"Title\", \"Title\", None),\n (\"zindex\", \"Z Index\", \"zIndex\", None),\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 # also callable as: setStyleName(self, style)\n\n\n\n\n\n\n\n\n\n # also callable as: setVisible(visible)\n",
"metadata": "root.UIObject",
"header": "['module', '___EOS___']",
"index": 62
},
{
"content": " @classmethod\n def _getProps(self):\n return Applier._getProps() + self._props",
"metadata": "root.UIObject._getProps",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 74
},
{
"content": " def __init__(self, **kwargs):\n # do not initialise element, here, to None, whatever you do.\n # there are circumstances where UIObject.__init__ is the last\n # thing that is done in derived classes, where self.setElement\n # will _already_ have been called.\n Applier.__init__(self, **kwargs)",
"metadata": "root.UIObject.__init__",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 78
},
{
"content": " def getAbsoluteLeft(self):\n return DOM.getAbsoluteLeft(self.getElement())",
"metadata": "root.UIObject.getAbsoluteLeft",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 85
},
{
"content": " def getAbsoluteTop(self):\n return DOM.getAbsoluteTop(self.getElement())",
"metadata": "root.UIObject.getAbsoluteTop",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 88
},
{
"content": " def getClientHeight(self):\n return DOM.getIntAttribute(self.getElement(), \"clientHeight\")",
"metadata": "root.UIObject.getClientHeight",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 91
},
{
"content": " def getClientWidth(self):\n \treturn DOM.getIntAttribute(self.getElement(), \"clientWidth\")",
"metadata": "root.UIObject.getClientWidth",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 94
},
{
"content": " def getElement(self):\n \"\"\"Get the DOM element associated with the UIObject, if any\"\"\"\n return self.element",
"metadata": "root.UIObject.getElement",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 97
},
{
"content": " def getOffsetHeight(self):\n return DOM.getIntAttribute(self.element, \"offsetHeight\")",
"metadata": "root.UIObject.getOffsetHeight",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 101
},
{
"content": " def getOffsetWidth(self):\n return DOM.getIntAttribute(self.element, \"offsetWidth\")",
"metadata": "root.UIObject.getOffsetWidth",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 104
},
{
"content": " def getStyleName(self):\n return DOM.getAttribute(self.element, \"className\")",
"metadata": "root.UIObject.getStyleName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 107
},
{
"content": " def getStylePrimaryName(self):\n \"\"\"Return with the first className if there are multiples\"\"\"\n fullClassName = self.getStyleName()\n if fullClassName: return fullClassName.split()[0]",
"metadata": "root.UIObject.getStylePrimaryName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 110
},
{
"content": " def getStyleAttribute(self, attribute):\n \"\"\" can be called with two forms:\n getStyleAttribute(self, attr) - returns value\n getStyleAttribute(self, (attr1,attr2,...)) - returns dictionary of attr:value pairs\n \"\"\"\n if isinstance(attribute, basestring):\n return DOM.getStyleAttribute(self.getElement(), attribute)\n # if attribute is not a string, assume it is iterable,\n # and return the multi-attribute form\n el = self.getElement()\n result = {}\n for attr in attribute:\n result[attr] = DOM.getStyleAttribute(el,attr)\n return result",
"metadata": "root.UIObject.getStyleAttribute",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 115
},
{
"content": " def getTitle(self):\n return DOM.getAttribute(self.element, \"title\")",
"metadata": "root.UIObject.getTitle",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 130
},
{
"content": " def setElement(self, element):\n \"\"\"Set the DOM element associated with the UIObject.\"\"\"\n self.element = element",
"metadata": "root.UIObject.setElement",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 133
},
{
"content": " def setHeight(self, height):\n \"\"\"Set the height of the element associated with this UIObject. The\n value should be given as a CSS value, such as 100px, 30%, or 50pi\n \"\"\"\n if height is None:\n height = \"\"\n DOM.setStyleAttribute(self.element, \"height\", str(height))",
"metadata": "root.UIObject.setHeight",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 137
},
{
"content": " def getHeight(self):\n return DOM.getStyleAttribute(self.element, \"height\")",
"metadata": "root.UIObject.getHeight",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 145
},
{
"content": " def setPixelSize(self, width, height):\n \"\"\"Set the width and height of the element associated with this UIObject\n in pixels. Width and height should be numbers.\n \"\"\"\n if width >= 0:\n self.setWidth(\"%dpx\" % width)\n if height >= 0:\n self.setHeight(\"%dpx\" % height)",
"metadata": "root.UIObject.setPixelSize",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 148
},
{
"content": " def setSize(self, width, height):\n \"\"\"Set the width and height of the element associated with this\n UIObject. The values should be given as a CSS value,\n such as 100px, 30%, or 50pi\n \"\"\"\n self.setWidth(width)\n self.setHeight(height)",
"metadata": "root.UIObject.setSize",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 157
},
{
"content": " def addStyleName(self, style):\n \"\"\"Append a style to the element associated with this UIObject.\n This is a CSS class name. It will be added after any\n already-assigned CSS class for the element.\n \"\"\"\n self.setStyleName(self.element, style, True)",
"metadata": "root.UIObject.addStyleName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 165
},
{
"content": " def addStyleDependentName(self, styleSuffix):\n \"\"\"Adds a secondary or dependent style name to this element.\n For example if the primary stylename is gwt-TextBox,\n self.addStyleDependentName(\"readonly\") will return\n gwt-TextBox-readonly.\n \"\"\"\n self.addStyleName(self.getStylePrimaryName()+\"-\"+styleSuffix)",
"metadata": "root.UIObject.addStyleDependentName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 172
},
{
"content": " def removeStyleName(self, style):\n \"\"\"Remove a style from the element associated with this UIObject. This is\n a CSS class name.\"\"\"\n self.setStyleName(self.element, style, False)",
"metadata": "root.UIObject.removeStyleName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 180
},
{
"content": " def removeStyleDependentName(self, styleSuffix):\n \"\"\"Remove a dependent style name by specifying the style name's suffix.\n \"\"\"\n self.removeStyleName(self.getStylePrimaryName()+\"-\"+styleSuffix)",
"metadata": "root.UIObject.removeStyleDependentName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 185
},
{
"content": " def setStyleName(self, element, style=None, add=True):\n \"\"\"When called with a single argument, this replaces all the CSS\n classes associated with this UIObject's element with the given\n parameter. Otherwise, this is assumed to be a worker function\n for addStyleName and removeStyleName.\n \"\"\"\n # emulate setStyleName(self, style)\n if style is not None:\n setStyleName(element, style, add)\n return\n style = element\n DOM.setAttribute(self.element, \"className\", style)",
"metadata": "root.UIObject.setStyleName",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 191
},
{
"content": " def setStyleAttribute(self, attribute, value=None):\n \"\"\" can be called with two forms:\n single attr: setStyleAttribute(self, attr, value)\n multi attr: setStyleAttribute(self, {attr1:val1, attr2:val2, ...})\n \"\"\"\n if value is not None: # assume single attr form\n DOM.setStyleAttribute(self.getElement(), attribute, value)\n return\n # assume multi value form\n el = self.getElement()\n for attr, val in attribute.items():\n DOM.setStyleAttribute(el, attr, val)",
"metadata": "root.UIObject.setStyleAttribute",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 204
},
{
"content": " def setTitle(self, title):\n DOM.setAttribute(self.element, \"title\", title)",
"metadata": "root.UIObject.setTitle",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 217
},
{
"content": " def setWidth(self, width):\n \"\"\"Set the width of the element associated with this UIObject. The\n value should be given as a CSS value, such as 100px, 30%, or 50pi\n \"\"\"\n if width is None:\n width = \"\"\n DOM.setStyleAttribute(self.element, \"width\", str(width))",
"metadata": "root.UIObject.setWidth",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 220
},
{
"content": " def getWidth(self):\n return DOM.getStyleAttribute(self.element, \"width\")",
"metadata": "root.UIObject.getWidth",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 228
},
{
"content": " def sinkEvents(self, eventBitsToAdd):\n \"\"\"Request that the given events be delivered to the event handler\n for this element. The event bits passed are added (using inclusive\n OR) to the events already \"sunk\" for the element associated with\n the UIObject. The event bits are a combination of values from\n class L{Event}.\n \"\"\"\n if self.element:\n DOM.sinkEvents(self.getElement(),\n eventBitsToAdd | DOM.getEventsSunk(self.getElement()))",
"metadata": "root.UIObject.sinkEvents",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 231
},
{
"content": " def setzIndex(self, index):\n DOM.setIntStyleAttribute(self.element, \"zIndex\", index)",
"metadata": "root.UIObject.setzIndex",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 242
},
{
"content": " def isVisible(self, element=None):\n \"\"\" XXX DEPRECATED - use getVisible\n \"\"\"\n return self.getVisible(element)",
"metadata": "root.UIObject.isVisible",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 245
},
{
"content": " def getVisible(self, element=None):\n \"\"\"Determine whether this element is currently visible, by checking\n the CSS property 'display'\n \"\"\"\n if not element:\n element = self.element\n try: # yuk!\n return element.style.display != \"none\"\n except AttributeError: # not been set (yet?)\n return True",
"metadata": "root.UIObject.getVisible",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 250
},
{
"content": " def setVisible(self, element, visible=None):\n \"\"\"Set whether this element is visible or not. If a single parameter\n is given, the self.element is used. This modifies the CSS\n property 'display', which means that an invisible element not\n only is not drawn, but doesn't occupy any space on the page.\n \"\"\"\n if visible is None:\n visible = element\n element = self.element\n\n if visible:\n DOM.setStyleAttribute(element, 'display', \"\")\n else:\n DOM.setStyleAttribute(element, 'display', \"none\")",
"metadata": "root.UIObject.setVisible",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 262
},
{
"content": " def unsinkEvents(self, eventBitsToRemove):\n \"\"\"Reverse the operation of sinkEvents. See L{UIObject.sinkEvents}.\n \"\"\"\n DOM.sinkEvents(self.getElement(),\n ~eventBitsToRemove & DOM.getEventsSunk(self.getElement()))",
"metadata": "root.UIObject.unsinkEvents",
"header": "['class', 'UIObject', '(', 'Applier', ')', ':', '___EOS___']",
"index": 277
}
]
| [
{
"span": "from pyjamas import Window",
"start_line": 16,
"start_column": 0,
"end_line": 16,
"end_column": 26
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"2006",
" ",
"Jam",
"es",
" ",
"Tau",
"ber",
" ",
"and",
" ",
"contributor",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"C",
")",
" ",
"200",
"9",
" ",
"Lu",
"ke",
" ",
"Ken",
"net",
"h",
" ",
"Cass",
"on",
" ",
"Lei",
"ght",
"on",
" ",
"<",
"lk",
"cl",
"@",
"lk",
"cl",
".",
"net",
">_",
"\\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_",
"from_",
"pyj",
"ama",
"s_",
"import_",
"DOM_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"pyj",
"ama",
"s_",
"import_",
"Factory_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"pyj",
"ama",
"s_",
"import_",
"Window_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"pyj",
"ama",
"s_",
"._",
"ui_",
"import_",
"Appl",
"ier_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"Factory_",
"._",
"register",
"Class_",
"(_",
"'",
"pyj",
"ama",
"s",
".",
"ui",
".",
"UI",
"Object",
"'_",
",_",
"'",
"UI",
"Object",
"'_",
",_",
"UI",
"Object_",
")_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"find",
"Style",
"Name_",
"(_",
"element_",
",_",
"style_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"old",
"Style_",
"=_",
"DOM_",
"._",
"get",
"Attribute_",
"(_",
"element_",
",_",
"\"",
"class",
"Name",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"old",
"Style_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"-_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"idx_",
"=_",
"old",
"Style_",
"._",
"find_",
"(_",
"style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Calculat",
"e",
" ",
"matchi",
"ng",
" ",
"index_",
"\\u\\u\\uNL\\u\\u\\u_",
"last",
"Pos_",
"=_",
"len_",
"(_",
"old",
"Style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"idx_",
"!=_",
"-_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"idx_",
"==_",
"0_",
"or_",
"(_",
"old",
"Style_",
"[_",
"idx_",
"-_",
"1_",
"]_",
"==_",
"\"",
" ",
"\"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"last_",
"=_",
"idx_",
"+_",
"len_",
"(_",
"style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"(_",
"last_",
"==_",
"last",
"Pos_",
")_",
"or_",
"(_",
"(_",
"last_",
"<_",
"last",
"Pos_",
")_",
"and_",
"(_",
"old",
"Style_",
"[_",
"last_",
"]_",
"==_",
"\"",
" ",
"\"_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"break_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"idx_",
"=_",
"old",
"Style_",
"._",
"find_",
"(_",
"style_",
",_",
"idx_",
"+_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"idx_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Style",
"Name_",
"(_",
"element_",
",_",
"style_",
",_",
"add_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"old",
"Style_",
"=_",
"DOM_",
"._",
"get",
"Attribute_",
"(_",
"element_",
",_",
"\"",
"class",
"Name",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"old",
"Style_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"old",
"Style_",
"=_",
"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"idx_",
"=_",
"find",
"Style",
"Name_",
"(_",
"element_",
",_",
"style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"add_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"idx_",
"==_",
"-_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Attribute_",
"(_",
"element_",
",_",
"\"",
"class",
"Name",
"\"_",
",_",
"old",
"Style_",
"+_",
"\"",
" ",
"\"_",
"+_",
"style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"idx_",
"==_",
"-_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"idx_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"begin_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"begin_",
"=_",
"old",
"Style_",
"[_",
":_",
"idx_",
"-_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"end_",
"=_",
"old",
"Style_",
"[_",
"idx_",
"+_",
"len_",
"(_",
"style_",
")_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DOM_",
"._",
"set",
"Attribute_",
"(_",
"element_",
",_",
"\"",
"class",
"Name",
"\"_",
",_",
"begin_",
"+_",
"end_",
")_",
"\\u\\u\\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_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\\u",
"props_",
"=_",
"[_",
"(_",
"\"",
"visi",
"ble",
"\"_",
",_",
"\"",
"Vis",
"ibi",
"lit",
"y",
"\"_",
",_",
"\"",
"Vis",
"ibl",
"e",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"element",
"\"_",
",_",
"\"",
"Element",
"\"_",
",_",
"\"",
"Element",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"style",
"name",
"\"_",
",_",
"\"",
"Style",
" ",
"name",
"\"_",
",_",
"\"",
"Style",
"Name",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"widt",
"h",
"\"_",
",_",
"\"",
"Wid",
"th",
"\"_",
",_",
"\"",
"Wid",
"th",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"height",
"\"_",
",_",
"\"",
"Hei",
"ght",
"\"_",
",_",
"\"",
"Hei",
"ght",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"size",
"\"_",
",_",
"\"",
"Size",
"\"_",
",_",
"\"",
"Size",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"title",
"\"_",
",_",
"\"",
"Tit",
"le",
"\"_",
",_",
"\"",
"Tit",
"le",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"\"",
"zin",
"dex",
"\"_",
",_",
"\"",
"Z",
" ",
"Index",
"\"_",
",_",
"\"",
"z",
"Index",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\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\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"als",
"o",
" ",
"calla",
"ble",
" ",
"as",
":",
" ",
"set",
"Vis",
"ibl",
"e",
"(",
"visi",
"ble",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"classmethod_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"\\u",
"get",
"Props_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"Appl",
"ier_",
"._",
"\\u",
"get",
"Props_",
"(_",
")_",
"+_",
"self_",
"._",
"\\u",
"props_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\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_",
",_",
"**_",
"kwargs_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"do",
" ",
"not",
" ",
"initialise",
" ",
"element",
",",
" ",
"here",
",",
" ",
"to",
" ",
"Non",
"e",
",",
" ",
"what",
"ever",
" ",
"you",
" ",
"do",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"there",
" ",
"are",
" ",
"circum",
"stance",
"s",
" ",
"where",
" ",
"UI",
"Object",
".\\u",
"\\u",
"init",
"\\u\\u",
" ",
"is",
" ",
"the",
" ",
"last_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"thing",
" ",
"tha",
"t",
" ",
"is",
" ",
"don",
"e",
" ",
"in",
" ",
"derive",
"d",
" ",
"classe",
"s",
",",
" ",
"where",
" ",
"self",
".",
"set",
"Element_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"will",
" ",
"\\u",
"alr",
"ead",
"y",
"\\u",
" ",
"have",
" ",
"bee",
"n",
" ",
"call",
"ed",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"Appl",
"ier_",
"._",
"\\u\\u",
"init\\u\\u_",
"(_",
"self_",
",_",
"**_",
"kwargs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Abs",
"olute",
"Left_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Abs",
"olute",
"Left_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Abs",
"olute",
"Top_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Abs",
"olute",
"Top_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Client",
"Height_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Int",
"Attribute_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
",_",
"\"",
"client",
"Hei",
"ght",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Client",
"Width_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" \t_",
"return_",
"DOM_",
"._",
"get",
"Int",
"Attribute_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
",_",
"\"",
"client",
"Wid",
"th",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Element_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Get",
" ",
"the",
" ",
"DOM",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"the",
" ",
"UI",
"Object",
",",
" ",
"if",
" ",
"any",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"element_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Off",
"set",
"Height_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Int",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"offset",
"Hei",
"ght",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Off",
"set",
"Width_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Int",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"offset",
"Wid",
"th",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Style",
"Name_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"class",
"Name",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Style",
"Prim",
"ary",
"Name_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Return",
" ",
"with",
" ",
"the",
" ",
"first",
" ",
"class",
"Name",
" ",
"if",
" ",
"there",
" ",
"are",
" ",
"multiple",
"s",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"full",
"Class",
"Name_",
"=_",
"self_",
"._",
"get",
"Style",
"Name_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"full",
"Class",
"Name_",
":_",
"return_",
"full",
"Class",
"Name_",
"._",
"split_",
"(_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Style",
"Attribute_",
"(_",
"self_",
",_",
"attribute_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"can",
" ",
"be",
" ",
"call",
"ed",
" ",
"with",
" ",
"two",
" ",
"forms",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"get",
"Style",
"Attribute",
"(",
"self",
",",
" ",
"attr",
")",
" ",
"-",
" ",
"return",
"s",
" ",
"value",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"get",
"Style",
"Attribute",
"(",
"self",
",",
" ",
"(",
"attr",
"1",
",",
"attr",
"2",
",...",
"))",
" ",
"-",
" ",
"return",
"s",
" ",
"dictionar",
"y",
" ",
"of",
" ",
"attr",
":",
"value",
" ",
"pair",
"s",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"isinstance_",
"(_",
"attribute_",
",_",
"basestring_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
",_",
"attribute_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"if",
" ",
"attribute",
" ",
"is",
" ",
"not",
" ",
"a",
" ",
"string",
",",
" ",
"assume",
" ",
"it",
" ",
"is",
" ",
"iterable",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"and",
" ",
"return",
" ",
"the",
" ",
"multi",
"-",
"attribute",
" ",
"form_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"el_",
"=_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"result_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"attr_",
"in_",
"attribute_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"result_",
"[_",
"attr_",
"]_",
"=_",
"DOM_",
"._",
"get",
"Style",
"Attribute_",
"(_",
"el_",
",_",
"attr_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"result_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Title_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"title",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Element_",
"(_",
"self_",
",_",
"element_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Set",
" ",
"the",
" ",
"DOM",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"the",
" ",
"UI",
"Object",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"element_",
"=_",
"element_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Height_",
"(_",
"self_",
",_",
"height_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Set",
" ",
"the",
" ",
"height",
" ",
"of",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
" ",
"UI",
"Object",
".",
" ",
" ",
"The",
"\\",
"10",
";",
" ",
" ",
" ",
"value",
" ",
"shou",
"ld",
" ",
"be",
" ",
"give",
"n",
" ",
"as",
" ",
"a",
" ",
"CS",
"S",
" ",
"value",
",",
" ",
"suc",
"h",
" ",
"as",
" ",
"100",
"px",
",",
" ",
"30",
"%,",
" ",
"or",
" ",
"50",
"pi",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"height_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"height_",
"=_",
"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"DOM_",
"._",
"set",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"height",
"\"_",
",_",
"str_",
"(_",
"height_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Height_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"height",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Pix",
"el",
"Size_",
"(_",
"self_",
",_",
"width_",
",_",
"height_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Set",
" ",
"the",
" ",
"widt",
"h",
" ",
"and",
" ",
"height",
" ",
"of",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
" ",
"UI",
"Object",
"\\",
"10",
";",
" ",
" ",
" ",
"in",
" ",
"pixel",
"s",
".",
" ",
" ",
"Wid",
"th",
" ",
"and",
" ",
"height",
" ",
"shou",
"ld",
" ",
"be",
" ",
"numbers",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"width_",
">=_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"set",
"Width_",
"(_",
"\"%",
"dp",
"x",
"\"_",
"%_",
"width_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"height_",
">=_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"set",
"Height_",
"(_",
"\"%",
"dp",
"x",
"\"_",
"%_",
"height_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\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",
"Size_",
"(_",
"self_",
",_",
"width_",
",_",
"height_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Set",
" ",
"the",
" ",
"widt",
"h",
" ",
"and",
" ",
"height",
" ",
"of",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
"\\",
"10",
";",
" ",
" ",
" ",
"UI",
"Object",
".",
" ",
" ",
"The",
" ",
"values",
" ",
"shou",
"ld",
" ",
"be",
" ",
"give",
"n",
" ",
"as",
" ",
"a",
" ",
"CS",
"S",
" ",
"value",
",",
"\\",
"10",
";",
" ",
" ",
" ",
"suc",
"h",
" ",
"as",
" ",
"100",
"px",
",",
" ",
"30",
"%,",
" ",
"or",
" ",
"50",
"pi",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"set",
"Width_",
"(_",
"width_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"set",
"Height_",
"(_",
"height_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"add",
"Style",
"Name_",
"(_",
"self_",
",_",
"style_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Append",
" ",
"a",
" ",
"style",
" ",
"to",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
" ",
"UI",
"Object",
".",
"\\",
"10",
";",
" ",
" ",
" ",
"Thi",
"s",
" ",
"is",
" ",
"a",
" ",
"CS",
"S",
" ",
"class",
" ",
"name",
".",
" ",
" ",
"It",
" ",
"will",
" ",
"be",
" ",
"adde",
"d",
" ",
"after",
" ",
"any",
"\\",
"10",
";",
" ",
" ",
" ",
"alr",
"ead",
"y",
"-",
"assign",
"ed",
" ",
"CS",
"S",
" ",
"class",
" ",
"for",
" ",
"the",
" ",
"element",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"set",
"Style",
"Name_",
"(_",
"self_",
"._",
"element_",
",_",
"style_",
",_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"add",
"Style",
"Dependent",
"Name_",
"(_",
"self_",
",_",
"style",
"Suffix_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Add",
"s",
" ",
"a",
" ",
"second",
"ary",
" ",
"or",
" ",
"dependent",
" ",
"style",
" ",
"name",
" ",
"to",
" ",
"this",
" ",
"element",
".",
"\\",
"10",
";",
" ",
" ",
" ",
"For",
" ",
"example",
" ",
"if",
" ",
"the",
" ",
"primary",
" ",
"style",
"name",
" ",
"is",
" ",
"gw",
"t",
"-",
"Text",
"Box",
",",
"\\",
"10",
";",
" ",
" ",
" ",
"self",
".",
"add",
"Style",
"Dependent",
"Name",
"(\"",
"read",
"only",
"\")",
" ",
"will",
" ",
"return",
"\\",
"10",
";",
" ",
" ",
" ",
"gw",
"t",
"-",
"Text",
"Box",
"-",
"read",
"only",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"add",
"Style",
"Name_",
"(_",
"self_",
"._",
"get",
"Style",
"Prim",
"ary",
"Name_",
"(_",
")_",
"+_",
"\"-\"_",
"+_",
"style",
"Suffix_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"remove",
"Style",
"Name_",
"(_",
"self_",
",_",
"style_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Remove",
" ",
"a",
" ",
"style",
" ",
"from",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
" ",
"UI",
"Object",
".",
" ",
" ",
"Thi",
"s",
" ",
"is",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"a",
" ",
"CS",
"S",
" ",
"class",
" ",
"name",
".\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"set",
"Style",
"Name_",
"(_",
"self_",
"._",
"element_",
",_",
"style_",
",_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"remove",
"Style",
"Dependent",
"Name_",
"(_",
"self_",
",_",
"style",
"Suffix_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Remove",
" ",
"a",
" ",
"dependent",
" ",
"style",
" ",
"name",
" ",
"by",
" ",
"speci",
"fy",
"ing",
" ",
"the",
" ",
"style",
" ",
"name",
"'",
"s",
" ",
"suff",
"ix",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"remove",
"Style",
"Name_",
"(_",
"self_",
"._",
"get",
"Style",
"Prim",
"ary",
"Name_",
"(_",
")_",
"+_",
"\"-\"_",
"+_",
"style",
"Suffix_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Style",
"Name_",
"(_",
"self_",
",_",
"element_",
",_",
"style_",
"=_",
"None_",
",_",
"add_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Whe",
"n",
" ",
"call",
"ed",
" ",
"with",
" ",
"a",
" ",
"single",
" ",
"argu",
"ment",
",",
" ",
"this",
" ",
"replace",
"s",
" ",
"all",
" ",
"the",
" ",
"CS",
"S",
"\\",
"10",
";",
" ",
" ",
" ",
"classe",
"s",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
" ",
"UI",
"Object",
"'",
"s",
" ",
"element",
" ",
"with",
" ",
"the",
" ",
"give",
"n",
"\\",
"10",
";",
" ",
" ",
" ",
"parameter",
".",
" ",
" ",
"Ot",
"her",
"wis",
"e",
",",
" ",
"this",
" ",
"is",
" ",
"assume",
"d",
" ",
"to",
" ",
"be",
" ",
"a",
" ",
"worker",
" ",
"function",
"\\",
"10",
";",
" ",
" ",
" ",
"for",
" ",
"add",
"Style",
"Name",
" ",
"and",
" ",
"remove",
"Style",
"Name",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"emulate",
" ",
"set",
"Style",
"Name",
"(",
"self",
",",
" ",
"style",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"style_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"set",
"Style",
"Name_",
"(_",
"element_",
",_",
"style_",
",_",
"add_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"style_",
"=_",
"element_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DOM_",
"._",
"set",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"class",
"Name",
"\"_",
",_",
"style_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Style",
"Attribute_",
"(_",
"self_",
",_",
"attribute_",
",_",
"value_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"can",
" ",
"be",
" ",
"call",
"ed",
" ",
"with",
" ",
"two",
" ",
"forms",
":",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"single",
" ",
"attr",
":",
" ",
" ",
"set",
"Style",
"Attribute",
"(",
"self",
",",
" ",
"attr",
",",
" ",
"value",
")",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"multi",
" ",
" ",
"attr",
":",
" ",
" ",
"set",
"Style",
"Attribute",
"(",
"self",
",",
" ",
"{",
"attr",
"1",
":",
"val",
"1",
",",
" ",
"attr",
"2",
":",
"val",
"2",
",",
" ",
"...",
"})",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"value_",
"is_",
"not_",
"None_",
":_",
"#",
" ",
"assume",
" ",
"single",
" ",
"attr",
" ",
"form_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
",_",
"attribute_",
",_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"assume",
" ",
"multi",
" ",
"value",
" ",
"form_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"el_",
"=_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"attr_",
",_",
"val_",
"in_",
"attribute_",
"._",
"items_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Style",
"Attribute_",
"(_",
"el_",
",_",
"attr_",
",_",
"val_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\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",
"Title_",
"(_",
"self_",
",_",
"title_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"title",
"\"_",
",_",
"title_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set",
"Width_",
"(_",
"self_",
",_",
"width_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Set",
" ",
"the",
" ",
"widt",
"h",
" ",
"of",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
" ",
"this",
" ",
"UI",
"Object",
".",
" ",
" ",
"The",
"\\",
"10",
";",
" ",
" ",
" ",
"value",
" ",
"shou",
"ld",
" ",
"be",
" ",
"give",
"n",
" ",
"as",
" ",
"a",
" ",
"CS",
"S",
" ",
"value",
",",
" ",
"suc",
"h",
" ",
"as",
" ",
"100",
"px",
",",
" ",
"30",
"%,",
" ",
"or",
" ",
"50",
"pi",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"width_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"width_",
"=_",
"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"DOM_",
"._",
"set",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"widt",
"h",
"\"_",
",_",
"str_",
"(_",
"width_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Width_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"DOM_",
"._",
"get",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"widt",
"h",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"sink",
"Events_",
"(_",
"self_",
",_",
"event",
"Bit",
"s",
"To",
"Add_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Request",
" ",
"tha",
"t",
" ",
"the",
" ",
"give",
"n",
" ",
"events",
" ",
"be",
" ",
"deliver",
"ed",
" ",
"to",
" ",
"the",
" ",
"event",
" ",
"handler",
"\\",
"10",
";",
" ",
" ",
" ",
"for",
" ",
"this",
" ",
"element",
".",
" ",
" ",
"The",
" ",
"event",
" ",
"bits",
" ",
"pass",
"ed",
" ",
"are",
" ",
"adde",
"d",
" ",
"(",
"usi",
"ng",
" ",
"inclu",
"sive",
"\\",
"10",
";",
" ",
" ",
" ",
"OR",
")",
" ",
"to",
" ",
"the",
" ",
"events",
" ",
"alr",
"ead",
"y",
" ",
"\"",
"sun",
"k",
"\"",
" ",
"for",
" ",
"the",
" ",
"element",
" ",
"associate",
"d",
" ",
"with",
"\\",
"10",
";",
" ",
" ",
" ",
"the",
" ",
"UI",
"Object",
".",
" ",
" ",
"The",
" ",
"event",
" ",
"bits",
" ",
"are",
" ",
"a",
" ",
"combinat",
"ion",
" ",
"of",
" ",
"values",
" ",
"from",
"\\",
"10",
";",
" ",
" ",
" ",
"class",
" ",
"L",
"{",
"Event",
"}.",
"\\",
"10",
";",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"element_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"sink",
"Events_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"event",
"Bit",
"s",
"To",
"Add_",
"|_",
"DOM_",
"._",
"get",
"Event",
"s",
"Sun",
"k_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\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",
"z",
"Index_",
"(_",
"self_",
",_",
"index_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Int",
"Style",
"Attribute_",
"(_",
"self_",
"._",
"element_",
",_",
"\"",
"z",
"Index",
"\"_",
",_",
"index_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"is",
"Visible_",
"(_",
"self_",
",_",
"element_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"XX",
"X",
" ",
"DEP",
"RECA",
"TED",
" ",
"-",
" ",
"use",
" ",
"get",
"Vis",
"ibl",
"e",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"self_",
"._",
"get",
"Visible_",
"(_",
"element_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"Visible_",
"(_",
"self_",
",_",
"element_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Det",
"erm",
"ine",
" ",
"whe",
"ther",
" ",
"this",
" ",
"element",
" ",
"is",
" ",
"currentl",
"y",
" ",
"visi",
"ble",
",",
" ",
"by",
" ",
"checking",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"the",
" ",
"CS",
"S",
" ",
"property",
" ",
"'",
"display",
"'",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"element_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"element_",
"=_",
"self_",
"._",
"element_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"try_",
":_",
"#",
" ",
"yu",
"k",
"!",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"element_",
"._",
"style_",
"._",
"display_",
"!=_",
"\"",
"none",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Attribute",
"Error_",
":_",
"#",
" ",
"not",
" ",
"bee",
"n",
" ",
"set",
" ",
"(",
"ye",
"t",
"?)",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\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",
"Visible_",
"(_",
"self_",
",_",
"element_",
",_",
"visible_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Set",
" ",
"whe",
"ther",
" ",
"this",
" ",
"element",
" ",
"is",
" ",
"visi",
"ble",
" ",
"or",
" ",
"not",
".",
" ",
" ",
"If",
" ",
"a",
" ",
"single",
" ",
"parameter",
"\\",
"10",
";",
" ",
" ",
" ",
"is",
" ",
"give",
"n",
",",
" ",
"the",
" ",
"self",
".",
"element",
" ",
"is",
" ",
"used",
".",
" ",
" ",
"Thi",
"s",
" ",
"modifi",
"es",
" ",
"the",
" ",
"CS",
"S",
"\\",
"10",
";",
" ",
" ",
" ",
"property",
" ",
"'",
"display",
"',",
" ",
"whi",
"ch",
" ",
"means",
" ",
"tha",
"t",
" ",
"an",
" ",
"invisible",
" ",
"element",
" ",
"not",
"\\",
"10",
";",
" ",
" ",
" ",
"only",
" ",
"is",
" ",
"not",
" ",
"draw",
"n",
",",
" ",
"but",
" ",
"doe",
"sn",
"'",
"t",
" ",
"occu",
"py",
" ",
"any",
" ",
"space",
" ",
"on",
" ",
"the",
" ",
"page",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"visible_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"visible_",
"=_",
"element_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"element_",
"=_",
"self_",
"._",
"element_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"visible_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Style",
"Attribute_",
"(_",
"element_",
",_",
"'",
"display",
"'_",
",_",
"\"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"DOM_",
"._",
"set",
"Style",
"Attribute_",
"(_",
"element_",
",_",
"'",
"display",
"'_",
",_",
"\"",
"none",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"UI",
"Object_",
"(_",
"Appl",
"ier_",
")_",
":_",
"\\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_",
"uns",
"ink",
"Events_",
"(_",
"self_",
",_",
"event",
"Bit",
"s",
"To",
"Remove_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"Revers",
"e",
" ",
"the",
" ",
"operati",
"on",
" ",
"of",
" ",
"sink",
"Event",
"s",
".",
" ",
" ",
"See",
" ",
"L",
"{",
"UI",
"Object",
".",
"sink",
"Event",
"s",
"}.",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DOM_",
"._",
"sink",
"Events_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"~_",
"event",
"Bit",
"s",
"To",
"Remove_",
"&_",
"DOM_",
"._",
"get",
"Event",
"s",
"Sun",
"k_",
"(_",
"self_",
"._",
"get",
"Element_",
"(_",
")_",
")_",
")_",
"\\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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2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | andriyko/sublime-robot-framework-assistant/test/unit/test_indexkw.py | [
{
"content": " def test_parse_table_data(self):\n t_name = os.path.join(\n env.RESOURCES_DIR,\n 'BuiltIn-ca8f2e8d70641ce17b9b304086c19657.json'\n )\n self.index.queue.add(t_name, None, None)\n data, status = self.index.read_table(\n os.path.join(env.RESOURCES_DIR, t_name))\n var, kw_index = self.index.parse_table_data(data, t_name)\n self.assertTrue(u'${/}' in var)\n self.assertTrue('${OUTPUT_FILE}' in var)\n self.assertTrue('@{TEST_TAGS}' in var)",
"metadata": "root.TestIndexing.test_parse_table_data",
"header": "['class', 'TestIndexing', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 50
},
{
"content": " def test_add_builtin(self):\n self.index.add_builtin_to_queue(self.db_dir)\n self.assertTrue(len(self.index.queue.queue) > 0)",
"metadata": "root.TestIndexing.test_add_builtin",
"header": "['class', 'TestIndexing', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 63
},
{
"content": " def test_get_keywords_resource(self):\n data = self.get_resource_b()\n expected_kw_list = ['Resource B Keyword 2', 'Resource B Keyword 1']\n expected_arg_list = [['kwb1'], []]\n kw_list, arg_list = self.index.get_keywords(data)\n self.assertEqual(kw_list, expected_kw_list)\n self.assertEqual(arg_list.sort(), expected_arg_list.sort())\n\n data = self.get_test_a()\n expected_kw_list = ['Test A Keyword', 'Keyword']\n kw_list, arg_list = self.index.get_keywords(data)\n self.assertEqual(kw_list, expected_kw_list)\n self.assertEqual(arg_list, [[], []])\n\n data = self.get_s2l()\n parsed_kw, arg_list = self.index.get_keywords(data)\n self.assertTrue('Set Window Position' in parsed_kw)\n self.assertTrue('Get Cookies' in parsed_kw)\n self.assertTrue('Unselect Frame' in parsed_kw)\n self.assertTrue(['name'] in arg_list)\n l = ['driver_name', 'alias', 'kwargs', '**init_kwargs']\n self.assertTrue(l in arg_list)\n self.assertTrue(['*code'] in arg_list)",
"metadata": "root.TestIndexing.test_get_keywords_resource",
"header": "['class', 'TestIndexing', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 74
}
]
| [
{
"span": "self.assertTrue(u'${/}' in var)",
"start_line": 59,
"start_column": 8,
"end_line": 59,
"end_column": 39
},
{
"span": "self.assertTrue('${OUTPUT_FILE}' in var)",
"start_line": 60,
"start_column": 8,
"end_line": 60,
"end_column": 48
},
{
"span": "self.assertTrue('@{TEST_TAGS}' in var)",
"start_line": 61,
"start_column": 8,
"end_line": 61,
"end_column": 46
},
{
"span": "self.assertTrue(len(self.index.queue.queue) > 0)",
"start_line": 65,
"start_column": 8,
"end_line": 65,
"end_column": 56
},
{
"span": "self.assertTrue('Set Window Position' in parsed_kw)",
"start_line": 90,
"start_column": 8,
"end_line": 90,
"end_column": 59
},
{
"span": "self.assertTrue('Get Cookies' in parsed_kw)",
"start_line": 91,
"start_column": 8,
"end_line": 91,
"end_column": 51
},
{
"span": "self.assertTrue('Unselect Frame' in parsed_kw)",
"start_line": 92,
"start_column": 8,
"end_line": 92,
"end_column": 54
},
{
"span": "self.assertTrue(['name'] in arg_list)",
"start_line": 93,
"start_column": 8,
"end_line": 93,
"end_column": 45
},
{
"span": "self.assertTrue(l in arg_list)",
"start_line": 95,
"start_column": 8,
"end_line": 95,
"end_column": 38
},
{
"span": "self.assertTrue(['*code'] in arg_list)",
"start_line": 96,
"start_column": 8,
"end_line": 96,
"end_column": 46
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Test",
"Index",
"ing_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"parse",
"\\u",
"table",
"\\u",
"data_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"t",
"\\u",
"name_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"env_",
"._",
"RESOURCES",
"\\u",
"DIR_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Bu",
"ilt",
"In",
"-",
"ca",
"8f",
"2e",
"8d",
"706",
"4",
"1c",
"e1",
"7b",
"9",
"b3",
"040",
"86",
"c1",
"965",
"7",
".",
"json",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"index_",
"._",
"queue_",
"._",
"add_",
"(_",
"t",
"\\u",
"name_",
",_",
"None_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"data_",
",_",
"status_",
"=_",
"self_",
"._",
"index_",
"._",
"read",
"\\u",
"table_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"env_",
"._",
"RESOURCES",
"\\u",
"DIR_",
",_",
"t",
"\\u",
"name_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"var_",
",_",
"kw",
"\\u",
"index_",
"=_",
"self_",
"._",
"index_",
"._",
"parse",
"\\u",
"table",
"\\u",
"data_",
"(_",
"data_",
",_",
"t",
"\\u",
"name_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"u",
"'$",
"{",
"/",
"}'_",
"in_",
"var_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'$",
"{",
"OUTPU",
"T",
"\\u",
"FILE",
"}'_",
"in_",
"var_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'@",
"{",
"TEST",
"\\u",
"TAG",
"S",
"}'_",
"in_",
"var_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Index",
"ing_",
"(_",
"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",
"builtin_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"index_",
"._",
"add",
"\\u",
"bui",
"lti",
"n",
"\\u",
"to",
"\\u",
"queue_",
"(_",
"self_",
"._",
"db",
"\\u",
"dir_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"len_",
"(_",
"self_",
"._",
"index_",
"._",
"queue_",
"._",
"queue_",
")_",
">_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Index",
"ing_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"get",
"\\u",
"keywords",
"\\u",
"resource_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"data_",
"=_",
"self_",
"._",
"get",
"\\u",
"resource",
"\\u",
"b_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"kw",
"\\u",
"list_",
"=_",
"[_",
"'",
"Reso",
"urc",
"e",
" ",
"B",
" ",
"Key",
"word",
" ",
"2",
"'_",
",_",
"'",
"Reso",
"urc",
"e",
" ",
"B",
" ",
"Key",
"word",
" ",
"1",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"arg",
"\\u",
"list_",
"=_",
"[_",
"[_",
"'",
"kw",
"b1",
"'_",
"]_",
",_",
"[_",
"]_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kw",
"\\u",
"list_",
",_",
"arg",
"\\u",
"list_",
"=_",
"self_",
"._",
"index_",
"._",
"get",
"\\u",
"keywords_",
"(_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"kw",
"\\u",
"list_",
",_",
"expected",
"\\u",
"kw",
"\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"arg",
"\\u",
"list_",
"._",
"sort_",
"(_",
")_",
",_",
"expected",
"\\u",
"arg",
"\\u",
"list_",
"._",
"sort_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"=_",
"self_",
"._",
"get",
"\\u",
"test\\u",
"a_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected",
"\\u",
"kw",
"\\u",
"list_",
"=_",
"[_",
"'",
"Test",
" ",
"A",
" ",
"Key",
"word",
"'_",
",_",
"'",
"Key",
"word",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"kw",
"\\u",
"list_",
",_",
"arg",
"\\u",
"list_",
"=_",
"self_",
"._",
"index_",
"._",
"get",
"\\u",
"keywords_",
"(_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"kw",
"\\u",
"list_",
",_",
"expected",
"\\u",
"kw",
"\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"arg",
"\\u",
"list_",
",_",
"[_",
"[_",
"]_",
",_",
"[_",
"]_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"data_",
"=_",
"self_",
"._",
"get",
"\\u",
"s2",
"l_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parsed",
"\\u",
"kw_",
",_",
"arg",
"\\u",
"list_",
"=_",
"self_",
"._",
"index_",
"._",
"get",
"\\u",
"keywords_",
"(_",
"data_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"Set",
" ",
"Window",
" ",
"Position",
"'_",
"in_",
"parsed",
"\\u",
"kw_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"Get",
" ",
"Cooki",
"es",
"'_",
"in_",
"parsed",
"\\u",
"kw_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"'",
"Unse",
"lect",
" ",
"Frame",
"'_",
"in_",
"parsed",
"\\u",
"kw_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"[_",
"'",
"name",
"'_",
"]_",
"in_",
"arg",
"\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"l_",
"=_",
"[_",
"'",
"driver",
"\\u",
"name",
"'_",
",_",
"'",
"alias",
"'_",
",_",
"'",
"kwarg",
"s",
"'_",
",_",
"'**",
"init",
"\\u",
"kwarg",
"s",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"l_",
"in_",
"arg",
"\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"[_",
"'*",
"code",
"'_",
"]_",
"in_",
"arg",
"\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2
]
|
Testing equality to None | vmware/pyvmomi/pyVmomi/Iso8601.py | [
{
"content": "# VMware vSphere Python SDK\n# Copyright (c) 2008-2015 VMware, Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import print_function\n# TODO (hartsocks): Introduce logging to remove the need for print function.\n\"\"\"\nThis module is for ISO 8601 parsing\n\"\"\"\n__author__ = 'VMware, Inc.'\n\nfrom six import iteritems\nimport time\nfrom datetime import datetime, timedelta, tzinfo\nimport re\n\n\"\"\" Regular expression to parse a subset of ISO 8601 format \"\"\"\n_dtExpr = re.compile(\n # XMLSchema datetime. Mandatory to have - and :\n # See: http://www.w3.org/TR/xmlschema-2/#isoformats\n # Note: python datetime cannot handle the following:\n # - leap second, ie. 0-60 seconds (not 0-59)\n # - BC (negative years)\n # year [-]0000..9999\n r'(?P<year>-?\\d{4})' \\\n # month 01..12\n r'(-(?P<month>(0[1-9]|1[0-2]))' \\\n # day 01..31\n r'(-(?P<day>(0[1-9]|[1-2]\\d|3[01])))?)?' \\\n # time separator 'T'\n r'(T' \\\n # hour 00..24\n r'(?P<hour>([01]\\d|2[0-4]))' \\\n # minute 00..59\n r'((:(?P<minute>[0-5]\\d))' \\\n # seconds 00..60 (leap second ok)\n r'(:(?P<second>([0-5]\\d|60))' \\\n # microsecond. max 16 digits\n # - Should not allows trailing zeros. But python isoformat() put zeros\n # after microseconds. Oh well, allows trailing zeros, quite harmless\n r'(\\.(?P<microsecond>\\d{1,16}))?)?)?' \\\n # UTC 'Z', or...\n r'((?P<tzutc>Z)' \\\n # tz [+-]00..13:0..59|14:00\n r'|((?P<tzhr>[+-](([0]\\d)|(1[0-3])|(?P<tzlimit>)14))' \\\n r'(:(?P<tzmin>(?(tzlimit)00|([0-5]\\d))))?))?' \\\n r')?$')\n\n\"\"\" Default date time val. Key should match the tags in _dtExpr \"\"\"\n_dtExprKeyDefValMap = {'year' : None, 'month' : 1, 'day' : 1,\n 'hour' : 0, 'minute' : 0, 'second' : 0,\n 'microsecond' : 0}\n\n\n\n\n\n\n\n\n\n# Testing\nif __name__ == '__main__':\n # Valid entries\n for testStr in [\n '1971', # 1971-01-01\n '1971-11', # 1971-11-01\n '1971-11-02',\n '1971-11-02T23',\n '1971-11-02T23Z',\n '1971-11-02T23:04',\n '1971-11-02T23:04Z',\n '1971-11-02T23:04:15',\n '1971-11-02T23:04:15Z',\n '1971-11-02T23:04:15.1',\n '1971-11-02T23:04:15.01',\n '1971-11-02T23:04:15.023456',\n '1971-11-02T23:04:15.103456Z',\n '1971-11-02T23:04:15.123456+11',\n '1971-11-02T23:04:15.123456-11',\n '1971-11-02T23:04:15.123456+11:30',\n '1971-11-02T23:04:15.123456-11:30',\n '1971-11-02T23:04:15.123456+00:00', # Same as Z\n '1971-11-02T23:04:15.123456-00:00', # Same as Z\n\n '1971-01-02T23:04:15+14',\n '1971-01-02T23:04:15+14:00',\n '1971-01-02T23:04:15-14',\n '1971-01-02T23:04:15-14:00',\n\n # Valid: Truncate microsec to 6 digits\n '1971-01-02T23:04:15.123456891+11',\n\n '1971-01-02T24', # 24 is valid. It should represent the 00:00 the\n # next day\n '1971-01-02T24:00',\n '1971-01-02T24:00:00',\n '1971-01-02T24:00:00.0',\n\n # Should NOT be valid but python isoformat adding trailing zeros\n '1971-01-02T23:04:15.123430', # Microseconds ends in zero\n '1971-01-02T23:04:15.0', # Microseconds ends in zero\n\n # Should be valid but python datetime don't support it\n #'2005-12-31T23:59:60Z', # Leap second\n #'-0001', # BC 1\n ]:\n dt = ParseISO8601(testStr)\n if dt == None:\n print('Failed to parse ({0})'.format(testStr))\n assert(False)\n\n # Make sure we can translate back\n isoformat = ISO8601Format(dt)\n dt1 = ParseISO8601(isoformat)\n if dt.tzinfo is None:\n dt = dt.replace(tzinfo=dt1.tzinfo)\n if dt1 != dt:\n print('ParseISO8601 -> ISO8601Format -> ParseISO8601 failed ({0})'.format(testStr))\n assert(False)\n\n # Make sure we can parse python isoformat()\n dt2 = ParseISO8601(dt.isoformat())\n if dt2 == None:\n print('ParseISO8601(\"{0}\".isoformat()) failed'.format(testStr))\n assert(False)\n\n print(testStr, '->', dt, isoformat)\n\n # Basic form\n for testStr in [\n '197111', # 1971-11-01\n '19711102',\n '19711102T23',\n '19711102T23Z',\n '19711102T2304',\n '19711102T2304Z',\n '19711102T230415',\n '19711102T230415Z',\n '19711102T230415.123456',\n '19711102T230415.123456Z',\n '19711102T230415.123456+11',\n '19711102T230415.123456-11',\n '19711102T230415.123456+1130',\n '19711102T230415.123456-1130',\n ]:\n # Reject for now\n dt = ParseISO8601(testStr)\n if dt != None:\n print('ParseISO8601 ({0}) should fail, but it did not'.format(testStr))\n assert(False)\n #print testStr, '->', dt\n #assert(dt != None)\n\n # Invalid entries\n for testStr in [\n # Xml schema reject year 0\n '0000', # 0 years are not allowed\n '+0001', # Leading + is not allowed\n\n '', # Empty datetime str\n '09', # Years must be at least 4 digits\n '1971-01-02T', # T not follow by time\n '1971-01-02TZ', # T not follow by time\n '1971-01-02T+10', # T not follow by time\n '1971-01-02T-10', # T not follow by time\n '1971-01-02T23:', # extra :\n '1971-01-02T23:04:', # extra :\n '1971-01-02T23:0d', # 0d\n '1971-01-02T23:04:15.', # Dot not follows by microsec\n '1971-01-02+12', # time without T\n '1971Z', # Z without T\n '1971-01-02T23:04:15.123456Z+11', # Z follows by +\n '1971-01-02T23:04:15.123456Z-11', # Z follows by -\n '1971-01-02T23:04:15.123456+:30', # extra :\n '1971-01-02T23:04:15.123456+30:', # extra :\n '1971-01-02T23:04:15.01234567890123456789', # Too many microseconds digits\n\n # Python isoformat leave trailing zeros in microseconds\n # Relax regular expression to accept it\n #'1971-01-02T23:04:15.123430', # Microseconds ends in zero\n #'1971-01-02T23:04:15.0', # Microseconds ends in zero\n\n # Timezone must be between +14 / -14\n '1971-01-02T23:04:15+15',\n '1971-01-02T23:04:15-15',\n '1971-01-02T23:04:15+14:01',\n '1971-01-02T23:04:15-14:01',\n\n # Mix basic form with extended format\n '197101-02T23:04:15.123456',\n '19710102T23:04:15.123456',\n '19710102T230415.123456+11:30',\n '1971-01-02T230415.123456',\n '1971-01-02T23:04:15.123456+1130',\n\n # Error captured by datetime class\n '1971-00-02', # Less than 1 month\n '1971-13-02', # Larger than 12 months\n '1971-01-00', # Less than 1 day\n '1971-11-32', # Larger than 30 days for Nov\n '1971-12-32', # Larger than 31 days\n '1971-01-02T24:01', # Larger than 23 hr\n '1971-01-02T23:61', # Larger than 60 min\n '1971-01-02T23:60:61', # Larger than 61 sec\n ]:\n dt = ParseISO8601(testStr)\n if dt != None:\n print('ParseISO8601 ({0}) should fail, but it did not'.format(testStr))\n assert(False)\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
}
]
| [
{
"span": "dt == None:",
"start_line": 257,
"start_column": 9,
"end_line": 257,
"end_column": 19
},
{
"span": "dt2 == None:",
"start_line": 272,
"start_column": 9,
"end_line": 272,
"end_column": 20
}
]
| []
| 1 | true | [
"[CLS]_",
"Test",
"ing_",
"equality",
"_",
"to_",
"None_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"VM",
"ware",
" ",
"v",
"Sphere",
" ",
"Pyth",
"on",
" ",
"SD",
"K_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"2008",
"-",
"201",
"5",
" ",
"VM",
"ware",
",",
" ",
"Inc",
".",
" ",
"All",
" ",
"Rig",
"hts",
" ",
"Reserve",
"d",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"License",
"d",
" ",
"under",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"License",
",",
" ",
"Version",
" ",
"2.0",
" ",
"(",
"the",
" ",
"\"",
"License",
"\");",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"you",
" ",
"may",
" ",
"not",
" ",
"use",
" ",
"this",
" ",
"file",
" ",
"except",
" ",
"in",
" ",
"compli",
"anc",
"e",
" ",
"with",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"You",
" ",
"may",
" ",
"obtain",
" ",
"a",
" ",
"copy",
" ",
"of",
" ",
"the",
" ",
"License",
" ",
"at_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"http",
"://",
"www",
".",
"apa",
"che",
".",
"org",
"/",
"license",
"s",
"/",
"LICENSE",
"-",
"2.0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Un",
"less",
" ",
"require",
"d",
" ",
"by",
" ",
"applica",
"ble",
" ",
"law",
" ",
"or",
" ",
"agree",
"d",
" ",
"to",
" ",
"in",
" ",
"writ",
"ing",
",",
" ",
"software",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"distributed",
" ",
"under",
" ",
"the",
" ",
"License",
" ",
"is",
" ",
"distributed",
" ",
"on",
" ",
"an",
" ",
"\"",
"AS",
" ",
"IS",
"\"",
" ",
"BAS",
"IS",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"WITH",
"OUT",
" ",
"WAR",
"RAN",
"TIES",
" ",
"OR",
" ",
"CONDITION",
"S",
" ",
"OF",
" ",
"ANY",
" ",
"KIND",
",",
" ",
"eit",
"her",
" ",
"express",
" ",
"or",
" ",
"impli",
"ed",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"See",
" ",
"the",
" ",
"License",
" ",
"for",
" ",
"the",
" ",
"specific",
" ",
"language",
" ",
"govern",
"ing",
" ",
"permissi",
"ons",
" ",
"and_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"limit",
"ation",
"s",
" ",
"under",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"\\u\\u",
"future\\u\\u_",
"import_",
"print",
"\\u",
"function_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
" ",
"(",
"hart",
"socks",
"):",
" ",
"Introduc",
"e",
" ",
"logg",
"ing",
" ",
"to",
" ",
"remove",
" ",
"the",
" ",
"need",
" ",
"for",
" ",
"print",
" ",
"function",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
"\\",
"10",
";",
"Thi",
"s",
" ",
"module",
" ",
"is",
" ",
"for",
" ",
"ISO",
" ",
"860",
"1",
" ",
"pars",
"ing",
"\\",
"10",
";\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u",
"author\\u\\u_",
"=_",
"'",
"VM",
"ware",
",",
" ",
"Inc",
".'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"six_",
"import_",
"iteritems_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"datetime_",
"import_",
"datetime_",
",_",
"timedelta_",
",_",
"tzinfo_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
" ",
"Regula",
"r",
" ",
"express",
"ion",
" ",
"to",
" ",
"parse",
" ",
"a",
" ",
"subse",
"t",
" ",
"of",
" ",
"ISO",
" ",
"860",
"1",
" ",
"format",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"dt",
"Expr_",
"=_",
"re_",
"._",
"compile_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"XML",
"Schema",
" ",
"datetime",
".",
" ",
"Mandato",
"ry",
" ",
"to",
" ",
"have",
" ",
"-",
" ",
"and",
" ",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"See",
":",
" ",
"http",
"://",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"xmls",
"chema",
"-",
"2",
"/",
"#",
"isof",
"ormat",
"s_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Not",
"e",
":",
" ",
"python",
" ",
"datetime",
" ",
"cann",
"ot",
" ",
"handle",
" ",
"the",
" ",
"follow",
"ing",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"-",
" ",
"leap",
" ",
"second",
",",
" ",
"ie",
".",
" ",
"0",
"-",
"60",
" ",
"second",
"s",
" ",
"(",
"not",
" ",
"0",
"-",
"5",
"9",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"-",
" ",
"BC",
" ",
"(",
"negati",
"ve",
" ",
"year",
"s",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"year",
" ",
"[-]",
"0000",
"..",
"9999_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(",
"?",
"P",
"<",
"year",
">-",
"?\\\\",
"d",
"{",
"4",
"})'_",
"#",
" ",
"month",
" ",
"01",
"..",
"12_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(",
"-(",
"?",
"P",
"<",
"month",
">(",
"0",
"[",
"1",
"-",
"9",
"]|",
"1",
"[",
"0",
"-",
"2",
"]))",
"'_",
"#",
" ",
"day",
" ",
"01",
"..",
"31_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(",
"-(",
"?",
"P",
"<",
"day",
">(",
"0",
"[",
"1",
"-",
"9",
"]|",
"[",
"1",
"-",
"2",
"]\\\\",
"d",
"|",
"3",
"[",
"01",
"]))",
")?",
")?'_",
"#",
" ",
"time",
" ",
"separator",
" ",
"'",
"T",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(",
"T",
"'_",
"#",
" ",
"hour",
" ",
"00",
"..",
"24_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(",
"?",
"P",
"<",
"hour",
">([",
"01",
"]\\\\",
"d",
"|",
"2",
"[",
"0",
"-",
"4",
"]))",
"'_",
"#",
" ",
"minute",
" ",
"00",
"..",
"59_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'((",
":(?",
"P",
"<",
"minute",
">[",
"0",
"-",
"5",
"]\\\\",
"d",
"))'_",
"#",
" ",
"second",
"s",
" ",
"00",
"..",
"60",
" ",
"(",
"leap",
" ",
"second",
" ",
"ok",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(",
":(?",
"P",
"<",
"second",
">([",
"0",
"-",
"5",
"]\\\\",
"d",
"|",
"60",
"))'_",
"#",
" ",
"microsecond",
".",
" ",
"max",
" ",
"16",
" ",
"digits_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"-",
" ",
"Sho",
"ul",
"d",
" ",
"not",
" ",
"allow",
"s",
" ",
"trail",
"ing",
" ",
"zero",
"s",
".",
" ",
"Bu",
"t",
" ",
"python",
" ",
"isof",
"ormat",
"()",
" ",
"put",
" ",
"zeros_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"after",
" ",
"microsecond",
"s",
".",
" ",
"Oh",
" ",
"well",
",",
" ",
"allow",
"s",
" ",
"trail",
"ing",
" ",
"zero",
"s",
",",
" ",
"quite",
" ",
"harm",
"less_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'(\\\\",
".(",
"?",
"P",
"<",
"microsecond",
">\\\\",
"d",
"{",
"1",
",",
"16",
"}))",
"?)",
"?)",
"?'_",
"#",
" ",
"UT",
"C",
" ",
"'",
"Z",
"',",
" ",
"or",
"..._",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'((",
"?",
"P",
"<",
"tz",
"utc",
">",
"Z",
")'_",
"#",
" ",
"tz",
" ",
"[+",
"-]",
"00",
"..",
"13",
":",
"0.",
".5",
"9",
"|",
"14",
":",
"00_",
"\\u\\u\\uNL\\u\\u\\u_",
"r",
"'|",
"((",
"?",
"P",
"<",
"tz",
"hr",
">[",
"+-",
"](",
"([",
"0",
"]\\\\",
"d",
")|(",
"1",
"[",
"0",
"-",
"3",
"])",
"|(?",
"P",
"<",
"tz",
"limit",
">)",
"14",
"))'_",
"r",
"'(",
":(?",
"P",
"<",
"tz",
"min",
">(",
"?(",
"tz",
"limit",
")",
"00",
"|(",
"[",
"0",
"-",
"5",
"]\\\\",
"d",
"))))",
"?)",
")?'_",
"r",
"')",
"?$",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"\"\"",
" ",
"Default",
" ",
"date",
" ",
"time",
" ",
"val",
".",
" ",
"Key",
" ",
"shou",
"ld",
" ",
"match",
" ",
"the",
" ",
"tags",
" ",
"in",
" ",
"\\u",
"dt",
"Exp",
"r",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u",
"dt",
"Exp",
"r",
"Key",
"Def",
"Val",
"Map_",
"=_",
"{_",
"'",
"year",
"'_",
":_",
"None_",
",_",
"'",
"month",
"'_",
":_",
"1_",
",_",
"'",
"day",
"'_",
":_",
"1_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"hour",
"'_",
":_",
"0_",
",_",
"'",
"minute",
"'_",
":_",
"0_",
",_",
"'",
"second",
"'_",
":_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"microsecond",
"'_",
":_",
"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\\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_",
"#",
" ",
"Test",
"ing_",
"\\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_",
"#",
" ",
"Valid",
" ",
"entries_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"test",
"Str_",
"in_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"'_",
",_",
"#",
" ",
"197",
"1",
"-0",
"1",
"-0",
"1_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"'_",
",_",
"#",
" ",
"197",
"1",
"-1",
"1",
"-0",
"1_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"1",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"01",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"023",
"456",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"103",
"456",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"+",
"11",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"-1",
"1",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"+",
"11",
":",
"30",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"-1",
"1",
":",
"30",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"+0",
"0",
":",
"00",
"'_",
",_",
"#",
" ",
"Sam",
"e",
" ",
"as",
" ",
"Z_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"-0",
"0",
":",
"00",
"'_",
",_",
"#",
" ",
"Sam",
"e",
" ",
"as",
" ",
"Z_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"+",
"14",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"+",
"14",
":",
"00",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"-1",
"4",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"-1",
"4",
":",
"00",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Valid",
":",
" ",
"Truncate",
" ",
"micros",
"ec",
" ",
"to",
" ",
"6",
" ",
"digits_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"689",
"1",
"+",
"11",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"4",
"'_",
",_",
"#",
" ",
"24",
" ",
"is",
" ",
"valid",
".",
" ",
"It",
" ",
"shou",
"ld",
" ",
"represent",
" ",
"the",
" ",
"00",
":",
"00",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"next",
" ",
"day_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"4",
":",
"00",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"4",
":",
"00",
":",
"00",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"4",
":",
"00",
":",
"00",
".0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sho",
"ul",
"d",
" ",
"NOT",
" ",
"be",
" ",
"valid",
" ",
"but",
" ",
"python",
" ",
"isof",
"ormat",
" ",
"addin",
"g",
" ",
"trail",
"ing",
" ",
"zeros_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"1234",
"30",
"'_",
",_",
"#",
" ",
"Micro",
"second",
"s",
" ",
"ends",
" ",
"in",
" ",
"zero_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"0",
"'_",
",_",
"#",
" ",
"Micro",
"second",
"s",
" ",
"ends",
" ",
"in",
" ",
"zero_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sho",
"ul",
"d",
" ",
"be",
" ",
"valid",
" ",
"but",
" ",
"python",
" ",
"datetime",
" ",
"don",
"'",
"t",
" ",
"support",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#'",
"2005",
"-1",
"2",
"-",
"3",
"1",
"T2",
"3",
":",
"5",
"9",
":",
"60",
"Z",
"',",
" ",
"#",
" ",
"Lea",
"p",
" ",
"second_",
"\\u\\u\\uNL\\u\\u\\u_",
"#'",
"-0",
"001",
"',",
" ",
"#",
" ",
"BC",
" ",
"1_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dt_",
"=_",
"Pars",
"e",
"ISO",
"860",
"1_",
"(_",
"test",
"Str_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"dt_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"Fail",
"ed",
" ",
"to",
" ",
"parse",
" ",
"({",
"0",
"})'_",
"._",
"format_",
"(_",
"test",
"Str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"(_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Make",
" ",
"sure",
" ",
"we",
" ",
"can",
" ",
"translat",
"e",
" ",
"back_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"isoformat_",
"=_",
"ISO",
"860",
"1",
"Format_",
"(_",
"dt_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"dt",
"1_",
"=_",
"Pars",
"e",
"ISO",
"860",
"1_",
"(_",
"isoformat_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"dt_",
"._",
"tzinfo_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dt_",
"=_",
"dt_",
"._",
"replace_",
"(_",
"tzinfo_",
"=_",
"dt",
"1_",
"._",
"tzinfo_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"dt",
"1_",
"!=_",
"dt_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"Pars",
"e",
"ISO",
"860",
"1",
" ",
"->",
" ",
"ISO",
"860",
"1",
"Format",
" ",
"->",
" ",
"Pars",
"e",
"ISO",
"860",
"1",
" ",
"fail",
"ed",
" ",
"({",
"0",
"})'_",
"._",
"format_",
"(_",
"test",
"Str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"(_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Make",
" ",
"sure",
" ",
"we",
" ",
"can",
" ",
"parse",
" ",
"python",
" ",
"isof",
"ormat",
"()",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"dt",
"2_",
"=_",
"Pars",
"e",
"ISO",
"860",
"1_",
"(_",
"dt_",
"._",
"isoformat_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"dt",
"2_",
"==_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"Pars",
"e",
"ISO",
"860",
"1",
"(\"",
"{",
"0",
"}\"",
".",
"isof",
"ormat",
"())",
" ",
"fail",
"ed",
"'_",
"._",
"format_",
"(_",
"test",
"Str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"(_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"(_",
"test",
"Str_",
",_",
"'->",
"'_",
",_",
"dt_",
",_",
"isoformat_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Basic",
" ",
"form_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"test",
"Str_",
"in_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"111",
"'_",
",_",
"#",
" ",
"197",
"1",
"-1",
"1",
"-0",
"1_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"3",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"3",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"Z",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"+",
"11",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"-1",
"1",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"+",
"113",
"0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1110",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"-1",
"130",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Reject",
" ",
"for",
" ",
"now_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dt_",
"=_",
"Pars",
"e",
"ISO",
"860",
"1_",
"(_",
"test",
"Str_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"dt_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"Pars",
"e",
"ISO",
"860",
"1",
" ",
"({",
"0",
"})",
" ",
"shou",
"ld",
" ",
"fail",
",",
" ",
"but",
" ",
"it",
" ",
"did",
" ",
"not",
"'_",
"._",
"format_",
"(_",
"test",
"Str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"(_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"print",
" ",
"test",
"Str",
",",
" ",
"'->",
"',",
" ",
"dt_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"assert",
"(",
"dt",
" ",
"!=",
" ",
"Non",
"e",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Inva",
"lid",
" ",
"entries_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"test",
"Str_",
"in_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Xm",
"l",
" ",
"schema",
" ",
"reject",
" ",
"year",
" ",
"0_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"0000",
"'_",
",_",
"#",
" ",
"0",
" ",
"year",
"s",
" ",
"are",
" ",
"not",
" ",
"allowed_",
"\\u\\u\\uNL\\u\\u\\u_",
"'+",
"0001",
"'_",
",_",
"#",
" ",
"Lead",
"ing",
" ",
"+",
" ",
"is",
" ",
"not",
" ",
"allowed_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"''_",
",_",
"#",
" ",
"Emp",
"ty",
" ",
"datetime",
" ",
"str_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"09",
"'_",
",_",
"#",
" ",
"Year",
"s",
" ",
"must",
" ",
"be",
" ",
"at",
" ",
"leas",
"t",
" ",
"4",
" ",
"digits_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T",
"'_",
",_",
"#",
" ",
"T",
" ",
"not",
" ",
"follow",
" ",
"by",
" ",
"time_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"TZ",
"'_",
",_",
"#",
" ",
"T",
" ",
"not",
" ",
"follow",
" ",
"by",
" ",
"time_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T",
"+",
"10",
"'_",
",_",
"#",
" ",
"T",
" ",
"not",
" ",
"follow",
" ",
"by",
" ",
"time_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T",
"-1",
"0",
"'_",
",_",
"#",
" ",
"T",
" ",
"not",
" ",
"follow",
" ",
"by",
" ",
"time_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":'_",
",_",
"#",
" ",
"extra",
" ",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":'_",
",_",
"#",
" ",
"extra",
" ",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"0d",
"'_",
",_",
"#",
" ",
"0d",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"'_",
",_",
"#",
" ",
"Dot",
" ",
"not",
" ",
"follow",
"s",
" ",
"by",
" ",
"micros",
"ec_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"+",
"1",
"2",
"'_",
",_",
"#",
" ",
"time",
" ",
"with",
"out",
" ",
"T_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"Z",
"'_",
",_",
"#",
" ",
"Z",
" ",
"with",
"out",
" ",
"T_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"Z",
"+",
"11",
"'_",
",_",
"#",
" ",
"Z",
" ",
"follow",
"s",
" ",
"by",
" ",
"+_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"Z",
"-1",
"1",
"'_",
",_",
"#",
" ",
"Z",
" ",
"follow",
"s",
" ",
"by",
" ",
"-_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"+:",
"30",
"'_",
",_",
"#",
" ",
"extra",
" ",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"+",
"30",
":'_",
",_",
"#",
" ",
"extra",
" ",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"0123456",
"7890",
"12345678",
"9",
"'_",
",_",
"#",
" ",
"Too",
" ",
"many",
" ",
"microsecond",
"s",
" ",
"digits_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Pyth",
"on",
" ",
"isof",
"ormat",
" ",
"lea",
"ve",
" ",
"trail",
"ing",
" ",
"zero",
"s",
" ",
"in",
" ",
"microseconds_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Rela",
"x",
" ",
"regular",
" ",
"express",
"ion",
" ",
"to",
" ",
"accept",
" ",
"it_",
"\\u\\u\\uNL\\u\\u\\u_",
"#'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"1234",
"30",
"',",
" ",
"#",
" ",
"Micro",
"second",
"s",
" ",
"ends",
" ",
"in",
" ",
"zero_",
"\\u\\u\\uNL\\u\\u\\u_",
"#'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"0",
"',",
" ",
"#",
" ",
"Micro",
"second",
"s",
" ",
"ends",
" ",
"in",
" ",
"zero_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Timezone",
" ",
"must",
" ",
"be",
" ",
"bet",
"ween",
" ",
"+",
"14",
" ",
"/",
" ",
"-1",
"4_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"+",
"15",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"-1",
"5",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"+",
"14",
":",
"01",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15",
"-1",
"4",
":",
"01",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Mix",
" ",
"basic",
" ",
"form",
" ",
"with",
" ",
"extend",
"ed",
" ",
"format_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"101",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1010",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1010",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"+",
"11",
":",
"30",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"304",
"15.",
"12345",
"6",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"04",
":",
"15.",
"12345",
"6",
"+",
"113",
"0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Error",
" ",
"captured",
" ",
"by",
" ",
"datetime",
" ",
"class_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"0",
"-0",
"2",
"'_",
",_",
"#",
" ",
"Less",
" ",
"than",
" ",
"1",
" ",
"month_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"3",
"-0",
"2",
"'_",
",_",
"#",
" ",
"Large",
"r",
" ",
"than",
" ",
"1",
"2",
" ",
"months_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"0",
"'_",
",_",
"#",
" ",
"Less",
" ",
"than",
" ",
"1",
" ",
"day_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"1",
"-",
"32",
"'_",
",_",
"#",
" ",
"Large",
"r",
" ",
"than",
" ",
"30",
" ",
"day",
"s",
" ",
"for",
" ",
"Nov",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-1",
"2",
"-",
"32",
"'_",
",_",
"#",
" ",
"Large",
"r",
" ",
"than",
" ",
"3",
"1",
" ",
"days_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"4",
":",
"01",
"'_",
",_",
"#",
" ",
"Large",
"r",
" ",
"than",
" ",
"23",
" ",
"hr_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"6",
"1",
"'_",
",_",
"#",
" ",
"Large",
"r",
" ",
"than",
" ",
"60",
" ",
"min_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"197",
"1",
"-0",
"1",
"-0",
"2",
"T2",
"3",
":",
"60",
":",
"6",
"1",
"'_",
",_",
"#",
" ",
"Large",
"r",
" ",
"than",
" ",
"6",
"1",
" ",
"sec_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dt_",
"=_",
"Pars",
"e",
"ISO",
"860",
"1_",
"(_",
"test",
"Str_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"dt_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"(_",
"'",
"Pars",
"e",
"ISO",
"860",
"1",
" ",
"({",
"0",
"})",
" ",
"shou",
"ld",
" ",
"fail",
",",
" ",
"but",
" ",
"it",
" ",
"did",
" ",
"not",
"'_",
"._",
"format_",
"(_",
"test",
"Str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"(_",
"False_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | tgonzales/mingus/tests/test_query.py | [
{
"content": "import random\nimport unittest\nimport requests\nimport json\n# python -m unittest tests/test_status_code.py -v\n\nuri = 'http://localhost:8888/v1/song'\nr = requests.get(uri)\nobjects = r.json()\nobj = [obj['_id']['$oid'] for obj in objects['objects']]\nobj_uri = obj[0] \nr.connection.close()\n\n\nif __name__ == '__main__':\n unittest.main()\n ",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class TestSequenceFunctions(unittest.TestCase):\n\n",
"metadata": "root.TestSequenceFunctions",
"header": "['module', '___EOS___']",
"index": 13
},
{
"content": " def setUp(self):\n self.seq = list(range(10))",
"metadata": "root.TestSequenceFunctions.setUp",
"header": "['class', 'TestSequenceFunctions', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 15
},
{
"content": " def test_query(self):\n pass ",
"metadata": "root.TestSequenceFunctions.test_query",
"header": "['class', 'TestSequenceFunctions', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 18
}
]
| [
{
"span": "import random",
"start_line": 0,
"start_column": 0,
"end_line": 0,
"end_column": 13
},
{
"span": "import json",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 11
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"random_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"requests_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"json_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"python",
" ",
"-",
"m",
" ",
"unittest",
" ",
"tests",
"/",
"test\\u",
"status",
"\\u",
"code",
".",
"py",
" ",
"-",
"v_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"uri_",
"=_",
"'",
"http",
"://",
"local",
"host",
":",
"8888",
"/",
"v1",
"/",
"song",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"requests_",
"._",
"get_",
"(_",
"uri_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"objects_",
"=_",
"r_",
"._",
"json_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"obj_",
"=_",
"[_",
"obj_",
"[_",
"'\\u",
"id",
"'_",
"]_",
"[_",
"'$",
"oid",
"'_",
"]_",
"for_",
"obj_",
"in_",
"objects_",
"[_",
"'",
"object",
"s",
"'_",
"]_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"obj",
"\\u",
"uri_",
"=_",
"obj_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"connection_",
"._",
"close_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"\\u\\u",
"name\\u\\u_",
"==_",
"'\\u",
"\\u",
"main",
"\\u\\u'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"unittest_",
"._",
"main_",
"(_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Test",
"Sequ",
"ence",
"Functions_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Sequ",
"ence",
"Functions_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"seq_",
"=_",
"list_",
"(_",
"range_",
"(_",
"10_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Sequ",
"ence",
"Functions_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"query_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
2,
2,
0,
1,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | ejeschke/ginga/ginga/pilw/CanvasRenderPil.py | [
{
"content": "#\n# CanvasRenderPil.py -- for rendering into a PIL Image\n#\n# Eric Jeschke ([email protected])\n#\n# Copyright (c) Eric R. Jeschke. All rights reserved.\n# This is open-source software licensed under a BSD license.\n# Please see the file LICENSE.txt for details.\n\nimport math\n\nfrom PIL import Image, ImageDraw, ImageFont\nfrom . import PilHelp\nfrom itertools import chain\n# force registration of all canvas types\nimport ginga.canvas.types.all\n\n\n\n\n#END\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class RenderContext(object):\n\n\n\n\n\n\n\n\n\n\n\n ##### DRAWING OPERATIONS #####\n\n\n\n\n\n",
"metadata": "root.RenderContext",
"header": "['module', '___EOS___']",
"index": 17
},
{
"content": " def __init__(self, viewer):\n self.viewer = viewer\n\n # TODO: encapsulate this drawable\n self.cr = PilHelp.PilContext(self.viewer.get_surface())\n\n self.pen = None\n self.brush = None\n self.font = None",
"metadata": "root.RenderContext.__init__",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 19
},
{
"content": " def set_line_from_shape(self, shape):\n # TODO: support line width and style\n alpha = getattr(shape, 'alpha', 1.0)\n self.pen = self.cr.get_pen(shape.color, alpha=alpha)",
"metadata": "root.RenderContext.set_line_from_shape",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 29
},
{
"content": " def set_fill_from_shape(self, shape):\n fill = getattr(shape, 'fill', False)\n if fill:\n if hasattr(shape, 'fillcolor') and shape.fillcolor:\n color = shape.fillcolor\n else:\n color = shape.color\n alpha = getattr(shape, 'alpha', 1.0)\n alpha = getattr(shape, 'fillalpha', alpha)\n self.brush = self.cr.get_brush(color, alpha=alpha)\n else:\n self.brush = None",
"metadata": "root.RenderContext.set_fill_from_shape",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 34
},
{
"content": " def set_font_from_shape(self, shape):\n if hasattr(shape, 'font'):\n if hasattr(shape, 'fontsize') and shape.fontsize is not None:\n fontsize = shape.fontsize\n else:\n fontsize = shape.scale_font(self.viewer)\n alpha = getattr(shape, 'alpha', 1.0)\n self.font = self.cr.get_font(shape.font, fontsize, shape.color,\n alpha=alpha)\n else:\n self.font = None",
"metadata": "root.RenderContext.set_font_from_shape",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 47
},
{
"content": " def initialize_from_shape(self, shape, line=True, fill=True, font=True):\n if line:\n self.set_line_from_shape(shape)\n if fill:\n self.set_fill_from_shape(shape)\n if font:\n self.set_font_from_shape(shape)",
"metadata": "root.RenderContext.initialize_from_shape",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 59
},
{
"content": " def set_line(self, color, alpha=1.0, linewidth=1, style='solid'):\n # TODO: support line width and style\n self.pen = self.cr.get_pen(color, alpha=alpha)",
"metadata": "root.RenderContext.set_line",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 67
},
{
"content": " def set_fill(self, color, alpha=1.0):\n if color is None:\n self.brush = None\n else:\n self.brush = self.cr.get_brush(color, alpha=alpha)",
"metadata": "root.RenderContext.set_fill",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 71
},
{
"content": " def set_font(self, fontname, fontsize, color='black', alpha=1.0):\n self.font = self.cr.get_font(fontname, fontsize, color,\n alpha=alpha)",
"metadata": "root.RenderContext.set_font",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 77
},
{
"content": " def text_extents(self, text):\n return self.cr.text_extents(text, self.font)",
"metadata": "root.RenderContext.text_extents",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 81
},
{
"content": " def get_affine_transform(self, cx, cy, rot_deg):\n x, y = 0, 0 # old center\n nx, ny = cx, cy # new center\n sx = sy = 1.0 # new scale\n cosine = math.cos(math.radians(rot_deg))\n sine = math.sin(math.radians(rot_deg))\n a = cosine / sx\n b = sine / sx\n c = x - nx*a - ny*b\n d = -sine / sy\n e = cosine / sy\n f = y - nx*d - ny*e\n return (a, b, c, d, e, f)",
"metadata": "root.RenderContext.get_affine_transform",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 84
},
{
"content": " def draw_text(self, cx, cy, text, rot_deg=0.0):\n\n wd, ht = self.cr.text_extents(text, self.font)\n\n self.cr.text((cx, cy-ht), text, self.font, self.pen)",
"metadata": "root.RenderContext.draw_text",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 100
},
{
"content": " def draw_polygon(self, cpoints):\n self.cr.polygon(cpoints, self.pen, self.brush)",
"metadata": "root.RenderContext.draw_polygon",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 106
},
{
"content": " def draw_circle(self, cx, cy, cradius):\n self.cr.circle((cx, cy), cradius, self.pen, self.brush)",
"metadata": "root.RenderContext.draw_circle",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 109
},
{
"content": " def draw_ellipse(self, cx, cy, cxradius, cyradius, theta):\n # NOTE: theta currently not supported with PIL renderer\n self.cr.ellipse((cx, cy), cxradius, cyradius, theta,\n self.pen, self.brush)",
"metadata": "root.RenderContext.draw_ellipse",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 112
},
{
"content": " def draw_line(self, cx1, cy1, cx2, cy2):\n self.cr.line((cx1, cy1), (cx2, cy2), self.pen)",
"metadata": "root.RenderContext.draw_line",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 117
},
{
"content": " def draw_path(self, cpoints):\n self.cr.path(cpoints, self.pen)",
"metadata": "root.RenderContext.draw_path",
"header": "['class', 'RenderContext', '(', 'object', ')', ':', '___EOS___']",
"index": 120
},
{
"content": "class CanvasRenderer(object):\n\n\n",
"metadata": "root.CanvasRenderer",
"header": "['module', '___EOS___']",
"index": 124
},
{
"content": " def __init__(self, viewer):\n self.viewer = viewer",
"metadata": "root.CanvasRenderer.__init__",
"header": "['class', 'CanvasRenderer', '(', 'object', ')', ':', '___EOS___']",
"index": 126
},
{
"content": " def setup_cr(self, shape):\n cr = RenderContext(self.viewer)\n cr.initialize_from_shape(shape, font=False)\n return cr",
"metadata": "root.CanvasRenderer.setup_cr",
"header": "['class', 'CanvasRenderer', '(', 'object', ')', ':', '___EOS___']",
"index": 129
},
{
"content": " def get_dimensions(self, shape):\n cr = self.setup_cr(shape)\n cr.set_font_from_shape(shape)\n return cr.text_extents(shape.text)",
"metadata": "root.CanvasRenderer.get_dimensions",
"header": "['class', 'CanvasRenderer', '(', 'object', ')', ':', '___EOS___']",
"index": 134
}
]
| [
{
"span": "from PIL import Image, ImageDraw, ImageFont",
"start_line": 11,
"start_column": 0,
"end_line": 11,
"end_column": 43
},
{
"span": "from itertools import chain",
"start_line": 13,
"start_column": 0,
"end_line": 13,
"end_column": 27
},
{
"span": "import ginga.canvas.types.all",
"start_line": 15,
"start_column": 0,
"end_line": 15,
"end_column": 29
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Can",
"vas",
"Render",
"Pil",
".",
"py",
" ",
"--",
" ",
"for",
" ",
"render",
"ing",
" ",
"int",
"o",
" ",
"a",
" ",
"PI",
"L",
" ",
"Image_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Eri",
"c",
" ",
"Je",
"sch",
"ke",
" ",
"(",
"eric",
"@",
"nao",
"j",
".",
"org",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Copy",
"right",
" ",
"(",
"c",
")",
" ",
"Eri",
"c",
" ",
"R",
".",
" ",
"Je",
"sch",
"ke",
".",
" ",
" ",
"All",
" ",
"rights",
" ",
"reserve",
"d",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"is",
" ",
"open",
"-",
"source",
" ",
"software",
" ",
"license",
"d",
" ",
"under",
" ",
"a",
" ",
"BS",
"D",
" ",
"license",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Ple",
"ase",
" ",
"see",
" ",
"the",
" ",
"file",
" ",
"LICENSE",
".",
"txt",
" ",
"for",
" ",
"deta",
"il",
"s",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"math_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"PIL_",
"import_",
"Image_",
",_",
"Image",
"Draw_",
",_",
"Image",
"Font_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"._",
"import_",
"Pil",
"Help_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"itertools_",
"import_",
"chain_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"force",
" ",
"registration",
" ",
"of",
" ",
"all",
" ",
"canv",
"as",
" ",
"types_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"ging",
"a_",
"._",
"canvas_",
"._",
"types_",
"._",
"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\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"END_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Render",
"Context_",
"(_",
"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_",
"#####",
" ",
"DRAW",
"ING",
" ",
"OPERATION",
"S",
" ",
"#####",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"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_",
",_",
"viewer_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"viewer_",
"=_",
"viewer_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"encapsulat",
"e",
" ",
"this",
" ",
"drawa",
"ble_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"cr_",
"=_",
"Pil",
"Help_",
"._",
"Pil",
"Context_",
"(_",
"self_",
"._",
"viewer_",
"._",
"get",
"\\u",
"surface_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"pen_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"brush_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"font_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"line",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"self_",
",_",
"shape_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"support",
" ",
"line",
" ",
"widt",
"h",
" ",
"and",
" ",
"style_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"alpha_",
"=_",
"getattr_",
"(_",
"shape_",
",_",
"'",
"alpha",
"'_",
",_",
"1.0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"pen_",
"=_",
"self_",
"._",
"cr_",
"._",
"get",
"\\u",
"pen_",
"(_",
"shape_",
"._",
"color_",
",_",
"alpha_",
"=_",
"alpha_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"fill",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"self_",
",_",
"shape_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fill_",
"=_",
"getattr_",
"(_",
"shape_",
",_",
"'",
"fill",
"'_",
",_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"fill_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"shape_",
",_",
"'",
"fillc",
"olor",
"'_",
")_",
"and_",
"shape_",
"._",
"fillc",
"olor_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"color_",
"=_",
"shape_",
"._",
"fillc",
"olor_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"color_",
"=_",
"shape_",
"._",
"color_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"alpha_",
"=_",
"getattr_",
"(_",
"shape_",
",_",
"'",
"alpha",
"'_",
",_",
"1.0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"alpha_",
"=_",
"getattr_",
"(_",
"shape_",
",_",
"'",
"fill",
"alpha",
"'_",
",_",
"alpha_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"brush_",
"=_",
"self_",
"._",
"cr_",
"._",
"get",
"\\u",
"brush_",
"(_",
"color_",
",_",
"alpha_",
"=_",
"alpha_",
")_",
"\\u\\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_",
"._",
"brush_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"font",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"self_",
",_",
"shape_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"shape_",
",_",
"'",
"font",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"hasattr_",
"(_",
"shape_",
",_",
"'",
"font",
"size",
"'_",
")_",
"and_",
"shape_",
"._",
"fontsize_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fontsize_",
"=_",
"shape_",
"._",
"fontsize_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"fontsize_",
"=_",
"shape_",
"._",
"scale",
"\\u",
"font_",
"(_",
"self_",
"._",
"viewer_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"alpha_",
"=_",
"getattr_",
"(_",
"shape_",
",_",
"'",
"alpha",
"'_",
",_",
"1.0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"font_",
"=_",
"self_",
"._",
"cr_",
"._",
"get",
"\\u",
"font_",
"(_",
"shape_",
"._",
"font_",
",_",
"fontsize_",
",_",
"shape_",
"._",
"color_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"alpha_",
"=_",
"alpha_",
")_",
"\\u\\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_",
"._",
"font_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"initialize",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"self_",
",_",
"shape_",
",_",
"line_",
"=_",
"True_",
",_",
"fill_",
"=_",
"True_",
",_",
"font_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"line_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"set\\u",
"line",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"shape_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"fill_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"set\\u",
"fill",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"shape_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"font_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"set\\u",
"font",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"shape_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"line_",
"(_",
"self_",
",_",
"color_",
",_",
"alpha_",
"=_",
"1.0_",
",_",
"linewidth_",
"=_",
"1_",
",_",
"style_",
"=_",
"'",
"solid",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"support",
" ",
"line",
" ",
"widt",
"h",
" ",
"and",
" ",
"style_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"pen_",
"=_",
"self_",
"._",
"cr_",
"._",
"get",
"\\u",
"pen_",
"(_",
"color_",
",_",
"alpha_",
"=_",
"alpha_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"fill_",
"(_",
"self_",
",_",
"color_",
",_",
"alpha_",
"=_",
"1.0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"color_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"brush_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"brush_",
"=_",
"self_",
"._",
"cr_",
"._",
"get",
"\\u",
"brush_",
"(_",
"color_",
",_",
"alpha_",
"=_",
"alpha_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"font_",
"(_",
"self_",
",_",
"font",
"name_",
",_",
"fontsize_",
",_",
"color_",
"=_",
"'",
"black",
"'_",
",_",
"alpha_",
"=_",
"1.0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"font_",
"=_",
"self_",
"._",
"cr_",
"._",
"get",
"\\u",
"font_",
"(_",
"font",
"name_",
",_",
"fontsize_",
",_",
"color_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"alpha_",
"=_",
"alpha_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"text",
"\\u",
"extents_",
"(_",
"self_",
",_",
"text_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"cr_",
"._",
"text",
"\\u",
"extents_",
"(_",
"text_",
",_",
"self_",
"._",
"font_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"affin",
"e\\u",
"transform_",
"(_",
"self_",
",_",
"cx_",
",_",
"cy_",
",_",
"rot",
"\\u",
"deg_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"x_",
",_",
"y_",
"=_",
"0_",
",_",
"0_",
"#",
" ",
"old",
" ",
"center_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nx_",
",_",
"ny_",
"=_",
"cx_",
",_",
"cy_",
"#",
" ",
"new",
" ",
"center_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"sx_",
"=_",
"sy_",
"=_",
"1.0_",
"#",
" ",
"new",
" ",
"scale_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cosine",
"_",
"=_",
"math_",
"._",
"cos_",
"(_",
"math_",
"._",
"radians_",
"(_",
"rot",
"\\u",
"deg_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"sine",
"_",
"=_",
"math_",
"._",
"sin_",
"(_",
"math_",
"._",
"radians_",
"(_",
"rot",
"\\u",
"deg_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"a_",
"=_",
"cosine",
"_",
"/_",
"sx_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"b_",
"=_",
"sine",
"_",
"/_",
"sx_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"c_",
"=_",
"x_",
"-_",
"nx_",
"*_",
"a_",
"-_",
"ny_",
"*_",
"b_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"d_",
"=_",
"-_",
"sine",
"_",
"/_",
"sy_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"e_",
"=_",
"cosine",
"_",
"/_",
"sy_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"f_",
"=_",
"y_",
"-_",
"nx_",
"*_",
"d_",
"-_",
"ny_",
"*_",
"e_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"(_",
"a_",
",_",
"b_",
",_",
"c_",
",_",
"d_",
",_",
"e_",
",_",
"f_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"draw",
"\\u",
"text_",
"(_",
"self_",
",_",
"cx_",
",_",
"cy_",
",_",
"text_",
",_",
"rot",
"\\u",
"deg_",
"=_",
"0.0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"wd_",
",_",
"ht_",
"=_",
"self_",
"._",
"cr_",
"._",
"text",
"\\u",
"extents_",
"(_",
"text_",
",_",
"self_",
"._",
"font_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"cr_",
"._",
"text_",
"(_",
"(_",
"cx_",
",_",
"cy_",
"-_",
"ht_",
")_",
",_",
"text_",
",_",
"self_",
"._",
"font_",
",_",
"self_",
"._",
"pen_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"draw",
"\\u",
"polygon_",
"(_",
"self_",
",_",
"cpo",
"ints_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cr_",
"._",
"polygon_",
"(_",
"cpo",
"ints_",
",_",
"self_",
"._",
"pen_",
",_",
"self_",
"._",
"brush_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"draw",
"\\u",
"circle_",
"(_",
"self_",
",_",
"cx_",
",_",
"cy_",
",_",
"cra",
"diu",
"s_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cr_",
"._",
"circle_",
"(_",
"(_",
"cx_",
",_",
"cy_",
")_",
",_",
"cra",
"diu",
"s_",
",_",
"self_",
"._",
"pen_",
",_",
"self_",
"._",
"brush_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"draw",
"\\u",
"ellipse_",
"(_",
"self_",
",_",
"cx_",
",_",
"cy_",
",_",
"cx",
"radius_",
",_",
"cyr",
"adi",
"us_",
",_",
"theta_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"NOTE",
":",
" ",
"theta",
" ",
"currentl",
"y",
" ",
"not",
" ",
"support",
"ed",
" ",
"with",
" ",
"PI",
"L",
" ",
"renderer_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cr_",
"._",
"ellipse_",
"(_",
"(_",
"cx_",
",_",
"cy_",
")_",
",_",
"cx",
"radius_",
",_",
"cyr",
"adi",
"us_",
",_",
"theta_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"pen_",
",_",
"self_",
"._",
"brush_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"draw",
"\\u",
"line_",
"(_",
"self_",
",_",
"cx",
"1_",
",_",
"cy",
"1_",
",_",
"cx",
"2_",
",_",
"cy",
"2_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cr_",
"._",
"line_",
"(_",
"(_",
"cx",
"1_",
",_",
"cy",
"1_",
")_",
",_",
"(_",
"cx",
"2_",
",_",
"cy",
"2_",
")_",
",_",
"self_",
"._",
"pen_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Render",
"Context_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"draw",
"\\u",
"path_",
"(_",
"self_",
",_",
"cpo",
"ints_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"cr_",
"._",
"path_",
"(_",
"cpo",
"ints_",
",_",
"self_",
"._",
"pen_",
")_",
"\\u\\u\\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_",
"Can",
"vas",
"Renderer_",
"(_",
"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_",
"[SEP]_",
"class_",
"Can",
"vas",
"Renderer_",
"(_",
"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_",
",_",
"viewer_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"viewer_",
"=_",
"viewer_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Can",
"vas",
"Renderer_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"setup",
"\\u",
"cr_",
"(_",
"self_",
",_",
"shape_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cr_",
"=_",
"Render",
"Context_",
"(_",
"self_",
"._",
"viewer_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"cr_",
"._",
"initialize",
"\\u",
"from",
"\\u",
"shape_",
"(_",
"shape_",
",_",
"font_",
"=_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"cr_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Can",
"vas",
"Renderer_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"dimensions_",
"(_",
"self_",
",_",
"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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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Imprecise assert | byt3bl33d3r/pth-toolkit/lib/python2.7/site-packages/samba/tests/param.py | [
{
"content": " def test_init(self):\n file = param.LoadParm()\n self.assertTrue(file is not None)",
"metadata": "root.LoadParmTestCase.test_init",
"header": "['class', 'LoadParmTestCase', '(', 'samba', '.', 'tests', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 24
}
]
| [
{
"span": "self.assertTrue(file is not None)",
"start_line": 26,
"start_column": 8,
"end_line": 26,
"end_column": 41
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Load",
"Parm",
"Test",
"Case_",
"(_",
"samba",
"_",
"._",
"tests_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"test\\u",
"init_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"file_",
"=_",
"param_",
"._",
"Load",
"Parm",
"_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"file_",
"is_",
"not_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2
]
|
Unused import | meejah/txtorcon/examples/add_hiddenservice_to_system_tor.py | [
{
"content": "#!/usr/bin/env python\n\n# This connects to the system Tor (by default on control port 9151)\n# and adds a new hidden service configuration to it.\n\nimport os\nimport functools\nimport shutil\n\nfrom twisted.internet import reactor, defer\nfrom twisted.internet.endpoints import TCP4ClientEndpoint, TCP4ServerEndpoint\nfrom twisted.web import server, resource\nfrom twisted.internet.task import react\n\nimport txtorcon\n\n\n\n\n\n\nreact(main)\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class Simple(resource.Resource):\n isLeaf = True\n",
"metadata": "root.Simple",
"header": "['module', '___EOS___']",
"index": 17
},
{
"content": " def render_GET(self, request):\n return \"<html>Hello, world! I'm a hidden service!</html>\"",
"metadata": "root.Simple.render_GET",
"header": "['class', 'Simple', '(', 'resource', '.', 'Resource', ')', ':', '___EOS___']",
"index": 20
},
{
"content": "@defer.inlineCallbacks\ndef main(reactor):\n ep = TCP4ClientEndpoint(reactor, \"localhost\", 9251)\n tor_protocol = yield txtorcon.build_tor_connection(ep, build_state=False)\n print \"Connected to Tor\"\n\n hs_public_port = 80\n hs_port = yield txtorcon.util.available_tcp_port(reactor)\n hs_string = '%s 127.0.0.1:%d' % (hs_public_port, hs_port)\n print \"Adding ephemeral service\", hs_string\n print \"(this can take some time; please be patient)\"\n hs = txtorcon.EphemeralHiddenService([hs_string])\n yield hs.add_to_tor(tor_protocol)\n print \"Added ephemeral HS to Tor:\", hs.hostname\n\n print \"Starting site\"\n site = server.Site(Simple())\n hs_endpoint = TCP4ServerEndpoint(reactor, hs_port, interface='127.0.0.1')\n yield hs_endpoint.listen(site)\n\n # in 5 seconds, remove the hidden service -- obviously this is\n # where you'd do your \"real work\" or whatever.\n d = defer.Deferred()\n\n @defer.inlineCallbacks\n def remove():\n print \"Removing the hiddenservice. Private key was\"\n print hs.private_key\n yield hs.remove_from_tor(tor_protocol)\n d.callback(None)\n if False:\n reactor.callLater(5, remove)\n print \"waiting 5 seconds\"\n else:\n print \"waiting forever\"\n yield d",
"metadata": "root.main",
"header": "['module', '___EOS___']",
"index": 24
}
]
| [
{
"span": "import os",
"start_line": 5,
"start_column": 0,
"end_line": 5,
"end_column": 9
},
{
"span": "import functools",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 16
},
{
"span": "import shutil",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 13
},
{
"span": "from twisted.internet import reactor, defer",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 43
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#!",
"/",
"usr",
"/",
"bin",
"/",
"env",
" ",
"python_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"connects",
" ",
"to",
" ",
"the",
" ",
"system",
" ",
"Tor",
" ",
"(",
"by",
" ",
"default",
" ",
"on",
" ",
"control",
" ",
"port",
" ",
"915",
"1",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"and",
" ",
"adds",
" ",
"a",
" ",
"new",
" ",
"hidden",
" ",
"service",
" ",
"configura",
"tion",
" ",
"to",
" ",
"it",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"functools_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"shutil_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"twisted_",
"._",
"internet_",
"import_",
"reactor_",
",_",
"defer_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"twisted_",
"._",
"internet_",
"._",
"endpoints_",
"import_",
"TC",
"P4",
"Client",
"Endpoint_",
",_",
"TC",
"P4",
"Server",
"Endpoint_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"twisted_",
"._",
"web_",
"import_",
"server_",
",_",
"resource_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"twisted_",
"._",
"internet_",
"._",
"task_",
"import_",
"react",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"txt",
"orc",
"on_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\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_",
"react",
"_",
"(_",
"main_",
")_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"Simple_",
"(_",
"resource_",
"._",
"Resource_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"is",
"Leaf_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Simple_",
"(_",
"resource_",
"._",
"Resource_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"render",
"\\u",
"GET_",
"(_",
"self_",
",_",
"request_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\"<",
"html",
">",
"Hell",
"o",
",",
" ",
"world",
"!",
" ",
"I",
"'",
"m",
" ",
"a",
" ",
"hidden",
" ",
"service",
"!<",
"/",
"html",
">\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"defer_",
"._",
"inline",
"Callbacks_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"main_",
"(_",
"reactor_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ep_",
"=_",
"TC",
"P4",
"Client",
"Endpoint_",
"(_",
"reactor_",
",_",
"\"",
"local",
"host",
"\"_",
",_",
"925",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tor",
"\\u",
"protocol_",
"=_",
"yield_",
"txt",
"orc",
"on_",
"._",
"build",
"\\u",
"tor",
"\\u",
"connection_",
"(_",
"ep_",
",_",
"build",
"\\u",
"state_",
"=_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"Connect",
"ed",
" ",
"to",
" ",
"Tor",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"hs",
"\\u",
"public",
"\\u",
"port_",
"=_",
"80_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"hs",
"\\u",
"port_",
"=_",
"yield_",
"txt",
"orc",
"on_",
"._",
"util_",
"._",
"avail",
"able",
"\\u",
"tcp",
"\\u",
"port_",
"(_",
"reactor_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"hs",
"\\u",
"string_",
"=_",
"'%",
"s",
" ",
"127",
".0",
".0",
".1",
":",
"%",
"d",
"'_",
"%_",
"(_",
"hs",
"\\u",
"public",
"\\u",
"port_",
",_",
"hs",
"\\u",
"port_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"Add",
"ing",
" ",
"ephemeral",
" ",
"service",
"\"_",
",_",
"hs",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"(",
"this",
" ",
"can",
" ",
"take",
" ",
"some",
" ",
"time",
";",
" ",
"plea",
"se",
" ",
"be",
" ",
"patien",
"t",
")\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"hs_",
"=_",
"txt",
"orc",
"on_",
"._",
"Ep",
"hem",
"eral",
"Hi",
"dde",
"n",
"Service_",
"(_",
"[_",
"hs",
"\\u",
"string_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"hs_",
"._",
"add",
"\\u",
"to",
"\\u",
"tor_",
"(_",
"tor",
"\\u",
"protocol_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"Added",
" ",
"ephemeral",
" ",
"HS",
" ",
"to",
" ",
"Tor",
":\"_",
",_",
"hs_",
"._",
"hostname_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"print_",
"\"",
"Start",
"ing",
" ",
"site",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"site_",
"=_",
"server_",
"._",
"Site_",
"(_",
"Simple_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"hs",
"\\u",
"endpoint_",
"=_",
"TC",
"P4",
"Server",
"Endpoint_",
"(_",
"reactor_",
",_",
"hs",
"\\u",
"port_",
",_",
"interface_",
"=_",
"'",
"127",
".0",
".0",
".1",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"hs",
"\\u",
"endpoint_",
"._",
"listen_",
"(_",
"site_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"in",
" ",
"5",
" ",
"second",
"s",
",",
" ",
"remove",
" ",
"the",
" ",
"hidden",
" ",
"service",
" ",
"--",
" ",
"ob",
"vio",
"usl",
"y",
" ",
"this",
" ",
"is_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"where",
" ",
"you",
"'",
"d",
" ",
"do",
" ",
"your",
" ",
"\"",
"real",
" ",
"work",
"\"",
" ",
"or",
" ",
"what",
"ever",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"d_",
"=_",
"defer_",
"._",
"Deferred_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"defer_",
"._",
"inline",
"Callbacks_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"remove_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"print_",
"\"",
"Remo",
"ving",
" ",
"the",
" ",
"hidden",
"service",
".",
" ",
"Priva",
"te",
" ",
"key",
" ",
"was",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"hs_",
"._",
"private",
"\\u",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"yield_",
"hs_",
"._",
"remove",
"\\u",
"from",
"\\u",
"tor_",
"(_",
"tor",
"\\u",
"protocol_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"d_",
"._",
"callback_",
"(_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"False_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"reactor_",
"._",
"call",
"Later_",
"(_",
"5_",
",_",
"remove_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"wait",
"ing",
" ",
"5",
" ",
"second",
"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 ",
" _",
"print_",
"\"",
"wait",
"ing",
" ",
"forever",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"yield_",
"d_",
"\\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,
0,
1,
2,
0,
1,
2,
0,
1,
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,
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,
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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
]
|
Imprecise assert | StackStorm/st2/st2common/tests/unit/test_db_liveaction.py | [
{
"content": " def test_liveaction_crud_no_notify(self):\n created = LiveActionDB()\n created.action = 'core.local'\n created.description = ''\n created.status = 'running'\n created.parameters = {}\n saved = LiveActionModelTest._save_liveaction(created)\n retrieved = LiveAction.get_by_id(saved.id)\n self.assertEqual(saved.action, retrieved.action,\n 'Same triggertype was not returned.')\n self.assertEqual(retrieved.notify, None)\n\n # Test update\n self.assertTrue(retrieved.end_timestamp is None)\n retrieved.end_timestamp = date_utils.get_datetime_utc_now()\n updated = LiveAction.add_or_update(retrieved)\n self.assertTrue(updated.end_timestamp == retrieved.end_timestamp)\n # Test delete\n LiveActionModelTest._delete([retrieved])\n try:\n retrieved = LiveAction.get_by_id(saved.id)\n except ValueError:\n retrieved = None\n self.assertIsNone(retrieved, 'managed to retrieve after failure.')",
"metadata": "root.LiveActionModelTest.test_liveaction_crud_no_notify",
"header": "['class', 'LiveActionModelTest', '(', 'DbTestCase', ')', ':', '___EOS___']",
"index": 29
}
]
| [
{
"span": "self.assertTrue(retrieved.end_timestamp is None)",
"start_line": 42,
"start_column": 8,
"end_line": 42,
"end_column": 56
},
{
"span": "self.assertTrue(updated.end_timestamp == retrieved.end_timestamp)",
"start_line": 45,
"start_column": 8,
"end_line": 45,
"end_column": 73
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Live",
"Action",
"Model",
"Test_",
"(_",
"Db",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"test\\u",
"live",
"action",
"\\u",
"crud",
"\\u",
"no",
"\\u",
"notify_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"created_",
"=_",
"Live",
"Action",
"DB_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"created_",
"._",
"action_",
"=_",
"'",
"core",
".",
"local",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"created_",
"._",
"description_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"created_",
"._",
"status_",
"=_",
"'",
"runn",
"ing",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"created_",
"._",
"parameters_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"saved_",
"=_",
"Live",
"Action",
"Model",
"Test_",
"._",
"\\u",
"save",
"\\u",
"live",
"action_",
"(_",
"created_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"retrieved",
"_",
"=_",
"Live",
"Action_",
"._",
"get",
"\\u",
"by",
"\\u",
"id_",
"(_",
"saved_",
"._",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"saved_",
"._",
"action_",
",_",
"retrieved",
"_",
"._",
"action_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"Sam",
"e",
" ",
"trigger",
"type",
" ",
"was",
" ",
"not",
" ",
"return",
"ed",
".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"retrieved",
"_",
"._",
"notify_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Test",
" ",
"update_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"retrieved",
"_",
"._",
"end",
"\\u",
"timestamp_",
"is_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"retrieved",
"_",
"._",
"end",
"\\u",
"timestamp_",
"=_",
"date",
"\\u",
"utils_",
"._",
"get",
"\\u",
"datetime",
"\\u",
"utc",
"\\u",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"updated_",
"=_",
"Live",
"Action_",
"._",
"add",
"\\u",
"or",
"\\u",
"update_",
"(_",
"retrieved",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"updated_",
"._",
"end",
"\\u",
"timestamp_",
"==_",
"retrieved",
"_",
"._",
"end",
"\\u",
"timestamp_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Test",
" ",
"delete_",
"\\u\\u\\uNL\\u\\u\\u_",
"Live",
"Action",
"Model",
"Test_",
"._",
"\\u",
"delete_",
"(_",
"[_",
"retrieved",
"_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"retrieved",
"_",
"=_",
"Live",
"Action_",
"._",
"get",
"\\u",
"by",
"\\u",
"id_",
"(_",
"saved_",
"._",
"id_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"Value",
"Error_",
":_",
"\\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
]
|
Unused import | zeaphoo/cocopot/tests/test_routing.py | [
{
"content": "import pytest\n\nfrom cocopot.routing import Router\nfrom cocopot.exceptions import BadRequest, NotFound, MethodNotAllowed\n\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "def test_basic_routing():\n r = Router()\n r.add('/', endpoint='index')\n r.add('/foo', endpoint='foo')\n r.add('/bar/', endpoint='bar')\n assert r.match('/') == ('index', {})\n assert r.match('/foo') == ('foo', {})\n assert r.match('/bar/') == ('bar', {})\n pytest.raises(NotFound, lambda: r.match('/blub'))\n pytest.raises(MethodNotAllowed, lambda: r.match('/foo', method='POST'))",
"metadata": "root.test_basic_routing",
"header": "['module', '___EOS___']",
"index": 5
},
{
"content": "def test_basic_routing2():\n r = Router(strict=True)\n r.add('/', endpoint='index')\n r.add('/foo', endpoint='foo')\n r.add('/bar/', endpoint='bar')\n assert r.match('/') == ('index', {})\n assert r.match('/foo') == ('foo', {})\n assert r.match('/bar/') == ('bar', {})\n pytest.raises(NotFound, lambda: r.match('/blub'))\n pytest.raises(MethodNotAllowed, lambda: r.match('/foo', method='POST'))",
"metadata": "root.test_basic_routing2",
"header": "['module', '___EOS___']",
"index": 16
},
{
"content": "def test_dynamic_routing():\n r = Router()\n r.add('/<name>', endpoint='index')\n r.add('/foo/<string:name2>', endpoint='foo')\n r.add('/bar/<int:bar>', endpoint='bar')\n r.add('/float/<float:bar2>', endpoint='bar2')\n r.add('/path/<path:bar3>', endpoint='bar3')\n assert r.match('/foo') == ('index', {'name': 'foo'})\n assert r.match('/foo/bar') == ('foo', {'name2': 'bar'})\n assert r.match('/bar/20') == ('bar', {'bar': 20})\n assert r.match('/float/20.333') == ('bar2', {'bar2': 20.333})\n assert r.match('/path/foo/bar/xxx') == ('bar3', {'bar3': 'foo/bar/xxx'})",
"metadata": "root.test_dynamic_routing",
"header": "['module', '___EOS___']",
"index": 28
},
{
"content": "def test_default_values():\n r = Router()\n r.add('/<name>', endpoint='index', defaults={'foo': 1234, 'name':'bar'})\n assert r.match('/foo') == ('index', {'name': 'foo', 'foo': 1234})",
"metadata": "root.test_default_values",
"header": "['module', '___EOS___']",
"index": 42
}
]
| [
{
"span": "from cocopot.exceptions import BadRequest, NotFound, MethodNotAllowed",
"start_line": 3,
"start_column": 0,
"end_line": 3,
"end_column": 69
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"pytest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"coco",
"pot_",
"._",
"routing_",
"import_",
"Router_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"coco",
"pot_",
"._",
"exceptions_",
"import_",
"Ba",
"d",
"Request_",
",_",
"Not",
"Found_",
",_",
"Meth",
"od",
"Not",
"Allowed_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"test\\u",
"basic",
"\\u",
"routing_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"Router_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/'_",
",_",
"endpoint_",
"=_",
"'",
"index",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"foo",
"'_",
",_",
"endpoint_",
"=_",
"'",
"foo",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"bar",
"/'_",
",_",
"endpoint_",
"=_",
"'",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/'_",
")_",
"==_",
"(_",
"'",
"index",
"'_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"'_",
")_",
"==_",
"(_",
"'",
"foo",
"'_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"bar",
"/'_",
")_",
"==_",
"(_",
"'",
"bar",
"'_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pytest_",
"._",
"raises_",
"(_",
"Not",
"Found_",
",_",
"lambda_",
":_",
"r_",
"._",
"match_",
"(_",
"'/",
"blu",
"b",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pytest_",
"._",
"raises_",
"(_",
"Meth",
"od",
"Not",
"Allowed_",
",_",
"lambda_",
":_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"'_",
",_",
"method_",
"=_",
"'",
"POST",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"basic",
"\\u",
"routin",
"g2_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"Router_",
"(_",
"strict_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/'_",
",_",
"endpoint_",
"=_",
"'",
"index",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"foo",
"'_",
",_",
"endpoint_",
"=_",
"'",
"foo",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"bar",
"/'_",
",_",
"endpoint_",
"=_",
"'",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/'_",
")_",
"==_",
"(_",
"'",
"index",
"'_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"'_",
")_",
"==_",
"(_",
"'",
"foo",
"'_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"bar",
"/'_",
")_",
"==_",
"(_",
"'",
"bar",
"'_",
",_",
"{_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pytest_",
"._",
"raises_",
"(_",
"Not",
"Found_",
",_",
"lambda_",
":_",
"r_",
"._",
"match_",
"(_",
"'/",
"blu",
"b",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pytest_",
"._",
"raises_",
"(_",
"Meth",
"od",
"Not",
"Allowed_",
",_",
"lambda_",
":_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"'_",
",_",
"method_",
"=_",
"'",
"POST",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"dynami",
"c\\u",
"routing_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"Router_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"<",
"name",
">'_",
",_",
"endpoint_",
"=_",
"'",
"index",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"foo",
"/",
"<",
"string",
":",
"name2",
">'_",
",_",
"endpoint_",
"=_",
"'",
"foo",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"bar",
"/",
"<",
"int",
":",
"bar",
">'_",
",_",
"endpoint_",
"=_",
"'",
"bar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"float",
"/",
"<",
"float",
":",
"bar",
"2",
">'_",
",_",
"endpoint_",
"=_",
"'",
"bar",
"2",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"path",
"/",
"<",
"path",
":",
"bar",
"3",
">'_",
",_",
"endpoint_",
"=_",
"'",
"bar",
"3",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"'_",
")_",
"==_",
"(_",
"'",
"index",
"'_",
",_",
"{_",
"'",
"name",
"'_",
":_",
"'",
"foo",
"'_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"/",
"bar",
"'_",
")_",
"==_",
"(_",
"'",
"foo",
"'_",
",_",
"{_",
"'",
"name2",
"'_",
":_",
"'",
"bar",
"'_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"bar",
"/",
"20",
"'_",
")_",
"==_",
"(_",
"'",
"bar",
"'_",
",_",
"{_",
"'",
"bar",
"'_",
":_",
"20_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"float",
"/",
"20.",
"333",
"'_",
")_",
"==_",
"(_",
"'",
"bar",
"2",
"'_",
",_",
"{_",
"'",
"bar",
"2",
"'_",
":_",
"20.",
"333_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"path",
"/",
"foo",
"/",
"bar",
"/",
"xxx",
"'_",
")_",
"==_",
"(_",
"'",
"bar",
"3",
"'_",
",_",
"{_",
"'",
"bar",
"3",
"'_",
":_",
"'",
"foo",
"/",
"bar",
"/",
"xxx",
"'_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"default",
"\\u",
"values_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"Router_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"._",
"add_",
"(_",
"'/",
"<",
"name",
">'_",
",_",
"endpoint_",
"=_",
"'",
"index",
"'_",
",_",
"defaults_",
"=_",
"{_",
"'",
"foo",
"'_",
":_",
"1234_",
",_",
"'",
"name",
"'_",
":_",
"'",
"bar",
"'_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"match_",
"(_",
"'/",
"foo",
"'_",
")_",
"==_",
"(_",
"'",
"index",
"'_",
",_",
"{_",
"'",
"name",
"'_",
":_",
"'",
"foo",
"'_",
",_",
"'",
"foo",
"'_",
":_",
"1234_",
"}_",
")_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
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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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | VisTrails/VisTrails/contrib/sahm/pySAHM/MaxentRunner.py | [
{
"content": "'''\nCreated on Sep 17, 2010\n\n@author: talbertc\n'''\n\nimport time\nimport os, sys\nimport csv\nimport itertools\nimport traceback\n\nimport subprocess\n\nfrom optparse import OptionParser\n\n#from core.modules.vistrails_module import Module, ModuleError, ModuleConnector\n#from core.system import execute_cmdline\n\n\n\nimport utilities\n#from packages.sahm.pySAHM.Utilites import self.writetolog\n\nfrom osgeo import gdalconst\nfrom osgeo import gdal\nfrom osgeo import osr\n\n\n\n\nif __name__ == \"__main__\":\n sys.exit(main(sys.argv[1:]))\n \n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class MAXENTRunner(object):\n \n \n \n \n\n \n \n\n \n \n \n ",
"metadata": "root.MAXENTRunner",
"header": "['module', '___EOS___']",
"index": 28
},
{
"content": " def __init__(self):\n self.verbose = False\n self.maxentpath = ''\n self.inputMDS = ''\n self.projectionlayers = ''\n self.testCSV = ''\n self.trainingCSV = ''\n self.backgroundCSV = ''\n self.outputDir = ''\n self.categoricals = []\n self.argsCSV = ''\n self.logger = None",
"metadata": "root.MAXENTRunner.__init__",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 30
},
{
"content": " def run(self):\n self.loadArgs()\n self.args['outputdirectory'] = self.outputDir\n \n# if self.projectionlayers <> '':\n# #A command line input overrides an input in the args csv\n# self.args['projectionlayers'] = self.projectionlayers\n# \n self.validateInputs()\n \n if self.inputMDS <> '':\n self.prepInputs()\n else:\n raise Exception, \"No MDS supplied.\"\n\n if not self.args.has_key('projectionlayers'):\n self.args['projectionlayers'] = ''\n\n if self.trainingCSV <> '':\n self.args['samplesfile'] = self.trainingCSV\n else:\n raise Exception, \"No Samples file supplied\"\n \n if self.testCSV <> '':\n self.args['testsamplesfile'] = self.testCSV\n \n if self.backgroundCSV <> '':\n self.args['environmentallayers'] = self.backgroundCSV\n \n \n self.args['autorun'] = 'true'\n #self.args['outputgrids'] = 'false'\n \n if ' ' in self.args['species_name']:\n self.args['species_name'] = self.args['species_name'].replace(' ', '_')\n \n strargs = ['='.join((str(k),str(v))) for k,v in self.args.iteritems() if k <> \"species_name\"]\n for categorical in self.categoricals:\n strargs += ['togglelayertype=' + categorical.replace('_categorical', '')]\n #strargs = ' '.join(strargs)\n #print strargs\n \n if not self.maxentpath.endswith('.jar'):\n jar = os.path.join(self.maxentpath, 'maxent.jar')\n else:\n jar = self.maxentpath\n \n self.run_cmd_line_jar(jar, strargs)",
"metadata": "root.MAXENTRunner.run",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 43
},
{
"content": " def run_cmd_line_jar(self, jar_name, args):\n #arg_items = list(itertools.chain(*args.items()))\n #arg_items = ['='.join((str(k),str(v))) for k,v in args.iteritems()]\n \n cmd = ' '.join(['java', '-mx512m', '-jar', jar_name] + args)\n \n self.writetolog(' running: ' + cmd, True, False)\n #res = execute_cmdline(['java', '-jar', jar_name] + args, output)\n p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\n self.writetolog(' Finished running: ', True, False)\n \n \n ret = p.communicate()\n self.writetolog(' Maxent strOut: ' + str(ret[0]))\n if ret[1] is not None:\n msg = \"An error was encountered running the Maxent jar file. The error message is below - \\n\"\n msg += ret[1]\n writetolog(msg)\n raise RuntimeError , msg\n del ret",
"metadata": "root.MAXENTRunner.run_cmd_line_jar",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 93
},
{
"content": " def loadArgs(self):\n argsReader = csv.reader(open(self.argsCSV, 'r'))\n header = argsReader.next()\n self.args = {}\n for row in argsReader:\n self.args[row[0]] = row[1]",
"metadata": "root.MAXENTRunner.loadArgs",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 114
},
{
"content": " def validateInputs(self):\n if not os.path.exists(self.argsCSV):\n raise RuntimeError(self, 'Input argsFile, ' + self.argsCSV + ', could not be found on file system')\n \n if not os.path.exists(self.inputMDS):\n raise RuntimeError(self, 'Input MDS, ' + self.inputMDS + ', could not be found on file system')\n \n if not self.args.has_key('projectionlayers'):\n self.args['projectionlayers'] = ''\n \n if self.args['projectionlayers'] <> '':\n dirs = self.args['projectionlayers'].split(',')\n for dir in dirs:\n if not os.path.isdir(dir):\n raise RuntimeError(self, \"Input 'projectionlayers' must be a directory\")\n \n if not utilities.isMDSFile(self.inputMDS):\n raise RuntimeError(self, 'Input MDS, ' + self.inputMDS + ', does not appear to be formated as an MDS file.')\n \n if not os.path.exists(self.outputDir):\n raise RuntimeError(self, 'Output directory, ' + self.outputDir + ', could not be found on file system')\n \n if self.logger is None:\n self.logger = utilities.logger(outDir, self.verbose)\n self.writetolog = self.logger.writetolog",
"metadata": "root.MAXENTRunner.validateInputs",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 121
},
{
"content": " def prepInputs(self):\n '''parses out input MDS file into the 1 to 3 SWD files that Maxent requires.\n '''\n \n #Create the outputs in our outputdirectory\n self.testCSV = os.path.join(self.outputDir, 'testSamples.csv')\n self.trainingCSV = os.path.join(self.outputDir, 'trainingSamples.csv')\n self.backgroundCSV = os.path.join(self.outputDir, 'backgroundPoints.csv')\n \n testWriter = csv.writer(open(self.testCSV, 'wb'))\n trainingWriter = csv.writer(open(self.trainingCSV, 'wb'))\n backgroundWriter = csv.writer(open(self.backgroundCSV, 'wb'))\n \n #Read through the MDS and pull the headers\n MDSreader = csv.reader(open(self.inputMDS, 'r'))\n header1 = MDSreader.next()\n header2 = MDSreader.next()\n header3 = MDSreader.next()\n \n self.pullCategoricals(header1)\n\n #The split column indicates that this file has been run through the \n #test training split and testing data should be writen to the test file.\n splitcol = None\n try:\n splitcol = header1.index('Split')\n deleteTest = False\n except ValueError:\n self.writetolog(\" The supplied MDS does not have a 'Split' column defaulting to having Maxent apply test/training split.\") \n deleteTest = True\n \n covariateIndexes = self.usedIndexes(header1, header2) \n covariateNames = self.usedValues(header1, covariateIndexes)\n covariateNamesClean = [name.replace('_categorical', '') for name in covariateNames]\n usedCovariateFiles = self.usedValues(header3, covariateIndexes)\n \n self.writetolog(' Used covariates:' + \", \".join(covariateNames), False, False)\n \n testWriter.writerow(['full_name', 'x', 'y'] + covariateNamesClean)\n trainingWriter.writerow(['full_name', 'x', 'y'] + covariateNamesClean)\n backgroundWriter.writerow(['full_name', 'x', 'y'] + covariateNamesClean)\n \n #loop through the rows sending each row to the appropriate file\n hasBackground = False\n for row in MDSreader:\n if row[2] == '-9999':\n hasBackground = True\n vals = self.usedValues(row, covariateIndexes)\n backgroundWriter.writerow([''] + row[:2] + vals)\n elif splitcol is None and row[2] <> 0:\n vals = self.usedValues(row, covariateIndexes)\n trainingWriter.writerow([self.args['species_name']] + row[:2] + vals)\n elif (row[splitcol] == 'test' and row[2] <> 0) or \\\n self.testCSV == '':\n vals = self.usedValues(row, covariateIndexes)\n testWriter.writerow([self.args['species_name']] + row[:2] + vals)\n elif row[splitcol] == 'train' and row[2] <> 0:\n vals = self.usedValues(row, covariateIndexes)\n trainingWriter.writerow([self.args['species_name']] + row[:2] + vals)\n #any absense points (row[2] == 0) will be ignored for maxent\n \n if not hasBackground:\n msg = \" No background points were detected in the input file.\"\n msg += \"\\n This implementation of Maxent does not have access to prepared ASCII environmental layers\"\n msg += \" from which to extract values. Background points must be supplied in the MDS file.\"\n self.writetolog(msg)\n raise RuntimeError(msg)\n \n #del our writers \n try:\n del testWriter\n if deleteTest:\n os.remove(self.testCSV)\n self.testCSV = ''\n del backgroundWriter\n if not hasBackground:\n os.remove(self.backgroundCSV)\n self.backgroundCSV = ''\n del trainingWriter\n except:\n print ' '.join([str(i) for i in sys.exc_info()[:2]])\n pass\n \n #First we have to figure out what they passed us\n #either a directory, a SWD file, or a csv with a list of files\n \n if self.args['projectionlayers'] <> '':\n pass\n else:\n self.args['outputgrids'] = 'false'",
"metadata": "root.MAXENTRunner.prepInputs",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 147
},
{
"content": " def usedIndexes(self, header1, header2):\n covariateIndexes = []\n for i in range(len(header1)):\n if header2[i] == '1' and header1[i] <> 'Split':\n covariateIndexes.append(i)\n return covariateIndexes",
"metadata": "root.MAXENTRunner.usedIndexes",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 238
},
{
"content": " def usedValues(self, values, indexes):\n usedvals = []\n for i in indexes:\n usedvals.append(values[i])\n return usedvals",
"metadata": "root.MAXENTRunner.usedValues",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 245
},
{
"content": " def pullCategoricals(self, headerline):\n for item in headerline:\n if item.endswith('_categorical'):\n self.categoricals.append(item)",
"metadata": "root.MAXENTRunner.pullCategoricals",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 251
},
{
"content": " def isSWD(self, file):\n '''Checks the format of a file to see if it is in the \n Maxent samples with data (SWD) format.\n '''\n if os.path.exists(file):\n reader = csv.reader(open(file, 'r'))\n header = reader.next()\n if header[0].lower() in ['species', 'full_name', 'fullname']:\n return True\n \n return False",
"metadata": "root.MAXENTRunner.isSWD",
"header": "['class', 'MAXENTRunner', '(', 'object', ')', ':', '___EOS___']",
"index": 257
},
{
"content": "def main(argv):\n '''Process our command line args and initiate a Maxent run\n '''\n usageStmt = \"usage: -m --MDSFile -a --argsCSV -o --outputDir\"\n desc = \"Formats and prepares input for running the Maxent Jar in a SAHM workflow\"\n\n parser = OptionParser(usage=usageStmt, description=desc)\n parser.add_option(\"-m\", \"--MDSFile\", \n dest=\"MDSFile\", \n help=\"The MDS file with our sample data.\")\n# parser.add_option(\"-p\", \"--projectionData\", \n# dest=\"projectionData\", \n# help=\"An optional CSV with a projection file for each of our environemnetal layers.\")\n parser.add_option(\"-a\", \"--argsCSV\", \n dest=\"argsCSV\", \n help=\"A CSV with each Maxent argument name and it's value on separate lines.\")\n parser.add_option(\"-e\", \"--maxentExecutable\", \n dest=\"maxentExecutable\", \n help=\"The full path to the maxent executable jar file.\")\n parser.add_option(\"-o\", \"--outputDir\", \n dest=\"outputDir\", \n help=\"The directory to save output files.\")\n parser.add_option(\"-v\", \"--verbose\", \n dest=\"verbose\", \n default=False, \n action=\"store_true\",\n help=\"the verbose flag causes diagnostic output to print\")\n\n (options, args) = parser.parse_args(argv)\n\n ourMaxent = MAXENTRunner()\n ourMaxent.verbose = options.verbose\n ourMaxent.maxentpath = options.maxentExecutable\n ourMaxent.inputMDS = options.MDSFile\n ourMaxent.outputDir = options.outputDir\n ourMaxent.argsCSV = options.argsCSV\n ourMaxent.projectionDataFile = options.projectionData\n\n utilities.createsessionlog(options.outputDir, options.verbose)\n ourMaxent.run()",
"metadata": "root.main",
"header": "['module', '___EOS___']",
"index": 270
}
]
| [
{
"span": "import time",
"start_line": 6,
"start_column": 0,
"end_line": 6,
"end_column": 11
},
{
"span": "import itertools",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 16
},
{
"span": "import traceback",
"start_line": 10,
"start_column": 0,
"end_line": 10,
"end_column": 16
},
{
"span": "from osgeo import gdalconst",
"start_line": 24,
"start_column": 0,
"end_line": 24,
"end_column": 27
},
{
"span": "from osgeo import gdal",
"start_line": 25,
"start_column": 0,
"end_line": 25,
"end_column": 22
},
{
"span": "from osgeo import osr",
"start_line": 26,
"start_column": 0,
"end_line": 26,
"end_column": 21
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"'''",
"\\",
"10",
";",
"Creat",
"ed",
" ",
"on",
" ",
"Se",
"p",
" ",
"1",
"7",
",",
" ",
"2010",
"\\",
"10",
";",
"\\",
"10",
";",
"@",
"author",
":",
" ",
"tal",
"bert",
"c",
"\\",
"10",
";'",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
",_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"csv_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"itertools_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"traceback_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"subprocess_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"optparse_",
"import_",
"Optio",
"n",
"Parser_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"from",
" ",
"core",
".",
"module",
"s",
".",
"vist",
"rail",
"s",
"\\u",
"module",
" ",
"import",
" ",
"Modul",
"e",
",",
" ",
"Modul",
"e",
"Error",
",",
" ",
"Modul",
"e",
"Connector_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"from",
" ",
"core",
".",
"system",
" ",
"import",
" ",
"execute",
"\\u",
"cmdline_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"utilities_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"from",
" ",
"package",
"s",
".",
"sa",
"hm",
".",
"py",
"SA",
"HM",
".",
"Utili",
"tes",
" ",
"import",
" ",
"self",
".",
"writet",
"olog",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"osg",
"eo_",
"import_",
"gdal",
"const_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"osg",
"eo_",
"import_",
"gdal_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"osg",
"eo_",
"import_",
"osr",
"_",
"\\u\\u\\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_",
"if_",
"\\u\\u",
"name\\u\\u_",
"==_",
"\"\\u\\u",
"main",
"\\u\\u\"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"sys_",
"._",
"exit_",
"(_",
"main_",
"(_",
"sys_",
"._",
"argv_",
"[_",
"1_",
":_",
"]_",
")_",
")_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\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_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"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_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"verbose_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"maxe",
"ntpath",
"_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"input",
"MD",
"S_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"projecti",
"onl",
"aye",
"rs_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"test",
"CSV_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"train",
"ing",
"CSV_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"background",
"CSV_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"output",
"Dir_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"categor",
"ical",
"s_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"args",
"CSV_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"logger_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"run_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"load",
"Args_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"args_",
"[_",
"'",
"output",
"director",
"y",
"'_",
"]_",
"=_",
"self_",
"._",
"output",
"Dir_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"if",
" ",
"self",
".",
"projecti",
"onl",
"aye",
"rs",
" ",
"<>",
" ",
"''",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"#",
"A",
" ",
"command",
" ",
"line",
" ",
"input",
" ",
"override",
"s",
" ",
"an",
" ",
"input",
" ",
"in",
" ",
"the",
" ",
"args",
" ",
"csv_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"self",
".",
"args",
"['",
"projecti",
"onl",
"aye",
"rs",
"']",
" ",
"=",
" ",
"self",
".",
"projecti",
"onl",
"aye",
"rs_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" _",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"validat",
"e",
"Inputs_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"self_",
"._",
"input",
"MD",
"S_",
"<_",
">_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"prep",
"Inputs_",
"(_",
")_",
"\\u\\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_",
",_",
"\"",
"No",
" ",
"MD",
"S",
" ",
"supplie",
"d",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"self_",
"._",
"args_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"train",
"ing",
"CSV_",
"<_",
">_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"samples",
"file",
"'_",
"]_",
"=_",
"self_",
"._",
"train",
"ing",
"CSV_",
"\\u\\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_",
",_",
"\"",
"No",
" ",
"Sampl",
"es",
" ",
"file",
" ",
"supplie",
"d",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"test",
"CSV_",
"<_",
">_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"tests",
"ample",
"sfi",
"le",
"'_",
"]_",
"=_",
"self_",
"._",
"test",
"CSV_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"background",
"CSV_",
"<_",
">_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"environ",
"menta",
"lla",
"yer",
"s",
"'_",
"]_",
"=_",
"self_",
"._",
"background",
"CSV_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"args_",
"[_",
"'",
"autor",
"un",
"'_",
"]_",
"=_",
"'",
"true",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"self",
".",
"args",
"['",
"output",
"grids",
"']",
" ",
"=",
" ",
"'",
"fal",
"se",
"'_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"'",
" ",
"'_",
"in_",
"self_",
"._",
"args_",
"[_",
"'",
"specie",
"s",
"\\u",
"name",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"specie",
"s",
"\\u",
"name",
"'_",
"]_",
"=_",
"self_",
"._",
"args_",
"[_",
"'",
"specie",
"s",
"\\u",
"name",
"'_",
"]_",
"._",
"replace_",
"(_",
"'",
" ",
"'_",
",_",
"'\\u'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"stra",
"rgs_",
"=_",
"[_",
"'='_",
"._",
"join_",
"(_",
"(_",
"str_",
"(_",
"k_",
")_",
",_",
"str_",
"(_",
"v_",
")_",
")_",
")_",
"for_",
"k_",
",_",
"v_",
"in_",
"self_",
"._",
"args_",
"._",
"iteritems_",
"(_",
")_",
"if_",
"k_",
"<_",
">_",
"\"",
"specie",
"s",
"\\u",
"name",
"\"_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"categorical_",
"in_",
"self_",
"._",
"categor",
"ical",
"s_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"stra",
"rgs_",
"+=_",
"[_",
"'",
"toggle",
"layer",
"type",
"='_",
"+_",
"categorical_",
"._",
"replace_",
"(_",
"'\\u",
"categor",
"ical",
"'_",
",_",
"''_",
")_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"stra",
"rg",
"s",
" ",
"=",
" ",
"'",
" ",
"'.",
"join",
"(",
"stra",
"rg",
"s",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
" ",
"stra",
"rgs_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"self_",
"._",
"maxe",
"ntpath",
"_",
"._",
"endswith_",
"(_",
"'.",
"jar",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"jar_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"maxe",
"ntpath",
"_",
",_",
"'",
"maxe",
"nt",
".",
"jar",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"jar_",
"=_",
"self_",
"._",
"maxe",
"ntpath",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"run",
"\\u",
"cmd",
"\\u",
"line",
"\\u",
"jar_",
"(_",
"jar_",
",_",
"stra",
"rgs_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"run",
"\\u",
"cmd",
"\\u",
"line",
"\\u",
"jar_",
"(_",
"self_",
",_",
"jar",
"\\u",
"name_",
",_",
"args_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"arg",
"\\u",
"items",
" ",
"=",
" ",
"list",
"(",
"iter",
"tool",
"s",
".",
"chain",
"(*",
"args",
".",
"items",
"())",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"arg",
"\\u",
"items",
" ",
"=",
" ",
"['",
"='",
".",
"join",
"((",
"str",
"(",
"k",
"),",
"str",
"(",
"v",
")))",
" ",
"for",
" ",
"k",
",",
"v",
" ",
"in",
" ",
"args",
".",
"iter",
"items",
"()]",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cmd_",
"=_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"[_",
"'",
"java",
"'_",
",_",
"'-",
"mx",
"512",
"m",
"'_",
",_",
"'-",
"jar",
"'_",
",_",
"jar",
"\\u",
"name_",
"]_",
"+_",
"args_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"writet",
"olog",
"_",
"(_",
"'",
" ",
" ",
" ",
" ",
"runn",
"ing",
":",
" ",
" ",
"'_",
"+_",
"cmd_",
",_",
"True_",
",_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"res",
" ",
"=",
" ",
"execute",
"\\u",
"cmdli",
"ne",
"([",
"'",
"java",
"',",
" ",
"'-",
"jar",
"',",
" ",
"jar",
"\\u",
"name",
"]",
" ",
"+",
" ",
"args",
",",
" ",
"output",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"p_",
"=_",
"subprocess_",
"._",
"Popen_",
"(_",
"cmd_",
",_",
"shell_",
"=_",
"True_",
",_",
"stdout_",
"=_",
"subprocess_",
"._",
"PIPE_",
",_",
"stderr_",
"=_",
"subprocess_",
"._",
"STDOUT_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"writet",
"olog",
"_",
"(_",
"'",
" ",
" ",
" ",
" ",
"Finish",
"ed",
" ",
"runn",
"ing",
":",
" ",
" ",
"'_",
",_",
"True_",
",_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"ret_",
"=_",
"p_",
"._",
"communicate_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"writet",
"olog",
"_",
"(_",
"'",
" ",
" ",
" ",
" ",
"Max",
"ent",
" ",
"str",
"Out",
":",
" ",
" ",
"'_",
"+_",
"str_",
"(_",
"ret_",
"[_",
"0_",
"]_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"ret_",
"[_",
"1_",
"]_",
"is_",
"not_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"\"",
"An",
" ",
"error",
" ",
"was",
" ",
"encounter",
"ed",
" ",
"runn",
"ing",
" ",
"the",
" ",
"Max",
"ent",
" ",
"jar",
" ",
"file",
".",
" ",
" ",
"The",
" ",
"error",
" ",
"message",
" ",
"is",
" ",
"belo",
"w",
" ",
"-",
" ",
"\\\\",
"n",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"msg_",
"+=_",
"ret_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"writet",
"olog",
"_",
"(_",
"msg_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Run",
"time",
"Error_",
",_",
"msg_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"del_",
"ret_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"load",
"Args_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"args",
"Reader_",
"=_",
"csv_",
"._",
"reader_",
"(_",
"open_",
"(_",
"self_",
"._",
"args",
"CSV_",
",_",
"'",
"r",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"header_",
"=_",
"args",
"Reader_",
"._",
"next_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"args_",
"=_",
"{_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"row_",
"in_",
"args",
"Reader_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"row_",
"[_",
"0_",
"]_",
"]_",
"=_",
"row_",
"[_",
"1_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"validat",
"e",
"Inputs_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"args",
"CSV_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Run",
"time",
"Error_",
"(_",
"self_",
",_",
"'",
"Inp",
"ut",
" ",
"args",
"File",
",",
" ",
"'_",
"+_",
"self_",
"._",
"args",
"CSV_",
"+_",
"',",
" ",
"coul",
"d",
" ",
"not",
" ",
"be",
" ",
"found",
" ",
"on",
" ",
"file",
" ",
"system",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"input",
"MD",
"S_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Run",
"time",
"Error_",
"(_",
"self_",
",_",
"'",
"Inp",
"ut",
" ",
"MD",
"S",
",",
" ",
"'_",
"+_",
"self_",
"._",
"input",
"MD",
"S_",
"+_",
"',",
" ",
"coul",
"d",
" ",
"not",
" ",
"be",
" ",
"found",
" ",
"on",
" ",
"file",
" ",
"system",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"self_",
"._",
"args_",
"._",
"has",
"\\u",
"key_",
"(_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
"]_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"args_",
"[_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
"]_",
"<_",
">_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dirs_",
"=_",
"self_",
"._",
"args_",
"[_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
"]_",
"._",
"split_",
"(_",
"','_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"dir_",
"in_",
"dirs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"isdir_",
"(_",
"dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"raise_",
"Run",
"time",
"Error_",
"(_",
"self_",
",_",
"\"",
"Inp",
"ut",
" ",
"'",
"projecti",
"onl",
"aye",
"rs",
"'",
" ",
"must",
" ",
"be",
" ",
"a",
" ",
"director",
"y",
"\"_",
")_",
"\\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_",
"utilities_",
"._",
"is",
"MD",
"SF",
"ile_",
"(_",
"self_",
"._",
"input",
"MD",
"S_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Run",
"time",
"Error_",
"(_",
"self_",
",_",
"'",
"Inp",
"ut",
" ",
"MD",
"S",
",",
" ",
"'_",
"+_",
"self_",
"._",
"input",
"MD",
"S_",
"+_",
"',",
" ",
"doe",
"s",
" ",
"not",
" ",
"appear",
" ",
"to",
" ",
"be",
" ",
"formate",
"d",
" ",
"as",
" ",
"an",
" ",
"MD",
"S",
" ",
"file",
".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"self_",
"._",
"output",
"Dir_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Run",
"time",
"Error_",
"(_",
"self_",
",_",
"'",
"Output",
" ",
"director",
"y",
",",
" ",
"'_",
"+_",
"self_",
"._",
"output",
"Dir_",
"+_",
"',",
" ",
"coul",
"d",
" ",
"not",
" ",
"be",
" ",
"found",
" ",
"on",
" ",
"file",
" ",
"system",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"logger_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"logger_",
"=_",
"utilities_",
"._",
"logger_",
"(_",
"out",
"Dir_",
",_",
"self_",
"._",
"verbose_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"writet",
"olog",
"_",
"=_",
"self_",
"._",
"logger_",
"._",
"writet",
"olog",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"prep",
"Inputs_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"parse",
"s",
" ",
"out",
" ",
"input",
" ",
"MD",
"S",
" ",
"file",
" ",
"int",
"o",
" ",
"the",
" ",
"1",
" ",
"to",
" ",
"3",
" ",
"SW",
"D",
" ",
"files",
" ",
"tha",
"t",
" ",
"Max",
"ent",
" ",
"require",
"s",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Creat",
"e",
" ",
"the",
" ",
"output",
"s",
" ",
"in",
" ",
"our",
" ",
"output",
"directory_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"test",
"CSV_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"output",
"Dir_",
",_",
"'",
"test",
"Sampl",
"es",
".",
"csv",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"train",
"ing",
"CSV_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"output",
"Dir_",
",_",
"'",
"train",
"ing",
"Sampl",
"es",
".",
"csv",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"background",
"CSV_",
"=_",
"os_",
"._",
"path_",
"._",
"join_",
"(_",
"self_",
"._",
"output",
"Dir_",
",_",
"'",
"background",
"Point",
"s",
".",
"csv",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"test",
"Writer_",
"=_",
"csv_",
"._",
"writer_",
"(_",
"open_",
"(_",
"self_",
"._",
"test",
"CSV_",
",_",
"'",
"wb",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"train",
"ing",
"Writer_",
"=_",
"csv_",
"._",
"writer_",
"(_",
"open_",
"(_",
"self_",
"._",
"train",
"ing",
"CSV_",
",_",
"'",
"wb",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"background",
"Writer_",
"=_",
"csv_",
"._",
"writer_",
"(_",
"open_",
"(_",
"self_",
"._",
"background",
"CSV_",
",_",
"'",
"wb",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Read",
" ",
"through",
" ",
"the",
" ",
"MD",
"S",
" ",
"and",
" ",
"pull",
" ",
"the",
" ",
"headers_",
"\\u\\u\\uNL\\u\\u\\u_",
"MD",
"Sr",
"eader",
"_",
"=_",
"csv_",
"._",
"reader_",
"(_",
"open_",
"(_",
"self_",
"._",
"input",
"MD",
"S_",
",_",
"'",
"r",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"header",
"1_",
"=_",
"MD",
"Sr",
"eader",
"_",
"._",
"next_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"header",
"2_",
"=_",
"MD",
"Sr",
"eader",
"_",
"._",
"next_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"header",
"3_",
"=_",
"MD",
"Sr",
"eader",
"_",
"._",
"next_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"pull",
"Categori",
"cals",
"_",
"(_",
"header",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"The",
" ",
"split",
" ",
"column",
" ",
"indicat",
"es",
" ",
"tha",
"t",
" ",
"this",
" ",
"file",
" ",
"has",
" ",
"bee",
"n",
" ",
"run",
" ",
"through",
" ",
"the",
" _",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"test",
" ",
"train",
"ing",
" ",
"split",
" ",
"and",
" ",
"testi",
"ng",
" ",
"data",
" ",
"shou",
"ld",
" ",
"be",
" ",
"write",
"n",
" ",
"to",
" ",
"the",
" ",
"test",
" ",
"file",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"split",
"col_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"split",
"col_",
"=_",
"header",
"1_",
"._",
"index_",
"(_",
"'",
"Split",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"delete",
"Test_",
"=_",
"False_",
"\\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 ",
" _",
"self_",
"._",
"writet",
"olog",
"_",
"(_",
"\"",
" ",
" ",
" ",
" ",
"The",
" ",
"supplie",
"d",
" ",
"MD",
"S",
" ",
"doe",
"s",
" ",
"not",
" ",
"have",
" ",
"a",
" ",
"'",
"Split",
"'",
" ",
"column",
" ",
"default",
"ing",
" ",
"to",
" ",
"hav",
"ing",
" ",
"Max",
"ent",
" ",
"appl",
"y",
" ",
"test",
"/",
"train",
"ing",
" ",
"split",
".\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"delete",
"Test_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"covar",
"iate",
"Indexes_",
"=_",
"self_",
"._",
"used",
"Indexes_",
"(_",
"header",
"1_",
",_",
"header",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"covar",
"iate",
"Names_",
"=_",
"self_",
"._",
"used",
"Values_",
"(_",
"header",
"1_",
",_",
"covar",
"iate",
"Indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"covar",
"iate",
"Names",
"Clean",
"_",
"=_",
"[_",
"name_",
"._",
"replace_",
"(_",
"'\\u",
"categor",
"ical",
"'_",
",_",
"''_",
")_",
"for_",
"name_",
"in_",
"covar",
"iate",
"Names_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"used",
"Covar",
"iate",
"Files_",
"=_",
"self_",
"._",
"used",
"Values_",
"(_",
"header",
"3_",
",_",
"covar",
"iate",
"Indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"writet",
"olog",
"_",
"(_",
"'",
" ",
" ",
" ",
" ",
"Us",
"ed",
" ",
"covar",
"iate",
"s",
":'_",
"+_",
"\",",
" ",
"\"_",
"._",
"join_",
"(_",
"covar",
"iate",
"Names_",
")_",
",_",
"False_",
",_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"test",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"'",
"full",
"\\u",
"name",
"'_",
",_",
"'",
"x",
"'_",
",_",
"'",
"y",
"'_",
"]_",
"+_",
"covar",
"iate",
"Names",
"Clean",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"train",
"ing",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"'",
"full",
"\\u",
"name",
"'_",
",_",
"'",
"x",
"'_",
",_",
"'",
"y",
"'_",
"]_",
"+_",
"covar",
"iate",
"Names",
"Clean",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"background",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"'",
"full",
"\\u",
"name",
"'_",
",_",
"'",
"x",
"'_",
",_",
"'",
"y",
"'_",
"]_",
"+_",
"covar",
"iate",
"Names",
"Clean",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"loop",
" ",
"through",
" ",
"the",
" ",
"rows",
" ",
"sendin",
"g",
" ",
"each",
" ",
"row",
" ",
"to",
" ",
"the",
" ",
"appropr",
"iate",
" ",
"file_",
"\\u\\u\\uNL\\u\\u\\u_",
"has",
"Background_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"row_",
"in_",
"MD",
"Sr",
"eader",
"_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"row_",
"[_",
"2_",
"]_",
"==_",
"'-",
"9999",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"has",
"Background_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"vals_",
"=_",
"self_",
"._",
"used",
"Values_",
"(_",
"row_",
",_",
"covar",
"iate",
"Indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"background",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"''_",
"]_",
"+_",
"row_",
"[_",
":_",
"2_",
"]_",
"+_",
"vals_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"split",
"col_",
"is_",
"None_",
"and_",
"row_",
"[_",
"2_",
"]_",
"<_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"vals_",
"=_",
"self_",
"._",
"used",
"Values_",
"(_",
"row_",
",_",
"covar",
"iate",
"Indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"train",
"ing",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"self_",
"._",
"args_",
"[_",
"'",
"specie",
"s",
"\\u",
"name",
"'_",
"]_",
"]_",
"+_",
"row_",
"[_",
":_",
"2_",
"]_",
"+_",
"vals_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"(_",
"row_",
"[_",
"split",
"col_",
"]_",
"==_",
"'",
"test",
"'_",
"and_",
"row_",
"[_",
"2_",
"]_",
"<_",
">_",
"0_",
")_",
"or_",
"self_",
"._",
"test",
"CSV_",
"==_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"vals_",
"=_",
"self_",
"._",
"used",
"Values_",
"(_",
"row_",
",_",
"covar",
"iate",
"Indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"test",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"self_",
"._",
"args_",
"[_",
"'",
"specie",
"s",
"\\u",
"name",
"'_",
"]_",
"]_",
"+_",
"row_",
"[_",
":_",
"2_",
"]_",
"+_",
"vals_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"row_",
"[_",
"split",
"col_",
"]_",
"==_",
"'",
"train",
"'_",
"and_",
"row_",
"[_",
"2_",
"]_",
"<_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"vals_",
"=_",
"self_",
"._",
"used",
"Values_",
"(_",
"row_",
",_",
"covar",
"iate",
"Indexes_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"train",
"ing",
"Writer_",
"._",
"writerow_",
"(_",
"[_",
"self_",
"._",
"args_",
"[_",
"'",
"specie",
"s",
"\\u",
"name",
"'_",
"]_",
"]_",
"+_",
"row_",
"[_",
":_",
"2_",
"]_",
"+_",
"vals_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"any",
" ",
"absen",
"se",
" ",
"points",
" ",
"(",
"row",
"[",
"2",
"]",
" ",
"==",
" ",
"0",
")",
" ",
"will",
" ",
"be",
" ",
"ignore",
"d",
" ",
"for",
" ",
"maxe",
"nt_",
"\\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_",
"not_",
"has",
"Background_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"msg_",
"=_",
"\"",
" ",
" ",
" ",
" ",
"No",
" ",
"background",
" ",
"points",
" ",
"wer",
"e",
" ",
"detect",
"ed",
" ",
"in",
" ",
"the",
" ",
"input",
" ",
"file",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"msg_",
"+=_",
"\"\\\\",
"n",
" ",
" ",
" ",
" ",
"Thi",
"s",
" ",
"implementation",
" ",
"of",
" ",
"Max",
"ent",
" ",
"doe",
"s",
" ",
"not",
" ",
"have",
" ",
"access",
" ",
"to",
" ",
"prepared",
" ",
"ASCII",
" ",
"environ",
"menta",
"l",
" ",
"layer",
"s",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"msg_",
"+=_",
"\"",
" ",
"from",
" ",
"whi",
"ch",
" ",
"to",
" ",
"extract",
" ",
"values",
".",
" ",
" ",
"Back",
"ground",
" ",
"points",
" ",
"must",
" ",
"be",
" ",
"supplie",
"d",
" ",
"in",
" ",
"the",
" ",
"MD",
"S",
" ",
"file",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"writet",
"olog",
"_",
"(_",
"msg_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"raise_",
"Run",
"time",
"Error_",
"(_",
"msg_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"del",
" ",
"our",
" ",
"writer",
"s",
" _",
"\\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 ",
" _",
"del_",
"test",
"Writer_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"delete",
"Test_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"remove_",
"(_",
"self_",
"._",
"test",
"CSV_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"test",
"CSV_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"del_",
"background",
"Writer_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"not_",
"has",
"Background_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"os_",
"._",
"remove_",
"(_",
"self_",
"._",
"background",
"CSV_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"background",
"CSV_",
"=_",
"''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"del_",
"train",
"ing",
"Writer_",
"\\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_",
"'",
" ",
"'_",
"._",
"join_",
"(_",
"[_",
"str_",
"(_",
"i_",
")_",
"for_",
"i_",
"in_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
":_",
"2_",
"]_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Fi",
"rst",
" ",
"we",
" ",
"have",
" ",
"to",
" ",
"figure",
" ",
"out",
" ",
"what",
" ",
"the",
"y",
" ",
"pass",
"ed",
" ",
"us_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"eit",
"her",
" ",
"a",
" ",
"director",
"y",
",",
" ",
"a",
" ",
"SW",
"D",
" ",
"file",
",",
" ",
"or",
" ",
"a",
" ",
"csv",
" ",
"with",
" ",
"a",
" ",
"list",
" ",
"of",
" ",
"files_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"args_",
"[_",
"'",
"projecti",
"onl",
"aye",
"rs",
"'_",
"]_",
"<_",
">_",
"''_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"args_",
"[_",
"'",
"output",
"grids",
"'_",
"]_",
"=_",
"'",
"fal",
"se",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"used",
"Indexes_",
"(_",
"self_",
",_",
"header",
"1_",
",_",
"header",
"2_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"covar",
"iate",
"Indexes_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"len_",
"(_",
"header",
"1_",
")_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"header",
"2_",
"[_",
"i_",
"]_",
"==_",
"'",
"1",
"'_",
"and_",
"header",
"1_",
"[_",
"i_",
"]_",
"<_",
">_",
"'",
"Split",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"covar",
"iate",
"Indexes_",
"._",
"append_",
"(_",
"i_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"covar",
"iate",
"Indexes_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"used",
"Values_",
"(_",
"self_",
",_",
"values_",
",_",
"indexes_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"used",
"vals_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"indexes_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"used",
"vals_",
"._",
"append_",
"(_",
"values_",
"[_",
"i_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"used",
"vals_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"pull",
"Categori",
"cals",
"_",
"(_",
"self_",
",_",
"header",
"line_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"item_",
"in_",
"header",
"line_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"item_",
"._",
"endswith_",
"(_",
"'\\u",
"categor",
"ical",
"'_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"categor",
"ical",
"s_",
"._",
"append_",
"(_",
"item_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"is",
"SW",
"D_",
"(_",
"self_",
",_",
"file_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"Check",
"s",
" ",
"the",
" ",
"format",
" ",
"of",
" ",
"a",
" ",
"file",
" ",
"to",
" ",
"see",
" ",
"if",
" ",
"it",
" ",
"is",
" ",
"in",
" ",
"the",
" ",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Max",
"ent",
" ",
"samples",
" ",
"with",
" ",
"data",
" ",
"(",
"SW",
"D",
")",
" ",
"format",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"os_",
"._",
"path_",
"._",
"exists_",
"(_",
"file_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"reader_",
"=_",
"csv_",
"._",
"reader_",
"(_",
"open_",
"(_",
"file_",
",_",
"'",
"r",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"header_",
"=_",
"reader_",
"._",
"next_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"header_",
"[_",
"0_",
"]_",
"._",
"lower_",
"(_",
")_",
"in_",
"[_",
"'",
"specie",
"s",
"'_",
",_",
"'",
"full",
"\\u",
"name",
"'_",
",_",
"'",
"full",
"name",
"'_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"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_",
"(_",
"argv_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"'''",
"Process",
" ",
"our",
" ",
"command",
" ",
"line",
" ",
"args",
" ",
"and",
" ",
"initiate",
" ",
"a",
" ",
"Max",
"ent",
" ",
"run",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"'''_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"usage",
"Stmt",
"_",
"=_",
"\"",
"usage",
":",
" ",
" ",
"-",
"m",
" ",
"--",
"MD",
"SF",
"ile",
" ",
"-",
"a",
" ",
"--",
"args",
"CSV",
" ",
"-",
"o",
" ",
"--",
"output",
"Dir",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"desc_",
"=_",
"\"",
"Format",
"s",
" ",
"and",
" ",
"prepar",
"es",
" ",
"input",
" ",
"for",
" ",
"runn",
"ing",
" ",
"the",
" ",
"Max",
"ent",
" ",
"Jar",
" ",
"in",
" ",
"a",
" ",
"SA",
"HM",
" ",
"workf",
"low",
"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"parser_",
"=_",
"Optio",
"n",
"Parser_",
"(_",
"usage_",
"=_",
"usage",
"Stmt",
"_",
",_",
"description_",
"=_",
"desc_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"option_",
"(_",
"\"-",
"m",
"\"_",
",_",
"\"--",
"MD",
"SF",
"ile",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"dest_",
"=_",
"\"",
"MD",
"SF",
"ile",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"\"",
"The",
" ",
"MD",
"S",
" ",
"file",
" ",
"with",
" ",
"our",
" ",
"sample",
" ",
"data",
".\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"parser",
".",
"add",
"\\u",
"option",
"(\"",
"-",
"p",
"\",",
" ",
"\"--",
"projecti",
"on",
"Data",
"\",",
" _",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"dest",
"=\"",
"projecti",
"on",
"Data",
"\",",
" _",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
" ",
"help",
"=\"",
"An",
" ",
"option",
"al",
" ",
"CSV",
" ",
"with",
" ",
"a",
" ",
"projecti",
"on",
" ",
"file",
" ",
"for",
" ",
"each",
" ",
"of",
" ",
"our",
" ",
"environ",
"em",
"net",
"al",
" ",
"layer",
"s",
".\"",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"option_",
"(_",
"\"-",
"a",
"\"_",
",_",
"\"--",
"args",
"CSV",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"dest_",
"=_",
"\"",
"args",
"CSV",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"\"",
"A",
" ",
"CSV",
" ",
"with",
" ",
"each",
" ",
"Max",
"ent",
" ",
"argu",
"ment",
" ",
"name",
" ",
"and",
" ",
"it",
"'",
"s",
" ",
"value",
" ",
"on",
" ",
"separate",
" ",
"lines",
".\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"option_",
"(_",
"\"-",
"e",
"\"_",
",_",
"\"--",
"maxe",
"nt",
"Executable",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"dest_",
"=_",
"\"",
"maxe",
"nt",
"Executable",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"\"",
"The",
" ",
"full",
" ",
"path",
" ",
"to",
" ",
"the",
" ",
"maxe",
"nt",
" ",
"executable",
" ",
"jar",
" ",
"file",
".\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"option_",
"(_",
"\"-",
"o",
"\"_",
",_",
"\"--",
"output",
"Dir",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"dest_",
"=_",
"\"",
"output",
"Dir",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"\"",
"The",
" ",
"director",
"y",
" ",
"to",
" ",
"save",
" ",
"output",
" ",
"files",
".\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"parser_",
"._",
"add",
"\\u",
"option_",
"(_",
"\"-",
"v",
"\"_",
",_",
"\"--",
"verbo",
"se",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"dest_",
"=_",
"\"",
"verbo",
"se",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"default_",
"=_",
"False_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"action_",
"=_",
"\"",
"store",
"\\u",
"true",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"help_",
"=_",
"\"",
"the",
" ",
"verbo",
"se",
" ",
"flag",
" ",
"caus",
"es",
" ",
"diagnostic",
" ",
"output",
" ",
"to",
" ",
"print",
"\"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"options_",
",_",
"args_",
")_",
"=_",
"parser_",
"._",
"parse",
"\\u",
"args_",
"(_",
"argv_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"our",
"Max",
"ent_",
"=_",
"MAX",
"ENTR",
"unne",
"r_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"verbose_",
"=_",
"options_",
"._",
"verbose_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"maxe",
"ntpath",
"_",
"=_",
"options_",
"._",
"maxe",
"nt",
"Executable",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"input",
"MD",
"S_",
"=_",
"options_",
"._",
"MD",
"SF",
"ile_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"output",
"Dir_",
"=_",
"options_",
"._",
"output",
"Dir_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"args",
"CSV_",
"=_",
"options_",
"._",
"args",
"CSV_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"projecti",
"on",
"Data",
"File_",
"=_",
"options_",
"._",
"projecti",
"on",
"Data_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"utilities_",
"._",
"create",
"session",
"log_",
"(_",
"options_",
"._",
"output",
"Dir_",
",_",
"options_",
"._",
"verbose_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"our",
"Max",
"ent_",
"._",
"run_",
"(_",
")_",
"\\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,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
2,
2,
2,
2,
2,
2,
2
]
|
Except block handles 'BaseException' | AppScale/appscale/AppServer/lib/jinja2-2.6/jinja2/testsuite/loader.py | [
{
"content": " def test_weak_references(self):\n self.compile_down()\n tmpl = self.mod_env.get_template('a/test.html')\n key = loaders.ModuleLoader.get_template_key('a/test.html')\n name = self.mod_env.loader.module.__name__\n\n assert hasattr(self.mod_env.loader.module, key)\n assert name in sys.modules\n\n # unset all, ensure the module is gone from sys.modules\n self.mod_env = tmpl = None\n\n try:\n import gc\n gc.collect()\n except:\n pass\n\n assert name not in sys.modules",
"metadata": "root.ModuleLoaderTestCase.test_weak_references",
"header": "['class', 'ModuleLoaderTestCase', '(', 'JinjaTestCase', ')', ':', '___EOS___']",
"index": 156
}
]
| [
{
"span": "except:",
"start_line": 171,
"start_column": 8,
"end_line": 171,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Modul",
"e",
"Load",
"er",
"Test",
"Case_",
"(_",
"Jin",
"ja",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"weak",
"\\u",
"references_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"compile",
"\\u",
"down_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"tmpl_",
"=_",
"self_",
"._",
"mod",
"\\u",
"env_",
"._",
"get",
"\\u",
"template_",
"(_",
"'",
"a",
"/",
"test",
".",
"html",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"key_",
"=_",
"loaders_",
"._",
"Modul",
"e",
"Loader_",
"._",
"get",
"\\u",
"template",
"\\u",
"key_",
"(_",
"'",
"a",
"/",
"test",
".",
"html",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"name_",
"=_",
"self_",
"._",
"mod",
"\\u",
"env_",
"._",
"loader_",
"._",
"module_",
"._",
"\\u\\u",
"name\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"assert_",
"hasattr_",
"(_",
"self_",
"._",
"mod",
"\\u",
"env_",
"._",
"loader_",
"._",
"module_",
",_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"name_",
"in_",
"sys_",
"._",
"modules_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"unse",
"t",
" ",
"all",
",",
" ",
"ensure",
" ",
"the",
" ",
"module",
" ",
"is",
" ",
"gone",
" ",
"from",
" ",
"sys",
".",
"modules_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"mod",
"\\u",
"env_",
"=_",
"tmpl_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"import_",
"gc_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"gc_",
"._",
"collect_",
"(_",
")_",
"\\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_",
"assert_",
"name_",
"not_",
"in_",
"sys_",
"._",
"modules_",
"\\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,
0,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Variable defined multiple times | statsmodels/statsmodels/statsmodels/sandbox/regression/tests/test_gmm.py | [
{
"content": " def test_bse_other(self):\n res1, res2 = self.res1, self.res2\n\n moms = res1.model.momcond(res1.params)\n w = res1.model.calc_weightmatrix(moms)\n # try other versions for bse,\n # TODO: next two produce the same as before (looks like)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=False,\n weights=res1.weights))))\n # TODO: doesn't look different\n #assert_allclose(res1.bse, res2.bse, rtol=5e-06, atol=0)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=False,\n #use_weights=True #weights=w\n ))))\n #assert_allclose(res1.bse, res2.bse, rtol=5e-06, atol=0)\n\n #This doesn't replicate Stata oneway either\n nobs = instrument.shape[0]\n w0inv = np.dot(instrument.T, instrument) / nobs\n q = self.res1.model.gmmobjective(self.res1.params, w)#self.res1.weights)",
"metadata": "root.TestGMMStOneiter.test_bse_other",
"header": "['class', 'TestGMMStOneiter', '(', 'CheckGMM', ')', ':', '___EOS___']",
"index": 385
},
{
"content": " def test_basic(self):\n res1, res2 = self.res1, self.res2\n # test both absolute and relative difference\n assert_allclose(res1.params, res2.params, rtol=5e-05, atol=0)\n assert_allclose(res1.params, res2.params, rtol=0, atol=5e-06)\n\n n = res1.model.exog.shape[0]\n # TODO: check df correction np.sqrt(745./758 )*res1.bse matches better\n dffact = np.sqrt(745. / 758 )\n assert_allclose(res1.bse * dffact, res2.bse, rtol=5e-03, atol=0)\n assert_allclose(res1.bse * dffact, res2.bse, rtol=0, atol=5e-03)\n\n # try other versions for bse,\n # TODO: next two produce the same as before (looks like)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=True,\n weights=res1.weights))))\n assert_allclose(res1.bse, res2.bse, rtol=5e-01, atol=0)\n\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=True,\n weights=res1.weights,\n use_weights=True))))\n assert_allclose(res1.bse, res2.bse, rtol=5e-02, atol=0)\n\n # TODO: resolve this\n # try bse from previous step, is closer to Stata\n # guess: Stata ivreg2 doesn't calc for bse update after final iteration\n # need better test case, bse difference is close to numerical optimization precision\n assert_allclose(self.res3.bse, res2.bse, rtol=5e-05, atol=0)\n assert_allclose(self.res3.bse, res2.bse, rtol=0, atol=5e-06)\n\n\n\n # TODO; tvalues are not available yet, no inheritance\n #assert_allclose(res1.tvalues, res2.tvalues, rtol=5e-10, atol=0)",
"metadata": "root.TestGMMSt2.test_basic",
"header": "['class', 'TestGMMSt2', '(', 'object', ')', ':', '___NEWLINE___', '# this looks like an old version, trying out different comparisons', '___NL___', '# of options with Stats', '___NL___', '___EOS___']",
"index": 578
}
]
| [
{
"span": "bse ",
"start_line": 392,
"start_column": 8,
"end_line": 392,
"end_column": 11
},
{
"span": "bse ",
"start_line": 592,
"start_column": 8,
"end_line": 592,
"end_column": 11
}
]
| [
{
"span": "bse ",
"start_line": 396,
"start_column": 8,
"end_line": 396,
"end_column": 11
},
{
"span": "bse ",
"start_line": 596,
"start_column": 8,
"end_line": 596,
"end_column": 11
}
]
| 1 | true | [
"[CLS]_",
"Variable_",
"defined_",
"multiple_",
"times_",
"[SEP]_",
"class_",
"Test",
"GM",
"MS",
"t",
"One",
"iter_",
"(_",
"Check",
"GM",
"M_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"bse",
"\\u",
"other_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"res1_",
",_",
"res2_",
"=_",
"self_",
"._",
"res1_",
",_",
"self_",
"._",
"res2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"mom",
"s_",
"=_",
"res1_",
"._",
"model_",
"._",
"mom",
"cond_",
"(_",
"res1_",
"._",
"params_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"w_",
"=_",
"res1_",
"._",
"model_",
"._",
"calc",
"\\u",
"weight",
"matrix_",
"(_",
"mom",
"s_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"try",
" ",
"other",
" ",
"version",
"s",
" ",
"for",
" ",
"bse",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"next",
" ",
"two",
" ",
"produce",
" ",
"the",
" ",
"same",
" ",
"as",
" ",
"bef",
"ore",
" ",
"(",
"look",
"s",
" ",
"like",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"bse",
"_",
"=_",
"np_",
"._",
"sqrt_",
"(_",
"np_",
"._",
"diag_",
"(_",
"(_",
"res1_",
"._",
"\\u",
"cov",
"\\u",
"params_",
"(_",
"has",
"\\u",
"optim",
"al",
"\\u",
"weights_",
"=_",
"False_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"weights_",
"=_",
"res1_",
"._",
"weights_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"doe",
"sn",
"'",
"t",
" ",
"look",
" ",
"different",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"assert",
"\\u",
"allc",
"lose",
"(",
"res",
"1",
".",
"bse",
",",
" ",
"res",
"2",
".",
"bse",
",",
" ",
"rto",
"l",
"=",
"5e-0",
"6",
",",
" ",
"atol",
"=",
"0",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"bse",
"_",
"=_",
"np_",
"._",
"sqrt_",
"(_",
"np_",
"._",
"diag_",
"(_",
"(_",
"res1_",
"._",
"\\u",
"cov",
"\\u",
"params_",
"(_",
"has",
"\\u",
"optim",
"al",
"\\u",
"weights_",
"=_",
"False_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"use",
"\\u",
"weight",
"s",
"=",
"Tru",
"e",
" ",
"#",
"weight",
"s",
"=",
"w_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"assert",
"\\u",
"allc",
"lose",
"(",
"res",
"1",
".",
"bse",
",",
" ",
"res",
"2",
".",
"bse",
",",
" ",
"rto",
"l",
"=",
"5e-0",
"6",
",",
" ",
"atol",
"=",
"0",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"Thi",
"s",
" ",
"doe",
"sn",
"'",
"t",
" ",
"replicate",
" ",
"Stat",
"a",
" ",
"one",
"way",
" ",
"eit",
"her_",
"\\u\\u\\uNL\\u\\u\\u_",
"nob",
"s_",
"=_",
"instrument_",
"._",
"shape_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"w",
"0",
"inv_",
"=_",
"np_",
"._",
"dot_",
"(_",
"instrument_",
"._",
"T_",
",_",
"instrument_",
")_",
"/_",
"nob",
"s_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"q_",
"=_",
"self_",
"._",
"res1_",
"._",
"model_",
"._",
"gmm",
"objective_",
"(_",
"self_",
"._",
"res1_",
"._",
"params_",
",_",
"w_",
")_",
"#",
"self",
".",
"res",
"1",
".",
"weight",
"s",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"GM",
"MS",
"t2_",
"(_",
"object_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"this",
" ",
"look",
"s",
" ",
"like",
" ",
"an",
" ",
"old",
" ",
"version",
",",
" ",
"try",
"ing",
" ",
"out",
" ",
"different",
" ",
"comparisons",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"of",
" ",
"options",
" ",
"with",
" ",
"Stats_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"basic_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"res1_",
",_",
"res2_",
"=_",
"self_",
"._",
"res1_",
",_",
"self_",
"._",
"res2_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"test",
" ",
"bot",
"h",
" ",
"abs",
"olute",
" ",
"and",
" ",
"relative",
" ",
"difference_",
"\\u\\u\\uNL\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"res1_",
"._",
"params_",
",_",
"res2_",
"._",
"params_",
",_",
"rtol_",
"=_",
"5e-0",
"5_",
",_",
"atol_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"res1_",
"._",
"params_",
",_",
"res2_",
"._",
"params_",
",_",
"rtol_",
"=_",
"0_",
",_",
"atol_",
"=_",
"5e-0",
"6_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"n_",
"=_",
"res1_",
"._",
"model_",
"._",
"exo",
"g_",
"._",
"shape_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"check",
" ",
"df",
" ",
"correcti",
"on",
" ",
"np",
".",
"sqrt",
"(",
"745",
"./",
"758",
" ",
")*",
"res",
"1",
".",
"bse",
" ",
"matche",
"s",
" ",
"bett",
"er_",
"\\u\\u\\uNL\\u\\u\\u_",
"dff",
"act_",
"=_",
"np_",
"._",
"sqrt_",
"(_",
"745",
"._",
"/_",
"758",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"res1_",
"._",
"bse",
"_",
"*_",
"dff",
"act_",
",_",
"res2_",
"._",
"bse",
"_",
",_",
"rtol_",
"=_",
"5e-0",
"3_",
",_",
"atol_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"res1_",
"._",
"bse",
"_",
"*_",
"dff",
"act_",
",_",
"res2_",
"._",
"bse",
"_",
",_",
"rtol_",
"=_",
"0_",
",_",
"atol_",
"=_",
"5e-0",
"3_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"try",
" ",
"other",
" ",
"version",
"s",
" ",
"for",
" ",
"bse",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"next",
" ",
"two",
" ",
"produce",
" ",
"the",
" ",
"same",
" ",
"as",
" ",
"bef",
"ore",
" ",
"(",
"look",
"s",
" ",
"like",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"bse",
"_",
"=_",
"np_",
"._",
"sqrt_",
"(_",
"np_",
"._",
"diag_",
"(_",
"(_",
"res1_",
"._",
"\\u",
"cov",
"\\u",
"params_",
"(_",
"has",
"\\u",
"optim",
"al",
"\\u",
"weights_",
"=_",
"True_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"weights_",
"=_",
"res1_",
"._",
"weights_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"res1_",
"._",
"bse",
"_",
",_",
"res2_",
"._",
"bse",
"_",
",_",
"rtol_",
"=_",
"5e-0",
"1_",
",_",
"atol_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"bse",
"_",
"=_",
"np_",
"._",
"sqrt_",
"(_",
"np_",
"._",
"diag_",
"(_",
"(_",
"res1_",
"._",
"\\u",
"cov",
"\\u",
"params_",
"(_",
"has",
"\\u",
"optim",
"al",
"\\u",
"weights_",
"=_",
"True_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"weights_",
"=_",
"res1_",
"._",
"weights_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"use",
"\\u",
"weights_",
"=_",
"True_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"res1_",
"._",
"bse",
"_",
",_",
"res2_",
"._",
"bse",
"_",
",_",
"rtol_",
"=_",
"5e-0",
"2_",
",_",
"atol_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"resolve",
" ",
"this_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"try",
" ",
"bse",
" ",
"from",
" ",
"previ",
"ous",
" ",
"step",
",",
" ",
"is",
" ",
"close",
"r",
" ",
"to",
" ",
"Stat",
"a_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"guess",
":",
" ",
"Stat",
"a",
" ",
"iv",
"reg",
"2",
" ",
"doe",
"sn",
"'",
"t",
" ",
"calc",
" ",
"for",
" ",
"bse",
" ",
"update",
" ",
"after",
" ",
"final",
" ",
"iteration_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"need",
" ",
"bett",
"er",
" ",
"test",
" ",
"case",
",",
" ",
"bse",
" ",
"difference",
" ",
"is",
" ",
"close",
" ",
"to",
" ",
"numerical",
" ",
"optimization",
" ",
"precision_",
"\\u\\u\\uNL\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"self_",
"._",
"res",
"3_",
"._",
"bse",
"_",
",_",
"res2_",
"._",
"bse",
"_",
",_",
"rtol_",
"=_",
"5e-0",
"5_",
",_",
"atol_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert",
"\\u",
"allclose_",
"(_",
"self_",
"._",
"res",
"3_",
"._",
"bse",
"_",
",_",
"res2_",
"._",
"bse",
"_",
",_",
"rtol_",
"=_",
"0_",
",_",
"atol_",
"=_",
"5e-0",
"6_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
";",
" ",
"tval",
"ues",
" ",
"are",
" ",
"not",
" ",
"avail",
"able",
" ",
"ye",
"t",
",",
" ",
"no",
" ",
"inherita",
"nce_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"assert",
"\\u",
"allc",
"lose",
"(",
"res",
"1",
".",
"tval",
"ues",
",",
" ",
"res",
"2",
".",
"tval",
"ues",
",",
" ",
"rto",
"l",
"=",
"5e-",
"10",
",",
" ",
"atol",
"=",
"0",
")_",
"\\u\\u\\uNL\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
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
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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' | denisenkom/django-sqlserver/sqlserver/base.py | [
{
"content": " def is_usable(self):\n try:\n # Use a mssql cursor directly, bypassing Django's utilities.\n with self.connection.cursor() as cursor:\n cursor.execute(\"SELECT 1\")\n except:\n return False\n else:\n return True",
"metadata": "root.DatabaseWrapper.is_usable",
"header": "['class', 'DatabaseWrapper', '(', 'sqlserver_ado', '.', 'base', '.', 'DatabaseWrapper', ')', ':', '___EOS___']",
"index": 174
}
]
| [
{
"span": "except:",
"start_line": 179,
"start_column": 8,
"end_line": 179,
"end_column": 15
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Databa",
"se",
"Wrapper_",
"(_",
"sqls",
"erver",
"\\u",
"ado_",
"._",
"base_",
"._",
"Databa",
"se",
"Wrapper_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"is",
"\\u",
"usable",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Us",
"e",
" ",
"a",
" ",
"mss",
"ql",
" ",
"cursor",
" ",
"direct",
"ly",
",",
" ",
"bypass",
"ing",
" ",
"Dj",
"ang",
"o",
"'",
"s",
" ",
"util",
"iti",
"es",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"with_",
"self_",
"._",
"connection_",
"._",
"cursor_",
"(_",
")_",
"as_",
"cursor_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"cursor_",
"._",
"execute_",
"(_",
"\"",
"SELECT",
" ",
"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 ",
" _",
"return_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"True_"
]
| [
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,
0,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Except block handles 'BaseException' | doozr/Xdebug-for-Vim/plugin/debugger.py | [
{
"content": " def recv(self, count=10000):\n \"\"\" receive message until response is last transaction id or received count's message \"\"\"\n while count>0:\n count = count - 1\n # recv message and convert to XML object\n txt = self.protocol.recv_msg()\n res = xml.dom.minidom.parseString(txt)\n # log messages {{{\n if self.debug:\n self.ui.tracewin.write( str(self.msgid) + ' : recv <===== {{{ ' + txt)\n self.ui.tracewin.write('}}}')\n # handle message\n self.handle_msg(res)\n # exit, if response's transaction id == last transaction id\n try:\n if int(res.firstChild.getAttribute('transaction_id')) == int(self.msgid):\n return\n except:\n pass",
"metadata": "root.Debugger.recv",
"header": "['class', 'Debugger', ':', '___EOS___']",
"index": 731
},
{
"content": "def debugger_command(msg, arg1 = '', arg2 = ''):\n try:\n debugger.command(msg, arg1, arg2)\n if debugger.status != 'stopped':\n debugger.command('stack_get')\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging', sys.exc_info()",
"metadata": "root.debugger_command",
"header": "['module', '___EOS___']",
"index": 1106
},
{
"content": "def debugger_run():\n try:\n debugger.run()\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging', sys.exc_info()",
"metadata": "root.debugger_run",
"header": "['module', '___EOS___']",
"index": 1117
},
{
"content": "def debugger_watch_input(cmd, arg = ''):\n try:\n if arg == '<cword>':\n arg = vim.eval('expand(\"<cword>\")')\n debugger.watch_input(cmd, arg)\n except:\n debugger.ui.tracewin.write( sys.exc_info() )\n debugger.ui.tracewin.write( \"\".join(traceback.format_tb(sys.exc_info()[2])) )\n debugger.stop()\n print 'Connection closed, stop debugging'",
"metadata": "root.debugger_watch_input",
"header": "['module', '___EOS___']",
"index": 1126
},
{
"content": "def debugger_context():\n try:\n debugger.command('context_get')\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging'",
"metadata": "root.debugger_context",
"header": "['module', '___EOS___']",
"index": 1137
},
{
"content": "def debugger_property(name = ''):\n try:\n debugger.property_get()\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging', sys.exc_info()",
"metadata": "root.debugger_property",
"header": "['module', '___EOS___']",
"index": 1146
},
{
"content": "def debugger_mark(exp = ''):\n try:\n debugger.mark(exp)\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging', sys.exc_info()",
"metadata": "root.debugger_mark",
"header": "['module', '___EOS___']",
"index": 1155
},
{
"content": "def debugger_up():\n try:\n debugger.up()\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging', sys.exc_info()",
"metadata": "root.debugger_up",
"header": "['module', '___EOS___']",
"index": 1164
},
{
"content": "def debugger_down():\n try:\n debugger.down()\n except:\n debugger.ui.tracewin.write(sys.exc_info())\n debugger.ui.tracewin.write(\"\".join(traceback.format_tb( sys.exc_info()[2])))\n debugger.stop()\n print 'Connection closed, stop debugging', sys.exc_info()",
"metadata": "root.debugger_down",
"header": "['module', '___EOS___']",
"index": 1173
}
]
| [
{
"span": "except:",
"start_line": 748,
"start_column": 6,
"end_line": 748,
"end_column": 13
},
{
"span": "except:",
"start_line": 1111,
"start_column": 2,
"end_line": 1111,
"end_column": 9
},
{
"span": "except:",
"start_line": 1120,
"start_column": 2,
"end_line": 1120,
"end_column": 9
},
{
"span": "except:",
"start_line": 1131,
"start_column": 2,
"end_line": 1131,
"end_column": 9
},
{
"span": "except:",
"start_line": 1140,
"start_column": 2,
"end_line": 1140,
"end_column": 9
},
{
"span": "except:",
"start_line": 1149,
"start_column": 2,
"end_line": 1149,
"end_column": 9
},
{
"span": "except:",
"start_line": 1158,
"start_column": 2,
"end_line": 1158,
"end_column": 9
},
{
"span": "except:",
"start_line": 1167,
"start_column": 2,
"end_line": 1167,
"end_column": 9
},
{
"span": "except:",
"start_line": 1176,
"start_column": 2,
"end_line": 1176,
"end_column": 9
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"class_",
"Debugger",
"_",
":_",
"\\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_",
"recv_",
"(_",
"self_",
",_",
"count_",
"=_",
"10000_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
" ",
"receive",
" ",
"message",
" ",
"unti",
"l",
" ",
"response",
" ",
"is",
" ",
"last",
" ",
"transaction",
" ",
"id",
" ",
"or",
" ",
"receive",
"d",
" ",
"count",
"'",
"s",
" ",
"message",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"count_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"count_",
"=_",
"count_",
"-_",
"1_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"recv",
" ",
"message",
" ",
"and",
" ",
"convert",
" ",
"to",
" ",
"XML",
" ",
"object_",
"\\u\\u\\uNL\\u\\u\\u_",
"txt_",
"=_",
"self_",
"._",
"protocol_",
"._",
"recv",
"\\u",
"msg_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"res_",
"=_",
"xml_",
"._",
"dom_",
"._",
"minidom_",
"._",
"parse",
"String_",
"(_",
"txt_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"log",
" ",
"message",
"s",
" ",
"{{",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"self_",
"._",
"debug_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"str_",
"(_",
"self_",
"._",
"msgid_",
")_",
"+_",
"'",
" ",
":",
" ",
"recv",
" ",
"<=",
"====",
" ",
"{{",
"{",
" ",
" ",
" ",
"'_",
"+_",
"txt_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"'}",
"}}'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"handle",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"handle",
"\\u",
"msg_",
"(_",
"res_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"exit",
",",
" ",
"if",
" ",
"response",
"'",
"s",
" ",
"transaction",
" ",
"id",
" ",
"==",
" ",
"last",
" ",
"transaction",
" ",
"id_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"int_",
"(_",
"res_",
"._",
"first",
"Child_",
"._",
"get",
"Attribute_",
"(_",
"'",
"transaction",
"\\u",
"id",
"'_",
")_",
")_",
"==_",
"int_",
"(_",
"self_",
"._",
"msgid_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pass_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"debugg",
"er",
"\\u",
"command_",
"(_",
"msg_",
",_",
"arg1_",
"=_",
"''_",
",_",
"arg2_",
"=_",
"''_",
")_",
":_",
"\\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 ",
" _",
"debugger_",
"._",
"command_",
"(_",
"msg_",
",_",
"arg1_",
",_",
"arg2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"debugger_",
"._",
"status_",
"!=_",
"'",
"stopp",
"ed",
"'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"debugger_",
"._",
"command_",
"(_",
"'",
"stack",
"\\u",
"get",
"'_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"run_",
"(_",
")_",
":_",
"\\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 ",
" _",
"debugger_",
"._",
"run_",
"(_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"watch",
"\\u",
"input_",
"(_",
"cmd_",
",_",
"arg_",
"=_",
"''_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"arg_",
"==_",
"'<",
"cw",
"ord",
">'_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"arg_",
"=_",
"vim_",
"._",
"eval_",
"(_",
"'",
"expand",
"(\"",
"<",
"cw",
"ord",
">\"",
")'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"debugger_",
"._",
"watch",
"\\u",
"input_",
"(_",
"cmd_",
",_",
"arg_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"context_",
"(_",
")_",
":_",
"\\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 ",
" _",
"debugger_",
"._",
"command_",
"(_",
"'",
"context",
"\\u",
"get",
"'_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"property_",
"(_",
"name_",
"=_",
"''_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"debugger_",
"._",
"property",
"\\u",
"get_",
"(_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"mark_",
"(_",
"exp_",
"=_",
"''_",
")_",
":_",
"\\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 ",
" _",
"debugger_",
"._",
"mark_",
"(_",
"exp_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"up_",
"(_",
")_",
":_",
"\\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 ",
" _",
"debugger_",
"._",
"up_",
"(_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\u\\u\\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_",
"debugg",
"er",
"\\u",
"down_",
"(_",
")_",
":_",
"\\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 ",
" _",
"debugger_",
"._",
"down_",
"(_",
")_",
"\\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 ",
" _",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"ui_",
"._",
"trace",
"win_",
"._",
"write_",
"(_",
"\"\"_",
"._",
"join_",
"(_",
"traceback_",
"._",
"format\\u",
"tb_",
"(_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"[_",
"2_",
"]_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"debugger_",
"._",
"stop_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"'",
"Connect",
"ion",
" ",
"close",
"d",
",",
" ",
"stop",
" ",
"debugg",
"ing",
"'_",
",_",
"sys_",
"._",
"exc",
"\\u",
"info_",
"(_",
")_",
"\\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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,
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 | django/django/django/forms/fields.py | [
{
"content": " def to_python(self, value):\n \"\"\"\n Validates that float() can be called on the input. Returns the result\n of float(). Returns None for empty values.\n \"\"\"\n value = super(IntegerField, self).to_python(value)\n if value in self.empty_values:\n return None\n if self.localize:\n value = formats.sanitize_separators(value)\n try:\n value = float(value)\n except (ValueError, TypeError):\n raise ValidationError(self.error_messages['invalid'], code='invalid')\n return value",
"metadata": "root.FloatField.to_python",
"header": "['class', 'FloatField', '(', 'IntegerField', ')', ':', '___EOS___']",
"index": 297
}
]
| [
{
"span": "super(IntegerField, self).",
"start_line": 302,
"start_column": 16,
"end_line": 302,
"end_column": 41
}
]
| []
| 1 | true | [
"[CLS]_",
"First_",
"argument_",
"to_",
"super_",
"(_",
")_",
"is_",
"not_",
"encl",
"osin",
"g_",
"class_",
"[SEP]_",
"class_",
"Float",
"Field_",
"(_",
"Integer",
"Field_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"to",
"\\u",
"python_",
"(_",
"self_",
",_",
"value_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"\"\"\"",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"Validate",
"s",
" ",
"tha",
"t",
" ",
"float",
"()",
" ",
"can",
" ",
"be",
" ",
"call",
"ed",
" ",
"on",
" ",
"the",
" ",
"input",
".",
" ",
"Return",
"s",
" ",
"the",
" ",
"result",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"of",
" ",
"float",
"()",
".",
" ",
"Return",
"s",
" ",
"Non",
"e",
" ",
"for",
" ",
"empty",
" ",
"values",
".",
"\\",
"10",
";",
" ",
" ",
" ",
" ",
"\"\"\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"value_",
"=_",
"super_",
"(_",
"Integer",
"Field_",
",_",
"self_",
")_",
"._",
"to",
"\\u",
"python_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"value_",
"in_",
"self_",
"._",
"empty",
"\\u",
"values_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"localize_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"value_",
"=_",
"formats_",
"._",
"sanitize",
"\\u",
"separators_",
"(_",
"value_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"value_",
"=_",
"float_",
"(_",
"value_",
")_",
"\\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 ",
" _",
"raise_",
"Validat",
"ion",
"Error_",
"(_",
"self_",
"._",
"error",
"\\u",
"messages_",
"[_",
"'",
"invalid",
"'_",
"]_",
",_",
"code_",
"=_",
"'",
"invalid",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"value_",
"\\u\\u\\uNEWLINE\\u\\u\\u_"
]
| [
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | gutomaia/pyNES/pynes/tests/image_test.py | [
{
"content": " def test_export_namespace(self):\n try:\n os.remove('/tmp/level.png')\n except:\n pass\n\n self.assertFileNotExists('/tmp/level.png')\n image.export_nametable(\n 'fixtures/nerdynights/scrolling/SMBlevel.bin',\n 'fixtures/nerdynights/scrolling/mario.chr',\n '/tmp/level.png')\n self.assertFileExists('/tmp/level.png')\n\n img = Image.open('/tmp/level.png')\n sprs, indexes = image.acquire_chr(img, optimize_repeated=False)\n sprite.length(sprs)\n self.assertEquals(1024, sprite.length(sprs))\n return # TODO why?!\n nt_file = open('fixtures/nerdynights/scrolling/SMBlevel.bin')\n nt = nt_file.read()\n nt_file.close()\n nts = [ord(n) for n in nt]\n mario = sprite.load_sprites('fixtures/nerdynights/scrolling/mario.chr')\n for i in range(32):\n for j in range(32):\n self.assertSpriteEquals(\n sprite.get_sprite(nts[i * j] + 256, mario),\n sprite.get_sprite(i * j, sprs)\n )\n os.remove('/tmp/level.png')",
"metadata": "root.ImageTest.test_export_namespace",
"header": "['class', 'ImageTest', '(', 'SpriteTestCase', ')', ':', '___EOS___']",
"index": 100
},
{
"content": " def test_read_nametable(self):\n # level = Image.open('fixtures/level.png')\n sprs = sprite.load_sprites('fixtures/nerdynights/scrolling/mario.chr')\n # nt = image.read_nametable(level, sprs)\n return\n expected = open(\n 'fixtures/nerdynights/scrolling/SMBlevel.bin', 'rb').read()\n actual = open('/tmp/level.bin', 'rb').read()\n size = len(actual)\n self.assertEquals(expected[:size], actual[:size])\n return\n # sprs = image.convert_chr(img)\n self.assertEquals(8192, len(sprs))\n self.assertEquals(self.mario1, sprite.get_sprite(0, sprs))\n self.assertEquals(self.mario2, sprite.get_sprite(1, sprs))",
"metadata": "root.ImageTest.test_read_nametable",
"header": "['class', 'ImageTest', '(', 'SpriteTestCase', ')', ':', '___EOS___']",
"index": 151
},
{
"content": " def test_convert_to_nametable(self):\n return\n (nt, sprs) = image.convert_to_nametable('fixtures/level.png')\n # self.assertEquals(sprite.length(sprs), 15)",
"metadata": "root.ImageTest.test_convert_to_nametable",
"header": "['class', 'ImageTest', '(', 'SpriteTestCase', ')', ':', '___EOS___']",
"index": 177
},
{
"content": " def test_convert_to_nametable_pythonbrasil(self):\n return\n (nt, sprs) = image.convert_to_nametable('fixtures/pythonbrasil8.png')",
"metadata": "root.ImageTest.test_convert_to_nametable_pythonbrasil",
"header": "['class', 'ImageTest', '(', 'SpriteTestCase', ')', ':', '___EOS___']",
"index": 182
},
{
"content": " def test_convert_to_nametable_pythonbrasil2(self):\n return\n nt, sprs = image.convert_to_nametable('fixtures/pythonbrasil8.png')\n image.export_chr('sprite.chr', 'pythonbrasil8.png')\n image.export_nametable(\n 'nametable.bin', 'sprite.chr', 'pythonbrasil8.png')\n import os\n os.rename('nametable.bin', 'pythonbrasil8.bin')\n image.export_nametable(\n 'fixtures/nerdynights/scrolling/garoa.bin',\n 'fixtures/nerdynights/scrolling/sprite.chr',\n 'garoa.png')",
"metadata": "root.ImageTest.test_convert_to_nametable_pythonbrasil2",
"header": "['class', 'ImageTest', '(', 'SpriteTestCase', ')', ':', '___EOS___']",
"index": 186
}
]
| [
{
"span": "nt_file = open('fixtures/nerdynights/scrolling/SMBlevel.bin')",
"start_line": 118,
"start_column": 8,
"end_line": 118,
"end_column": 69
},
{
"span": "expected = open(\n 'fixtures/nerdynights/scrolling/SMBlevel.bin', 'rb').read()",
"start_line": 156,
"start_column": 8,
"end_line": 157,
"end_column": 71
},
{
"span": "(nt, sprs) = image.convert_to_nametable('fixtures/level.png')",
"start_line": 179,
"start_column": 8,
"end_line": 179,
"end_column": 69
},
{
"span": "(nt, sprs) = image.convert_to_nametable('fixtures/pythonbrasil8.png')",
"start_line": 184,
"start_column": 8,
"end_line": 184,
"end_column": 77
},
{
"span": "nt, sprs = image.convert_to_nametable('fixtures/pythonbrasil8.png')",
"start_line": 188,
"start_column": 8,
"end_line": 188,
"end_column": 75
}
]
| []
| 1 | true | [
"[CLS]_",
"Unrea",
"chab",
"le_",
"code_",
"[SEP]_",
"class_",
"Image",
"Test_",
"(_",
"Spr",
"ite",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"export",
"\\u",
"namespace_",
"(_",
"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_",
"._",
"remove_",
"(_",
"'/",
"tmp",
"/",
"level",
".",
"png",
"'_",
")_",
"\\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_",
"self_",
"._",
"assert",
"File",
"Not",
"Exists_",
"(_",
"'/",
"tmp",
"/",
"level",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"image_",
"._",
"export",
"\\u",
"name",
"table_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"SMB",
"level",
".",
"bin",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"mari",
"o",
".",
"chr",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'/",
"tmp",
"/",
"level",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"File",
"Exists_",
"(_",
"'/",
"tmp",
"/",
"level",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"img_",
"=_",
"Image_",
"._",
"open_",
"(_",
"'/",
"tmp",
"/",
"level",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"spr",
"s_",
",_",
"indexes_",
"=_",
"image_",
"._",
"acquir",
"e\\u",
"chr_",
"(_",
"img_",
",_",
"optimize",
"\\u",
"repeated_",
"=_",
"False_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"sprite_",
"._",
"length_",
"(_",
"spr",
"s_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"1024_",
",_",
"sprite_",
"._",
"length_",
"(_",
"spr",
"s_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"#",
" ",
"TOD",
"O",
" ",
"wh",
"y",
"?!",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nt",
"\\u",
"file_",
"=_",
"open_",
"(_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"SMB",
"level",
".",
"bin",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nt_",
"=_",
"nt",
"\\u",
"file_",
"._",
"read_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nt",
"\\u",
"file_",
"._",
"close_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nts_",
"=_",
"[_",
"ord_",
"(_",
"n_",
")_",
"for_",
"n_",
"in_",
"nt_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"mari",
"o_",
"=_",
"sprite_",
"._",
"load",
"\\u",
"sprites_",
"(_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"mari",
"o",
".",
"chr",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"i_",
"in_",
"range_",
"(_",
"32_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"for_",
"j_",
"in_",
"range_",
"(_",
"32_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"assert",
"Spr",
"ite",
"Equals_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"sprite_",
"._",
"get",
"\\u",
"sprite_",
"(_",
"nts_",
"[_",
"i_",
"*_",
"j_",
"]_",
"+_",
"256_",
",_",
"mari",
"o_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"sprite_",
"._",
"get",
"\\u",
"sprite_",
"(_",
"i_",
"*_",
"j_",
",_",
"spr",
"s_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"os_",
"._",
"remove_",
"(_",
"'/",
"tmp",
"/",
"level",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Image",
"Test_",
"(_",
"Spr",
"ite",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"read",
"\\u",
"name",
"table_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"level",
" ",
"=",
" ",
"Image",
".",
"open",
"('",
"fixture",
"s",
"/",
"level",
".",
"png",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"spr",
"s_",
"=_",
"sprite_",
"._",
"load",
"\\u",
"sprites_",
"(_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"mari",
"o",
".",
"chr",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"nt",
" ",
"=",
" ",
"image",
".",
"read",
"\\u",
"name",
"table",
"(",
"level",
",",
" ",
"spr",
"s",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"expected_",
"=_",
"open_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"SMB",
"level",
".",
"bin",
"'_",
",_",
"'",
"rb",
"'_",
")_",
"._",
"read_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"actual_",
"=_",
"open_",
"(_",
"'/",
"tmp",
"/",
"level",
".",
"bin",
"'_",
",_",
"'",
"rb",
"'_",
")_",
"._",
"read_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"size_",
"=_",
"len_",
"(_",
"actual_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"expected_",
"[_",
":_",
"size_",
"]_",
",_",
"actual_",
"[_",
":_",
"size_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"spr",
"s",
" ",
"=",
" ",
"image",
".",
"convert",
"\\u",
"chr",
"(",
"img",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"8192_",
",_",
"len_",
"(_",
"spr",
"s_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"self_",
"._",
"mari",
"o1_",
",_",
"sprite_",
"._",
"get",
"\\u",
"sprite_",
"(_",
"0_",
",_",
"spr",
"s_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"self_",
"._",
"mari",
"o2_",
",_",
"sprite_",
"._",
"get",
"\\u",
"sprite_",
"(_",
"1_",
",_",
"spr",
"s_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Image",
"Test_",
"(_",
"Spr",
"ite",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"convert",
"\\u",
"to",
"\\u",
"name",
"table_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"nt_",
",_",
"spr",
"s_",
")_",
"=_",
"image_",
"._",
"convert",
"\\u",
"to",
"\\u",
"name",
"table_",
"(_",
"'",
"fixture",
"s",
"/",
"level",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"self",
".",
"assert",
"Equal",
"s",
"(",
"spri",
"te",
".",
"length",
"(",
"spr",
"s",
"),",
" ",
"15",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Image",
"Test_",
"(_",
"Spr",
"ite",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"convert",
"\\u",
"to",
"\\u",
"name",
"table",
"\\u",
"python",
"bra",
"sil",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"nt_",
",_",
"spr",
"s_",
")_",
"=_",
"image_",
"._",
"convert",
"\\u",
"to",
"\\u",
"name",
"table_",
"(_",
"'",
"fixture",
"s",
"/",
"python",
"bra",
"sil",
"8",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Image",
"Test_",
"(_",
"Spr",
"ite",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"convert",
"\\u",
"to",
"\\u",
"name",
"table",
"\\u",
"python",
"bra",
"sil",
"2_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"nt_",
",_",
"spr",
"s_",
"=_",
"image_",
"._",
"convert",
"\\u",
"to",
"\\u",
"name",
"table_",
"(_",
"'",
"fixture",
"s",
"/",
"python",
"bra",
"sil",
"8",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"image_",
"._",
"export",
"\\u",
"chr_",
"(_",
"'",
"spri",
"te",
".",
"chr",
"'_",
",_",
"'",
"python",
"bra",
"sil",
"8",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"image_",
"._",
"export",
"\\u",
"name",
"table_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"name",
"table",
".",
"bin",
"'_",
",_",
"'",
"spri",
"te",
".",
"chr",
"'_",
",_",
"'",
"python",
"bra",
"sil",
"8",
".",
"png",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"os_",
"._",
"rename_",
"(_",
"'",
"name",
"table",
".",
"bin",
"'_",
",_",
"'",
"python",
"bra",
"sil",
"8",
".",
"bin",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"image_",
"._",
"export",
"\\u",
"name",
"table_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"gar",
"oa",
".",
"bin",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"fixture",
"s",
"/",
"ner",
"dyn",
"ight",
"s",
"/",
"scrolling",
"/",
"spri",
"te",
".",
"chr",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"gar",
"oa",
".",
"png",
"'_",
")_"
]
| [
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,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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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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' | bayespy/bayespy/bayespy/inference/vmp/nodes/GaussianProcesses.py | [
{
"content": "def gp_posterior_moment_function(m, k, x, y, k_sparse=None, pseudoinputs=None, noise=None):\n\n # Prior\n # FIXME: We are ignoring the covariance of mu now..\n mu = m(x)[0]\n ## if np.ndim(mu) == 1:\n ## mu = np.asmatrix(mu).T\n ## else:\n ## mu = np.asmatrix(mu)\n \n K_noise = None\n \n if noise != None:\n if K_noise is None:\n K_noise = noise\n else:\n K_noise += noise\n \n if k_sparse != None:\n if K_noise is None:\n K_noise = k_sparse(x,x)[0]\n else:\n K_noise += k_sparse(x,x)[0]\n\n if pseudoinputs != None:\n p = pseudoinputs\n #print('in pseudostuff')\n #print(K_noise)\n #print(np.shape(K_noise))\n K_pp = k(p,p)[0]\n K_xp = k(x,p)[0]\n U = utils.chol(K_noise)\n\n # Compute Lambda\n Lambda = K_pp + np.dot(K_xp.T, utils.chol_solve(U, K_xp))\n U_lambda = utils.chol(Lambda)\n\n # Compute statistics for posterior predictions\n #print(np.shape(U_lambda))\n #print(np.shape(y))\n z = utils.chol_solve(U_lambda,\n np.dot(K_xp.T,\n utils.chol_solve(U,\n y - mu)))\n U = utils.chol(K_pp)\n\n # Now we can forget the location of the observations and\n # consider only the pseudoinputs when predicting.\n x = p\n\n \n else:\n K = K_noise\n if K is None:\n K = k(x,x)[0]\n else:\n try:\n K += k(x,x)[0]\n except:\n K = K + k(x,x)[0]\n\n # Compute posterior GP\n N = len(y)\n U = None\n z = None\n if N > 0:\n U = utils.chol(K)\n z = utils.chol_solve(U, y-mu)\n\n def get_moments(h, covariance=1, mean=True):\n\n K_xh = k(x, h)[0]\n if k_sparse != None:\n try:\n # This may not work, for instance, if either one is a\n # sparse matrix.\n K_xh += k_sparse(x, h)[0]\n except:\n K_xh = K_xh + k_sparse(x, h)[0]\n \n # NumPy has problems when mixing matrices and arrays.\n # Matrices may appear, for instance, when you sum an array and\n # a sparse matrix. Make sure the result is either an array or\n # a sparse matrix (not dense matrix!), because matrix objects\n # cause lots of problems:\n #\n # array.dot(array) = array\n # matrix.dot(array) = matrix\n # sparse.dot(array) = array\n if not sp.issparse(K_xh):\n K_xh = np.asarray(K_xh)\n\n # Function for computing posterior moments\n if mean:\n # Mean vector\n # FIXME: Ignoring the covariance of prior mu\n m_h = m(h)[0]\n \n if z != None:\n m_h += K_xh.T.dot(z)\n \n else:\n m_h = None\n\n # Compute (co)variance matrix/vector\n if covariance:\n if covariance == 1:\n ## Compute variance vector\n \n k_h = k(h)[0]\n if k_sparse != None:\n k_h += k_sparse(h)[0]\n if U != None:\n if isinstance(K_xh, np.ndarray):\n k_h -= np.einsum('i...,i...',\n K_xh,\n utils.chol_solve(U, K_xh))\n else:\n # TODO: This isn't very efficient way, but\n # einsum doesn't work for sparse matrices..\n # This may consume A LOT of memory for sparse\n # matrices.\n k_h -= np.asarray(K_xh.multiply(utils.chol_solve(U, K_xh))).sum(axis=0)\n if pseudoinputs != None:\n if isinstance(K_xh, np.ndarray):\n k_h += np.einsum('i...,i...',\n K_xh,\n utils.chol_solve(U_lambda, K_xh))\n else:\n # TODO: This isn't very efficient way, but\n # einsum doesn't work for sparse matrices..\n # This may consume A LOT of memory for sparse\n # matrices.\n k_h += np.asarray(K_xh.multiply(utils.chol_solve(U_lambda, K_xh))).sum(axis=0)\n # Ensure non-negative variances \n k_h[k_h<0] = 0\n \n return (m_h, k_h)\n \n elif covariance == 2:\n ## Compute full covariance matrix\n \n K_hh = k(h,h)[0]\n if k_sparse != None:\n K_hh += k_sparse(h)[0]\n if U != None:\n K_hh -= K_xh.T.dot(utils.chol_solve(U,K_xh))\n #K_hh -= np.dot(K_xh.T, utils.chol_solve(U,K_xh))\n if pseudoinputs != None:\n K_hh += K_xh.T.dot(utils.chol_solve(U_lambda, K_xh))\n #K_hh += np.dot(K_xh.T, utils.chol_solve(U_lambda, K_xh))\n return (m_h, K_hh)\n else:\n return (m_h, None)\n\n\n return get_moments",
"metadata": "root.gp_posterior_moment_function",
"header": "['module', '___EOS___']",
"index": 37
},
{
"content": " def lower_bound_contribution(self, gradient=False):\n\n # Get moment functions from parents\n m = self.parents[0].message_to_child(gradient=gradient)\n k = self.parents[1].message_to_child(gradient=gradient)\n if self.parents[2]:\n k_sparse = self.parents[2].message_to_child(gradient=gradient)\n else:\n k_sparse = None\n if self.parents[3]:\n pseudoinputs = self.parents[3].message_to_child(gradient=gradient)\n #pseudoinputs = self.parents[3].message_to_child(gradient=gradient)[0]\n else:\n pseudoinputs = None\n ## m = self.parents[0].message_to_child(gradient=gradient)[0]\n ## k = self.parents[1].message_to_child(gradient=gradient)[0]\n\n # Compute the parameters (covariance matrices etc) using\n # parents' moment functions\n DKs_xx = []\n DKd_xx = []\n DKd_xp = []\n DKd_pp = []\n Dxp = []\n Dmu = []\n if gradient:\n # FIXME: We are ignoring the covariance of mu now..\n ((mu, _), Dmu) = m(self.x, gradient=True)\n ## if k_sparse:\n ## ((Ks_xx,), DKs_xx) = k_sparse(self.x, self.x, gradient=True)\n if pseudoinputs:\n ((Ks_xx,), DKs_xx) = k_sparse(self.x, self.x, gradient=True)\n ((xp,), Dxp) = pseudoinputs\n ((Kd_pp,), DKd_pp) = k(xp,xp, gradient=True)\n ((Kd_xp,), DKd_xp) = k(self.x, xp, gradient=True)\n else:\n ((K_xx,), DKd_xx) = k(self.x, self.x, gradient=True)\n if k_sparse:\n ((Ks_xx,), DKs_xx) = k_sparse(self.x, self.x, gradient=True)\n try:\n K_xx += Ks_xx\n except:\n K_xx = K_xx + Ks_xx\n \n else:\n # FIXME: We are ignoring the covariance of mu now..\n (mu, _) = m(self.x)\n ## if k_sparse:\n ## (Ks_xx,) = k_sparse(self.x, self.x)\n if pseudoinputs:\n (Ks_xx,) = k_sparse(self.x, self.x)\n (xp,) = pseudoinputs\n (Kd_pp,) = k(xp, xp)\n (Kd_xp,) = k(self.x, xp)\n else:\n (K_xx,) = k(self.x, self.x)\n if k_sparse:\n (Ks_xx,) = k_sparse(self.x, self.x)\n try:\n K_xx += Ks_xx\n except:\n K_xx = K_xx + Ks_xx\n\n\n mu = mu[0]\n #K = K[0]\n\n # Log pdf\n if self.observed:\n ## Log pdf for directly observed GP\n \n f0 = self.f - mu\n \n #print('hereiam')\n #print(K)\n if pseudoinputs:\n\n ## Pseudo-input approximation\n\n # Decompose the full-rank sparse/noise covariance matrix\n try:\n Us_xx = utils.cholesky(Ks_xx)\n except linalg.LinAlgError:\n print('Noise/sparse covariance not positive definite')\n return -np.inf\n\n # Use Woodbury-Sherman-Morrison formula with the\n # following notation:\n #\n # y2 = f0' * inv(Kd_xp*inv(Kd_pp)*Kd_xp' + Ks_xx) * f0\n #\n # z = Ks_xx \\ f0\n # Lambda = Kd_pp + Kd_xp'*inv(Ks_xx)*Kd_xp\n # nu = inv(Lambda) * (Kd_xp' * (Ks_xx \\ f0))\n # rho = Kd_xp * inv(Lambda) * (Kd_xp' * (Ks_xx \\ f0))\n #\n # y2 = f0' * z - z' * rho\n \n z = Us_xx.solve(f0)\n Lambda = Kd_pp + np.dot(Kd_xp.T,\n Us_xx.solve(Kd_xp))\n ## z = utils.chol_solve(Us_xx, f0)\n ## Lambda = Kd_pp + np.dot(Kd_xp.T,\n ## utils.chol_solve(Us_xx, Kd_xp))\n try:\n U_Lambda = utils.cholesky(Lambda)\n #U_Lambda = utils.chol(Lambda)\n except linalg.LinAlgError:\n print('Lambda not positive definite')\n return -np.inf\n\n nu = U_Lambda.solve(np.dot(Kd_xp.T, z))\n #nu = utils.chol_solve(U_Lambda, np.dot(Kd_xp.T, z))\n rho = np.dot(Kd_xp, nu)\n\n y2 = np.dot(f0, z) - np.dot(z, rho)\n\n # Use matrix determinant lemma\n #\n # det(Kd_xp*inv(Kd_pp)*Kd_xp' + Ks_xx)\n # = det(Kd_pp + Kd_xp'*inv(Ks_xx)*Kd_xp)\n # * det(inv(Kd_pp)) * det(Ks_xx)\n # = det(Lambda) * det(Ks_xx) / det(Kd_pp)\n try:\n Ud_pp = utils.cholesky(Kd_pp)\n #Ud_pp = utils.chol(Kd_pp)\n except linalg.LinAlgError:\n print('Covariance of pseudo inputs not positive definite')\n return -np.inf\n logdet = (U_Lambda.logdet()\n + Us_xx.logdet()\n - Ud_pp.logdet())\n ## logdet = (utils.logdet_chol(U_Lambda)\n ## + utils.logdet_chol(Us_xx)\n ## - utils.logdet_chol(Ud_pp))\n\n # Compute the log pdf\n \n L = gaussian_logpdf(y2,\n 0,\n 0,\n logdet,\n np.size(self.f))\n\n # Add the variational cost of the pseudo-input\n # approximation\n\n # Compute gradients\n\n \n \n for (dmu, func) in Dmu:\n # Derivative w.r.t. mean vector\n d = np.nan\n # Send the derivative message\n func(d)\n \n for (dKs_xx, func) in DKs_xx:\n # Compute derivative w.r.t. covariance matrix\n d = np.nan\n # Send the derivative message\n func(d)\n \n for (dKd_xp, func) in DKd_xp:\n # Compute derivative w.r.t. covariance matrix\n d = np.nan\n # Send the derivative message\n func(d)\n\n V = Ud_pp.solve(Kd_xp.T)\n Z = Us_xx.solve(V.T)\n ## V = utils.chol_solve(Ud_pp, Kd_xp.T)\n ## Z = utils.chol_solve(Us_xx, V.T)\n for (dKd_pp, func) in DKd_pp:\n # Compute derivative w.r.t. covariance matrix\n d = (0.5 * np.trace(Ud_pp.solve(dKd_pp))\n - 0.5 * np.trace(U_Lambda.solve(dKd_pp))\n + np.dot(nu, np.dot(dKd_pp, nu))\n + np.trace(np.dot(dKd_pp,\n np.dot(V,Z))))\n ## d = (0.5 * np.trace(utils.chol_solve(Ud_pp, dKd_pp))\n ## - 0.5 * np.trace(utils.chol_solve(U_Lambda, dKd_pp))\n ## + np.dot(nu, np.dot(dKd_pp, nu))\n ## + np.trace(np.dot(dKd_pp,\n ## np.dot(V,Z))))\n # Send the derivative message\n func(d)\n \n for (dxp, func) in Dxp:\n # Compute derivative w.r.t. covariance matrix\n d = np.nan\n # Send the derivative message\n func(d)\n \n \n\n else:\n \n ## Full exact (no pseudo approximations)\n \n try:\n U = utils.cholesky(K_xx)\n #U = utils.chol(K_xx)\n except linalg.LinAlgError:\n print('non positive definite, return -inf')\n return -np.inf\n z = U.solve(f0)\n #z = utils.chol_solve(U, f0)\n #print(K)\n L = utils.gaussian_logpdf(np.dot(f0, z),\n 0,\n 0,\n U.logdet(),\n ## utils.logdet_chol(U),\n np.size(self.f))\n\n for (dmu, func) in Dmu:\n # Derivative w.r.t. mean vector\n d = -np.sum(z)\n # Send the derivative message\n func(d)\n\n for (dK, func) in DKd_xx:\n # Compute derivative w.r.t. covariance matrix\n #\n # TODO: trace+chol_solve should be handled better\n # for sparse matrices. Use sparse-inverse!\n d = 0.5 * (dK.dot(z).dot(z)\n - U.trace_solve_gradient(dK))\n ## - np.trace(U.solve(dK)))\n ## d = 0.5 * (dK.dot(z).dot(z)\n ## - np.trace(utils.chol_solve(U, dK)))\n #print('derivate', d, dK)\n ## d = 0.5 * (np.dot(z, np.dot(dK, z))\n ## - np.trace(utils.chol_solve(U, dK)))\n #\n # Send the derivative message\n func(d)\n \n for (dK, func) in DKs_xx:\n # Compute derivative w.r.t. covariance matrix\n d = 0.5 * (dK.dot(z).dot(z)\n - U.trace_solve_gradient(dK))\n ## - np.trace(U.solve(dK)))\n ## d = 0.5 * (dK.dot(z).dot(z)\n ## - np.trace(utils.chol_solve(U, dK)))\n ## d = 0.5 * (np.dot(z, np.dot(dK, z))\n ## - np.trace(utils.chol_solve(U, dK)))\n # Send the derivative message\n func(d)\n\n else:\n ## Log pdf for latent GP\n raise Exception('Not implemented yet')\n\n return L\n\n ## Let f1 be observed and f2 latent function values.\n\n # Compute <log p(f1,f2|m,k)>\n \n #L = gaussian_logpdf(sum_product(np.outer(self.f,self.f) + self.Cov,\n \n\n # Compute <log q(f2)>",
"metadata": "root.GaussianProcess.lower_bound_contribution",
"header": "['class', 'GaussianProcess', '(', 'EF', '.', 'Node', ')', ':', '___EOS___']",
"index": 377
}
]
| [
{
"span": "except:",
"start_line": 95,
"start_column": 12,
"end_line": 95,
"end_column": 19
},
{
"span": "except:",
"start_line": 114,
"start_column": 12,
"end_line": 114,
"end_column": 19
},
{
"span": "except:",
"start_line": 418,
"start_column": 20,
"end_line": 418,
"end_column": 27
},
{
"span": "except:",
"start_line": 437,
"start_column": 20,
"end_line": 437,
"end_column": 27
}
]
| []
| 1 | true | [
"[CLS]_",
"Except",
"_",
"block_",
"handles_",
"'",
"Base",
"Except",
"ion",
"'_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"gp",
"\\u",
"posterior",
"\\u",
"moment",
"\\u",
"function_",
"(_",
"m_",
",_",
"k_",
",_",
"x_",
",_",
"y_",
",_",
"k",
"\\u",
"sparse_",
"=_",
"None_",
",_",
"pseudo",
"inputs_",
"=_",
"None_",
",_",
"noise_",
"=_",
"None_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Prior",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"FIX",
"ME",
":",
" ",
"We",
" ",
"are",
" ",
"ign",
"orin",
"g",
" ",
"the",
" ",
"covariance",
" ",
"of",
" ",
"mu",
" ",
"now",
"..",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"mu_",
"=_",
"m_",
"(_",
"x_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"if",
" ",
"np",
".",
"ndim",
"(",
"mu",
")",
" ",
"==",
" ",
"1",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"mu",
" ",
"=",
" ",
"np",
".",
"asm",
"atrix",
"(",
"mu",
").",
"T_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"else",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"mu",
" ",
"=",
" ",
"np",
".",
"asm",
"atrix",
"(",
"mu",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"K",
"\\u",
"noise_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"noise_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"K",
"\\u",
"noise_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"noise_",
"=_",
"noise_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"noise_",
"+=_",
"noise_",
"\\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_",
"k",
"\\u",
"sparse_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"K",
"\\u",
"noise_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"noise_",
"=_",
"k",
"\\u",
"sparse_",
"(_",
"x_",
",_",
"x_",
")_",
"[_",
"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 ",
" _",
"K",
"\\u",
"noise_",
"+=_",
"k",
"\\u",
"sparse_",
"(_",
"x_",
",_",
"x_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"pseudo",
"inputs_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"p_",
"=_",
"pseudo",
"inputs_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"print",
"('",
"in",
" ",
"pseudo",
"stu",
"ff",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"(",
"K",
"\\u",
"noise",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"(",
"np",
".",
"shape",
"(",
"K",
"\\u",
"noise",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"K",
"\\u",
"pp_",
"=_",
"k_",
"(_",
"p_",
",_",
"p_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"K",
"\\u",
"xp_",
"=_",
"k_",
"(_",
"x_",
",_",
"p_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"U_",
"=_",
"utils_",
"._",
"chol",
"_",
"(_",
"K",
"\\u",
"noise_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"Lambda_",
"\\u\\u\\uNL\\u\\u\\u_",
"Lambda_",
"=_",
"K",
"\\u",
"pp_",
"+_",
"np_",
"._",
"dot_",
"(_",
"K",
"\\u",
"xp_",
"._",
"T_",
",_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U_",
",_",
"K",
"\\u",
"xp_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"U",
"\\u",
"lambda_",
"=_",
"utils_",
"._",
"chol",
"_",
"(_",
"Lambda_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"statistic",
"s",
" ",
"for",
" ",
"posterior",
" ",
"predictions_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"(",
"np",
".",
"shape",
"(",
"U",
"\\u",
"lambda",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"(",
"np",
".",
"shape",
"(",
"y",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"z_",
"=_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U",
"\\u",
"lambda_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"np_",
"._",
"dot_",
"(_",
"K",
"\\u",
"xp_",
"._",
"T_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"y_",
"-_",
"mu_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"U_",
"=_",
"utils_",
"._",
"chol",
"_",
"(_",
"K",
"\\u",
"pp_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"No",
"w",
" ",
"we",
" ",
"can",
" ",
"forget",
" ",
"the",
" ",
"location",
" ",
"of",
" ",
"the",
" ",
"observa",
"tion",
"s",
" ",
"and_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"consider",
" ",
"only",
" ",
"the",
" ",
"pseudo",
"inputs",
" ",
"whe",
"n",
" ",
"predicti",
"ng",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"x_",
"=_",
"p_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K_",
"=_",
"K",
"\\u",
"noise_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"K_",
"is_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K_",
"=_",
"k_",
"(_",
"x_",
",_",
"x_",
")_",
"[_",
"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 ",
" _",
"K_",
"+=_",
"k_",
"(_",
"x_",
",_",
"x_",
")_",
"[_",
"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 ",
" _",
"K_",
"=_",
"K_",
"+_",
"k_",
"(_",
"x_",
",_",
"x_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"posterior",
" ",
"GP",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"N_",
"=_",
"len_",
"(_",
"y_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"U_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"z_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"N_",
">_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"U_",
"=_",
"utils_",
"._",
"chol",
"_",
"(_",
"K_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"z_",
"=_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U_",
",_",
"y_",
"-_",
"mu_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"get",
"\\u",
"moments_",
"(_",
"h_",
",_",
"covariance_",
"=_",
"1_",
",_",
"mean_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"xh",
"_",
"=_",
"k_",
"(_",
"x_",
",_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"k",
"\\u",
"sparse_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"may",
" ",
"not",
" ",
"work",
",",
" ",
"for",
" ",
"instance",
",",
" ",
"if",
" ",
"eit",
"her",
" ",
"one",
" ",
"is",
" ",
"a_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"spars",
"e",
" ",
"matrix",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"xh",
"_",
"+=_",
"k",
"\\u",
"sparse_",
"(_",
"x_",
",_",
"h_",
")_",
"[_",
"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 ",
" _",
"K",
"\\u",
"xh",
"_",
"=_",
"K",
"\\u",
"xh",
"_",
"+_",
"k",
"\\u",
"sparse_",
"(_",
"x_",
",_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Num",
"Py",
" ",
"has",
" ",
"problem",
"s",
" ",
"whe",
"n",
" ",
"mixing",
" ",
"matric",
"es",
" ",
"and",
" ",
"arrays",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Matr",
"ices",
" ",
"may",
" ",
"appear",
",",
" ",
"for",
" ",
"instance",
",",
" ",
"whe",
"n",
" ",
"you",
" ",
"sum",
" ",
"an",
" ",
"array",
" ",
"and_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"a",
" ",
"spars",
"e",
" ",
"matrix",
".",
" ",
" ",
"Make",
" ",
"sure",
" ",
"the",
" ",
"result",
" ",
"is",
" ",
"eit",
"her",
" ",
"an",
" ",
"array",
" ",
"or_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"a",
" ",
"spars",
"e",
" ",
"matrix",
" ",
"(",
"not",
" ",
"dens",
"e",
" ",
"matrix",
"!)",
",",
" ",
"bec",
"aus",
"e",
" ",
"matrix",
" ",
"objects_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"caus",
"e",
" ",
"lots",
" ",
"of",
" ",
"problem",
"s",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"array",
".",
"dot",
"(",
"array",
")",
" ",
"=",
" ",
"array_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"matrix",
".",
"dot",
"(",
"array",
")",
" ",
"=",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"spars",
"e",
".",
"dot",
"(",
"array",
")",
" ",
"=",
" ",
"array_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"not_",
"sp_",
"._",
"iss",
"parse_",
"(_",
"K",
"\\u",
"xh",
"_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"xh",
"_",
"=_",
"np_",
"._",
"asarray_",
"(_",
"K",
"\\u",
"xh",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Function",
" ",
"for",
" ",
"compu",
"ting",
" ",
"posterior",
" ",
"moments_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"mean_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Mea",
"n",
" ",
"vector_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"FIX",
"ME",
":",
" ",
"Ignor",
"ing",
" ",
"the",
" ",
"covariance",
" ",
"of",
" ",
"prior",
" ",
"mu_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"m",
"\\u",
"h_",
"=_",
"m_",
"(_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"z_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"m",
"\\u",
"h_",
"+=_",
"K",
"\\u",
"xh",
"_",
"._",
"T_",
"._",
"dot_",
"(_",
"z_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"m",
"\\u",
"h_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"(",
"co",
")",
"varian",
"ce",
" ",
"matrix",
"/",
"vector_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"covariance_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"covariance_",
"==_",
"1_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"Compute",
" ",
"varian",
"ce",
" ",
"vector_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"k",
"\\u",
"h_",
"=_",
"k_",
"(_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"k",
"\\u",
"sparse_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"k",
"\\u",
"h_",
"+=_",
"k",
"\\u",
"sparse_",
"(_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"U_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"if_",
"isinstance_",
"(_",
"K",
"\\u",
"xh",
"_",
",_",
"np_",
"._",
"ndarray_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"k",
"\\u",
"h_",
"-=_",
"np_",
"._",
"einsum_",
"(_",
"'",
"i",
"...",
",",
"i",
"...'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"K",
"\\u",
"xh",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U_",
",_",
"K",
"\\u",
"xh",
"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"Thi",
"s",
" ",
"isn",
"'",
"t",
" ",
"very",
" ",
"efficien",
"t",
" ",
"way",
",",
" ",
"but",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"ein",
"sum",
" ",
"doe",
"sn",
"'",
"t",
" ",
"work",
" ",
"for",
" ",
"spars",
"e",
" ",
"matric",
"es",
"..",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"may",
" ",
"consume",
" ",
"A",
" ",
"LOT",
" ",
"of",
" ",
"memory",
" ",
"for",
" ",
"sparse_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"matric",
"es",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"k",
"\\u",
"h_",
"-=_",
"np_",
"._",
"asarray_",
"(_",
"K",
"\\u",
"xh",
"_",
"._",
"multiply_",
"(_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U_",
",_",
"K",
"\\u",
"xh",
"_",
")_",
")_",
")_",
"._",
"sum_",
"(_",
"axis_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"pseudo",
"inputs_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"if_",
"isinstance_",
"(_",
"K",
"\\u",
"xh",
"_",
",_",
"np_",
"._",
"ndarray_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"k",
"\\u",
"h_",
"+=_",
"np_",
"._",
"einsum_",
"(_",
"'",
"i",
"...",
",",
"i",
"...'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"K",
"\\u",
"xh",
"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U",
"\\u",
"lambda_",
",_",
"K",
"\\u",
"xh",
"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"Thi",
"s",
" ",
"isn",
"'",
"t",
" ",
"very",
" ",
"efficien",
"t",
" ",
"way",
",",
" ",
"but",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"ein",
"sum",
" ",
"doe",
"sn",
"'",
"t",
" ",
"work",
" ",
"for",
" ",
"spars",
"e",
" ",
"matric",
"es",
"..",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Thi",
"s",
" ",
"may",
" ",
"consume",
" ",
"A",
" ",
"LOT",
" ",
"of",
" ",
"memory",
" ",
"for",
" ",
"sparse_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"matric",
"es",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"k",
"\\u",
"h_",
"+=_",
"np_",
"._",
"asarray_",
"(_",
"K",
"\\u",
"xh",
"_",
"._",
"multiply_",
"(_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U",
"\\u",
"lambda_",
",_",
"K",
"\\u",
"xh",
"_",
")_",
")_",
")_",
"._",
"sum_",
"(_",
"axis_",
"=_",
"0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Ensur",
"e",
" ",
"non",
"-",
"negati",
"ve",
" ",
"varian",
"ces",
" _",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"k",
"\\u",
"h_",
"[_",
"k",
"\\u",
"h_",
"<_",
"0_",
"]_",
"=_",
"0_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"return_",
"(_",
"m",
"\\u",
"h_",
",_",
"k",
"\\u",
"h_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"covariance_",
"==_",
"2_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"Compute",
" ",
"full",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"K",
"\\u",
"hh_",
"=_",
"k_",
"(_",
"h_",
",_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"k",
"\\u",
"sparse_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"K",
"\\u",
"hh_",
"+=_",
"k",
"\\u",
"sparse_",
"(_",
"h_",
")_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"U_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"K",
"\\u",
"hh_",
"-=_",
"K",
"\\u",
"xh",
"_",
"._",
"T_",
"._",
"dot_",
"(_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U_",
",_",
"K",
"\\u",
"xh",
"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"K",
"\\u",
"hh",
" ",
"-=",
" ",
"np",
".",
"dot",
"(",
"K",
"\\u",
"xh",
".",
"T",
",",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
",",
"K",
"\\u",
"xh",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"pseudo",
"inputs_",
"!=_",
"None_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"K",
"\\u",
"hh_",
"+=_",
"K",
"\\u",
"xh",
"_",
"._",
"T_",
"._",
"dot_",
"(_",
"utils_",
"._",
"chol",
"\\u",
"solve_",
"(_",
"U",
"\\u",
"lambda_",
",_",
"K",
"\\u",
"xh",
"_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"K",
"\\u",
"hh",
" ",
"+=",
" ",
"np",
".",
"dot",
"(",
"K",
"\\u",
"xh",
".",
"T",
",",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
"\\u",
"lambda",
",",
" ",
"K",
"\\u",
"xh",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"(_",
"m",
"\\u",
"h_",
",_",
"K",
"\\u",
"hh_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"(_",
"m",
"\\u",
"h_",
",_",
"None_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"get",
"\\u",
"moments_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Gaussian",
"Process_",
"(_",
"EF",
"_",
"._",
"Node_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"lower",
"\\u",
"bound",
"\\u",
"contribution",
"_",
"(_",
"self_",
",_",
"gradient_",
"=_",
"False_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Get",
" ",
"moment",
" ",
"function",
"s",
" ",
"from",
" ",
"parents_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"m_",
"=_",
"self_",
"._",
"parents_",
"[_",
"0_",
"]_",
"._",
"message",
"\\u",
"to",
"\\u",
"child_",
"(_",
"gradient_",
"=_",
"gradient_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"k_",
"=_",
"self_",
"._",
"parents_",
"[_",
"1_",
"]_",
"._",
"message",
"\\u",
"to",
"\\u",
"child_",
"(_",
"gradient_",
"=_",
"gradient_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"self_",
"._",
"parents_",
"[_",
"2_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"k",
"\\u",
"sparse_",
"=_",
"self_",
"._",
"parents_",
"[_",
"2_",
"]_",
"._",
"message",
"\\u",
"to",
"\\u",
"child_",
"(_",
"gradient_",
"=_",
"gradient_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"k",
"\\u",
"sparse_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"self_",
"._",
"parents_",
"[_",
"3_",
"]_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"pseudo",
"inputs_",
"=_",
"self_",
"._",
"parents_",
"[_",
"3_",
"]_",
"._",
"message",
"\\u",
"to",
"\\u",
"child_",
"(_",
"gradient_",
"=_",
"gradient_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"pseudo",
"inputs",
" ",
"=",
" ",
"self",
".",
"parents",
"[",
"3",
"].",
"message",
"\\u",
"to",
"\\u",
"child",
"(",
"gradi",
"ent",
"=",
"gradi",
"ent",
")[",
"0",
"]_",
"\\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 ",
" _",
"pseudo",
"inputs_",
"=_",
"None_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"m",
" ",
"=",
" ",
"self",
".",
"parents",
"[",
"0",
"].",
"message",
"\\u",
"to",
"\\u",
"child",
"(",
"gradi",
"ent",
"=",
"gradi",
"ent",
")[",
"0",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"k",
" ",
"=",
" ",
"self",
".",
"parents",
"[",
"1",
"].",
"message",
"\\u",
"to",
"\\u",
"child",
"(",
"gradi",
"ent",
"=",
"gradi",
"ent",
")[",
"0",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"the",
" ",
"parameter",
"s",
" ",
"(",
"covariance",
" ",
"matric",
"es",
" ",
"etc",
")",
" ",
"using_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"parents",
"'",
" ",
"moment",
" ",
"functions_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"DK",
"s",
"\\u",
"xx_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DK",
"d\\u",
"xx_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DK",
"d\\u",
"xp_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"DK",
"d\\u",
"pp_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Dx",
"p_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Dm",
"u_",
"=_",
"[_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"gradient_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"FIX",
"ME",
":",
" ",
"We",
" ",
"are",
" ",
"ign",
"orin",
"g",
" ",
"the",
" ",
"covariance",
" ",
"of",
" ",
"mu",
" ",
"now",
"..",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"(_",
"(_",
"mu_",
",_",
"\\u_",
")_",
",_",
"Dm",
"u_",
")_",
"=_",
"m_",
"(_",
"self_",
"._",
"x_",
",_",
"gradient_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"if",
" ",
"k",
"\\u",
"spars",
"e",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"((",
"Ks",
"\\u",
"xx",
",)",
",",
" ",
"DK",
"s",
"\\u",
"xx",
")",
" ",
"=",
" ",
"k",
"\\u",
"spars",
"e",
"(",
"self",
".",
"x",
",",
" ",
"self",
".",
"x",
",",
" ",
"gradi",
"ent",
"=",
"Tru",
"e",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"pseudo",
"inputs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"(_",
"(_",
"Ks",
"\\u",
"xx_",
",_",
")_",
",_",
"DK",
"s",
"\\u",
"xx_",
")_",
"=_",
"k",
"\\u",
"sparse_",
"(_",
"self_",
"._",
"x_",
",_",
"self_",
"._",
"x_",
",_",
"gradient_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"(_",
"xp_",
",_",
")_",
",_",
"Dx",
"p_",
")_",
"=_",
"pseudo",
"inputs_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"(_",
"Kd",
"\\u",
"pp_",
",_",
")_",
",_",
"DK",
"d\\u",
"pp_",
")_",
"=_",
"k_",
"(_",
"xp_",
",_",
"xp_",
",_",
"gradient_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"(_",
"Kd",
"\\u",
"xp_",
",_",
")_",
",_",
"DK",
"d\\u",
"xp_",
")_",
"=_",
"k_",
"(_",
"self_",
"._",
"x_",
",_",
"xp_",
",_",
"gradient_",
"=_",
"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 ",
" _",
"(_",
"(_",
"K",
"\\u",
"xx_",
",_",
")_",
",_",
"DK",
"d\\u",
"xx_",
")_",
"=_",
"k_",
"(_",
"self_",
"._",
"x_",
",_",
"self_",
"._",
"x_",
",_",
"gradient_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"k",
"\\u",
"sparse_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"(_",
"(_",
"Ks",
"\\u",
"xx_",
",_",
")_",
",_",
"DK",
"s",
"\\u",
"xx_",
")_",
"=_",
"k",
"\\u",
"sparse_",
"(_",
"self_",
"._",
"x_",
",_",
"self_",
"._",
"x_",
",_",
"gradient_",
"=_",
"True_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"K",
"\\u",
"xx_",
"+=_",
"Ks",
"\\u",
"xx_",
"\\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 ",
" ",
" _",
"K",
"\\u",
"xx_",
"=_",
"K",
"\\u",
"xx_",
"+_",
"Ks",
"\\u",
"xx_",
"\\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_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"FIX",
"ME",
":",
" ",
"We",
" ",
"are",
" ",
"ign",
"orin",
"g",
" ",
"the",
" ",
"covariance",
" ",
"of",
" ",
"mu",
" ",
"now",
"..",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"(_",
"mu_",
",_",
"\\u_",
")_",
"=_",
"m_",
"(_",
"self_",
"._",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"if",
" ",
"k",
"\\u",
"spars",
"e",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"(",
"Ks",
"\\u",
"xx",
",)",
" ",
"=",
" ",
"k",
"\\u",
"spars",
"e",
"(",
"self",
".",
"x",
",",
" ",
"self",
".",
"x",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"pseudo",
"inputs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"(_",
"Ks",
"\\u",
"xx_",
",_",
")_",
"=_",
"k",
"\\u",
"sparse_",
"(_",
"self_",
"._",
"x_",
",_",
"self_",
"._",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"xp_",
",_",
")_",
"=_",
"pseudo",
"inputs_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"Kd",
"\\u",
"pp_",
",_",
")_",
"=_",
"k_",
"(_",
"xp_",
",_",
"xp_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"(_",
"Kd",
"\\u",
"xp_",
",_",
")_",
"=_",
"k_",
"(_",
"self_",
"._",
"x_",
",_",
"xp_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"(_",
"K",
"\\u",
"xx_",
",_",
")_",
"=_",
"k_",
"(_",
"self_",
"._",
"x_",
",_",
"self_",
"._",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"k",
"\\u",
"sparse_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"(_",
"Ks",
"\\u",
"xx_",
",_",
")_",
"=_",
"k",
"\\u",
"sparse_",
"(_",
"self_",
"._",
"x_",
",_",
"self_",
"._",
"x_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
" _",
"K",
"\\u",
"xx_",
"+=_",
"Ks",
"\\u",
"xx_",
"\\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 ",
" ",
" _",
"K",
"\\u",
"xx_",
"=_",
"K",
"\\u",
"xx_",
"+_",
"Ks",
"\\u",
"xx_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"mu_",
"=_",
"mu_",
"[_",
"0_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"K",
" ",
"=",
" ",
"K",
"[",
"0",
"]_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Log",
" ",
"pdf_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"self_",
"._",
"observed_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"Log",
" ",
"pdf",
" ",
"for",
" ",
"direct",
"ly",
" ",
"observe",
"d",
" ",
"GP",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"f0_",
"=_",
"self_",
"._",
"f_",
"-_",
"mu_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"('",
"here",
"iam",
"')",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"(",
"K",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"pseudo",
"inputs_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"Pse",
"udo",
"-",
"input",
" ",
"approx",
"imat",
"ion_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Decomp",
"ose",
" ",
"the",
" ",
"full",
"-",
"rank",
" ",
"spars",
"e",
"/",
"noise",
" ",
"covariance",
" ",
"matrix_",
"\\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 ",
" ",
"_",
"Us",
"\\u",
"xx_",
"=_",
"utils_",
"._",
"choles",
"ky_",
"(_",
"Ks",
"\\u",
"xx_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"linalg_",
"._",
"Lin",
"Alg",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"print_",
"(_",
"'",
"No",
"ise",
"/",
"spars",
"e",
" ",
"covariance",
" ",
"not",
" ",
"posit",
"ive",
" ",
"definit",
"e",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"-_",
"np_",
"._",
"inf_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Us",
"e",
" ",
"Wood",
"bur",
"y",
"-",
"She",
"rman",
"-",
"Mor",
"ris",
"on",
" ",
"formula",
" ",
"with",
" ",
"the_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"follow",
"ing",
" ",
"notation",
":_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"y2",
" ",
"=",
" ",
"f0",
"'",
" ",
"*",
" ",
"inv",
"(",
"Kd",
"\\u",
"xp",
"*",
"inv",
"(",
"Kd",
"\\u",
"pp",
")*",
"Kd",
"\\u",
"xp",
"'",
" ",
"+",
" ",
"Ks",
"\\u",
"xx",
")",
" ",
"*",
" ",
"f0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"z",
" ",
"=",
" ",
"Ks",
"\\u",
"xx",
" ",
"\\\\",
" ",
"f0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Lam",
"bda",
" ",
"=",
" ",
"Kd",
"\\u",
"pp",
" ",
"+",
" ",
"Kd",
"\\u",
"xp",
"'*",
"inv",
"(",
"Ks",
"\\u",
"xx",
")*",
"Kd",
"\\u",
"xp_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"nu",
" ",
"=",
" ",
"inv",
"(",
"Lam",
"bda",
")",
" ",
"*",
" ",
"(",
"Kd",
"\\u",
"xp",
"'",
" ",
"*",
" ",
"(",
"Ks",
"\\u",
"xx",
" ",
"\\\\",
" ",
"f0",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"rho",
" ",
"=",
" ",
"Kd",
"\\u",
"xp",
" ",
"*",
" ",
"inv",
"(",
"Lam",
"bda",
")",
" ",
"*",
" ",
"(",
"Kd",
"\\u",
"xp",
"'",
" ",
"*",
" ",
"(",
"Ks",
"\\u",
"xx",
" ",
"\\\\",
" ",
"f0",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"y2",
" ",
"=",
" ",
"f0",
"'",
" ",
"*",
" ",
"z",
" ",
"-",
" ",
"z",
"'",
" ",
"*",
" ",
"rho_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"z_",
"=_",
"Us",
"\\u",
"xx_",
"._",
"solve_",
"(_",
"f0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Lambda_",
"=_",
"Kd",
"\\u",
"pp_",
"+_",
"np_",
"._",
"dot_",
"(_",
"Kd",
"\\u",
"xp_",
"._",
"T_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"Us",
"\\u",
"xx_",
"._",
"solve_",
"(_",
"Kd",
"\\u",
"xp_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"z",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"Us",
"\\u",
"xx",
",",
" ",
"f0",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"Lam",
"bda",
" ",
"=",
" ",
"Kd",
"\\u",
"pp",
" ",
"+",
" ",
"np",
".",
"dot",
"(",
"Kd",
"\\u",
"xp",
".",
"T",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"Us",
"\\u",
"xx",
",",
" ",
"Kd",
"\\u",
"xp",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"U",
"\\u",
"Lambda_",
"=_",
"utils_",
"._",
"choles",
"ky_",
"(_",
"Lambda_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"U",
"\\u",
"Lam",
"bda",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"(",
"Lam",
"bda",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"linalg_",
"._",
"Lin",
"Alg",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"print_",
"(_",
"'",
"Lam",
"bda",
" ",
"not",
" ",
"posit",
"ive",
" ",
"definit",
"e",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"-_",
"np_",
"._",
"inf_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"nu_",
"=_",
"U",
"\\u",
"Lambda_",
"._",
"solve_",
"(_",
"np_",
"._",
"dot_",
"(_",
"Kd",
"\\u",
"xp_",
"._",
"T_",
",_",
"z_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"nu",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
"\\u",
"Lam",
"bda",
",",
" ",
"np",
".",
"dot",
"(",
"Kd",
"\\u",
"xp",
".",
"T",
",",
" ",
"z",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"rho_",
"=_",
"np_",
"._",
"dot_",
"(_",
"Kd",
"\\u",
"xp_",
",_",
"nu_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"y2_",
"=_",
"np_",
"._",
"dot_",
"(_",
"f0_",
",_",
"z_",
")_",
"-_",
"np_",
"._",
"dot_",
"(_",
"z_",
",_",
"rho_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Us",
"e",
" ",
"matrix",
" ",
"determina",
"nt",
" ",
"lemma_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"det",
"(",
"Kd",
"\\u",
"xp",
"*",
"inv",
"(",
"Kd",
"\\u",
"pp",
")*",
"Kd",
"\\u",
"xp",
"'",
" ",
"+",
" ",
"Ks",
"\\u",
"xx",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=",
" ",
"det",
"(",
"Kd",
"\\u",
"pp",
" ",
"+",
" ",
"Kd",
"\\u",
"xp",
"'*",
"inv",
"(",
"Ks",
"\\u",
"xx",
")*",
"Kd",
"\\u",
"xp",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
" ",
" ",
"*",
" ",
"det",
"(",
"inv",
"(",
"Kd",
"\\u",
"pp",
"))",
" ",
"*",
" ",
"det",
"(",
"Ks",
"\\u",
"xx",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"=",
" ",
"det",
"(",
"Lam",
"bda",
")",
" ",
"*",
" ",
"det",
"(",
"Ks",
"\\u",
"xx",
")",
" ",
"/",
" ",
"det",
"(",
"Kd",
"\\u",
"pp",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"Ud",
"\\u",
"pp_",
"=_",
"utils_",
"._",
"choles",
"ky_",
"(_",
"Kd",
"\\u",
"pp_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"Ud",
"\\u",
"pp",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"(",
"Kd",
"\\u",
"pp",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"linalg_",
"._",
"Lin",
"Alg",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"print_",
"(_",
"'",
"Covar",
"iance",
" ",
"of",
" ",
"pseudo",
" ",
"inputs",
" ",
"not",
" ",
"posit",
"ive",
" ",
"definit",
"e",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"-_",
"np_",
"._",
"inf_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"logd",
"et_",
"=_",
"(_",
"U",
"\\u",
"Lambda_",
"._",
"logd",
"et_",
"(_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"+_",
"Us",
"\\u",
"xx_",
"._",
"logd",
"et_",
"(_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"-_",
"Ud",
"\\u",
"pp_",
"._",
"logd",
"et_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"logd",
"et",
" ",
"=",
" ",
"(",
"util",
"s",
".",
"logd",
"et",
"\\u",
"chol",
"(",
"U",
"\\u",
"Lam",
"bda",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
"+",
" ",
"util",
"s",
".",
"logd",
"et",
"\\u",
"chol",
"(",
"Us",
"\\u",
"xx",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
"-",
" ",
"util",
"s",
".",
"logd",
"et",
"\\u",
"chol",
"(",
"Ud",
"\\u",
"pp",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"the",
" ",
"log",
" ",
"pdf_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"L_",
"=_",
"gauss",
"ian",
"\\u",
"logp",
"df_",
"(_",
"y2_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"logd",
"et_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"np_",
"._",
"size_",
"(_",
"self_",
"._",
"f_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Add",
" ",
"the",
" ",
"variatio",
"nal",
" ",
"cost",
" ",
"of",
" ",
"the",
" ",
"pseudo",
"-",
"input_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"approx",
"imat",
"ion_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"gradients_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"(_",
"dm",
"u_",
",_",
"func_",
")_",
"in_",
"Dm",
"u_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Derivati",
"ve",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"mean",
" ",
"vector_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"np_",
"._",
"nan_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"(_",
"d",
"Ks",
"\\u",
"xx_",
",_",
"func_",
")_",
"in_",
"DK",
"s",
"\\u",
"xx_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"deriv",
"ative",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"np_",
"._",
"nan_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"(_",
"d",
"Kd",
"\\u",
"xp_",
",_",
"func_",
")_",
"in_",
"DK",
"d\\u",
"xp_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"deriv",
"ative",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"np_",
"._",
"nan_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"V_",
"=_",
"Ud",
"\\u",
"pp_",
"._",
"solve_",
"(_",
"Kd",
"\\u",
"xp_",
"._",
"T_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"Z_",
"=_",
"Us",
"\\u",
"xx_",
"._",
"solve_",
"(_",
"V_",
"._",
"T_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"V",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"Ud",
"\\u",
"pp",
",",
" ",
"Kd",
"\\u",
"xp",
".",
"T",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"Z",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"Us",
"\\u",
"xx",
",",
" ",
"V",
".",
"T",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"(_",
"d",
"Kd",
"\\u",
"pp_",
",_",
"func_",
")_",
"in_",
"DK",
"d\\u",
"pp_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"deriv",
"ative",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"(_",
"0.5_",
"*_",
"np_",
"._",
"trace_",
"(_",
"Ud",
"\\u",
"pp_",
"._",
"solve_",
"(_",
"d",
"Kd",
"\\u",
"pp_",
")_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"-_",
"0.5_",
"*_",
"np_",
"._",
"trace_",
"(_",
"U",
"\\u",
"Lambda_",
"._",
"solve_",
"(_",
"d",
"Kd",
"\\u",
"pp_",
")_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"+_",
"np_",
"._",
"dot_",
"(_",
"nu_",
",_",
"np_",
"._",
"dot_",
"(_",
"d",
"Kd",
"\\u",
"pp_",
",_",
"nu_",
")_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"+_",
"np_",
"._",
"trace_",
"(_",
"np_",
"._",
"dot_",
"(_",
"d",
"Kd",
"\\u",
"pp_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"np_",
"._",
"dot_",
"(_",
"V_",
",_",
"Z_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"d",
" ",
"=",
" ",
"(",
"0.",
"5",
" ",
"*",
" ",
"np",
".",
"trace",
"(",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"Ud",
"\\u",
"pp",
",",
" ",
"d",
"Kd",
"\\u",
"pp",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
"-",
" ",
"0.",
"5",
" ",
"*",
" ",
"np",
".",
"trace",
"(",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
"\\u",
"Lam",
"bda",
",",
" ",
"d",
"Kd",
"\\u",
"pp",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
"+",
" ",
"np",
".",
"dot",
"(",
"nu",
",",
" ",
"np",
".",
"dot",
"(",
"d",
"Kd",
"\\u",
"pp",
",",
" ",
"nu",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
"+",
" ",
"np",
".",
"trace",
"(",
"np",
".",
"dot",
"(",
"d",
"Kd",
"\\u",
"pp",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
" ",
" ",
"np",
".",
"dot",
"(",
"V",
",",
"Z",
"))))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"(_",
"dxp",
"_",
",_",
"func_",
")_",
"in_",
"Dx",
"p_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"deriv",
"ative",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"np_",
"._",
"nan_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\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_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"Full",
" ",
"exact",
" ",
"(",
"no",
" ",
"pseudo",
" ",
"approx",
"imat",
"ion",
"s",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"try_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"U_",
"=_",
"utils_",
"._",
"choles",
"ky_",
"(_",
"K",
"\\u",
"xx_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"U",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"(",
"K",
"\\u",
"xx",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"except_",
"linalg_",
"._",
"Lin",
"Alg",
"Error_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"print_",
"(_",
"'",
"non",
" ",
"posit",
"ive",
" ",
"definit",
"e",
",",
" ",
"return",
" ",
"-",
"inf",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"-_",
"np_",
"._",
"inf_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"z_",
"=_",
"U_",
"._",
"solve_",
"(_",
"f0_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
"z",
" ",
"=",
" ",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
",",
" ",
"f0",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"(",
"K",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"L_",
"=_",
"utils_",
"._",
"gauss",
"ian",
"\\u",
"logp",
"df_",
"(_",
"np_",
"._",
"dot_",
"(_",
"f0_",
",_",
"z_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"0_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"U_",
"._",
"logd",
"et_",
"(_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"util",
"s",
".",
"logd",
"et",
"\\u",
"chol",
"(",
"U",
"),",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"np_",
"._",
"size_",
"(_",
"self_",
"._",
"f_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"(_",
"dm",
"u_",
",_",
"func_",
")_",
"in_",
"Dm",
"u_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Derivati",
"ve",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"mean",
" ",
"vector_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"-_",
"np_",
"._",
"sum_",
"(_",
"z_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"(_",
"d",
"K_",
",_",
"func_",
")_",
"in_",
"DK",
"d\\u",
"xx_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"deriv",
"ative",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"TOD",
"O",
":",
" ",
"trace",
"+",
"chol",
"\\u",
"solve",
" ",
"shou",
"ld",
" ",
"be",
" ",
"handle",
"d",
" ",
"bett",
"er_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"for",
" ",
"spars",
"e",
" ",
"matric",
"es",
".",
" ",
" ",
"Us",
"e",
" ",
"spars",
"e-",
"inv",
"erse",
"!",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"0.5_",
"*_",
"(_",
"d",
"K_",
"._",
"dot_",
"(_",
"z_",
")_",
"._",
"dot_",
"(_",
"z_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"-_",
"U_",
"._",
"trace",
"\\u",
"solve",
"\\u",
"gradient_",
"(_",
"d",
"K_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"-",
" ",
"np",
".",
"trace",
"(",
"U",
".",
"solve",
"(",
"d",
"K",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"d",
" ",
"=",
" ",
"0.",
"5",
" ",
"*",
" ",
"(",
"d",
"K",
".",
"dot",
"(",
"z",
").",
"dot",
"(",
"z",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
" ",
"-",
" ",
"np",
".",
"trace",
"(",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
",",
" ",
"d",
"K",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"print",
"('",
"deriv",
"ate",
"',",
" ",
"d",
",",
" ",
"d",
"K",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"d",
" ",
"=",
" ",
"0.",
"5",
" ",
"*",
" ",
"(",
"np",
".",
"dot",
"(",
"z",
",",
" ",
"np",
".",
"dot",
"(",
"d",
"K",
",",
" ",
"z",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
" ",
"-",
" ",
"np",
".",
"trace",
"(",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
",",
" ",
"d",
"K",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"for_",
"(_",
"d",
"K_",
",_",
"func_",
")_",
"in_",
"DK",
"s",
"\\u",
"xx_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"deriv",
"ative",
" ",
"w",
".",
"r",
".",
"t",
".",
" ",
"covariance",
" ",
"matrix_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"d_",
"=_",
"0.5_",
"*_",
"(_",
"d",
"K_",
"._",
"dot_",
"(_",
"z_",
")_",
"._",
"dot_",
"(_",
"z_",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"-_",
"U_",
"._",
"trace",
"\\u",
"solve",
"\\u",
"gradient_",
"(_",
"d",
"K_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"-",
" ",
"np",
".",
"trace",
"(",
"U",
".",
"solve",
"(",
"d",
"K",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"d",
" ",
"=",
" ",
"0.",
"5",
" ",
"*",
" ",
"(",
"d",
"K",
".",
"dot",
"(",
"z",
").",
"dot",
"(",
"z",
")_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
" ",
"-",
" ",
"np",
".",
"trace",
"(",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
",",
" ",
"d",
"K",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"d",
" ",
"=",
" ",
"0.",
"5",
" ",
"*",
" ",
"(",
"np",
".",
"dot",
"(",
"z",
",",
" ",
"np",
".",
"dot",
"(",
"d",
"K",
",",
" ",
"z",
"))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
" ",
" ",
" ",
"-",
" ",
"np",
".",
"trace",
"(",
"util",
"s",
".",
"chol",
"\\u",
"solve",
"(",
"U",
",",
" ",
"d",
"K",
")))",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Sen",
"d",
" ",
"the",
" ",
"deriv",
"ative",
" ",
"message_",
"\\u\\u\\uNL\\u\\u\\u_",
"func_",
"(_",
"d_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"##",
" ",
"Log",
" ",
"pdf",
" ",
"for",
" ",
"latent",
" ",
"GP",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Exception_",
"(_",
"'",
"Not",
" ",
"implemented",
" ",
"ye",
"t",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"return_",
"L_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"##",
" ",
"Let",
" ",
"f1",
" ",
"be",
" ",
"observe",
"d",
" ",
"and",
" ",
"f2",
" ",
"latent",
" ",
"function",
" ",
"values",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"<",
"log",
" ",
"p",
"(",
"f1",
",",
"f2",
"|",
"m",
",",
"k",
")>",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"L",
" ",
"=",
" ",
"gauss",
"ian",
"\\u",
"logp",
"df",
"(",
"sum",
"\\u",
"product",
"(",
"np",
".",
"outer",
"(",
"self",
".",
"f",
",",
"self",
".",
"f",
")",
" ",
"+",
" ",
"self",
".",
"Cov",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Compute",
" ",
"<",
"log",
" ",
"q",
"(",
"f2",
")>",
"_",
"\\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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | Kami/python-yubico-client/yubico_client/py3.py | [
{
"content": "# Licensed to the Apache Software Foundation (ASF) under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You under the Apache License, Version 2.0\n# (the \"License\"); you may not use this file except in compliance with\n# the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# Libcloud Python 2.x and 3.x compatibility layer\n# Some methods bellow are taken from Django PYK3 port which is licensed under 3\n# clause BSD license\n# https://bitbucket.org/loewis/django-3k\n\n# Taken from Apache Libcloud which is license under the Apache 2.0 License\nimport sys\n\nPY3 = False\nPY2 = False\nPY25 = False\nPY27 = False\nPY3 = False\nPY32 = False\n\nif sys.version_info >= (2, 0) and sys.version_info < (3, 0):\n PY2 = True\n\nif sys.version_info >= (2, 5) and sys.version_info <= (2, 6):\n PY25 = True\n\nif sys.version_info >= (2, 7) and sys.version_info <= (2, 8):\n PY27 = True\n\nif sys.version_info >= (3, 0):\n PY3 = True\n\nif sys.version_info >= (3, 2) and sys.version_info < (3, 3):\n PY32 = True\n\nif PY3:\n from urllib.parse import urlencode as urlencode\n from urllib.parse import unquote as unquote\n\n u = str\n\nelse:\n from urllib import urlencode as urlencode # NOQA\n from urllib import unquote as unquote # NOQA\n\n u = unicode\n b = bytes = str\n\nif PY27 or PY3:\n unittest2_required = False\nelse:\n unittest2_required = True\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": " def b(s):\n if isinstance(s, str):\n return s.encode('utf-8')\n elif isinstance(s, bytes):\n return s\n else:\n raise TypeError(\"Invalid argument %r for b()\" % (s,))",
"metadata": "root.b",
"header": "['module', '___EOS___']",
"index": 51
}
]
| [
{
"span": "from urllib.parse import urlencode as urlencode",
"start_line": 46,
"start_column": 4,
"end_line": 46,
"end_column": 51
},
{
"span": "from urllib.parse import unquote as unquote",
"start_line": 47,
"start_column": 4,
"end_line": 47,
"end_column": 47
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"#",
" ",
"License",
"d",
" ",
"to",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"Sof",
"twa",
"re",
" ",
"Foun",
"dati",
"on",
" ",
"(",
"AS",
"F",
")",
" ",
"under",
" ",
"one",
" ",
"or",
" ",
"more_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"contributor",
" ",
"license",
" ",
"agreement",
"s",
".",
" ",
" ",
"See",
" ",
"the",
" ",
"NOTICE",
" ",
"file",
" ",
"distributed",
" ",
"with_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"this",
" ",
"work",
" ",
"for",
" ",
"addition",
"al",
" ",
"informati",
"on",
" ",
"regarding",
" ",
"copyr",
"ight",
" ",
"owner",
"ship",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"The",
" ",
"AS",
"F",
" ",
"license",
"s",
" ",
"this",
" ",
"file",
" ",
"to",
" ",
"You",
" ",
"under",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"License",
",",
" ",
"Version",
" ",
"2.0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"(",
"the",
" ",
"\"",
"License",
"\");",
" ",
"you",
" ",
"may",
" ",
"not",
" ",
"use",
" ",
"this",
" ",
"file",
" ",
"except",
" ",
"in",
" ",
"compli",
"anc",
"e",
" ",
"with_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"the",
" ",
"License",
".",
" ",
" ",
"You",
" ",
"may",
" ",
"obtain",
" ",
"a",
" ",
"copy",
" ",
"of",
" ",
"the",
" ",
"License",
" ",
"at_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"http",
"://",
"www",
".",
"apa",
"che",
".",
"org",
"/",
"license",
"s",
"/",
"LICENSE",
"-",
"2.0_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Un",
"less",
" ",
"require",
"d",
" ",
"by",
" ",
"applica",
"ble",
" ",
"law",
" ",
"or",
" ",
"agree",
"d",
" ",
"to",
" ",
"in",
" ",
"writ",
"ing",
",",
" ",
"software",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"distributed",
" ",
"under",
" ",
"the",
" ",
"License",
" ",
"is",
" ",
"distributed",
" ",
"on",
" ",
"an",
" ",
"\"",
"AS",
" ",
"IS",
"\"",
" ",
"BAS",
"IS",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"WITH",
"OUT",
" ",
"WAR",
"RAN",
"TIES",
" ",
"OR",
" ",
"CONDITION",
"S",
" ",
"OF",
" ",
"ANY",
" ",
"KIND",
",",
" ",
"eit",
"her",
" ",
"express",
" ",
"or",
" ",
"impli",
"ed",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"See",
" ",
"the",
" ",
"License",
" ",
"for",
" ",
"the",
" ",
"specific",
" ",
"language",
" ",
"govern",
"ing",
" ",
"permissi",
"ons",
" ",
"and_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"limit",
"ation",
"s",
" ",
"under",
" ",
"the",
" ",
"License",
"._",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Lib",
"cloud",
" ",
"Pyth",
"on",
" ",
"2",
".",
"x",
" ",
"and",
" ",
"3",
".",
"x",
" ",
"compatibility",
" ",
"layer_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Some",
" ",
"method",
"s",
" ",
"bell",
"ow",
" ",
"are",
" ",
"take",
"n",
" ",
"from",
" ",
"Dj",
"ang",
"o",
" ",
"PY",
"K",
"3",
" ",
"port",
" ",
"whi",
"ch",
" ",
"is",
" ",
"license",
"d",
" ",
"under",
" ",
"3_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"clause",
" ",
"BS",
"D",
" ",
"license_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"https",
"://",
"bitb",
"ucket",
".",
"org",
"/",
"lo",
"ew",
"is",
"/",
"django",
"-",
"3",
"k_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"Taken",
" ",
"from",
" ",
"Ap",
"ache",
" ",
"Lib",
"cloud",
" ",
"whi",
"ch",
" ",
"is",
" ",
"license",
" ",
"under",
" ",
"the",
" ",
"Ap",
"ache",
" ",
"2.0",
" ",
"License",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"import_",
"sys_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"PY",
"3_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"PY",
"2_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"PY",
"25_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"PY",
"27_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"PY",
"3_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"PY",
"32_",
"=_",
"False_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"if_",
"sys_",
"._",
"version",
"\\u",
"info_",
">=_",
"(_",
"2_",
",_",
"0_",
")_",
"and_",
"sys_",
"._",
"version",
"\\u",
"info_",
"<_",
"(_",
"3_",
",_",
"0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"PY",
"2_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"sys_",
"._",
"version",
"\\u",
"info_",
">=_",
"(_",
"2_",
",_",
"5_",
")_",
"and_",
"sys_",
"._",
"version",
"\\u",
"info_",
"<=_",
"(_",
"2_",
",_",
"6_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"PY",
"25_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"sys_",
"._",
"version",
"\\u",
"info_",
">=_",
"(_",
"2_",
",_",
"7_",
")_",
"and_",
"sys_",
"._",
"version",
"\\u",
"info_",
"<=_",
"(_",
"2_",
",_",
"8_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"PY",
"27_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"sys_",
"._",
"version",
"\\u",
"info_",
">=_",
"(_",
"3_",
",_",
"0_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"PY",
"3_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"sys_",
"._",
"version",
"\\u",
"info_",
">=_",
"(_",
"3_",
",_",
"2_",
")_",
"and_",
"sys_",
"._",
"version",
"\\u",
"info_",
"<_",
"(_",
"3_",
",_",
"3_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"PY",
"32_",
"=_",
"True_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"PY",
"3_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"from_",
"urllib_",
"._",
"parse_",
"import_",
"urlencode_",
"as_",
"urlencode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"urllib_",
"._",
"parse_",
"import_",
"unquote_",
"as_",
"unquote_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"u_",
"=_",
"str_",
"\\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 ",
" _",
"from_",
"urllib_",
"import_",
"urlencode_",
"as_",
"urlencode_",
"#",
" ",
"NO",
"QA",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"urllib_",
"import_",
"unquote_",
"as_",
"unquote_",
"#",
" ",
"NO",
"QA",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"u_",
"=_",
"unicode_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"b_",
"=_",
"bytes_",
"=_",
"str_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"if_",
"PY",
"27_",
"or_",
"PY",
"3_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"unittest",
"2",
"\\u",
"required_",
"=_",
"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 ",
" _",
"unittest",
"2",
"\\u",
"required_",
"=_",
"True_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"def_",
"b_",
"(_",
"s_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"isinstance_",
"(_",
"s_",
",_",
"str_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"s_",
"._",
"encode_",
"(_",
"'",
"utf",
"-",
"8",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"elif_",
"isinstance_",
"(_",
"s_",
",_",
"bytes_",
")_",
":_",
"\\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_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"raise_",
"Type",
"Error_",
"(_",
"\"",
"Inva",
"lid",
" ",
"argu",
"ment",
" ",
"%",
"r",
" ",
"for",
" ",
"b",
"()\"_",
"%_",
"(_",
"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,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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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openpds/questions/crowdsos_tasks.py | [
{
"content": "from celery import task\nfrom openpds.core.models import Profile, Notification, Device\nfrom bson import ObjectId\nfrom pymongo import Connection\nfrom django.conf import settings\nimport time\nfrom datetime import date, timedelta, datetime\nimport json\nimport pdb\nimport math\nimport cluster\nfrom gcm import GCM\n\nfrom openpds.core.models import Profile\n\nconnection = Connection(\n host=getattr(settings, \"MONGODB_HOST\", None),\n port=getattr(settings, \"MONGODB_PORT\", None)\n)\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "@task()\ndef findRecentIncidents():\n currentTime = time.time()\n today = date.fromtimestamp(currentTime)\n startTime = currentTime - (3600 * 24)#time.mktime((today - timedelta(days=1)).timetuple())\n\n profiles = Profile.objects.all()\n answer = { \"key\": \"RecentIncidents\", \"value\": [] }\n print \"Aggregating incidents over the last day...\"\n for profile in profiles:\n dbName = profile.getDBName()\n collection = connection[dbName][\"incident\"]\n for incident in collection.find({ \"date\": { \"$gte\": startTime } }, limit=50):\n answer[\"value\"].append(incident)\n\n print \"Storing %i incidents into %i profiles...\" % (len(answer[\"value\"]), profiles.count())\n for profile in profiles:\n dbName = profile.getDBName()\n answerlistCollection = connection[dbName][\"answerlist\"]\n answerlistCollection.remove({ \"key\": \"RecentIncidents\" })\n answerlistCollection.save(answer)\n print \"Done.\"",
"metadata": "root.findRecentIncidents",
"header": "['module', '___EOS___']",
"index": 21
},
{
"content": "@task()\ndef ensureIncidentIndexes():\n profiles = Profile.objects.all()\n\n for profile in profiles:\n dbName = profile.getDBName()\n collection = connection[dbName][\"incident\"]\n collection.ensure_index([(\"date\", -1), (\"type\", 1)], cache_for=7200, background=True)",
"metadata": "root.ensureIncidentIndexes",
"header": "['module', '___EOS___']",
"index": 44
}
]
| [
{
"span": "from openpds.core.models import Profile, Notification, Device",
"start_line": 1,
"start_column": 0,
"end_line": 1,
"end_column": 61
},
{
"span": "from bson import ObjectId",
"start_line": 2,
"start_column": 0,
"end_line": 2,
"end_column": 25
},
{
"span": "import json",
"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": "import math",
"start_line": 9,
"start_column": 0,
"end_line": 9,
"end_column": 11
},
{
"span": "import cluster",
"start_line": 10,
"start_column": 0,
"end_line": 10,
"end_column": 14
},
{
"span": "from gcm import GCM",
"start_line": 11,
"start_column": 0,
"end_line": 11,
"end_column": 19
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"from_",
"celery_",
"import_",
"task_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"openp",
"ds_",
"._",
"core_",
"._",
"models_",
"import_",
"Profile_",
",_",
"Notification_",
",_",
"Device_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"bson_",
"import_",
"Object",
"Id_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"pymongo_",
"import_",
"Connection_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"conf_",
"import_",
"settings_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"time_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"datetime_",
"import_",
"date_",
",_",
"timedelta_",
",_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"json_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"pdb_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"math_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"cluster_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"gcm",
"_",
"import_",
"GCM",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"openp",
"ds_",
"._",
"core_",
"._",
"models_",
"import_",
"Profile_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"connection_",
"=_",
"Connection_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"host_",
"=_",
"getattr_",
"(_",
"settings_",
",_",
"\"",
"MONGO",
"DB",
"\\u",
"HOST",
"\"_",
",_",
"None_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"port_",
"=_",
"getattr_",
"(_",
"settings_",
",_",
"\"",
"MONGO",
"DB",
"\\u",
"PORT",
"\"_",
",_",
"None_",
")_",
"\\u\\u\\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_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"@_",
"task_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"find",
"Rece",
"nt",
"Inciden",
"ts_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"current",
"Time_",
"=_",
"time_",
"._",
"time_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"today_",
"=_",
"date_",
"._",
"fromtimestamp_",
"(_",
"current",
"Time_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"start",
"Time_",
"=_",
"current",
"Time_",
"-_",
"(_",
"3600_",
"*_",
"24_",
")_",
"#",
"time",
".",
"mkt",
"ime",
"((",
"toda",
"y",
" ",
"-",
" ",
"timedelta",
"(",
"day",
"s",
"=",
"1",
"))",
".",
"time",
"tuple",
"())",
"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"profiles_",
"=_",
"Profile_",
"._",
"objects_",
"._",
"all_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"answer_",
"=_",
"{_",
"\"",
"key",
"\"_",
":_",
"\"",
"Rece",
"nt",
"Inciden",
"ts",
"\"_",
",_",
"\"",
"value",
"\"_",
":_",
"[_",
"]_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"print_",
"\"",
"Agg",
"rega",
"ting",
" ",
"incidents",
" ",
"over",
" ",
"the",
" ",
"last",
" ",
"day",
"...\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"profile_",
"in_",
"profiles_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"db",
"Name_",
"=_",
"profile_",
"._",
"get",
"DB",
"Name_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"collection_",
"=_",
"connection_",
"[_",
"db",
"Name_",
"]_",
"[_",
"\"",
"incident",
"\"_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"incident",
"_",
"in_",
"collection_",
"._",
"find_",
"(_",
"{_",
"\"",
"date",
"\"_",
":_",
"{_",
"\"$",
"gte",
"\"_",
":_",
"start",
"Time_",
"}_",
"}_",
",_",
"limit_",
"=_",
"50_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"answer_",
"[_",
"\"",
"value",
"\"_",
"]_",
"._",
"append_",
"(_",
"incident",
"_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"\"",
"Stor",
"ing",
" ",
"%",
"i",
" ",
"incidents",
" ",
"int",
"o",
" ",
"%",
"i",
" ",
"profile",
"s",
"...\"_",
"%_",
"(_",
"len_",
"(_",
"answer_",
"[_",
"\"",
"value",
"\"_",
"]_",
")_",
",_",
"profiles_",
"._",
"count_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"profile_",
"in_",
"profiles_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"db",
"Name_",
"=_",
"profile_",
"._",
"get",
"DB",
"Name_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"answer",
"list",
"Collection_",
"=_",
"connection_",
"[_",
"db",
"Name_",
"]_",
"[_",
"\"",
"answer",
"list",
"\"_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"answer",
"list",
"Collection_",
"._",
"remove_",
"(_",
"{_",
"\"",
"key",
"\"_",
":_",
"\"",
"Rece",
"nt",
"Inciden",
"ts",
"\"_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"answer",
"list",
"Collection_",
"._",
"save_",
"(_",
"answer_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"print_",
"\"",
"Don",
"e",
".\"_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"@_",
"task_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"def_",
"ensure",
"Inciden",
"t",
"Indexes_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"profiles_",
"=_",
"Profile_",
"._",
"objects_",
"._",
"all_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"profile_",
"in_",
"profiles_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"db",
"Name_",
"=_",
"profile_",
"._",
"get",
"DB",
"Name_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"collection_",
"=_",
"connection_",
"[_",
"db",
"Name_",
"]_",
"[_",
"\"",
"incident",
"\"_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"collection_",
"._",
"ensure",
"\\u",
"index_",
"(_",
"[_",
"(_",
"\"",
"date",
"\"_",
",_",
"-_",
"1_",
")_",
",_",
"(_",
"\"",
"type",
"\"_",
",_",
"1_",
")_",
"]_",
",_",
"cache",
"\\u",
"for_",
"=_",
"7200",
"_",
",_",
"background_",
"=_",
"True_",
")_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
0,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
1,
2,
0,
1,
2,
0,
1,
2,
0,
1,
2,
0,
1,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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
]
|
Unused import | gavinwahl/django-u2f/testproj/testproj/tests.py | [
{
"content": "import os\nimport re\nimport json\nimport string\nimport datetime\nfrom base64 import b32decode\nfrom six import StringIO\nimport unittest\n\nfrom django.test import TestCase, Client\nfrom django.core.urlresolvers import reverse\nfrom django.contrib.auth import get_user_model, SESSION_KEY\nfrom django.utils.crypto import get_random_string\nfrom django.utils import timezone\nfrom django.core.management import call_command\n\nfrom django_u2f.forms import BackupCodeForm, TOTPForm\nfrom django_u2f import oath\nfrom django_u2f.models import TOTPDevice\n\nUser = get_user_model()\n\n\n\n\n\n\n\n\n\n\n\n\n",
"metadata": "root",
"header": "['module', '___EOS___']",
"index": 0
},
{
"content": "class TwoFactorTest(TestCase):\n\n",
"metadata": "root.TwoFactorTest",
"header": "['module', '___EOS___']",
"index": 23
},
{
"content": " def setUp(self):\n self.client = Client()\n self.user = User.objects.create_superuser(\n username='test',\n email='[email protected]',\n password='asdfasdf',\n )\n self.login_url = reverse('u2f:login')",
"metadata": "root.TwoFactorTest.setUp",
"header": "['class', 'TwoFactorTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 24
},
{
"content": " def login(self):\n return self.client.post(self.login_url, {\n 'username': 'test',\n 'password': 'asdfasdf',\n 'next': '/next/'\n })",
"metadata": "root.TwoFactorTest.login",
"header": "['class', 'TwoFactorTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 33
},
{
"content": " def enable_backupcode(self):\n code = get_random_string(length=6, allowed_chars=string.digits)\n self.user.backup_codes.create(code=code)\n return code",
"metadata": "root.TwoFactorTest.enable_backupcode",
"header": "['class', 'TwoFactorTest', '(', 'TestCase', ')', ':', '___EOS___']",
"index": 40
},
{
"content": "class U2FTest(TwoFactorTest):\n\n",
"metadata": "root.U2FTest",
"header": "['module', '___EOS___']",
"index": 46
},
{
"content": " def enable_u2f(self):\n self.user.u2f_keys.create(\n public_key='BCux01toHSq_5YHfsw3EAqfGGKirLoHnDqAuW5RedtP8dGbJTJ55-QEJ_alPDM06kHw7UOUOCawdHinHVrNbnKw',\n key_handle='OJiPPVZ6oU-PszwbAAJhbanYvhawFrQi6n3AkcT1k7SeZDo3Ch6BU8i21kp2tcsyQ2BE7nc34RdljU4iS997vA',\n app_id='http://localhost.com:8000',\n )",
"metadata": "root.U2FTest.enable_u2f",
"header": "['class', 'U2FTest', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 47
},
{
"content": " def set_challenge(self):\n session = self.client.session\n session['u2f_authentication_challenges'] = [\n {\n \"challenge\": \"jUvsJfqf2FMXkUTTFQ57gqNhVn0K2eJ7ElxnF3EK_M8\",\n \"version\": \"U2F_V2\",\n \"keyHandle\": \"OJiPPVZ6oU-PszwbAAJhbanYvhawFrQi6n3AkcT1k7SeZDo3Ch6BU8i21kp2tcsyQ2BE7nc34RdljU4iS997vA\",\n \"appId\": \"http://localhost.com:8000\",\n }\n ]\n session.save()\n return {\n \"keyHandle\": \"OJiPPVZ6oU-PszwbAAJhbanYvhawFrQi6n3AkcT1k7SeZDo3Ch6BU8i21kp2tcsyQ2BE7nc34RdljU4iS997vA\",\n \"clientData\": \"eyJ0eXAiOiJuYXZpZ2F0b3IuaWQuZ2V0QXNzZXJ0aW9uIiwiY2hhbGxlbmdlIjoialV2c0pmcWYyRk1Ya1VUVEZRNTdncU5oVm4wSzJlSjdFbHhuRjNFS19NOCIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3QuY29tOjgwMDAiLCJjaWRfcHVia2V5IjoiIn0\",\n \"signatureData\": \"AQAAADcwRQIhALnYwD3DMN3CAhKzhH7hwoJfSSiNMrOHhZq2nQA0WunTAiB2hKEpPn4u0znti-mjC4Xq6Ekv1tfopsapTsJ8EOxmYg\",\n }",
"metadata": "root.U2FTest.set_challenge",
"header": "['class', 'U2FTest', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 54
},
{
"content": " def set_add_key(self):\n session = self.client.session\n session['u2f_registration_challenge'] = {\n 'challenge': \"1C57ZaTxUkXyMJqcfdNc_7Lp34aPgYDNt_nL2wwsLPQ\",\n 'version': \"U2F_V2\",\n 'appId': \"http://localhost.com:8000\",\n }\n\n session.save()\n return {\n \"registrationData\": \"BQR-zQiLHRPYDlXEDG_yZ_Y53mLP20BXMUpm-zqH1ntWHr3S1EZtJbFKNkWRwo2BQA-SBRZH4SvA2mZyCK2wP4AZQMF2iVGLM8guW_L2o7tfu9THxhMtOFRC6WICT_Kn2Vn3kxkMLjt4fBYO0ZeatzA5qaBk_O6PIypq0R9oYmHiQYEwggIcMIIBBqADAgECAgQk26tAMAsGCSqGSIb3DQEBCzAuMSwwKgYDVQQDEyNZdWJpY28gVTJGIFJvb3QgQ0EgU2VyaWFsIDQ1NzIwMDYzMTAgFw0xNDA4MDEwMDAwMDBaGA8yMDUwMDkwNDAwMDAwMFowKzEpMCcGA1UEAwwgWXViaWNvIFUyRiBFRSBTZXJpYWwgMTM1MDMyNzc4ODgwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQCsJS-NH1HeUHEd46-xcpN7SpHn6oeb-w5r-veDCBwy1vUvWnJanjjv4dR_rV5G436ysKUAXUcsVe5fAnkORo2oxIwEDAOBgorBgEEAYLECgEBBAAwCwYJKoZIhvcNAQELA4IBAQCjY64OmDrzC7rxLIst81pZvxy7ShsPy2jEhFWEkPaHNFhluNsCacNG5VOITCxWB68OonuQrIzx70MfcqwYnbIcgkkUvxeIpVEaM9B7TI40ZHzp9h4VFqmps26QCkAgYfaapG4SxTK5k_lCPvqqTPmjtlS03d7ykkpUj9WZlVEN1Pf02aTVIZOHPHHJuH6GhT6eLadejwxtKDBTdNTv3V4UlvjDOQYQe9aL1jUNqtLDeBHso8pDvJMLc0CX3vadaI2UVQxM-xip4kuGouXYj0mYmaCbzluBDFNsrzkNyL3elg3zMMrKvAUhoYMjlX_-vKWcqQsgsQ0JtSMcWMJ-umeDMEUCIDmr7y3CyKDwDThdf8MUyp3R_meuSz6pYPavyjt5vDlHAiEApjqut4HuWZzTz9WmjDTAa8_Dn8DmrXfMCbFFsYXU_nU\",\n \"challenge\": \"1C57ZaTxUkXyMJqcfdNc_7Lp34aPgYDNt_nL2wwsLPQ\",\n \"version\": \"U2F_V2\",\n \"appId\": \"http://localhost.com:8000\",\n \"clientData\": \"eyJ0eXAiOiJuYXZpZ2F0b3IuaWQuZmluaXNoRW5yb2xsbWVudCIsImNoYWxsZW5nZSI6IjFDNTdaYVR4VWtYeU1KcWNmZE5jXzdMcDM0YVBnWUROdF9uTDJ3d3NMUFEiLCJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0LmNvbTo4MDAwIiwiY2lkX3B1YmtleSI6IiJ9\",\n }",
"metadata": "root.U2FTest.set_add_key",
"header": "['class', 'U2FTest', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 71
},
{
"content": "class TestU2F(U2FTest):\n\n\n\n\n",
"metadata": "root.TestU2F",
"header": "['module', '___EOS___']",
"index": 89
},
{
"content": " def test_normal_login(self):\n r = self.login()\n self.assertTrue(r['location'].endswith('/next/'))\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))",
"metadata": "root.TestU2F.test_normal_login",
"header": "['class', 'TestU2F', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 90
},
{
"content": " def test_u2f_login(self):\n self.enable_u2f()\n r = self.login()\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertIn(reverse('u2f:verify-second-factor'), r['location'])\n\n device_response = self.set_challenge()\n r = self.client.post(r['location'], {\n 'response': json.dumps(device_response),\n 'type': 'u2f',\n })\n self.assertEquals(r.status_code, 302)\n self.assertTrue(r['location'].endswith('/next/'))\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))",
"metadata": "root.TestU2F.test_u2f_login",
"header": "['class', 'TestU2F', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 95
},
{
"content": " def test_failed_u2f_login(self):\n self.enable_u2f()\n r = self.login()\n device_response = self.set_challenge()\n device_response['signatureData'] = 'a' + device_response['signatureData'][1:]\n r = self.client.post(r['location'], {\n 'response': json.dumps(device_response),\n 'type': 'u2f',\n })\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertContains(r, 'U2F validation failed')",
"metadata": "root.TestU2F.test_failed_u2f_login",
"header": "['class', 'TestU2F', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 110
},
{
"content": " def test_verify_when_not_logged_in(self):\n r = self.client.get(reverse('u2f:verify-second-factor'))\n self.assertTrue(r['location'].endswith(self.login_url))",
"metadata": "root.TestU2F.test_verify_when_not_logged_in",
"header": "['class', 'TestU2F', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 122
},
{
"content": " def test_add_key(self):\n self.login()\n\n url = reverse('u2f:add-u2f-key')\n r = self.client.get(url)\n self.assertContains(r, '\"challenge\"')\n\n device_response = self.set_add_key()\n r = self.client.post(url, {\n 'response': json.dumps(device_response),\n })\n added_key_obj = self.user.u2f_keys.get()\n self.assertEqual(added_key_obj.public_key, 'BH7NCIsdE9gOVcQMb_Jn9jneYs_bQFcxSmb7OofWe1YevdLURm0lsUo2RZHCjYFAD5IFFkfhK8DaZnIIrbA_gBk')\n self.assertEqual(added_key_obj.key_handle, 'wXaJUYszyC5b8vaju1-71MfGEy04VELpYgJP8qfZWfeTGQwuO3h8Fg7Rl5q3MDmpoGT87o8jKmrRH2hiYeJBgQ')\n self.assertEqual(added_key_obj.app_id, 'http://localhost.com:8000')",
"metadata": "root.TestU2F.test_add_key",
"header": "['class', 'TestU2F', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 126
},
{
"content": " def test_key_delete(self):\n other_user = User.objects.create_superuser(\n username='abc',\n email='[email protected]',\n password='asdfasdf',\n )\n other_user.u2f_keys.create()\n self.enable_u2f()\n self.client.login(username='test', password='asdfasdf')\n\n r = self.client.post(reverse('u2f:u2f-keys'), {\n 'key_id': self.user.u2f_keys.get().pk,\n 'delete': '1',\n })\n self.assertFalse(self.user.u2f_keys.exists())\n\n # cant delete someone else's keys\n r = self.client.post(reverse('u2f:u2f-keys'), {\n 'key_id': other_user.u2f_keys.get().pk,\n 'delete': '1',\n })\n self.assertTrue(other_user.u2f_keys.exists())\n self.assertEqual(r.status_code, 404)",
"metadata": "root.TestU2F.test_key_delete",
"header": "['class', 'TestU2F', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 142
},
{
"content": "class TestAdminLogin(TwoFactorTest):\n\n\n",
"metadata": "root.TestAdminLogin",
"header": "['module', '___EOS___']",
"index": 167
},
{
"content": " def setUp(self):\n super(TestAdminLogin, self).setUp()\n self.admin_url = reverse('admin:index')\n # discover admin login url, different on django 1.6 and django 1.7\n r = self.client.get(self.admin_url)\n if r.status_code == 302:\n # django 1.7\n self.login_url = r['location']\n else:\n # django 1.6\n self.login_url = self.admin_url",
"metadata": "root.TestAdminLogin.setUp",
"header": "['class', 'TestAdminLogin', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 168
},
{
"content": " def test_admin_template_rendered(self):\n r = self.client.get(self.login_url)\n self.assertEqual(r.templates[0].name, 'admin/login.html')",
"metadata": "root.TestAdminLogin.test_admin_template_rendered",
"header": "['class', 'TestAdminLogin', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 180
},
{
"content": " def test_login_with_u2f(self):\n code = self.enable_backupcode()\n r = self.client.post(self.login_url, {\n 'username': 'test',\n 'password': 'asdfasdf',\n })\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertIn(reverse('u2f:verify-second-factor'), r['location'])\n\n verify_key_response = self.client.get(r['location'])\n self.assertContains(verify_key_response, 'Django administration')\n\n r = self.client.post(r['location'], {\n 'code': code,\n 'type': 'backup',\n })\n\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))\n self.assertTrue(r['location'].endswith(self.admin_url))",
"metadata": "root.TestAdminLogin.test_login_with_u2f",
"header": "['class', 'TestAdminLogin', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 184
},
{
"content": " def test_login_without_u2f(self):\n r = self.client.post(self.login_url, {\n 'username': 'test',\n 'password': 'asdfasdf',\n 'this_is_the_login_form': 1,\n 'next': self.admin_url,\n })\n self.assertTrue(r['location'].endswith(self.admin_url))\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))",
"metadata": "root.TestAdminLogin.test_login_without_u2f",
"header": "['class', 'TestAdminLogin', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 204
},
{
"content": "class TestBackupCode(TwoFactorTest):\n\n\n\n\n\n",
"metadata": "root.TestBackupCode",
"header": "['module', '___EOS___']",
"index": 215
},
{
"content": " def test_validation_error(self):\n self.enable_backupcode()\n r = self.login()\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertIn(reverse('u2f:verify-second-factor'), r['location'])\n\n r = self.client.post(r['location'], {\n 'type': 'backup',\n })\n self.assertContains(r, 'This field is required.')",
"metadata": "root.TestBackupCode.test_validation_error",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 216
},
{
"content": " def test_code_required_and_login(self):\n code = self.enable_backupcode()\n r = self.login()\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertIn(reverse('u2f:verify-second-factor'), r['location'])\n\n r = self.client.post(r['location'], {\n 'code': code,\n 'type': 'backup',\n })\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))\n self.assertTrue(r['location'].endswith('/next/'))\n self.assertFalse(self.user.backup_codes.filter(code=code).exists())",
"metadata": "root.TestBackupCode.test_code_required_and_login",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 227
},
{
"content": " def test_incorrect_code(self):\n self.enable_backupcode()\n r = self.login()\n r = self.client.post(r['location'], {\n 'code': 'abc',\n 'type': 'backup',\n })\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertContains(r, BackupCodeForm.INVALID_ERROR_MESSAGE)",
"metadata": "root.TestBackupCode.test_incorrect_code",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 241
},
{
"content": " def test_add_backup_codes(self):\n self.login()\n r = self.client.post(reverse('u2f:backup-codes'))\n self.assertEqual(r.status_code, 302)\n self.assertEqual(self.user.backup_codes.count(), 10)",
"metadata": "root.TestBackupCode.test_add_backup_codes",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 251
},
{
"content": " def test_list_backup_codes(self):\n self.login()\n self.user.backup_codes.create(code='foobar')\n otheruser = User.objects.create_superuser(\n username='test2',\n email='[email protected]',\n password='asdfasdf',\n )\n otheruser.backup_codes.create(code='test2code')\n\n r = self.client.get(reverse('u2f:backup-codes'))\n self.assertContains(r, 'foobar')\n self.assertNotContains(r, 'test2code')",
"metadata": "root.TestBackupCode.test_list_backup_codes",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 257
},
{
"content": " def test_addbackupcode(self):\n out = StringIO()\n call_command('addbackupcode', self.user.get_username(), stdout=out)\n code = out.getvalue().strip()\n self.assertTrue(self.user.backup_codes.filter(code=code).exists())\n\n call_command('addbackupcode', self.user.get_username(), code='foo', stdout=out)\n self.assertTrue(self.user.backup_codes.filter(code='foo').exists())",
"metadata": "root.TestBackupCode.test_addbackupcode",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 271
},
{
"content": " def test_login_while_already_logged_in(self):\n User.objects.create_superuser(\n username='test2',\n email='[email protected]',\n password='asdfasdf',\n )\n r = self.client.post(self.login_url, {\n 'username': 'test2',\n 'password': 'asdfasdf',\n 'next': '/next/'\n })\n assert r.status_code == 302\n\n code = self.enable_backupcode()\n r = self.login()\n self.assertIn(reverse('u2f:verify-second-factor'), r['location'])\n\n r = self.client.post(r['location'], {\n 'code': code,\n 'type': 'backup',\n })\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))\n self.assertTrue(r['location'].endswith('/next/'))\n self.assertFalse(self.user.backup_codes.filter(code=code).exists())",
"metadata": "root.TestBackupCode.test_login_while_already_logged_in",
"header": "['class', 'TestBackupCode', '(', 'TwoFactorTest', ')', ':', '___EOS___']",
"index": 280
},
{
"content": "class TestTOTP(U2FTest):\n\n\n\n\n\n\n\n",
"metadata": "root.TestTOTP",
"header": "['module', '___EOS___']",
"index": 306
},
{
"content": " def enable_totp(self):\n key = os.urandom(20)\n self.user.totp_devices.create(\n key=key,\n )\n return key",
"metadata": "root.TestTOTP.enable_totp",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 307
},
{
"content": " def test_login(self):\n key = self.enable_totp()\n r = self.login()\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertIn(reverse('u2f:verify-second-factor'), r['location'])\n\n r = self.client.post(r['location'], {\n 'token': oath.totp(key, timezone.now()),\n 'type': 'totp',\n })\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))\n self.assertTrue(r['location'].endswith('/next/'))",
"metadata": "root.TestTOTP.test_login",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 314
},
{
"content": " def test_token_cant_be_used_twice(self):\n key = self.enable_totp()\n r = self.login()\n token = oath.totp(key, timezone.now()),\n r = self.client.post(r['location'], {\n 'token': token,\n 'type': 'totp',\n })\n self.assertEqual(str(self.client.session[SESSION_KEY]), str(self.user.id))\n self.client.logout()\n r = self.login()\n r = self.client.post(r['location'], {\n 'token': token,\n 'type': 'totp',\n })\n self.assertContains(r, TOTPForm.INVALID_ERROR_MESSAGE)",
"metadata": "root.TestTOTP.test_token_cant_be_used_twice",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 327
},
{
"content": " def test_incorrect_code(self):\n key = self.enable_totp()\n r = self.login()\n r = self.client.post(r['location'], {\n 'token': oath.totp(key, timezone.now() + datetime.timedelta(seconds=120)),\n 'type': 'totp',\n })\n self.assertNotIn(SESSION_KEY, self.client.session)\n self.assertContains(r, TOTPForm.INVALID_ERROR_MESSAGE)",
"metadata": "root.TestTOTP.test_incorrect_code",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 344
},
{
"content": " def _extract_key(self, response):\n return re.search('<tt>([A-Z0-9]+)</tt>', response.content.decode('utf-8')).group(1)",
"metadata": "root.TestTOTP._extract_key",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 354
},
{
"content": " def test_add_device(self):\n self.login()\n url = reverse('u2f:add-totp')\n r = self.client.get(url)\n self.assertContains(r, 'svg')\n base32_key = self._extract_key(r)\n key = b32decode(base32_key)\n\n r = self.client.post(url, {\n 'base32_key': base32_key,\n 'token': oath.totp(key, timezone.now()),\n })\n self.assertEqual(r.status_code, 302)\n self.assertTrue(self.user.totp_devices.filter(key=key).exists())",
"metadata": "root.TestTOTP.test_add_device",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 357
},
{
"content": " def test_add_device_incorrect_token(self):\n self.login()\n url = reverse('u2f:add-totp')\n r = self.client.get(url)\n base32_key = self._extract_key(r)\n key = b32decode(base32_key)\n\n r = self.client.post(url, {\n 'base32_key': base32_key,\n 'token': oath.totp(key, timezone.now() + datetime.timedelta(seconds=120)),\n })\n self.assertEqual(r.status_code, 200)\n self.assertContains(r, TOTPForm.INVALID_ERROR_MESSAGE)",
"metadata": "root.TestTOTP.test_add_device_incorrect_token",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 372
},
{
"content": " def test_delete_device(self):\n self.login()\n self.enable_totp()\n r = self.client.post(reverse('u2f:totp-devices'), {\n 'device_id': self.user.totp_devices.get().pk,\n 'delete': '1',\n })\n self.assertEqual(r.status_code, 302)\n self.assertFalse(self.user.totp_devices.exists())",
"metadata": "root.TestTOTP.test_delete_device",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 386
},
{
"content": " def test_slop(self):\n key = os.urandom(20)\n device = TOTPDevice(key=key)\n now = timezone.now()\n\n self.assertTrue(device.validate_token(oath.totp(key, now - datetime.timedelta(seconds=30))))\n self.assertTrue(device.validate_token(oath.totp(key, now)))\n self.assertTrue(device.validate_token(oath.totp(key, now + datetime.timedelta(seconds=30))))",
"metadata": "root.TestTOTP.test_slop",
"header": "['class', 'TestTOTP', '(', 'U2FTest', ')', ':', '___EOS___']",
"index": 396
}
]
| [
{
"span": "import unittest",
"start_line": 7,
"start_column": 0,
"end_line": 7,
"end_column": 15
}
]
| []
| 1 | false | [
"[CLS]_",
"Un",
"used_",
"import_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"import_",
"os_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"re_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"json_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"datetime_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"base64_",
"import_",
"b3",
"2de",
"code_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"six_",
"import_",
"String",
"IO_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"import_",
"unittest_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"django_",
"._",
"test_",
"import_",
"Test",
"Case_",
",_",
"Client_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"core_",
"._",
"urlresolvers_",
"import_",
"reverse_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"contrib_",
"._",
"auth_",
"import_",
"get",
"\\u",
"user",
"\\u",
"model_",
",_",
"SES",
"SION",
"\\u",
"KEY_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"utils_",
"._",
"crypto_",
"import_",
"get",
"\\u",
"random",
"\\u",
"string_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"utils_",
"import_",
"timezone_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django_",
"._",
"core_",
"._",
"management_",
"import_",
"call",
"\\u",
"command_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"from_",
"django",
"\\u",
"u2",
"f_",
"._",
"forms_",
"import_",
"Back",
"up",
"Code",
"Form_",
",_",
"TO",
"TP",
"Form_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django",
"\\u",
"u2",
"f_",
"import_",
"oat",
"h_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"from_",
"django",
"\\u",
"u2",
"f_",
"._",
"models_",
"import_",
"TO",
"TP",
"Device_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"User_",
"=_",
"get",
"\\u",
"user",
"\\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\\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_",
"Tw",
"o",
"Factor",
"Test_",
"(_",
"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_",
"[SEP]_",
"class_",
"Tw",
"o",
"Factor",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"client_",
"=_",
"Client_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"user_",
"=_",
"User_",
"._",
"objects_",
"._",
"create",
"\\u",
"superuser_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"username_",
"=_",
"'",
"test",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"email_",
"=_",
"'",
"test",
"@",
"example",
".",
"com",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"password_",
"=_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"login",
"\\u",
"url_",
"=_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"login",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Tw",
"o",
"Factor",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"login_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"self_",
"._",
"login",
"\\u",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"name",
"'_",
":_",
"'",
"test",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"password",
"'_",
":_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"next",
"'_",
":_",
"'/",
"next",
"/'_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Tw",
"o",
"Factor",
"Test_",
"(_",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"enable",
"\\u",
"backup",
"code_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"code_",
"=_",
"get",
"\\u",
"random",
"\\u",
"string_",
"(_",
"length_",
"=_",
"6_",
",_",
"allow",
"ed",
"\\u",
"chars_",
"=_",
"string_",
"._",
"digits_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"create_",
"(_",
"code_",
"=_",
"code_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"code_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"U2",
"FT",
"est_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"U2",
"FT",
"est_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"enable",
"\\u",
"u2",
"f_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"create_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"public",
"\\u",
"key_",
"=_",
"'",
"BC",
"ux",
"01",
"to",
"HS",
"q",
"\\u",
"5",
"YH",
"fs",
"w3",
"EA",
"qf",
"GG",
"Ki",
"r",
"Lo",
"Hn",
"Dq",
"Au",
"W",
"5",
"Red",
"t",
"P",
"8d",
"Gb",
"JT",
"J",
"5",
"5",
"-",
"QE",
"J",
"\\u",
"al",
"PD",
"M",
"0",
"6",
"k",
"Hw",
"7",
"UO",
"UO",
"Ca",
"wd",
"Hin",
"HV",
"r",
"Nb",
"n",
"Kw",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"key",
"\\u",
"handle_",
"=_",
"'",
"OJ",
"i",
"PP",
"VZ",
"6",
"o",
"U",
"-",
"Ps",
"zw",
"b",
"AA",
"Jh",
"ban",
"Yv",
"haw",
"Fr",
"Qi",
"6",
"n",
"3",
"Ak",
"c",
"T1",
"k",
"7",
"Se",
"ZD",
"o3",
"Ch",
"6",
"BU",
"8",
"i2",
"1",
"kp",
"2t",
"cs",
"y",
"Q2",
"BE",
"7",
"nc",
"3",
"4",
"Rd",
"lj",
"U",
"4",
"i",
"S",
"997",
"v",
"A",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"app",
"\\u",
"id_",
"=_",
"'",
"http",
"://",
"local",
"host",
".",
"com",
":",
"800",
"0",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"U2",
"FT",
"est_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"challenge_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"session_",
"=_",
"self_",
"._",
"client_",
"._",
"session_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"session_",
"[_",
"'",
"u2",
"f",
"\\u",
"authenticat",
"ion",
"\\u",
"challenges",
"'_",
"]_",
"=_",
"[_",
"\\u\\u\\uNL\\u\\u\\u_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"chall",
"enge",
"\"_",
":_",
"\"",
"j",
"Uv",
"s",
"Jf",
"qf",
"2",
"FM",
"Xk",
"UT",
"TF",
"Q",
"5",
"7",
"gq",
"Nh",
"Vn",
"0",
"K2",
"e",
"J",
"7E",
"lx",
"n",
"F3",
"EK",
"\\u",
"M",
"8",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"version",
"\"_",
":_",
"\"",
"U2",
"F",
"\\u",
"V2",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"key",
"Handle",
"\"_",
":_",
"\"",
"OJ",
"i",
"PP",
"VZ",
"6",
"o",
"U",
"-",
"Ps",
"zw",
"b",
"AA",
"Jh",
"ban",
"Yv",
"haw",
"Fr",
"Qi",
"6",
"n",
"3",
"Ak",
"c",
"T1",
"k",
"7",
"Se",
"ZD",
"o3",
"Ch",
"6",
"BU",
"8",
"i2",
"1",
"kp",
"2t",
"cs",
"y",
"Q2",
"BE",
"7",
"nc",
"3",
"4",
"Rd",
"lj",
"U",
"4",
"i",
"S",
"997",
"v",
"A",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"app",
"Id",
"\"_",
":_",
"\"",
"http",
"://",
"local",
"host",
".",
"com",
":",
"800",
"0",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNL\\u\\u\\u_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"session_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"key",
"Handle",
"\"_",
":_",
"\"",
"OJ",
"i",
"PP",
"VZ",
"6",
"o",
"U",
"-",
"Ps",
"zw",
"b",
"AA",
"Jh",
"ban",
"Yv",
"haw",
"Fr",
"Qi",
"6",
"n",
"3",
"Ak",
"c",
"T1",
"k",
"7",
"Se",
"ZD",
"o3",
"Ch",
"6",
"BU",
"8",
"i2",
"1",
"kp",
"2t",
"cs",
"y",
"Q2",
"BE",
"7",
"nc",
"3",
"4",
"Rd",
"lj",
"U",
"4",
"i",
"S",
"997",
"v",
"A",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"client",
"Data",
"\"_",
":_",
"\"",
"ey",
"J",
"0e",
"XA",
"i",
"Oi",
"Ju",
"YX",
"Zp",
"Z2",
"F0",
"b3",
"Iu",
"a",
"WQ",
"u",
"Z2",
"V0",
"QX",
"Nz",
"ZX",
"J",
"0a",
"W",
"9",
"u",
"Ii",
"wi",
"Y",
"2h",
"hb",
"Gx",
"lb",
"mdl",
"Ij",
"oi",
"al",
"V2",
"c0",
"pmc",
"WY",
"y",
"Rk",
"1",
"Ya",
"1",
"VU",
"VE",
"ZR",
"NT",
"dn",
"c",
"U",
"5",
"o",
"Vm",
"4",
"w",
"Sz",
"Jl",
"Sj",
"d",
"Fb",
"Hh",
"u",
"R",
"j",
"NF",
"S1",
"9",
"NOC",
"Is",
"Im",
"9",
"ya",
"Wd",
"pb",
"i",
"I",
"6",
"Im",
"h",
"0d",
"HA",
"6",
"Ly",
"9",
"sb",
"2",
"Nh",
"b",
"Gh",
"vc",
"3",
"Qu",
"Y",
"2",
"9",
"t",
"Oj",
"gw",
"MD",
"Ai",
"LC",
"J",
"ja",
"WR",
"fc",
"HV",
"ia",
"2",
"V",
"5",
"Ij",
"oi",
"In",
"0",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"signa",
"ture",
"Data",
"\"_",
":_",
"\"",
"AQA",
"AA",
"Dc",
"w",
"RQ",
"Ih",
"AL",
"n",
"Y",
"w",
"D3",
"DM",
"N3",
"CA",
"h",
"Kz",
"h",
"H",
"7",
"hw",
"o",
"Jf",
"SS",
"i",
"NM",
"r",
"OH",
"h",
"Zq",
"2n",
"QA",
"0",
"Wu",
"n",
"TA",
"i",
"B2",
"h",
"KE",
"p",
"Pn",
"4",
"u0",
"zn",
"ti",
"-",
"mj",
"C4",
"Xq",
"6",
"Ek",
"v1",
"tfo",
"ps",
"ap",
"Ts",
"J",
"8",
"EO",
"xm",
"Y",
"g",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"U2",
"FT",
"est_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"set\\u",
"add",
"\\u",
"key_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"session_",
"=_",
"self_",
"._",
"client_",
"._",
"session_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"session_",
"[_",
"'",
"u2",
"f",
"\\u",
"registration",
"\\u",
"chall",
"enge",
"'_",
"]_",
"=_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"chall",
"enge",
"'_",
":_",
"\"",
"1",
"C5",
"7",
"Za",
"Tx",
"Uk",
"Xy",
"MJ",
"qc",
"fd",
"Nc",
"\\u",
"7",
"Lp",
"3",
"4a",
"Pg",
"YD",
"Nt",
"\\u",
"n",
"L",
"2w",
"ws",
"LP",
"Q",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"version",
"'_",
":_",
"\"",
"U2",
"F",
"\\u",
"V2",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"app",
"Id",
"'_",
":_",
"\"",
"http",
"://",
"local",
"host",
".",
"com",
":",
"800",
"0",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"session_",
"._",
"save_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"registration",
"Data",
"\"_",
":_",
"\"",
"BQ",
"R",
"-",
"z",
"Qi",
"LH",
"RP",
"YD",
"l",
"XE",
"DG",
"\\u",
"y",
"Z",
"\\u",
"Y",
"5",
"3",
"m",
"LP",
"20",
"BX",
"MU",
"pm",
"-",
"zq",
"H1",
"nt",
"WH",
"r3",
"S1",
"EZ",
"t",
"J",
"b",
"FK",
"N",
"k",
"WR",
"wo",
"2",
"BQ",
"A",
"-",
"SB",
"RZ",
"H",
"4",
"Sv",
"A2",
"m",
"Zy",
"CK",
"2w",
"P4",
"AZ",
"QM",
"F2",
"i",
"VG",
"LM",
"8",
"gu",
"W",
"\\u",
"L",
"2o",
"7",
"tf",
"u",
"9",
"TH",
"xh",
"Mt",
"OF",
"RC",
"6",
"WI",
"CT",
"\\u",
"Kn",
"2",
"Vn",
"3",
"kx",
"k",
"ML",
"jt",
"4f",
"BY",
"O0",
"Ze",
"at",
"z",
"A5",
"qa",
"Bk",
"\\u",
"O",
"6",
"PI",
"yp",
"q",
"0",
"R",
"9",
"o",
"Ym",
"Hi",
"QY",
"Ew",
"gg",
"Ic",
"MI",
"IB",
"B",
"q",
"ADA",
"g",
"EC",
"Ag",
"Qk",
"2",
"6",
"t",
"AMA",
"s",
"GC",
"Sq",
"GS",
"Ib",
"3",
"DQ",
"EB",
"Cz",
"Au",
"MS",
"ww",
"K",
"g",
"YD",
"VQ",
"QD",
"Ey",
"NZ",
"d",
"WJ",
"p",
"Y",
"2",
"8",
"g",
"VT",
"JG",
"IF",
"Jv",
"b3",
"Qg",
"Q",
"0E",
"g",
"U2",
"Vy",
"a",
"WF",
"s",
"ID",
"Q1",
"Nz",
"I",
"w",
"MD",
"Y",
"z",
"MT",
"Ag",
"Fw",
"0",
"x",
"ND",
"A4",
"MD",
"Ew",
"MD",
"Aw",
"MD",
"Ba",
"GA",
"8",
"y",
"MD",
"U",
"w",
"MD",
"kw",
"ND",
"Aw",
"MD",
"Aw",
"MF",
"ow",
"Kz",
"Ep",
"MC",
"c",
"GA",
"1",
"UE",
"Aw",
"wg",
"WX",
"Via",
"WN",
"v",
"IF",
"U",
"y",
"Ri",
"BF",
"RS",
"BT",
"ZX",
"Jp",
"Y",
"Ww",
"g",
"MT",
"M1",
"MD",
"My",
"Nz",
"c4",
"OD",
"gw",
"WT",
"AT",
"Bg",
"cq",
"hk",
"j",
"OP",
"QI",
"BB",
"gg",
"qh",
"kj",
"OP",
"QM",
"BB",
"w",
"NC",
"AA",
"QC",
"s",
"JS",
"-",
"NH",
"1",
"He",
"UH",
"Ed",
"4",
"6",
"-",
"xc",
"p",
"N",
"7",
"Sp",
"Hn",
"6",
"oe",
"b",
"-",
"w",
"5",
"r",
"-",
"ve",
"DC",
"Bw",
"y1",
"v",
"Uv",
"Wn",
"Jan",
"jj",
"v",
"4d",
"R",
"\\u",
"r",
"V",
"5",
"G",
"436",
"ys",
"KU",
"AX",
"Uc",
"s",
"Ve",
"5f",
"An",
"k",
"OR",
"o",
"2o",
"x",
"I",
"w",
"EDA",
"OB",
"gor",
"Bg",
"EE",
"AY",
"LE",
"Cg",
"EB",
"BAA",
"w",
"Cw",
"YJ",
"Ko",
"ZI",
"hv",
"c",
"NA",
"QE",
"LA",
"4",
"IBA",
"QC",
"j",
"Y",
"64",
"Om",
"Dr",
"z",
"C",
"7",
"rx",
"LI",
"st",
"8",
"1p",
"Zv",
"xy",
"7",
"Sh",
"s",
"Py",
"2j",
"Eh",
"FW",
"Ek",
"Pa",
"HN",
"Fh",
"lu",
"Ns",
"Ca",
"c",
"NG",
"5",
"VO",
"IT",
"Cx",
"WB",
"6",
"8",
"Oo",
"nu",
"Qr",
"Iz",
"x",
"7",
"0",
"Mf",
"cq",
"w",
"Y",
"nb",
"Ic",
"gk",
"k",
"Uv",
"xe",
"Ip",
"VE",
"a",
"M",
"9",
"B",
"7",
"TI",
"40",
"ZH",
"zp",
"9",
"h",
"4",
"VF",
"qm",
"ps",
"2",
"6",
"QC",
"k",
"Ag",
"Yf",
"aa",
"p",
"G",
"4",
"Sx",
"TK",
"5",
"k",
"\\u",
"l",
"CP",
"vq",
"q",
"TP",
"mj",
"tl",
"S0",
"3d",
"7",
"yk",
"kp",
"Uj",
"9",
"WZ",
"l",
"VEN",
"1",
"Pf",
"02",
"a",
"TV",
"IZ",
"OH",
"PH",
"HJ",
"u",
"H",
"6",
"Gh",
"T6",
"e",
"Lad",
"ej",
"wx",
"t",
"KD",
"BT",
"d",
"NT",
"v",
"3",
"V4",
"Ul",
"vj",
"DO",
"QY",
"Qe",
"9",
"a",
"L1",
"j",
"UN",
"qt",
"LD",
"e",
"BH",
"so",
"8",
"p",
"Dv",
"JM",
"Lc",
"0",
"CX",
"3",
"vad",
"a",
"I2",
"UV",
"Q",
"x",
"M",
"-",
"xi",
"p4",
"ku",
"Go",
"u",
"XY",
"j",
"0",
"m",
"Ym",
"a",
"Cb",
"zl",
"u",
"BD",
"FN",
"sr",
"zk",
"Ny",
"L3",
"el",
"g3",
"z",
"MM",
"r",
"Kv",
"AU",
"ho",
"YM",
"jl",
"X",
"\\u",
"-",
"v",
"KW",
"cq",
"Qs",
"gs",
"Q",
"0",
"J",
"t",
"SM",
"c",
"WM",
"J",
"-",
"ume",
"DM",
"EU",
"CID",
"mr",
"7",
"y",
"3",
"Cy",
"KD",
"w",
"DT",
"hd",
"f8",
"MU",
"yp",
"3",
"R",
"\\u",
"me",
"u",
"Sz",
"6",
"p",
"YP",
"av",
"yj",
"t5",
"v",
"Dl",
"HA",
"i",
"EA",
"pj",
"qu",
"t",
"4",
"Hu",
"WZ",
"z",
"T",
"z",
"9",
"Wm",
"j",
"DT",
"Aa",
"8",
"\\u",
"Dn",
"8",
"Dm",
"r",
"Xf",
"MC",
"b",
"FF",
"s",
"YX",
"U",
"\\u",
"n",
"U",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"chall",
"enge",
"\"_",
":_",
"\"",
"1",
"C5",
"7",
"Za",
"Tx",
"Uk",
"Xy",
"MJ",
"qc",
"fd",
"Nc",
"\\u",
"7",
"Lp",
"3",
"4a",
"Pg",
"YD",
"Nt",
"\\u",
"n",
"L",
"2w",
"ws",
"LP",
"Q",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"version",
"\"_",
":_",
"\"",
"U2",
"F",
"\\u",
"V2",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"app",
"Id",
"\"_",
":_",
"\"",
"http",
"://",
"local",
"host",
".",
"com",
":",
"800",
"0",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"\"",
"client",
"Data",
"\"_",
":_",
"\"",
"ey",
"J",
"0e",
"XA",
"i",
"Oi",
"Ju",
"YX",
"Zp",
"Z2",
"F0",
"b3",
"Iu",
"a",
"WQ",
"u",
"Zm",
"lua",
"XN",
"o",
"RW",
"5",
"yb",
"2x",
"sb",
"WV",
"ud",
"CI",
"s",
"Im",
"No",
"Y",
"Wx",
"s",
"ZW",
"5",
"n",
"ZS",
"I",
"6",
"Ij",
"FD",
"NT",
"da",
"YV",
"R",
"4",
"VW",
"t",
"Ye",
"U1",
"Kc",
"WN",
"m",
"ZE",
"5",
"j",
"X",
"zd",
"Mc",
"DM",
"0",
"YV",
"Bn",
"WU",
"RO",
"d",
"F",
"9",
"u",
"TD",
"J",
"3d",
"3",
"NM",
"UF",
"Ei",
"LC",
"Jv",
"cml",
"na",
"W",
"4",
"i",
"Oi",
"Jo",
"d",
"HR",
"w",
"Oi",
"8",
"vb",
"G",
"9",
"j",
"Y",
"Wx",
"ob",
"3",
"N",
"0",
"Lm",
"Nvb",
"To",
"4",
"MD",
"Aw",
"Ii",
"wi",
"Y",
"2l",
"k",
"X",
"3",
"B1",
"Ym",
"tle",
"SI",
"6",
"Ii",
"J",
"9",
"\"_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\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_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"test\\u",
"normal",
"\\u",
"login_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"'/",
"next",
"/'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"u2",
"f",
"\\u",
"login_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"enable",
"\\u",
"u2",
"f_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
",_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"device",
"\\u",
"response_",
"=_",
"self_",
"._",
"set\\u",
"challenge_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"response",
"'_",
":_",
"json_",
"._",
"dumps_",
"(_",
"device",
"\\u",
"response_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"u2",
"f",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equals_",
"(_",
"r_",
"._",
"status",
"\\u",
"code_",
",_",
"302_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"'/",
"next",
"/'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"fail",
"ed",
"\\u",
"u2",
"f",
"\\u",
"login_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"enable",
"\\u",
"u2",
"f_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"device",
"\\u",
"response_",
"=_",
"self_",
"._",
"set\\u",
"challenge_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"device",
"\\u",
"response_",
"[_",
"'",
"signa",
"ture",
"Data",
"'_",
"]_",
"=_",
"'",
"a",
"'_",
"+_",
"device",
"\\u",
"response_",
"[_",
"'",
"signa",
"ture",
"Data",
"'_",
"]_",
"[_",
"1_",
":_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"response",
"'_",
":_",
"json_",
"._",
"dumps_",
"(_",
"device",
"\\u",
"response_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"u2",
"f",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"'",
"U2",
"F",
" ",
"validation",
" ",
"fail",
"ed",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"verify",
"\\u",
"whe",
"n",
"\\u",
"not",
"\\u",
"logged",
"\\u",
"in_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"self_",
"._",
"login",
"\\u",
"url_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"add",
"\\u",
"key_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"url_",
"=_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"add",
"-",
"u2",
"f",
"-",
"key",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"url_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"'\"",
"chall",
"enge",
"\"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"device",
"\\u",
"response_",
"=_",
"self_",
"._",
"set\\u",
"add",
"\\u",
"key_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"response",
"'_",
":_",
"json_",
"._",
"dumps_",
"(_",
"device",
"\\u",
"response_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"adde",
"d\\u",
"key",
"\\u",
"obj_",
"=_",
"self_",
"._",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"get_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"adde",
"d\\u",
"key",
"\\u",
"obj_",
"._",
"public",
"\\u",
"key_",
",_",
"'",
"BH",
"7",
"NCI",
"sd",
"E",
"9",
"g",
"OV",
"c",
"QM",
"b",
"\\u",
"Jn",
"9",
"jn",
"e",
"Ys",
"\\u",
"b",
"QF",
"cx",
"Sm",
"b7",
"Oo",
"f",
"We",
"1",
"Ye",
"vd",
"LU",
"Rm",
"0",
"ls",
"U",
"o",
"2",
"RZ",
"HC",
"j",
"YF",
"AD",
"5",
"IF",
"Fk",
"fh",
"K",
"8",
"Da",
"Z",
"n",
"II",
"rb",
"A",
"\\u",
"g",
"Bk",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"adde",
"d\\u",
"key",
"\\u",
"obj_",
"._",
"key",
"\\u",
"handle_",
",_",
"'",
"w",
"Xa",
"JU",
"Ys",
"zy",
"C5",
"b8",
"va",
"ju",
"1",
"-",
"7",
"1",
"Mf",
"GE",
"y",
"04",
"VEL",
"p",
"Y",
"g",
"JP",
"8",
"qf",
"ZW",
"fe",
"TG",
"Q",
"wu",
"O",
"3",
"h",
"8",
"Fg",
"7",
"Rl",
"5",
"q",
"3",
"MD",
"mpo",
"GT",
"87",
"o",
"8",
"j",
"Km",
"r",
"RH",
"2h",
"i",
"Ye",
"JB",
"g",
"Q",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"adde",
"d\\u",
"key",
"\\u",
"obj_",
"._",
"app",
"\\u",
"id_",
",_",
"'",
"http",
"://",
"local",
"host",
".",
"com",
":",
"800",
"0",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"U2",
"F_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"key",
"\\u",
"delete_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"other",
"\\u",
"user_",
"=_",
"User_",
"._",
"objects_",
"._",
"create",
"\\u",
"superuser_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"username_",
"=_",
"'",
"abc",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"email_",
"=_",
"'",
"abc",
"@",
"example",
".",
"com",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"password_",
"=_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"other",
"\\u",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"create_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"enable",
"\\u",
"u2",
"f_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"client_",
"._",
"login_",
"(_",
"username_",
"=_",
"'",
"test",
"'_",
",_",
"password_",
"=_",
"'",
"asd",
"fas",
"df",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"u2",
"f",
"-",
"keys",
"'_",
")_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"key",
"\\u",
"id",
"'_",
":_",
"self_",
"._",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"get_",
"(_",
")_",
"._",
"pk_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"delete",
"'_",
":_",
"'",
"1",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"self_",
"._",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"#",
" ",
"cant",
" ",
"delete",
" ",
"some",
"one",
" ",
"else",
"'",
"s",
" ",
"keys_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"u2",
"f",
"-",
"keys",
"'_",
")_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"key",
"\\u",
"id",
"'_",
":_",
"other",
"\\u",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"get_",
"(_",
")_",
"._",
"pk_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"delete",
"'_",
":_",
"'",
"1",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"other",
"\\u",
"user_",
"._",
"u2",
"f",
"\\u",
"keys_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"r_",
"._",
"status",
"\\u",
"code_",
",_",
"404_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"Admi",
"n",
"Login_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\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_",
"Test",
"Admi",
"n",
"Login_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"set",
"Up_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"super_",
"(_",
"Test",
"Admi",
"n",
"Login_",
",_",
"self_",
")_",
"._",
"set",
"Up_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"admin",
"\\u",
"url_",
"=_",
"reverse_",
"(_",
"'",
"admin",
":",
"index",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"discove",
"r",
" ",
"admin",
" ",
"login",
" ",
"url",
",",
" ",
"different",
" ",
"on",
" ",
"django",
" ",
"1.6",
" ",
"and",
" ",
"django",
" ",
"1.7",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"self_",
"._",
"admin",
"\\u",
"url_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"r_",
"._",
"status",
"\\u",
"code_",
"==_",
"302_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"django",
" ",
"1.7",
"_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login",
"\\u",
"url_",
"=_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"else_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"#",
" ",
"django",
" ",
"1.6_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login",
"\\u",
"url_",
"=_",
"self_",
"._",
"admin",
"\\u",
"url_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Admi",
"n",
"Login_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\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",
"admin",
"\\u",
"template",
"\\u",
"rendered_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"self_",
"._",
"login",
"\\u",
"url_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"r_",
"._",
"templates_",
"[_",
"0_",
"]_",
"._",
"name_",
",_",
"'",
"admin",
"/",
"login",
".",
"html",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Admi",
"n",
"Login_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"login",
"\\u",
"with",
"\\u",
"u2",
"f_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"code_",
"=_",
"self_",
"._",
"enable",
"\\u",
"backup",
"code_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"self_",
"._",
"login",
"\\u",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"name",
"'_",
":_",
"'",
"test",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"password",
"'_",
":_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
",_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"verify",
"\\u",
"key",
"\\u",
"response_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"verify",
"\\u",
"key",
"\\u",
"response_",
",_",
"'",
"Dj",
"ang",
"o",
" ",
"administrati",
"on",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"code",
"'_",
":_",
"code_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"backup",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"self_",
"._",
"admin",
"\\u",
"url_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Admi",
"n",
"Login_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"login",
"\\u",
"with",
"out",
"\\u",
"u2",
"f_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"self_",
"._",
"login",
"\\u",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"name",
"'_",
":_",
"'",
"test",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"password",
"'_",
":_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"this",
"\\u",
"is",
"\\u",
"the",
"\\u",
"login",
"\\u",
"form",
"'_",
":_",
"1_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"next",
"'_",
":_",
"self_",
"._",
"admin",
"\\u",
"url_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"self_",
"._",
"admin",
"\\u",
"url_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\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",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"test\\u",
"validation",
"\\u",
"error_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"enable",
"\\u",
"backup",
"code_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
",_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"backup",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"'",
"Thi",
"s",
" ",
"field",
" ",
"is",
" ",
"require",
"d",
".'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"code",
"\\u",
"require",
"d\\u",
"and",
"\\u",
"login_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"code_",
"=_",
"self_",
"._",
"enable",
"\\u",
"backup",
"code_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
",_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"code",
"'_",
":_",
"code_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"backup",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"'/",
"next",
"/'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"filter_",
"(_",
"code_",
"=_",
"code_",
")_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"incorrect",
"\\u",
"code_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"enable",
"\\u",
"backup",
"code_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"code",
"'_",
":_",
"'",
"abc",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"backup",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"Back",
"up",
"Code",
"Form_",
"._",
"INVALID",
"\\u",
"ERROR",
"\\u",
"MESSAGE_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"add",
"\\u",
"backup",
"\\u",
"codes_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"backup",
"-",
"codes",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"r_",
"._",
"status",
"\\u",
"code_",
",_",
"302_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"count_",
"(_",
")_",
",_",
"10_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"list",
"\\u",
"backup",
"\\u",
"codes_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"create_",
"(_",
"code_",
"=_",
"'",
"fooba",
"r",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"other",
"user_",
"=_",
"User_",
"._",
"objects_",
"._",
"create",
"\\u",
"superuser_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"username_",
"=_",
"'",
"test",
"2",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"email_",
"=_",
"'",
"test",
"2",
"@",
"example",
".",
"com",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"password_",
"=_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"other",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"create_",
"(_",
"code_",
"=_",
"'",
"test",
"2co",
"de",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"backup",
"-",
"codes",
"'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"'",
"fooba",
"r",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"Contains_",
"(_",
"r_",
",_",
"'",
"test",
"2co",
"de",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"add",
"backup",
"code_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"out_",
"=_",
"String",
"IO_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"call",
"\\u",
"command_",
"(_",
"'",
"add",
"backup",
"code",
"'_",
",_",
"self_",
"._",
"user_",
"._",
"get",
"\\u",
"username_",
"(_",
")_",
",_",
"stdout_",
"=_",
"out_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"code_",
"=_",
"out_",
"._",
"getvalue_",
"(_",
")_",
"._",
"strip_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"filter_",
"(_",
"code_",
"=_",
"code_",
")_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"call",
"\\u",
"command_",
"(_",
"'",
"add",
"backup",
"code",
"'_",
",_",
"self_",
"._",
"user_",
"._",
"get",
"\\u",
"username_",
"(_",
")_",
",_",
"code_",
"=_",
"'",
"foo",
"'_",
",_",
"stdout_",
"=_",
"out_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"filter_",
"(_",
"code_",
"=_",
"'",
"foo",
"'_",
")_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"Back",
"up",
"Code_",
"(_",
"Tw",
"o",
"Factor",
"Test_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"login",
"\\u",
"whi",
"le",
"\\u",
"alr",
"ead",
"y",
"\\u",
"logged",
"\\u",
"in_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"User_",
"._",
"objects_",
"._",
"create",
"\\u",
"superuser_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"username_",
"=_",
"'",
"test",
"2",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"email_",
"=_",
"'",
"test",
"2",
"@",
"example",
".",
"com",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"password_",
"=_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"self_",
"._",
"login",
"\\u",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"user",
"name",
"'_",
":_",
"'",
"test",
"2",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"password",
"'_",
":_",
"'",
"asd",
"fas",
"df",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"next",
"'_",
":_",
"'/",
"next",
"/'_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"assert_",
"r_",
"._",
"status",
"\\u",
"code_",
"==_",
"302_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"code_",
"=_",
"self_",
"._",
"enable",
"\\u",
"backup",
"code_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
",_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"code",
"'_",
":_",
"code_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"backup",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"'/",
"next",
"/'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"self_",
"._",
"user_",
"._",
"backup",
"\\u",
"codes_",
"._",
"filter_",
"(_",
"code_",
"=_",
"code_",
")_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"module_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"def_",
"enable",
"\\u",
"tot",
"p_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"key_",
"=_",
"os_",
"._",
"urandom_",
"(_",
"20_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"user_",
"._",
"tot",
"p",
"\\u",
"devices_",
"._",
"create_",
"(_",
"\\u\\u\\uNL\\u\\u\\u_",
"key_",
"=_",
"key_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"return_",
"key_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"login_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"key_",
"=_",
"self_",
"._",
"enable",
"\\u",
"tot",
"p_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"In_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"verify",
"-",
"second",
"-",
"factor",
"'_",
")_",
",_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"timezone_",
"._",
"now_",
"(_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"tot",
"p",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
"._",
"endswith_",
"(_",
"'/",
"next",
"/'_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"token",
"\\u",
"cant",
"\\u",
"be",
"\\u",
"used",
"\\u",
"twi",
"ce_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"key_",
"=_",
"self_",
"._",
"enable",
"\\u",
"tot",
"p_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"token_",
"=_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"timezone_",
"._",
"now_",
"(_",
")_",
")_",
",_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"token_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"tot",
"p",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"str_",
"(_",
"self_",
"._",
"client_",
"._",
"session_",
"[_",
"SES",
"SION",
"\\u",
"KEY_",
"]_",
")_",
",_",
"str_",
"(_",
"self_",
"._",
"user_",
"._",
"id_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"client_",
"._",
"logout_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"token_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"tot",
"p",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"TO",
"TP",
"Form_",
"._",
"INVALID",
"\\u",
"ERROR",
"\\u",
"MESSAGE_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"incorrect",
"\\u",
"code_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"key_",
"=_",
"self_",
"._",
"enable",
"\\u",
"tot",
"p_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"r_",
"[_",
"'",
"location",
"'_",
"]_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"timezone_",
"._",
"now_",
"(_",
")_",
"+_",
"datetime_",
"._",
"timedelta_",
"(_",
"seconds_",
"=_",
"120_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"type",
"'_",
":_",
"'",
"tot",
"p",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Not",
"In_",
"(_",
"SES",
"SION",
"\\u",
"KEY_",
",_",
"self_",
"._",
"client_",
"._",
"session_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"TO",
"TP",
"Form_",
"._",
"INVALID",
"\\u",
"ERROR",
"\\u",
"MESSAGE_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"\\u",
"extract",
"\\u",
"key_",
"(_",
"self_",
",_",
"response_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"return_",
"re_",
"._",
"search_",
"(_",
"'<",
"tt",
">([",
"A",
"-",
"Z",
"0",
"-",
"9",
"]+)",
"</",
"tt",
">'_",
",_",
"response_",
"._",
"content_",
"._",
"decode_",
"(_",
"'",
"utf",
"-",
"8",
"'_",
")_",
")_",
"._",
"group_",
"(_",
"1_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"add",
"\\u",
"device_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"url_",
"=_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"add",
"-",
"tot",
"p",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"url_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"'",
"svg",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"base",
"32",
"\\u",
"key_",
"=_",
"self_",
"._",
"\\u",
"extract",
"\\u",
"key_",
"(_",
"r_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"key_",
"=_",
"b3",
"2de",
"code_",
"(_",
"base",
"32",
"\\u",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"base",
"32",
"\\u",
"key",
"'_",
":_",
"base",
"32",
"\\u",
"key_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"timezone_",
"._",
"now_",
"(_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"r_",
"._",
"status",
"\\u",
"code_",
",_",
"302_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"self_",
"._",
"user_",
"._",
"tot",
"p",
"\\u",
"devices_",
"._",
"filter_",
"(_",
"key_",
"=_",
"key_",
")_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"add",
"\\u",
"device",
"\\u",
"incorrect",
"\\u",
"token_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"url_",
"=_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"add",
"-",
"tot",
"p",
"'_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"get_",
"(_",
"url_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"base",
"32",
"\\u",
"key_",
"=_",
"self_",
"._",
"\\u",
"extract",
"\\u",
"key_",
"(_",
"r_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"key_",
"=_",
"b3",
"2de",
"code_",
"(_",
"base",
"32",
"\\u",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"url_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"base",
"32",
"\\u",
"key",
"'_",
":_",
"base",
"32",
"\\u",
"key_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"token",
"'_",
":_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"timezone_",
"._",
"now_",
"(_",
")_",
"+_",
"datetime_",
"._",
"timedelta_",
"(_",
"seconds_",
"=_",
"120_",
")_",
")_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"r_",
"._",
"status",
"\\u",
"code_",
",_",
"200_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Contains_",
"(_",
"r_",
",_",
"TO",
"TP",
"Form_",
"._",
"INVALID",
"\\u",
"ERROR",
"\\u",
"MESSAGE_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"delete",
"\\u",
"device_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"self_",
"._",
"login_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"enable",
"\\u",
"tot",
"p_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"r_",
"=_",
"self_",
"._",
"client_",
"._",
"post_",
"(_",
"reverse_",
"(_",
"'",
"u2",
"f",
":",
"tot",
"p",
"-",
"device",
"s",
"'_",
")_",
",_",
"{_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"device",
"\\u",
"id",
"'_",
":_",
"self_",
"._",
"user_",
"._",
"tot",
"p",
"\\u",
"devices_",
"._",
"get_",
"(_",
")_",
"._",
"pk_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"'",
"delete",
"'_",
":_",
"'",
"1",
"'_",
",_",
"\\u\\u\\uNL\\u\\u\\u_",
"}_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"r_",
"._",
"status",
"\\u",
"code_",
",_",
"302_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"False_",
"(_",
"self_",
"._",
"user_",
"._",
"tot",
"p",
"\\u",
"devices_",
"._",
"exists_",
"(_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"TO",
"TP_",
"(_",
"U2",
"FT",
"est_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"slo",
"p_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"key_",
"=_",
"os_",
"._",
"urandom_",
"(_",
"20_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"device_",
"=_",
"TO",
"TP",
"Device_",
"(_",
"key_",
"=_",
"key_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"now_",
"=_",
"timezone_",
"._",
"now_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"device_",
"._",
"validat",
"e\\u",
"token_",
"(_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"now_",
"-_",
"datetime_",
"._",
"timedelta_",
"(_",
"seconds_",
"=_",
"30_",
")_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"device_",
"._",
"validat",
"e\\u",
"token_",
"(_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"now_",
")_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"device_",
"._",
"validat",
"e\\u",
"token_",
"(_",
"oat",
"h_",
"._",
"tot",
"p_",
"(_",
"key_",
",_",
"now_",
"+_",
"datetime_",
"._",
"timedelta_",
"(_",
"seconds_",
"=_",
"30_",
")_",
")_",
")_",
")_"
]
| [
4,
4,
4,
4,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
0,
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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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,
4,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
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 | SmokinCaterpillar/pypet/pypet/tests/unittests/annotations_test.py | [
{
"content": " def test_to_str(self):\n dict_str = self.dict_to_str(self.annotations)\n for node in self.traj.f_iter_nodes(recursive=True):\n ann_str = node.f_ann_to_str()\n\n self.assertTrue(not ann_str.endswith(' ') or not ann_str.endswith(','))\n\n for name in self.annotations:\n if name==0:\n name = 'annotation'\n self.assertTrue(name in ann_str)\n\n self.assertEqual(dict_str, ann_str, '%s!=%s' % (dict_str, ann_str))\n\n ann_str = str(node.v_annotations)\n self.assertEqual(dict_str, ann_str, '%s!=%s' % (dict_str, ann_str))",
"metadata": "root.AnnotationsTest.test_to_str",
"header": "['class', 'AnnotationsTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 156
},
{
"content": " def test_f_set_numbering(self):\n int_list = list(range(10))\n for node in self.traj.f_iter_nodes(recursive=True):\n node.v_annotations.f_set(*int_list)\n\n self.assertEqual(node.v_annotations.f_get(*int_list), tuple(int_list))\n\n for integer in int_list:\n if integer == 0:\n name = 'annotation'\n else:\n name = 'annotation_%d' % integer\n\n self.assertTrue(name in node.v_annotations)",
"metadata": "root.AnnotationsTest.test_f_set_numbering",
"header": "['class', 'AnnotationsTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 208
}
]
| [
{
"span": "self.assertTrue(name in ann_str)",
"start_line": 166,
"start_column": 16,
"end_line": 166,
"end_column": 48
},
{
"span": "self.assertTrue(name in node.v_annotations)",
"start_line": 221,
"start_column": 16,
"end_line": 221,
"end_column": 59
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Annotations",
"Test_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"to",
"\\u",
"str_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"dict",
"\\u",
"str_",
"=_",
"self_",
"._",
"dict",
"\\u",
"to",
"\\u",
"str_",
"(_",
"self_",
"._",
"annotations_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"node_",
"in_",
"self_",
"._",
"traj_",
"._",
"f",
"\\u",
"iter",
"\\u",
"nodes_",
"(_",
"recursive_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"ann",
"\\u",
"str_",
"=_",
"node_",
"._",
"f",
"\\u",
"ann",
"\\u",
"to",
"\\u",
"str_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"not_",
"ann",
"\\u",
"str_",
"._",
"endswith_",
"(_",
"'",
" ",
"'_",
")_",
"or_",
"not_",
"ann",
"\\u",
"str_",
"._",
"endswith_",
"(_",
"','_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"name_",
"in_",
"self_",
"._",
"annotations_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"name_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"name_",
"=_",
"'",
"annot",
"ation",
"'_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"name_",
"in_",
"ann",
"\\u",
"str_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"dict",
"\\u",
"str_",
",_",
"ann",
"\\u",
"str_",
",_",
"'%",
"s",
"!=",
"%",
"s",
"'_",
"%_",
"(_",
"dict",
"\\u",
"str_",
",_",
"ann",
"\\u",
"str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"ann",
"\\u",
"str_",
"=_",
"str_",
"(_",
"node_",
"._",
"v",
"\\u",
"annotations_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"dict",
"\\u",
"str_",
",_",
"ann",
"\\u",
"str_",
",_",
"'%",
"s",
"!=",
"%",
"s",
"'_",
"%_",
"(_",
"dict",
"\\u",
"str_",
",_",
"ann",
"\\u",
"str_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Annotations",
"Test_",
"(_",
"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",
"f",
"\\u",
"set\\u",
"numbering",
"_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"int\\u",
"list_",
"=_",
"list_",
"(_",
"range_",
"(_",
"10_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"for_",
"node_",
"in_",
"self_",
"._",
"traj_",
"._",
"f",
"\\u",
"iter",
"\\u",
"nodes_",
"(_",
"recursive_",
"=_",
"True_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"node_",
"._",
"v",
"\\u",
"annotations_",
"._",
"f",
"\\u",
"set_",
"(_",
"*_",
"int\\u",
"list_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"self_",
"._",
"assert",
"Equal_",
"(_",
"node_",
"._",
"v",
"\\u",
"annotations_",
"._",
"f",
"\\u",
"get_",
"(_",
"*_",
"int\\u",
"list_",
")_",
",_",
"tuple_",
"(_",
"int\\u",
"list_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"for_",
"integer_",
"in_",
"int\\u",
"list_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"if_",
"integer_",
"==_",
"0_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" ",
"_",
"name_",
"=_",
"'",
"annot",
"ation",
"'_",
"\\u\\u\\uNEWL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,
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,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2
]
|
Imprecise assert | hosford42/xcs/tests/test_MUXProblem.py | [
{
"content": " def test_get_possible_actions(self):\n actions = self.scenario.get_possible_actions()\n self.assertTrue(len(actions) == 2)\n self.assertTrue(True in actions)\n self.assertTrue(False in actions)",
"metadata": "root.TestMUXProblem.test_get_possible_actions",
"header": "['class', 'TestMUXProblem', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 13
},
{
"content": " def test_sense(self):\n situation_size = (self.scenario.address_size +\n (1 << self.scenario.address_size))\n previous = self.scenario.sense()\n self.assertIsInstance(previous, BitString)\n self.assertTrue(len(previous) == situation_size)\n while self.scenario.more():\n current = self.scenario.sense()\n self.assertIsInstance(current, BitString)\n self.assertTrue(len(current) == situation_size)\n if current != previous:\n break\n else:\n self.fail(\"All situations are the same.\")",
"metadata": "root.TestMUXProblem.test_sense",
"header": "['class', 'TestMUXProblem', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']",
"index": 19
}
]
| [
{
"span": "self.assertTrue(len(actions) == 2)",
"start_line": 15,
"start_column": 8,
"end_line": 15,
"end_column": 42
},
{
"span": "self.assertTrue(True in actions)",
"start_line": 16,
"start_column": 8,
"end_line": 16,
"end_column": 40
},
{
"span": "self.assertTrue(False in actions)",
"start_line": 17,
"start_column": 8,
"end_line": 17,
"end_column": 41
},
{
"span": "self.assertTrue(len(previous) == situation_size)",
"start_line": 24,
"start_column": 8,
"end_line": 24,
"end_column": 56
},
{
"span": "self.assertTrue(len(current) == situation_size)",
"start_line": 28,
"start_column": 12,
"end_line": 28,
"end_column": 59
}
]
| []
| 1 | true | [
"[CLS]_",
"Imp",
"reci",
"se_",
"assert_",
"[SEP]_",
"class_",
"Test",
"MU",
"XP",
"rob",
"lem",
"_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"get",
"\\u",
"possib",
"le",
"\\u",
"actions_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"actions_",
"=_",
"self_",
"._",
"scenario_",
"._",
"get",
"\\u",
"possib",
"le",
"\\u",
"actions_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"len_",
"(_",
"actions_",
")_",
"==_",
"2_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"True_",
"in_",
"actions_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"False_",
"in_",
"actions_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"[SEP]_",
"class_",
"Test",
"MU",
"XP",
"rob",
"lem",
"_",
"(_",
"unittest_",
"._",
"Test",
"Case_",
")_",
":_",
"\\u\\u\\uEOS\\u\\u\\u_",
"\\u\\u\\uNL\\u\\u\\u_",
"\\u\\u\\uDEDENT\\u\\u\\u_",
"def_",
"test\\u",
"sense_",
"(_",
"self_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"situation",
"\\u",
"size_",
"=_",
"(_",
"self_",
"._",
"scenario_",
"._",
"address",
"\\u",
"size_",
"+_",
"\\u\\u\\uNL\\u\\u\\u_",
"(_",
"1_",
"<<_",
"self_",
"._",
"scenario_",
"._",
"address",
"\\u",
"size_",
")_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"previous_",
"=_",
"self_",
"._",
"scenario_",
"._",
"sense_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Is",
"Instance_",
"(_",
"previous_",
",_",
"Bit",
"String_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"len_",
"(_",
"previous_",
")_",
"==_",
"situation",
"\\u",
"size_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"while_",
"self_",
"._",
"scenario_",
"._",
"more_",
"(_",
")_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u ",
" _",
"current_",
"=_",
"self_",
"._",
"scenario_",
"._",
"sense_",
"(_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"Is",
"Instance_",
"(_",
"current_",
",_",
"Bit",
"String_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"self_",
"._",
"assert",
"True_",
"(_",
"len_",
"(_",
"current_",
")_",
"==_",
"situation",
"\\u",
"size_",
")_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"if_",
"current_",
"!=_",
"previous_",
":_",
"\\u\\u\\uNEWLINE\\u\\u\\u_",
"\\u\\u\\uINDENT\\u\\u\\u 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
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.